Add AgregatesManager.get()
utils.find_resource() uses manager.get() as part of converting Resource names to IDs. AggregatesManager had get_details() instead of get(). Add AggregatesManager.get(), leaving .get_details() in place for backward API compatibility. Bug: 1200341 Change-Id: I7d238bbe43e1760e31f1a9ba783c668246f20844
This commit is contained in:
parent
a45c49bafc
commit
c360c3e8da
@ -35,6 +35,15 @@ class AggregatesTest(utils.TestCase):
|
||||
cs.assert_called('POST', '/os-aggregates', body)
|
||||
self.assertTrue(isinstance(aggregate, aggregates.Aggregate))
|
||||
|
||||
def test_get(self):
|
||||
aggregate = cs.aggregates.get("1")
|
||||
cs.assert_called('GET', '/os-aggregates/1')
|
||||
self.assertTrue(isinstance(aggregate, aggregates.Aggregate))
|
||||
|
||||
aggregate2 = cs.aggregates.get(aggregate)
|
||||
cs.assert_called('GET', '/os-aggregates/1')
|
||||
self.assertTrue(isinstance(aggregate2, aggregates.Aggregate))
|
||||
|
||||
def test_get_details(self):
|
||||
aggregate = cs.aggregates.get_details("1")
|
||||
cs.assert_called('GET', '/os-aggregates/1')
|
||||
@ -45,7 +54,7 @@ class AggregatesTest(utils.TestCase):
|
||||
self.assertTrue(isinstance(aggregate2, aggregates.Aggregate))
|
||||
|
||||
def test_update(self):
|
||||
aggregate = cs.aggregates.get_details("1")
|
||||
aggregate = cs.aggregates.get("1")
|
||||
values = {"name": "foo"}
|
||||
body = {"aggregate": values}
|
||||
|
||||
@ -58,7 +67,7 @@ class AggregatesTest(utils.TestCase):
|
||||
self.assertTrue(isinstance(result2, aggregates.Aggregate))
|
||||
|
||||
def test_update_with_availability_zone(self):
|
||||
aggregate = cs.aggregates.get_details("1")
|
||||
aggregate = cs.aggregates.get("1")
|
||||
values = {"name": "foo", "availability_zone": "new_zone"}
|
||||
body = {"aggregate": values}
|
||||
|
||||
@ -67,7 +76,7 @@ class AggregatesTest(utils.TestCase):
|
||||
self.assertTrue(isinstance(result3, aggregates.Aggregate))
|
||||
|
||||
def test_add_host(self):
|
||||
aggregate = cs.aggregates.get_details("1")
|
||||
aggregate = cs.aggregates.get("1")
|
||||
host = "host1"
|
||||
body = {"add_host": {"host": "host1"}}
|
||||
|
||||
@ -84,7 +93,7 @@ class AggregatesTest(utils.TestCase):
|
||||
self.assertTrue(isinstance(result3, aggregates.Aggregate))
|
||||
|
||||
def test_remove_host(self):
|
||||
aggregate = cs.aggregates.get_details("1")
|
||||
aggregate = cs.aggregates.get("1")
|
||||
host = "host1"
|
||||
body = {"remove_host": {"host": "host1"}}
|
||||
|
||||
@ -101,7 +110,7 @@ class AggregatesTest(utils.TestCase):
|
||||
self.assertTrue(isinstance(result3, aggregates.Aggregate))
|
||||
|
||||
def test_set_metadata(self):
|
||||
aggregate = cs.aggregates.get_details("1")
|
||||
aggregate = cs.aggregates.get("1")
|
||||
metadata = {"foo": "bar"}
|
||||
body = {"set_metadata": {"metadata": metadata}}
|
||||
|
||||
|
@ -862,7 +862,8 @@ class ShellTest(utils.TestCase):
|
||||
self.run_command('aggregate-create test_name nova1')
|
||||
body = {"aggregate": {"name": "test_name",
|
||||
"availability_zone": "nova1"}}
|
||||
self.assert_called('POST', '/os-aggregates', body)
|
||||
self.assert_called('POST', '/os-aggregates', body, pos=-2)
|
||||
self.assert_called('GET', '/os-aggregates/1', pos=-1)
|
||||
|
||||
def test_aggregate_delete(self):
|
||||
self.run_command('aggregate-delete 1')
|
||||
@ -871,28 +872,33 @@ class ShellTest(utils.TestCase):
|
||||
def test_aggregate_update(self):
|
||||
self.run_command('aggregate-update 1 new_name')
|
||||
body = {"aggregate": {"name": "new_name"}}
|
||||
self.assert_called('PUT', '/os-aggregates/1', body)
|
||||
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(self):
|
||||
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)
|
||||
self.assert_called('PUT', '/os-aggregates/1', body, pos=-2)
|
||||
self.assert_called('GET', '/os-aggregates/1', pos=-1)
|
||||
|
||||
def test_aggregate_set_metadata(self):
|
||||
self.run_command('aggregate-set-metadata 1 foo=bar delete_key')
|
||||
body = {"set_metadata": {"metadata": {"foo": "bar",
|
||||
"delete_key": None}}}
|
||||
self.assert_called('POST', '/os-aggregates/1/action', body)
|
||||
self.assert_called('POST', '/os-aggregates/1/action', body, pos=-2)
|
||||
self.assert_called('GET', '/os-aggregates/1', pos=-1)
|
||||
|
||||
def test_aggregate_add_host(self):
|
||||
self.run_command('aggregate-add-host 1 host1')
|
||||
body = {"add_host": {"host": "host1"}}
|
||||
self.assert_called('POST', '/os-aggregates/1/action', body)
|
||||
self.assert_called('POST', '/os-aggregates/1/action', body, pos=-2)
|
||||
self.assert_called('GET', '/os-aggregates/1', pos=-1)
|
||||
|
||||
def test_aggregate_remove_host(self):
|
||||
self.run_command('aggregate-remove-host 1 host1')
|
||||
body = {"remove_host": {"host": "host1"}}
|
||||
self.assert_called('POST', '/os-aggregates/1/action', body)
|
||||
self.assert_called('POST', '/os-aggregates/1/action', body, pos=-2)
|
||||
self.assert_called('GET', '/os-aggregates/1', pos=-1)
|
||||
|
||||
def test_aggregate_details(self):
|
||||
self.run_command('aggregate-details 1')
|
||||
|
@ -54,11 +54,17 @@ class AggregateManager(base.ManagerWithFind):
|
||||
'availability_zone': availability_zone}}
|
||||
return self._create('/os-aggregates', body, 'aggregate')
|
||||
|
||||
def get_details(self, aggregate):
|
||||
def get(self, aggregate):
|
||||
"""Get details of the specified aggregate."""
|
||||
return self._get('/os-aggregates/%s' % (base.getid(aggregate)),
|
||||
"aggregate")
|
||||
|
||||
# NOTE:(dtroyer): utils.find_resource() uses manager.get() but we need to
|
||||
# keep the API backward compatible
|
||||
def get_details(self, aggregate):
|
||||
"""Get details of the specified aggregate."""
|
||||
return self.get(aggregate)
|
||||
|
||||
def update(self, aggregate, values):
|
||||
"""Update the name and/or availability zone."""
|
||||
body = {'aggregate': values}
|
||||
|
@ -2486,7 +2486,7 @@ def do_aggregate_remove_host(cs, args):
|
||||
@utils.arg('id', metavar='<id>', help='Aggregate id.')
|
||||
def do_aggregate_details(cs, args):
|
||||
"""Show details of the specified aggregate."""
|
||||
_print_aggregate_details(cs.aggregates.get_details(args.id))
|
||||
_print_aggregate_details(cs.aggregates.get(args.id))
|
||||
|
||||
|
||||
def _print_aggregate_details(aggregate):
|
||||
|
Loading…
Reference in New Issue
Block a user