@@ -72,6 +72,25 @@ def take_action(self, parsed_args):
7272class ListNetworkAgent (command .Lister ):
7373 _description = _ ("List network agents" )
7474
75+ def get_parser (self , prog_name ):
76+ parser = super (ListNetworkAgent , self ).get_parser (prog_name )
77+ parser .add_argument (
78+ '--agent-type' ,
79+ metavar = '<agent-type>' ,
80+ choices = ["dhcp" , "open-vswitch" , "linux-bridge" , "ofa" , "l3" ,
81+ "loadbalancer" , "metering" , "metadata" , "macvtap" , "nic" ],
82+ help = _ ("List only agents with the specified agent type. "
83+ "The supported agent types are: dhcp, open-vswitch, "
84+ "linux-bridge, ofa, l3, loadbalancer, metering, "
85+ "metadata, macvtap, nic." )
86+ )
87+ parser .add_argument (
88+ '--host' ,
89+ metavar = '<host>' ,
90+ help = _ ("List only agents running on the specified host" )
91+ )
92+ return parser
93+
7594 def take_action (self , parsed_args ):
7695 client = self .app .client_manager .network
7796 columns = (
@@ -92,7 +111,27 @@ def take_action(self, parsed_args):
92111 'State' ,
93112 'Binary'
94113 )
95- data = client .agents ()
114+
115+ key_value = {
116+ 'dhcp' : 'DHCP agent' ,
117+ 'open-vswitch' : 'Open vSwitch agent' ,
118+ 'linux-bridge' : 'Linux bridge agent' ,
119+ 'ofa' : 'OFA driver agent' ,
120+ 'l3' : 'L3 agent' ,
121+ 'loadbalancer' : 'Loadbalancer agent' ,
122+ 'metering' : 'Metering agent' ,
123+ 'metadata' : 'Metadata agent' ,
124+ 'macvtap' : 'Macvtap agent' ,
125+ 'nic' : 'NIC Switch agent'
126+ }
127+
128+ filters = {}
129+ if parsed_args .agent_type is not None :
130+ filters ['agent_type' ] = key_value [parsed_args .agent_type ]
131+ if parsed_args .host is not None :
132+ filters ['host' ] = parsed_args .host
133+
134+ data = client .agents (** filters )
96135 return (column_headers ,
97136 (utils .get_item_properties (
98137 s , columns , formatters = _formatters ,
0 commit comments