@@ -119,7 +119,10 @@ def take_action(self, parsed_args):
119119 result = 0
120120 for trunk in parsed_args .trunk :
121121 try :
122- trunk_id = network_client .find_trunk (trunk ).id
122+ trunk_id = network_client .find_trunk (
123+ trunk ,
124+ ignore_missing = False ,
125+ ).id
123126 network_client .delete_trunk (trunk_id )
124127 except Exception as e :
125128 result += 1
@@ -220,7 +223,10 @@ def get_parser(self, prog_name):
220223 def take_action (self , parsed_args ):
221224 network_client = self .app .client_manager .network
222225 identity_client = self .app .client_manager .identity
223- trunk_id = network_client .find_trunk (parsed_args .trunk )
226+ trunk_id = network_client .find_trunk (
227+ parsed_args .trunk ,
228+ ignore_missing = False ,
229+ )
224230 attrs = _get_attrs_for_trunk (
225231 network_client , identity_client , parsed_args
226232 )
@@ -258,7 +264,10 @@ def get_parser(self, prog_name):
258264
259265 def take_action (self , parsed_args ):
260266 network_client = self .app .client_manager .network
261- trunk_id = network_client .find_trunk (parsed_args .trunk ).id
267+ trunk_id = network_client .find_trunk (
268+ parsed_args .trunk ,
269+ ignore_missing = False ,
270+ ).id
262271 obj = network_client .get_trunk (trunk_id )
263272 display_columns , columns = _get_columns (obj )
264273 data = osc_utils .get_dict_properties (
@@ -282,7 +291,10 @@ def get_parser(self, prog_name):
282291
283292 def take_action (self , parsed_args ):
284293 network_client = self .app .client_manager .network
285- trunk_id = network_client .find_trunk (parsed_args .trunk )
294+ trunk_id = network_client .find_trunk (
295+ parsed_args .trunk ,
296+ ignore_missing = False ,
297+ )
286298 data = network_client .get_trunk_subports (trunk_id )
287299 headers : tuple [str , ...] = (
288300 'Port' ,
@@ -332,7 +344,10 @@ def get_parser(self, prog_name):
332344 def take_action (self , parsed_args ):
333345 network_client = self .app .client_manager .network
334346 attrs = _get_attrs_for_subports (network_client , parsed_args )
335- trunk_id = network_client .find_trunk (parsed_args .trunk )
347+ trunk_id = network_client .find_trunk (
348+ parsed_args .trunk ,
349+ ignore_missing = False ,
350+ )
336351 network_client .delete_trunk_subports (trunk_id , attrs )
337352
338353
@@ -360,7 +375,10 @@ def _get_attrs_for_trunk(network_client, identity_client, parsed_args):
360375 if parsed_args .disable :
361376 attrs ['admin_state_up' ] = False
362377 if 'parent_port' in parsed_args and parsed_args .parent_port is not None :
363- port_id = network_client .find_port (parsed_args .parent_port )['id' ]
378+ port_id = network_client .find_port (
379+ parsed_args .parent_port ,
380+ ignore_missing = False ,
381+ ).id
364382 attrs ['port_id' ] = port_id
365383 if 'add_subports' in parsed_args and parsed_args .add_subports is not None :
366384 attrs [SUB_PORTS ] = _format_subports (
@@ -384,7 +402,10 @@ def _format_subports(network_client, subports):
384402 for subport in subports :
385403 subport_attrs = {}
386404 if subport .get ('port' ):
387- port_id = network_client .find_port (subport ['port' ])['id' ]
405+ port_id = network_client .find_port (
406+ subport ['port' ],
407+ ignore_missing = False ,
408+ ).id
388409 subport_attrs ['port_id' ] = port_id
389410 if subport .get ('segmentation-id' ):
390411 try :
@@ -413,11 +434,10 @@ def _get_attrs_for_subports(network_client, parsed_args):
413434 ):
414435 subports_list = []
415436 for subport in parsed_args .unset_subports :
416- port_id = network_client .find_port (subport )['id' ]
437+ port_id = network_client .find_port (
438+ subport ,
439+ ignore_missing = False ,
440+ )['id' ]
417441 subports_list .append ({'port_id' : port_id })
418442 attrs = subports_list
419443 return attrs
420-
421-
422- def _get_id (client , id_or_name , resource ):
423- return client .find_resource (resource , str (id_or_name ))['id' ]
0 commit comments