diff options
author | Alan Pevec <apevec@redhat.com> | 2014-02-27 13:12:41 +0100 |
---|---|---|
committer | Alan Pevec <apevec@redhat.com> | 2014-02-27 13:13:14 +0100 |
commit | 360a3393f4d52746a9e87ac0011cc700a51965ad (patch) | |
tree | c8ae43fb2fd08b2785a0af2bbd44f898b4799723 | |
parent | 4a2c9b2621b2abb65f03b4003f648deebd4baebc (diff) | |
download | python-novaclient-360a3393f4d52746a9e87ac0011cc700a51965ad.tar.gz |
Revert "'name' should as be optional param on aggregate-update"
This reverts commit a2a1ef8f36644c3487bdaf00b2e70bcc6b948fb4.
Change-Id: I43bdc254e391c4b20254b8732c772fc9e728310c
Reopens-bug: #1280118
Partial-bug: #1281416
-rw-r--r-- | novaclient/tests/v1_1/test_shell.py | 28 | ||||
-rw-r--r-- | novaclient/tests/v3/test_shell.py | 28 | ||||
-rw-r--r-- | novaclient/v1_1/shell.py | 12 | ||||
-rw-r--r-- | novaclient/v3/shell.py | 12 |
4 files changed, 20 insertions, 60 deletions
diff --git a/novaclient/tests/v1_1/test_shell.py b/novaclient/tests/v1_1/test_shell.py index feeba487..a4c4ca19 100644 --- a/novaclient/tests/v1_1/test_shell.py +++ b/novaclient/tests/v1_1/test_shell.py @@ -1149,42 +1149,26 @@ class ShellTest(utils.TestCase): self.assert_called('DELETE', '/os-aggregates/1') def test_aggregate_update_by_id(self): - self.run_command('aggregate-update 1 --name new_name') + self.run_command('aggregate-update 1 new_name') body = {"aggregate": {"name": "new_name"}} self.assert_called('PUT', '/os-aggregates/1', body, pos=-2) self.assert_called('GET', '/os-aggregates/1', pos=-1) def test_aggregate_update_by_name(self): - self.run_command('aggregate-update test --name new_name') + self.run_command('aggregate-update test new_name') body = {"aggregate": {"name": "new_name"}} self.assert_called('PUT', '/os-aggregates/1', body, pos=-2) self.assert_called('GET', '/os-aggregates/1', pos=-1) def test_aggregate_update_with_availability_zone_by_id(self): - self.run_command('aggregate-update 1 --availability_zone new_zone') - body = {"aggregate": {"availability_zone": "new_zone"}} + self.run_command('aggregate-update 1 foo new_zone') + body = {"aggregate": {"name": "foo", "availability_zone": "new_zone"}} self.assert_called('PUT', '/os-aggregates/1', body, pos=-2) self.assert_called('GET', '/os-aggregates/1', pos=-1) def test_aggregate_update_with_availability_zone_by_name(self): - self.run_command('aggregate-update test --availability_zone new_zone') - body = {"aggregate": {"availability_zone": "new_zone"}} - self.assert_called('PUT', '/os-aggregates/1', body, pos=-2) - self.assert_called('GET', '/os-aggregates/1', pos=-1) - - def test_aggregate_update_all_parameters_by_id(self): - self.run_command('aggregate-update 1 --name new_name ' - '--availability_zone new_zone') - body = {"aggregate": {"name": "new_name", - "availability_zone": "new_zone"}} - self.assert_called('PUT', '/os-aggregates/1', body, pos=-2) - self.assert_called('GET', '/os-aggregates/1', pos=-1) - - def test_aggregate_update_all_parameters_by_name(self): - self.run_command('aggregate-update test --name new_name ' - '--availability_zone new_zone') - body = {"aggregate": {"name": "new_name", - "availability_zone": "new_zone"}} + self.run_command('aggregate-update test foo new_zone') + body = {"aggregate": {"name": "foo", "availability_zone": "new_zone"}} self.assert_called('PUT', '/os-aggregates/1', body, pos=-2) self.assert_called('GET', '/os-aggregates/1', pos=-1) diff --git a/novaclient/tests/v3/test_shell.py b/novaclient/tests/v3/test_shell.py index 796e73c6..85a839b4 100644 --- a/novaclient/tests/v3/test_shell.py +++ b/novaclient/tests/v3/test_shell.py @@ -104,42 +104,26 @@ class ShellTest(utils.TestCase): self.assert_called('DELETE', '/os-aggregates/1') def test_aggregate_update_by_id(self): - self.run_command('aggregate-update 1 --name new_name') + self.run_command('aggregate-update 1 new_name') body = {"aggregate": {"name": "new_name"}} self.assert_called('PUT', '/os-aggregates/1', body, pos=-2) self.assert_called('GET', '/os-aggregates/1', pos=-1) def test_aggregate_update_by_name(self): - self.run_command('aggregate-update test --name new_name') + self.run_command('aggregate-update test new_name') body = {"aggregate": {"name": "new_name"}} self.assert_called('PUT', '/os-aggregates/1', body, pos=-2) self.assert_called('GET', '/os-aggregates/1', pos=-1) def test_aggregate_update_with_availability_zone_by_id(self): - self.run_command('aggregate-update 1 --availability_zone new_zone') - body = {"aggregate": {"availability_zone": "new_zone"}} + self.run_command('aggregate-update 1 foo new_zone') + body = {"aggregate": {"name": "foo", "availability_zone": "new_zone"}} self.assert_called('PUT', '/os-aggregates/1', body, pos=-2) self.assert_called('GET', '/os-aggregates/1', pos=-1) def test_aggregate_update_with_availability_zone_by_name(self): - self.run_command('aggregate-update test --availability_zone new_zone') - body = {"aggregate": {"availability_zone": "new_zone"}} - self.assert_called('PUT', '/os-aggregates/1', body, pos=-2) - self.assert_called('GET', '/os-aggregates/1', pos=-1) - - def test_aggregate_update_all_parameters_by_id(self): - self.run_command('aggregate-update 1 --name new_name ' - '--availability_zone new_zone') - body = {"aggregate": {"name": "new_name", - "availability_zone": "new_zone"}} - self.assert_called('PUT', '/os-aggregates/1', body, pos=-2) - self.assert_called('GET', '/os-aggregates/1', pos=-1) - - def test_aggregate_update_all_parameters_by_name(self): - self.run_command('aggregate-update test --name new_name ' - '--availability_zone new_zone') - body = {"aggregate": {"name": "new_name", - "availability_zone": "new_zone"}} + self.run_command('aggregate-update test foo new_zone') + body = {"aggregate": {"name": "foo", "availability_zone": "new_zone"}} self.assert_called('PUT', '/os-aggregates/1', body, pos=-2) self.assert_called('GET', '/os-aggregates/1', pos=-1) diff --git a/novaclient/v1_1/shell.py b/novaclient/v1_1/shell.py index 24317642..c7a52098 100644 --- a/novaclient/v1_1/shell.py +++ b/novaclient/v1_1/shell.py @@ -2704,22 +2704,18 @@ def do_aggregate_delete(cs, args): @utils.arg('aggregate', metavar='<aggregate>', help=_('Name or ID of aggregate to update.')) -@utils.arg('--name', metavar='<name>', help=_('New name of aggregate.')) -@utils.arg('--availability_zone', +@utils.arg('name', metavar='<name>', help=_('Name of aggregate.')) +@utils.arg('availability_zone', metavar='<availability-zone>', + nargs='?', default=None, help=_('The availability zone of the aggregate.')) def do_aggregate_update(cs, args): """Update the aggregate's name and optionally availability zone.""" aggregate = _find_aggregate(cs, args.aggregate) - updates = {} - if args.name: - updates["name"] = args.name + updates = {"name": args.name} if args.availability_zone: updates["availability_zone"] = args.availability_zone - if not updates: - raise exceptions.CommandError(_("Must supply name " - "or availability_zone.")) aggregate = cs.aggregates.update(aggregate.id, updates) print(_("Aggregate %s has been successfully updated.") % aggregate.id) diff --git a/novaclient/v3/shell.py b/novaclient/v3/shell.py index 02706c35..10a6975d 100644 --- a/novaclient/v3/shell.py +++ b/novaclient/v3/shell.py @@ -2230,22 +2230,18 @@ def do_aggregate_delete(cs, args): @utils.arg('aggregate', metavar='<aggregate>', help='Name or ID of aggregate to update.') -@utils.arg('--name', metavar='<name>', help='New name of aggregate.') -@utils.arg('--availability_zone', +@utils.arg('name', metavar='<name>', help='Name of aggregate.') +@utils.arg('availability_zone', metavar='<availability-zone>', + nargs='?', default=None, help='The availability zone of the aggregate.') def do_aggregate_update(cs, args): """Update the aggregate's name and optionally availability zone.""" aggregate = _find_aggregate(cs, args.aggregate) - updates = {} - if args.name: - updates["name"] = args.name + updates = {"name": args.name} if args.availability_zone: updates["availability_zone"] = args.availability_zone - if not updates: - raise exceptions.CommandError("Must supply name " - "or availability_zone.") aggregate = cs.aggregates.update(aggregate.id, updates) print("Aggregate %s has been successfully updated." % aggregate.id) |