@@ -3139,21 +3139,18 @@ def _show_progress(progress):
31393139 self .app .stdout .write ('\r Progress: %s' % progress )
31403140 self .app .stdout .flush ()
31413141
3142- compute_client = self .app .client_manager .compute
3142+ compute_client = self .app .client_manager .sdk_connection . compute
31433143
3144- server = utils .find_resource (
3145- compute_client .servers ,
3146- parsed_args .server ,
3144+ server = compute_client .find_server (
3145+ parsed_args .server , ignore_missing = False
31473146 )
31483147
31493148 if parsed_args .live_migration :
31503149 kwargs = {}
31513150
31523151 block_migration = parsed_args .block_migration
31533152 if block_migration is None :
3154- if compute_client .api_version < api_versions .APIVersion (
3155- '2.25'
3156- ):
3153+ if not sdk_utils .supports_microversion (compute_client , '2.25' ):
31573154 block_migration = False
31583155 else :
31593156 block_migration = 'auto'
@@ -3166,10 +3163,8 @@ def _show_progress(progress):
31663163 # want to support, so if the user is using --live-migration
31673164 # and --host, we want to enforce that they are using version
31683165 # 2.30 or greater.
3169- if (
3170- parsed_args .host
3171- and compute_client .api_version
3172- < api_versions .APIVersion ('2.30' )
3166+ if parsed_args .host and not sdk_utils .supports_microversion (
3167+ compute_client , '2.30'
31733168 ):
31743169 raise exceptions .CommandError (
31753170 '--os-compute-api-version 2.30 or greater is required '
@@ -3179,13 +3174,13 @@ def _show_progress(progress):
31793174 # The host parameter is required in the API even if None.
31803175 kwargs ['host' ] = parsed_args .host
31813176
3182- if compute_client . api_version < api_versions . APIVersion ( '2.25' ):
3183- kwargs ['disk_over_commit ' ] = parsed_args .disk_overcommit
3177+ if not sdk_utils . supports_microversion ( compute_client , '2.25' ):
3178+ kwargs ['disk_overcommit ' ] = parsed_args .disk_overcommit
31843179 # We can't use an argparse default value because then we can't
31853180 # distinguish between explicit 'False' and unset for the below
31863181 # case (microversion >= 2.25)
3187- if kwargs ['disk_over_commit ' ] is None :
3188- kwargs ['disk_over_commit ' ] = False
3182+ if kwargs ['disk_overcommit ' ] is None :
3183+ kwargs ['disk_overcommit ' ] = False
31893184 elif parsed_args .disk_overcommit is not None :
31903185 # TODO(stephenfin): Raise an error here in OSC 7.0
31913186 msg = _ (
@@ -3196,7 +3191,7 @@ def _show_progress(progress):
31963191 )
31973192 self .log .warning (msg )
31983193
3199- server . live_migrate ( ** kwargs )
3194+ compute_client . live_migrate_server ( server , ** kwargs )
32003195 else : # cold migration
32013196 if parsed_args .block_migration or parsed_args .disk_overcommit :
32023197 raise exceptions .CommandError (
@@ -3205,23 +3200,21 @@ def _show_progress(progress):
32053200 "specified"
32063201 )
32073202 if parsed_args .host :
3208- if compute_client .api_version < api_versions .APIVersion (
3209- '2.56'
3210- ):
3203+ if not sdk_utils .supports_microversion (compute_client , '2.56' ):
32113204 msg = _ (
32123205 '--os-compute-api-version 2.56 or greater is '
32133206 'required to use --host without --live-migration.'
32143207 )
32153208 raise exceptions .CommandError (msg )
32163209
32173210 kwargs = {'host' : parsed_args .host } if parsed_args .host else {}
3218- server . migrate ( ** kwargs )
3211+ compute_client . migrate_server ( server , ** kwargs )
32193212
32203213 if parsed_args .wait :
32213214 if utils .wait_for_status (
3222- compute_client .servers . get ,
3215+ compute_client .get_server ,
32233216 server .id ,
3224- success_status = [ 'active' , 'verify_resize' ] ,
3217+ success_status = ( 'active' , 'verify_resize' ) ,
32253218 callback = _show_progress ,
32263219 ):
32273220 self .app .stdout .write (
0 commit comments