def get_resources(cls): """ Returns all defined resources """ controller = StatsController(QuantumManager.get_plugin()) parent_resource = dict(member_name="port", collection_name="extensions/ovs/tenants/" + \ ":(tenant_id)/networks/:(network_id)/ports") return [extensions.ResourceExtension('stats', controller, parent=parent_resource)]
def get_resources(cls): """ Returns Ext Resources """ parent_resource = dict(member_name="tenant", collection_name="extensions/csco/tenants") controller = MultiportController(QuantumManager.get_plugin()) return [ extensions.ResourceExtension('multiport', controller, parent=parent_resource) ]
def test_resource_can_be_added_as_extension(self): res_ext = extensions.ResourceExtension( 'tweedles', self.ResourceExtensionController()) test_app = setup_extensions_test_app(SimpleExtensionManager(res_ext)) index_response = test_app.get("/tweedles") self.assertEqual(200, index_response.status_int) self.assertEqual("resource index", index_response.body) show_response = test_app.get("/tweedles/25266") self.assertEqual({'data': {'id': "25266"}}, show_response.json)
def get_resources(cls): """ Returns Ext Resource """ parent_resource = dict(member_name="tenant", collection_name="extensions/csco/tenants") member_actions = {'schedule_host': "PUT", 'associate_port': "PUT", 'detach_port': "PUT"} controller = EnginetenantsController(QuantumManager.get_plugin()) return [extensions.ResourceExtension('enginetenants', controller, parent=parent_resource, member_actions=member_actions)]
def test_resource_extension_for_get_custom_collection_action(self): controller = self.ResourceExtensionController() collections = {'custom_collection_action': "GET"} res_ext = extensions.ResourceExtension('tweedles', controller, collection_actions=collections) test_app = setup_extensions_test_app(SimpleExtensionManager(res_ext)) response = test_app.get("/tweedles/custom_collection_action") self.assertEqual(200, response.status_int) self.assertEqual(json.loads(response.body)['collection'], "value")
def test_resource_extension_with_custom_member_action(self): controller = self.ResourceExtensionController() member = {'custom_member_action': "GET"} res_ext = extensions.ResourceExtension('tweedles', controller, member_actions=member) test_app = setup_extensions_test_app(SimpleExtensionManager(res_ext)) response = test_app.get("/tweedles/some_id/custom_member_action") self.assertEqual(200, response.status_int) self.assertEqual(json.loads(response.body)['member_action'], "value")
def get_resources(cls): """ Returns all defined resources """ parent_resource = dict(member_name="tenant", collection_name="extensions/csco/tenants") member_actions = { 'associate_portprofile': "PUT", 'disassociate_portprofile': "PUT" } controller = PortprofilesController(QuantumManager.get_plugin()) return [ extensions.ResourceExtension('portprofiles', controller, parent=parent_resource, member_actions=member_actions) ]
def test_resource_ext_for_nested_resource_custom_collection_action(self): controller = self.ResourceExtensionController() collections = {'custom_collection_action': "GET"} parent = dict(collection_name='beetles', member_name='beetle') res_ext = extensions.ResourceExtension('tweedles', controller, collection_actions=collections, parent=parent) test_app = setup_extensions_test_app(SimpleExtensionManager(res_ext)) response = test_app.get("/beetles/beetle_id" "/tweedles/custom_collection_action") self.assertEqual(200, response.status_int) self.assertEqual(json.loads(response.body)['collection'], "value")
def get_resources(self): resources = [] resource = extensions.ResourceExtension('foxnsocks', FoxInSocksController()) resources.append(resource) return resources