From fcafd987b0143a08eff964f1e988a3aaa40ad824 Mon Sep 17 00:00:00 2001 From: M V P Nitesh Date: Wed, 14 Jun 2017 18:29:08 +0530 Subject: Now OSC server create check keys in --nic Now OSC command to create server will check all the keys in --nic and throws an exception if the key is invalid key. Change-Id: I5482da0ae63d6d4298aa614e4d09bb0547da9ec3 Closes-Bug: #1681411 --- openstackclient/compute/v2/server.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'openstackclient/compute') diff --git a/openstackclient/compute/v2/server.py b/openstackclient/compute/v2/server.py index e8846d16..cd321aa6 100644 --- a/openstackclient/compute/v2/server.py +++ b/openstackclient/compute/v2/server.py @@ -651,12 +651,16 @@ class CreateServer(command.ShowOne): else: nic_info = {"net-id": "", "v4-fixed-ip": "", "v6-fixed-ip": "", "port-id": ""} - try: - nic_info.update(dict(kv_str.split("=", 1) - for kv_str in nic_str.split(","))) - except ValueError: - msg = _('Invalid --nic argument %s.') % nic_str - raise exceptions.CommandError(msg) + for kv_str in nic_str.split(","): + k, sep, v = kv_str.partition("=") + if k in nic_info and v: + nic_info[k] = v + else: + msg = (_("Invalid nic argument '%s'. Nic arguments " + "must be of the form --nic .")) + raise exceptions.CommandError(msg % k) if bool(nic_info["net-id"]) == bool(nic_info["port-id"]): msg = _("either network or port should be specified " "but not both") -- cgit v1.2.1