2020from osc_lib import utils
2121from osc_lib .utils import tags as _tag
2222
23+ from openstackclient .api import compute_v2
2324from openstackclient .i18n import _
2425from openstackclient .identity import common as identity_common
2526from openstackclient .network import common
@@ -180,7 +181,8 @@ def take_action_network(self, client, parsed_args):
180181
181182 def take_action_compute (self , client , parsed_args ):
182183 description = self ._get_description (parsed_args )
183- obj = client .api .security_group_create (
184+ obj = compute_v2 .create_security_group (
185+ client ,
184186 parsed_args .name ,
185187 description ,
186188 )
@@ -212,7 +214,8 @@ def take_action_network(self, client, parsed_args):
212214 client .delete_security_group (obj )
213215
214216 def take_action_compute (self , client , parsed_args ):
215- client .api .security_group_delete (self .r )
217+ security_group = compute_v2 .find_security_group (client , self .r )
218+ compute_v2 .delete_security_group (client , security_group ['id' ])
216219
217220
218221# TODO(rauta): Use the SDK resource mapped attribute names once
@@ -291,10 +294,10 @@ def take_action_network(self, client, parsed_args):
291294 )
292295
293296 def take_action_compute (self , client , parsed_args ):
294- search = {'all_tenants' : parsed_args .all_projects }
295- data = client .api .security_group_list (
297+ data = compute_v2 .list_security_groups (
296298 # TODO(dtroyer): add limit, marker
297- search_opts = search ,
299+ client ,
300+ all_projects = parsed_args .all_projects ,
298301 )
299302
300303 columns = (
@@ -383,20 +386,21 @@ def take_action_network(self, client, parsed_args):
383386 _tag .update_tags_for_set (client , obj , parsed_args )
384387
385388 def take_action_compute (self , client , parsed_args ):
386- data = client .api .security_group_find (parsed_args .group )
389+ security_group = compute_v2 .find_security_group (
390+ client , parsed_args .group
391+ )
387392
393+ params = {}
388394 if parsed_args .name is not None :
389- data ['name' ] = parsed_args .name
395+ params ['name' ] = parsed_args .name
390396 if parsed_args .description is not None :
391- data ['description' ] = parsed_args .description
397+ params ['description' ] = parsed_args .description
392398
393399 # NOTE(rtheis): Previous behavior did not raise a CommandError
394400 # if there were no updates. Maintain this behavior and issue
395401 # the update.
396- client .api .security_group_set (
397- data ,
398- data ['name' ],
399- data ['description' ],
402+ compute_v2 .update_security_group (
403+ client , security_group ['id' ], ** params
400404 )
401405
402406
@@ -422,7 +426,7 @@ def take_action_network(self, client, parsed_args):
422426 return (display_columns , data )
423427
424428 def take_action_compute (self , client , parsed_args ):
425- obj = client . api . security_group_find ( parsed_args .group )
429+ obj = compute_v2 . find_security_group ( client , parsed_args .group )
426430 display_columns , property_columns = _get_columns (obj )
427431 data = utils .get_dict_properties (
428432 obj , property_columns , formatters = _formatters_compute
0 commit comments