@@ -2065,6 +2065,14 @@ def get_parser(self, prog_name):
20652065 metavar = '<status>' ,
20662066 help = _ ('Filter migrations by status' )
20672067 )
2068+ parser .add_argument (
2069+ '--type' ,
2070+ metavar = '<type>' ,
2071+ choices = [
2072+ 'evacuation' , 'live-migration' , 'cold-migration' , 'resize' ,
2073+ ],
2074+ help = _ ('Filter migrations by type' ),
2075+ )
20682076 parser .add_argument (
20692077 '--marker' ,
20702078 metavar = '<marker>' ,
@@ -2140,10 +2148,6 @@ def print_migrations(self, parsed_args, compute_client, migrations):
21402148 if compute_client .api_version >= api_versions .APIVersion ("2.59" ):
21412149 columns .insert (0 , "UUID" )
21422150
2143- # TODO(brinzhang): It also suppports filter migrations by type
2144- # since 2.1. https://review.opendev.org/#/c/675117 supported
2145- # filtering the migrations by 'migration_type' and 'source_compute'
2146- # in novaclient, that will be added in OSC by follow-up.
21472151 if compute_client .api_version >= api_versions .APIVersion ("2.23" ):
21482152 columns .insert (0 , "Id" )
21492153 columns .insert (len (columns ) - 2 , "Type" )
@@ -2168,6 +2172,13 @@ def take_action(self, parsed_args):
21682172 'status' : parsed_args .status ,
21692173 }
21702174
2175+ if parsed_args .type :
2176+ migration_type = parsed_args .type
2177+ # we're using an alias because the default value is confusing
2178+ if migration_type == 'cold-migration' :
2179+ migration_type = 'migration'
2180+ search_opts ['type' ] = migration_type
2181+
21712182 if parsed_args .marker :
21722183 if compute_client .api_version < api_versions .APIVersion ('2.59' ):
21732184 msg = _ (
0 commit comments