summaryrefslogtreecommitdiff
path: root/openstackclient/compute/v2
diff options
context:
space:
mode:
authorM V P Nitesh <m.nitesh@nectechnologies.in>2017-06-14 18:29:08 +0530
committerM V P Nitesh <m.nitesh@nectechnologies.in>2017-06-23 13:20:43 +0530
commitfcafd987b0143a08eff964f1e988a3aaa40ad824 (patch)
treeedc51c31214530409b7cd8237b7d17eeaac63a2e /openstackclient/compute/v2
parenteb793dc8c6a8bd30e612f19f30808528b10eb344 (diff)
downloadpython-openstackclient-fcafd987b0143a08eff964f1e988a3aaa40ad824.tar.gz
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
Diffstat (limited to 'openstackclient/compute/v2')
-rw-r--r--openstackclient/compute/v2/server.py16
1 files changed, 10 insertions, 6 deletions
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 <net-id=net-uuid"
+ ",v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,"
+ "port-id=port-uuid>."))
+ 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")