summaryrefslogtreecommitdiff
path: root/neutronclient/neutron/v2_0/agentscheduler.py
diff options
context:
space:
mode:
Diffstat (limited to 'neutronclient/neutron/v2_0/agentscheduler.py')
-rw-r--r--neutronclient/neutron/v2_0/agentscheduler.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/neutronclient/neutron/v2_0/agentscheduler.py b/neutronclient/neutron/v2_0/agentscheduler.py
index e77f186..6776b99 100644
--- a/neutronclient/neutron/v2_0/agentscheduler.py
+++ b/neutronclient/neutron/v2_0/agentscheduler.py
@@ -275,3 +275,56 @@ class GetLbaasAgentHostingPool(neutronV20.ListCommand):
agent = neutron_client.get_lbaas_agent_hosting_pool(**search_opts)
data = {'agents': [agent['agent']]}
return data
+
+
+class ListLoadBalancersOnLbaasAgent(neutronV20.ListCommand):
+ """List the loadbalancers on a loadbalancer v2 agent."""
+
+ list_columns = ['id', 'name', 'admin_state_up', 'provisioning_status']
+ resource = 'loadbalancer'
+ unknown_parts_flag = False
+
+ def get_parser(self, prog_name):
+ parser = super(ListLoadBalancersOnLbaasAgent, self).get_parser(
+ prog_name)
+ parser.add_argument(
+ 'lbaas_agent',
+ help=_('ID of the loadbalancer agent to query.'))
+ return parser
+
+ def call_server(self, neutron_client, search_opts, parsed_args):
+ data = neutron_client.list_loadbalancers_on_lbaas_agent(
+ parsed_args.lbaas_agent, **search_opts)
+ return data
+
+
+class GetLbaasAgentHostingLoadBalancer(neutronV20.ListCommand):
+ """Get lbaas v2 agent hosting a loadbalancer.
+
+ Deriving from ListCommand though server will return only one agent
+ to keep common output format for all agent schedulers
+ """
+
+ resource = 'agent'
+ list_columns = ['id', 'host', 'admin_state_up', 'alive']
+ unknown_parts_flag = False
+
+ def get_parser(self, prog_name):
+ parser = super(GetLbaasAgentHostingLoadBalancer,
+ self).get_parser(prog_name)
+ parser.add_argument('loadbalancer',
+ help=_('LoadBalancer to query.'))
+ return parser
+
+ def extend_list(self, data, parsed_args):
+ for agent in data:
+ agent['alive'] = ":-)" if agent['alive'] else 'xxx'
+
+ def call_server(self, neutron_client, search_opts, parsed_args):
+ _id = neutronV20.find_resourceid_by_name_or_id(
+ neutron_client, 'loadbalancer', parsed_args.loadbalancer)
+ search_opts['loadbalancer'] = _id
+ agent = neutron_client.get_lbaas_agent_hosting_loadbalancer(
+ **search_opts)
+ data = {'agents': [agent['agent']]}
+ return data \ No newline at end of file