From: Ying Liu Date: Fri, 26 Aug 2011 00:01:50 +0000 (-0700) Subject: change get_host and get_instance_port function name X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=4a79f89f7bc3316fcb728c3d9421198ed5fc3bd2;p=openstack-build%2Fneutron-build.git change get_host and get_instance_port function name --- diff --git a/extensions/novatenant.py b/extensions/novatenant.py index 5cbfc4bd0..4f21516bc 100644 --- a/extensions/novatenant.py +++ b/extensions/novatenant.py @@ -65,8 +65,8 @@ class Novatenant(object): """ Returns Ext Resource Name """ parent_resource = dict(member_name="tenant", collection_name="extensions/csco/tenants") - member_actions = {'get_host': "PUT", - 'get_instance_port': "PUT"} + member_actions = {'schedule_host': "PUT", + 'associate_port': "PUT"} controller = NovatenantsController(QuantumManager.get_plugin()) return [extensions.ResourceExtension('novatenants', controller, parent=parent_resource, @@ -81,7 +81,7 @@ class NovatenantsController(common.QuantumController): 'param-name': 'novatenant_name', 'required': True}] - _get_host_ops_param_list = [{ + _schedule_host_ops_param_list = [{ 'param-name': 'instance_id', 'required': True}, { 'param-name': 'instance_desc', @@ -126,21 +126,21 @@ class NovatenantsController(common.QuantumController): return "novatenant is a dummy resource" #added for cisco's extension - def get_host(self, request, tenant_id, id): + def schedule_host(self, request, tenant_id, id): content_type = request.best_match_content_type() print "Content type:%s" % content_type try: req_params = \ self._parse_request_params(request, - self._get_host_ops_param_list) + self._schedule_host_ops_param_list) except exc.HTTPError as exp: return faults.Fault(exp) instance_id = req_params['instance_id'] instance_desc = req_params['instance_desc'] try: - host = self._plugin.get_host(tenant_id, instance_id, instance_desc) + host = self._plugin.schedule_host(tenant_id, instance_id, instance_desc) builder = novatenant_view.get_view_builder(request) result = builder.build_host(host) return result @@ -148,14 +148,14 @@ class NovatenantsController(common.QuantumController): except qexception.PortNotFound as exp: return faults.Fault(faults.PortNotFound(exp)) - def get_instance_port(self, request, tenant_id, id): + def associate_port(self, request, tenant_id, id): content_type = request.best_match_content_type() print "Content type:%s" % content_type try: req_params = \ self._parse_request_params(request, - self._get_host_ops_param_list) + self._schedule_host_ops_param_list) except exc.HTTPError as exp: return faults.Fault(exp) instance_id = req_params['instance_id'] @@ -163,7 +163,7 @@ class NovatenantsController(common.QuantumController): instance_desc = req_params['instance_desc'] try: vif = self._plugin. \ - get_instance_port(tenant_id, instance_id, instance_desc) + associate_port(tenant_id, instance_id, instance_desc) builder = novatenant_view.get_view_builder(request) result = builder.build_vif(vif) return result diff --git a/quantum/plugins/cisco/tests/unit/test_cisco_extension.py b/quantum/plugins/cisco/tests/unit/test_cisco_extension.py index f69ac3df0..172a2e712 100644 --- a/quantum/plugins/cisco/tests/unit/test_cisco_extension.py +++ b/quantum/plugins/cisco/tests/unit/test_cisco_extension.py @@ -405,8 +405,8 @@ class NovatenantExtensionTest(unittest.TestCase): def setUp(self): parent_resource = dict(member_name="tenant", collection_name="extensions/csco/tenants") - member_actions = {'get_host': "PUT", - 'get_instance_port': "PUT"} + member_actions = {'schedule_host': "PUT", + 'associate_port': "PUT"} controller = novatenant.NovatenantsController( QuantumManager.get_plugin()) res_ext = extensions.ResourceExtension('novatenants', controller, @@ -420,29 +420,29 @@ class NovatenantExtensionTest(unittest.TestCase): 'instance_desc': {'key1': '1', 'key2': '2'}}} - def test_get_host(self): - LOG.debug("test_get_host - START") + def test_schedule_host(self): + LOG.debug("test_schedule_host - START") req_body = json.dumps(self.test_instance_data) - host_path = self.novatenants_path + "001/get_host" + host_path = self.novatenants_path + "001/schedule_host" host_response = self.test_app.put( host_path, req_body, content_type=self.contenttype) self.assertEqual(200, host_response.status_int) - LOG.debug("test_get_host - END") + LOG.debug("test_schedule_host - END") - def test_get_hostBADRequest(self): - LOG.debug("test_get_hostBADRequest - START") - host_path = self.novatenants_path + "001/get_host" + def test_schedule_hostBADRequest(self): + LOG.debug("test_schedule_hostBADRequest - START") + host_path = self.novatenants_path + "001/schedule_host" host_response = self.test_app.put( host_path, 'BAD_REQUEST', content_type=self.contenttype, status='*') self.assertEqual(400, host_response.status_int) - LOG.debug("test_get_hostBADRequest - END") + LOG.debug("test_schedule_hostBADRequest - END") def test_instance_port(self): LOG.debug("test_instance_port - START") req_body = json.dumps(self.test_instance_data) - instance_port_path = self.novatenants_path + "001/get_instance_port" + instance_port_path = self.novatenants_path + "001/associate_port" instance_port_response = self.test_app.put( instance_port_path, req_body, content_type=self.contenttype)