2222from openstackclient .identity import common as identity_common
2323from openstackclient .network import common
2424from openstackclient .network import sdk_utils
25+ from openstackclient .network .v2 import _tag
2526
2627
2728def _get_network_columns (item ):
@@ -139,11 +140,14 @@ def update_parser_network(self, parser):
139140 help = _ ("Owner's project (name or ID)" )
140141 )
141142 identity_common .add_project_domain_option_to_parser (parser )
143+ _tag .add_tag_option_to_parser_for_create (parser , _ ('floating IP' ))
142144 return parser
143145
144146 def take_action_network (self , client , parsed_args ):
145147 attrs = _get_attrs (self .app .client_manager , parsed_args )
146148 obj = client .create_ip (** attrs )
149+ # tags cannot be set when created, so tags need to be set later.
150+ _tag .update_tags_for_set (client , obj , parsed_args )
147151 display_columns , columns = _get_network_columns (obj )
148152 data = utils .get_item_properties (obj , columns )
149153 return (display_columns , data )
@@ -280,6 +284,7 @@ def update_parser_network(self, parser):
280284 help = _ ("List floating IP(s) according to "
281285 "given router (name or ID)" )
282286 )
287+ _tag .add_tag_filtering_option_to_parser (parser , _ ('floating IP' ))
283288
284289 return parser
285290
@@ -308,11 +313,13 @@ def take_action_network(self, client, parsed_args):
308313 'router_id' ,
309314 'status' ,
310315 'description' ,
316+ 'tags' ,
311317 )
312318 headers = headers + (
313319 'Router' ,
314320 'Status' ,
315321 'Description' ,
322+ 'Tags' ,
316323 )
317324
318325 query = {}
@@ -342,6 +349,8 @@ def take_action_network(self, client, parsed_args):
342349 ignore_missing = False )
343350 query ['router_id' ] = router .id
344351
352+ _tag .get_tag_filtering_args (parsed_args , query )
353+
345354 data = client .ips (** query )
346355
347356 return (headers ,
@@ -431,6 +440,9 @@ def get_parser(self, prog_name):
431440 action = 'store_true' ,
432441 help = _ ("Remove the QoS policy attached to the floating IP" )
433442 )
443+
444+ _tag .add_tag_option_to_parser_for_set (parser , _ ('floating IP' ))
445+
434446 return parser
435447
436448 def take_action (self , parsed_args ):
@@ -453,7 +465,11 @@ def take_action(self, parsed_args):
453465 if 'no_qos_policy' in parsed_args and parsed_args .no_qos_policy :
454466 attrs ['qos_policy_id' ] = None
455467
456- client .update_ip (obj , ** attrs )
468+ if attrs :
469+ client .update_ip (obj , ** attrs )
470+
471+ # tags is a subresource and it needs to be updated separately.
472+ _tag .update_tags_for_set (client , obj , parsed_args )
457473
458474
459475class ShowFloatingIP (common .NetworkAndComputeShowOne ):
@@ -528,6 +544,8 @@ def get_parser(self, prog_name):
528544 default = False ,
529545 help = _ ("Remove the QoS policy attached to the floating IP" )
530546 )
547+ _tag .add_tag_option_to_parser_for_unset (parser , _ ('floating IP' ))
548+
531549 return parser
532550
533551 def take_action (self , parsed_args ):
@@ -544,3 +562,6 @@ def take_action(self, parsed_args):
544562
545563 if attrs :
546564 client .update_ip (obj , ** attrs )
565+
566+ # tags is a subresource and it needs to be updated separately.
567+ _tag .update_tags_for_unset (client , obj , parsed_args )
0 commit comments