summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-02-20 18:30:19 +0000
committerGerrit Code Review <review@openstack.org>2013-02-20 18:30:19 +0000
commitf478fa696746ba61f3749a9b0559bbbaaf25cfa5 (patch)
tree20ede37043e1612bbf80ae84273a33ec2e623520
parent666cb4eaf70c9f2f8dd05ba0df91f0e7dd6810cb (diff)
parent5cb12a228468924c506d2e552c1748f48528f6d8 (diff)
downloadnova-f478fa696746ba61f3749a9b0559bbbaaf25cfa5.tar.gz
nova-f478fa696746ba61f3749a9b0559bbbaaf25cfa5.tar.xz
nova-f478fa696746ba61f3749a9b0559bbbaaf25cfa5.zip
Merge "Prevent the unexpected with nova-manage network modify."
-rwxr-xr-xbin/nova-manage25
1 files changed, 21 insertions, 4 deletions
diff --git a/bin/nova-manage b/bin/nova-manage
index e3b0ec6f7..c4e9841ce 100755
--- a/bin/nova-manage
+++ b/bin/nova-manage
@@ -561,14 +561,31 @@ class NetworkCommands(object):
#1) Associate (set not None value given by project/host parameter)
#2) Disassociate (set None by disassociate parameter)
#3) Keep unchanged (project/host key is not added to 'net')
+ if dis_project:
+ net['project_id'] = None
+ if dis_host:
+ net['host'] = None
+
+ # The --disassociate-X are boolean options, but if they user
+ # mistakenly provides a value, it will be used as a positional argument
+ # and be erroneously interepreted as some other parameter (e.g.
+ # a project instead of host value). The safest thing to do is error-out
+ # with a message indicating that there is probably a problem with
+ # how the disassociate modifications are being used.
+ if dis_project or dis_host:
+ if project or host:
+ error_msg = "ERROR: Unexpected arguments provided. Please " \
+ "use separate commands."
+ print(error_msg)
+ sys.exit(1)
+ db.network_update(admin_context, network['id'], net)
+ return
+
if project:
net['project_id'] = project
- elif dis_project:
- net['project_id'] = None
if host:
net['host'] = host
- elif dis_host:
- net['host'] = None
+
db.network_update(admin_context, network['id'], net)