How to use list_l3_agents_hosting_router method in tempest

Best Python code snippet using tempest_python

l3agentscheduler.py

Source:l3agentscheduler.py Github

copy

Full Screen

...56 plugin = manager.NeutronManager.get_plugin()57 policy.enforce(request.context,58 "get_%s" % L3_AGENTS,59 {})60 return plugin.list_l3_agents_hosting_router(61 request.context, kwargs['router_id'])62class L3agentscheduler(extensions.ExtensionDescriptor):63 """Extension class supporting l3 agent scheduler.64 """65 @classmethod66 def get_name(cls):67 return "L3 Agent Scheduler"68 @classmethod69 def get_alias(cls):70 return constants.L3_AGENT_SCHEDULER_EXT_ALIAS71 @classmethod72 def get_description(cls):73 return "Schedule routers among l3 agents"74 @classmethod75 def get_namespace(cls):76 return "http://docs.openstack.org/ext/l3_agent_scheduler/api/v1.0"77 @classmethod78 def get_updated(cls):79 return "2013-02-07T10:00:00-00:00"80 @classmethod81 def get_resources(cls):82 """Returns Ext Resources."""83 exts = []84 parent = dict(member_name="agent",85 collection_name="agents")86 controller = resource.Resource(RouterSchedulerController(),87 base.FAULT_MAP)88 exts.append(extensions.ResourceExtension(89 L3_ROUTERS, controller, parent))90 parent = dict(member_name="router",91 collection_name="routers")92 controller = resource.Resource(L3AgentsHostingRouterController(),93 base.FAULT_MAP)94 exts.append(extensions.ResourceExtension(95 L3_AGENTS, controller, parent))96 return exts97 def get_extended_resources(self, version):98 return {}99class InvalidL3Agent(agent.AgentNotFound):100 message = _("Agent %(id)s is not a L3 Agent or has been disabled")101class RouterHostedByL3Agent(exceptions.Conflict):102 message = _("The router %(router_id)s has been already hosted"103 " by the L3 Agent %(agent_id)s.")104class RouterSchedulingFailed(exceptions.Conflict):105 message = _("Failed scheduling router %(router_id)s to"106 " the L3 Agent %(agent_id)s.")107class RouterNotHostedByL3Agent(exceptions.Conflict):108 message = _("The router %(router_id)s is not hosted"109 " by L3 agent %(agent_id)s.")110class L3AgentSchedulerPluginBase(object):111 """REST API to operate the l3 agent scheduler.112 All of method must be in an admin context.113 """114 @abstractmethod115 def add_router_to_l3_agent(self, context, id, router_id):116 pass117 @abstractmethod118 def remove_router_from_l3_agent(self, context, id, router_id):119 pass120 @abstractmethod121 def list_routers_on_l3_agent(self, context, id):122 pass123 @abstractmethod124 def list_l3_agents_hosting_router(self, context, router_id):...

Full Screen

Full Screen

test_l3_agent_scheduler.py

Source:test_l3_agent_scheduler.py Github

copy

Full Screen

...55 @decorators.idempotent_id('9464e5e7-8625-49c3-8fd1-89c52be59d66')56 def test_add_list_remove_router_on_l3_agent(self):57 l3_agent_ids = list()58 # First list agents which host router59 body = self.admin_client.list_l3_agents_hosting_router(60 self.router['id'])61 # Now remove router from all agents62 for agent in body['agents']:63 self.admin_client.remove_router_from_l3_agent(64 agent['id'], self.router['id'])65 # Now list agents which host router again - list should be empty66 body = self.admin_client.list_l3_agents_hosting_router(67 self.router['id'])68 self.assertEqual([], body['agents'])69 # Now add router to one of agents70 self.admin_client.add_router_to_l3_agent(71 self.agent['id'],72 router_id=self.router['id'])73 # And check that router is hosted by this agent74 body = self.admin_client.list_l3_agents_hosting_router(75 self.router['id'])76 for agent in body['agents']:77 l3_agent_ids.append(agent['id'])78 self.assertIn('agent_type', agent)79 self.assertEqual('L3 agent', agent['agent_type'])...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run tempest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful