@@ -1866,99 +1866,99 @@ def _show_progress(progress):
18661866
18671867
18681868class ListMigration (command .Command ):
1869- _description = _ ("""List server migrations. """ )
1869+ _description = _ ("""List server migrations""" )
18701870
18711871 def get_parser (self , prog_name ):
18721872 parser = super (ListMigration , self ).get_parser (prog_name )
18731873 parser .add_argument (
1874- " --server" ,
1875- metavar = " <server>" ,
1876- dest = 'server' ,
1877- default = None ,
1878- help = _ ( 'Server to show migration details (name or ID).' )
1874+ ' --server' ,
1875+ metavar = ' <server>' ,
1876+ help = _ (
1877+ 'Filter migrations by server (name or ID)'
1878+ )
18791879 )
18801880 parser .add_argument (
1881- "--host" ,
1882- metavar = "<host>" ,
1883- default = None ,
1884- help = _ ('Fetch migrations for the given host.' )
1881+ '--host' ,
1882+ metavar = '<host>' ,
1883+ help = _ (
1884+ 'Filter migrations by source or destination host'
1885+ ),
18851886 )
18861887 parser .add_argument (
1887- "--status" ,
1888- metavar = "<status>" ,
1889- default = None ,
1890- help = _ ('Fetch migrations for the given status.' )
1888+ '--status' ,
1889+ metavar = '<status>' ,
1890+ help = _ ('Filter migrations by status' )
18911891 )
18921892 parser .add_argument (
1893- " --marker" ,
1894- metavar = " <marker>" ,
1895- dest = 'marker' ,
1896- default = None ,
1897- help = _ ( "The last migration of the previous page; displays list "
1898- "of migrations after 'marker'. Note that the marker is "
1899- "the migration UUID. (Supported with "
1900- "``--os-compute-api-version`` 2.59 or greater.)" )
1893+ ' --marker' ,
1894+ metavar = ' <marker>' ,
1895+ help = _ (
1896+ "The last migration of the previous page; displays list "
1897+ " of migrations after 'marker'. Note that the marker is "
1898+ " the migration UUID. "
1899+ "(supported with --os-compute-api-version 2.59 or above) "
1900+ ),
19011901 )
19021902 parser .add_argument (
1903- "--limit" ,
1904- metavar = "<limit>" ,
1905- dest = 'limit' ,
1903+ '--limit' ,
1904+ metavar = '<limit>' ,
19061905 type = int ,
1907- default = None ,
1908- help = _ ( "Maximum number of migrations to display. Note that there "
1909- "is a configurable max limit on the server, and the limit "
1910- "that is used will be the minimum of what is requested "
1911- "here and what is configured in the server. "
1912- "(Supported with `` --os-compute-api-version`` 2.59 "
1913- "or greater.)" )
1906+ help = _ (
1907+ "Maximum number of migrations to display. Note that there "
1908+ "is a configurable max limit on the server, and the limit "
1909+ "that is used will be the minimum of what is requested "
1910+ "here and what is configured in the server. "
1911+ "(supported with --os-compute-api-version 2.59 or above) "
1912+ ),
19141913 )
19151914 parser .add_argument (
19161915 '--changes-since' ,
19171916 dest = 'changes_since' ,
19181917 metavar = '<changes-since>' ,
1919- default = None ,
1920- help = _ ( "List only migrations changed later or equal to a certain "
1921- "point of time. The provided time should be an ISO 8061 "
1922- "formatted time, e.g. ``2016-03-04T06:27:59Z``. "
1923- "(Supported with `` --os-compute-api-version`` 2.59 "
1924- "or greater.)" )
1918+ help = _ (
1919+ "List only migrations changed later or equal to a certain "
1920+ "point of time. The provided time should be an ISO 8061 "
1921+ "formatted time, e.g. ``2016-03-04T06:27:59Z``. "
1922+ "(supported with --os-compute-api-version 2.59 or above) "
1923+ ),
19251924 )
19261925 parser .add_argument (
19271926 '--changes-before' ,
19281927 dest = 'changes_before' ,
19291928 metavar = '<changes-before>' ,
1930- default = None ,
1931- help = _ ( "List only migrations changed earlier or equal to a "
1932- "certain point of time. The provided time should be an ISO "
1933- "8061 formatted time, e.g. ``2016-03-04T06:27:59Z``. "
1934- "(Supported with `` --os-compute-api-version`` 2.66 or "
1935- "greater.)" )
1929+ help = _ (
1930+ "List only migrations changed earlier or equal to a "
1931+ "certain point of time. The provided time should be an ISO "
1932+ "8061 formatted time, e.g. ``2016-03-04T06:27:59Z``. "
1933+ "(supported with --os-compute-api-version 2.66 or above) "
1934+ ),
19361935 )
19371936 parser .add_argument (
19381937 '--project' ,
19391938 metavar = '<project>' ,
19401939 dest = 'project_id' ,
1941- default = None ,
1942- help = _ ( "Filter the migrations by the given project ID. "
1943- "(Supported with `` --os-compute-api-version`` 2.80 "
1944- "or greater.)" ),
1940+ help = _ (
1941+ "Filter migrations by project (ID) "
1942+ "(supported with --os-compute-api-version 2.80 or above) "
1943+ ),
19451944 )
19461945 parser .add_argument (
19471946 '--user' ,
19481947 metavar = '<user>' ,
19491948 dest = 'user_id' ,
1950- default = None ,
1951- help = _ ( "Filter the migrations by the given user ID. "
1952- "(Supported with `` --os-compute-api-version`` 2.80 "
1953- "or greater.)" ),
1949+ help = _ (
1950+ "Filter migrations by user (ID) "
1951+ "(supported with --os-compute-api-version 2.80 or above) "
1952+ ),
19541953 )
19551954 return parser
19561955
19571956 def print_migrations (self , parsed_args , compute_client , migrations ):
1958- columns = ['Source Node' , 'Dest Node' , 'Source Compute' ,
1959- 'Dest Compute' , 'Dest Host' , 'Status' ,
1960- 'Server UUID' , 'Old Flavor' , 'New Flavor' ,
1961- 'Created At' , 'Updated At' ]
1957+ columns = [
1958+ 'Source Node' , 'Dest Node' , 'Source Compute' , 'Dest Compute' ,
1959+ 'Dest Host' , 'Status' , 'Server UUID' , 'Old Flavor' , 'New Flavor' ,
1960+ 'Created At' , 'Updated At' ,
1961+ ]
19621962
19631963 # Insert migrations UUID after ID
19641964 if compute_client .api_version >= api_versions .APIVersion ("2.59" ):
@@ -1978,48 +1978,73 @@ def print_migrations(self, parsed_args, compute_client, migrations):
19781978 if parsed_args .user_id :
19791979 columns .insert (len (columns ) - 2 , "User" )
19801980
1981- columns_header = columns
1982- return (columns_header , (utils .get_item_properties (
1983- mig , columns ) for mig in migrations ))
1981+ return (
1982+ columns ,
1983+ (utils .get_item_properties (mig , columns ) for mig in migrations ),
1984+ )
19841985
19851986 def take_action (self , parsed_args ):
19861987 compute_client = self .app .client_manager .compute
19871988
19881989 search_opts = {
1989- " host" : parsed_args .host ,
1990- " server" : parsed_args .server ,
1991- " status" : parsed_args .status ,
1990+ ' host' : parsed_args .host ,
1991+ ' server' : parsed_args .server ,
1992+ ' status' : parsed_args .status ,
19921993 }
19931994
1994- if (parsed_args .marker or parsed_args .limit or
1995- parsed_args .changes_since ):
1996- if compute_client .api_version < api_versions .APIVersion ("2.59" ):
1997- msg = _ ("marker, limit and/or changes_since is not supported "
1998- "for --os-compute-api-version less than 2.59" )
1995+ if parsed_args .marker :
1996+ if compute_client .api_version < api_versions .APIVersion ('2.59' ):
1997+ msg = _ (
1998+ '--os-compute-api-version 2.59 or greater is required to '
1999+ 'support the --marker option'
2000+ )
19992001 raise exceptions .CommandError (msg )
2000- if parsed_args .marker :
2001- search_opts ['marker' ] = parsed_args .marker
2002- if parsed_args .limit :
2003- search_opts ['limit' ] = parsed_args .limit
2004- if parsed_args .changes_since :
2005- search_opts ['changes_since' ] = parsed_args .changes_since
2002+ search_opts ['marker' ] = parsed_args .marker
2003+
2004+ if parsed_args .limit :
2005+ if compute_client .api_version < api_versions .APIVersion ('2.59' ):
2006+ msg = _ (
2007+ '--os-compute-api-version 2.59 or greater is required to '
2008+ 'support the --limit option'
2009+ )
2010+ raise exceptions .CommandError (msg )
2011+ search_opts ['limit' ] = parsed_args .limit
2012+
2013+ if parsed_args .changes_since :
2014+ if compute_client .api_version < api_versions .APIVersion ('2.59' ):
2015+ msg = _ (
2016+ '--os-compute-api-version 2.59 or greater is required to '
2017+ 'support the --changes-since option'
2018+ )
2019+ raise exceptions .CommandError (msg )
2020+ search_opts ['changes_since' ] = parsed_args .changes_since
20062021
20072022 if parsed_args .changes_before :
2008- if compute_client .api_version < api_versions .APIVersion ("2.66" ):
2009- msg = _ ("changes_before is not supported for "
2010- "--os-compute-api-version less than 2.66" )
2023+ if compute_client .api_version < api_versions .APIVersion ('2.66' ):
2024+ msg = _ (
2025+ '--os-compute-api-version 2.66 or greater is required to '
2026+ 'support the --changes-before option'
2027+ )
20112028 raise exceptions .CommandError (msg )
20122029 search_opts ['changes_before' ] = parsed_args .changes_before
20132030
2014- if parsed_args .project_id or parsed_args .user_id :
2015- if compute_client .api_version < api_versions .APIVersion ("2.80" ):
2016- msg = _ ("Project and/or user is not supported for "
2017- "--os-compute-api-version less than 2.80" )
2031+ if parsed_args .project_id :
2032+ if compute_client .api_version < api_versions .APIVersion ('2.80' ):
2033+ msg = _ (
2034+ '--os-compute-api-version 2.80 or greater is required to '
2035+ 'support the --project option'
2036+ )
2037+ raise exceptions .CommandError (msg )
2038+ search_opts ['project_id' ] = parsed_args .project_id
2039+
2040+ if parsed_args .user_id :
2041+ if compute_client .api_version < api_versions .APIVersion ('2.80' ):
2042+ msg = _ (
2043+ '--os-compute-api-version 2.80 or greater is required to '
2044+ 'support the --user option'
2045+ )
20182046 raise exceptions .CommandError (msg )
2019- if parsed_args .project_id :
2020- search_opts ['project_id' ] = parsed_args .project_id
2021- if parsed_args .user_id :
2022- search_opts ['user_id' ] = parsed_args .user_id
2047+ search_opts ['user_id' ] = parsed_args .user_id
20232048
20242049 migrations = compute_client .migrations .list (** search_opts )
20252050
0 commit comments