From 415545ab9fd842bdc19b7fbfa63e3332dd63fe6c Mon Sep 17 00:00:00 2001 From: yanpuqing Date: Thu, 20 Jun 2019 11:14:22 +0800 Subject: Add an error message when server bind floating IP If we add a floating IP for the server with no fixed IP, CLI doesn't report an error and nothing happens. The patch adds an error message when the server which don't have fixed IP bind floating IP. Change-Id: I400f2bab08521bb7fa443d87c7f45cc79eb80694 Task: 27941 Story: 2004346 --- openstackclient/compute/v2/server.py | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'openstackclient/compute/v2') diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index e5a7a328..30057111 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -292,6 +292,10 @@ class AddFloatingIP(network_common.NetworkAndComputeCommand): parsed_args.server, ) ports = list(client.ports(device_id=server.id)) + if not ports: + msg = _('No attached ports found to associate floating IP with') + raise exceptions.CommandError(msg) + # If the fixed IP address was specified, we need to find the # corresponding port. if parsed_args.fixed_ip_address: -- cgit v1.2.1