diff --git a/magnumclient/tests/v1/test_replicationcontrollers.py b/magnumclient/tests/v1/test_replicationcontrollers.py index 1696b32d..5fd413a0 100644 --- a/magnumclient/tests/v1/test_replicationcontrollers.py +++ b/magnumclient/tests/v1/test_replicationcontrollers.py @@ -55,7 +55,14 @@ fake_responses = { CREATE_RC, ), }, - '/v1/rcs/%s/%s' % (RC1['id'], RC1['bay_uuid']): + '/v1/rcs/?bay_ident=%s' % (RC1['bay_uuid']): + { + 'GET': ( + {}, + {'rcs': [RC1, RC2]}, + ), + }, + '/v1/rcs/%s/?bay_ident=%s' % (RC1['id'], RC1['bay_uuid']): { 'GET': ( {}, @@ -70,7 +77,7 @@ fake_responses = { UPDATED_RC, ), }, - '/v1/rcs/%s/%s' % (RC1['name'], RC1['bay_uuid']): + '/v1/rcs/%s/?bay_ident=%s' % (RC1['name'], RC1['bay_uuid']): { 'GET': ( {}, @@ -106,7 +113,8 @@ class RCManagerTest(testtools.TestCase): def test_rc_show_by_id(self): rc = self.mgr.get(RC1['id'], RC1['bay_uuid']) expect = [ - ('GET', '/v1/rcs/%s/%s' % (RC1['id'], RC1['bay_uuid']), {}, None) + ('GET', '/v1/rcs/%s/?bay_ident=%s' % (RC1['id'], + RC1['bay_uuid']), {}, None) ] self.assertEqual(expect, self.api.calls) self.assertEqual(RC1['name'], rc.name) @@ -116,8 +124,8 @@ class RCManagerTest(testtools.TestCase): def test_rc_show_by_name(self): rc = self.mgr.get(RC1['name'], RC1['bay_uuid']) expect = [ - ('GET', '/v1/rcs/%s/%s' % (RC1['name'], - RC1['bay_uuid']), {}, None) + ('GET', '/v1/rcs/%s/?bay_ident=%s' % (RC1['name'], + RC1['bay_uuid']), {}, None) ] self.assertEqual(expect, self.api.calls) self.assertEqual(RC1['name'], rc.name) @@ -144,8 +152,9 @@ class RCManagerTest(testtools.TestCase): def test_rc_delete_by_id(self): rc = self.mgr.delete(RC1['id'], RC1['bay_uuid']) expect = [ - ('DELETE', '/v1/rcs/%s/%s' % (RC1['id'], - RC1['bay_uuid']), {}, None), + ('DELETE', '/v1/rcs/%s/?bay_ident=%s' % (RC1['id'], + RC1['bay_uuid']), + {}, None), ] self.assertEqual(expect, self.api.calls) self.assertIsNone(rc) @@ -153,8 +162,9 @@ class RCManagerTest(testtools.TestCase): def test_rc_delete_by_name(self): rc = self.mgr.delete(RC1['name'], RC1['bay_uuid']) expect = [ - ('DELETE', '/v1/rcs/%s/%s' % (RC1['name'], - RC1['bay_uuid']), {}, None), + ('DELETE', '/v1/rcs/%s/?bay_ident=%s' % (RC1['name'], + RC1['bay_uuid']), + {}, None), ] self.assertEqual(expect, self.api.calls) self.assertIsNone(rc) @@ -164,11 +174,12 @@ class RCManagerTest(testtools.TestCase): 'value': NEW_REPLICAS, 'path': '/replicas'} rc = self.mgr.update(id=RC1['id'], - bay_uuid=RC1['bay_uuid'], + bay_ident=RC1['bay_uuid'], patch=patch) expect = [ - ('PATCH', '/v1/rcs/%s/%s' % (RC1['id'], - RC1['bay_uuid']), {}, patch), + ('PATCH', '/v1/rcs/%s/?bay_ident=%s' % (RC1['id'], + RC1['bay_uuid']), {}, + patch), ] self.assertEqual(expect, self.api.calls) self.assertEqual(NEW_REPLICAS, rc.replicas) diff --git a/magnumclient/v1/replicationcontrollers.py b/magnumclient/v1/replicationcontrollers.py index e4f91c0a..ba66d2d4 100644 --- a/magnumclient/v1/replicationcontrollers.py +++ b/magnumclient/v1/replicationcontrollers.py @@ -29,9 +29,11 @@ class ReplicationControllerManager(base.Manager): resource_class = ReplicationController @staticmethod - def _path(id=None, bay_uuid=None): - if id and bay_uuid: - return '/v1/rcs/%s/%s' % (id, bay_uuid) + def _path(id=None, bay_ident=None): + if id and bay_ident: + return '/v1/rcs/%s/?bay_ident=%s' % (id, bay_ident) + elif bay_ident: + return '/v1/rcs/?bay_ident=%s' % (bay_ident) else: return '/v1/rcs' @@ -76,14 +78,14 @@ class ReplicationControllerManager(base.Manager): path += '?' + '&'.join(filters) if limit is None: - return self._list(self._path(path), "rcs") + return self._list(self._path(bay_ident), "rcs") else: - return self._list_pagination(self._path(path), "rcs", + return self._list_pagination(self._path(bay_ident), "rcs", limit=limit) - def get(self, id, bay_uuid): + def get(self, id, bay_ident): try: - return self._list(self._path(id, bay_uuid))[0] + return self._list(self._path(id, bay_ident))[0] except IndexError: return None @@ -97,8 +99,8 @@ class ReplicationControllerManager(base.Manager): "Key must be in %s" % ",".join(CREATION_ATTRIBUTES)) return self._create(self._path(), new) - def delete(self, id, bay_uuid): - return self._delete(self._path(id, bay_uuid)) + def delete(self, id, bay_ident): + return self._delete(self._path(id, bay_ident)) - def update(self, id, bay_uuid, patch): - return self._update(self._path(id, bay_uuid), patch) + def update(self, id, bay_ident, patch): + return self._update(self._path(id, bay_ident), patch)