@@ -1383,9 +1383,11 @@ def get_parser(self, prog_name):
13831383 parser .add_argument (
13841384 '--ip6' ,
13851385 metavar = '<ip-address-regex>' ,
1386- help = _ ('Regular expression to match IPv6 addresses. Note '
1387- 'that this option only applies for non-admin users '
1388- 'when using ``--os-compute-api-version`` 2.5 or greater.' ),
1386+ help = _ (
1387+ 'Regular expression to match IPv6 addresses. Note '
1388+ 'that this option only applies for non-admin users '
1389+ 'when using ``--os-compute-api-version`` 2.5 or greater.'
1390+ ),
13891391 )
13901392 parser .add_argument (
13911393 '--name' ,
@@ -1436,6 +1438,12 @@ def get_parser(self, prog_name):
14361438 help = _ ('Search by user (admin only) (name or ID)' ),
14371439 )
14381440 identity_common .add_user_domain_option_to_parser (parser )
1441+ parser .add_argument (
1442+ '--deleted' ,
1443+ action = 'store_true' ,
1444+ default = False ,
1445+ help = _ ('Only display deleted servers (admin only)' ),
1446+ )
14391447 parser .add_argument (
14401448 '--long' ,
14411449 action = 'store_true' ,
@@ -1447,74 +1455,83 @@ def get_parser(self, prog_name):
14471455 '-n' , '--no-name-lookup' ,
14481456 action = 'store_true' ,
14491457 default = False ,
1450- help = _ ('Skip flavor and image name lookup.'
1451- 'Mutually exclusive with "--name-lookup-one-by-one"'
1452- ' option.' ),
1458+ help = _ (
1459+ 'Skip flavor and image name lookup. '
1460+ 'Mutually exclusive with "--name-lookup-one-by-one" option.'
1461+ ),
14531462 )
14541463 name_lookup_group .add_argument (
14551464 '--name-lookup-one-by-one' ,
14561465 action = 'store_true' ,
14571466 default = False ,
1458- help = _ ('When looking up flavor and image names, look them up'
1459- 'one by one as needed instead of all together (default). '
1460- 'Mutually exclusive with "--no-name-lookup|-n" option.' ),
1467+ help = _ (
1468+ 'When looking up flavor and image names, look them up'
1469+ 'one by one as needed instead of all together (default). '
1470+ 'Mutually exclusive with "--no-name-lookup|-n" option.'
1471+ ),
14611472 )
14621473 parser .add_argument (
14631474 '--marker' ,
14641475 metavar = '<server>' ,
14651476 default = None ,
1466- help = _ ('The last server of the previous page. Display '
1467- 'list of servers after marker. Display all servers if not '
1468- 'specified. When used with ``--deleted``, the marker must '
1469- 'be an ID, otherwise a name or ID can be used.' ),
1477+ help = _ (
1478+ 'The last server of the previous page. Display '
1479+ 'list of servers after marker. Display all servers if not '
1480+ 'specified. When used with ``--deleted``, the marker must '
1481+ 'be an ID, otherwise a name or ID can be used.'
1482+ ),
14701483 )
14711484 parser .add_argument (
14721485 '--limit' ,
14731486 metavar = '<num-servers>' ,
14741487 type = int ,
14751488 default = None ,
1476- help = _ ("Maximum number of servers to display. If limit equals -1, "
1477- "all servers will be displayed. If limit is greater than "
1478- "'osapi_max_limit' option of Nova API, "
1479- "'osapi_max_limit' will be used instead." ),
1480- )
1481- parser .add_argument (
1482- '--deleted' ,
1483- action = "store_true" ,
1484- default = False ,
1485- help = _ ('Only display deleted servers (Admin only).' )
1489+ help = _ (
1490+ "Maximum number of servers to display. If limit equals -1, "
1491+ "all servers will be displayed. If limit is greater than "
1492+ "'osapi_max_limit' option of Nova API, "
1493+ "'osapi_max_limit' will be used instead."
1494+ ),
14861495 )
14871496 parser .add_argument (
14881497 '--changes-before' ,
14891498 metavar = '<changes-before>' ,
14901499 default = None ,
1491- help = _ ("List only servers changed before a certain point of time. "
1492- "The provided time should be an ISO 8061 formatted time "
1493- "(e.g., 2016-03-05T06:27:59Z). "
1494- "(Supported by API versions '2.66' - '2.latest')" )
1500+ help = _ (
1501+ "List only servers changed before a certain point of time. "
1502+ "The provided time should be an ISO 8061 formatted time "
1503+ "(e.g., 2016-03-05T06:27:59Z). "
1504+ '(supported by --os-compute-api-version 2.66 or above)'
1505+ ),
14951506 )
14961507 parser .add_argument (
14971508 '--changes-since' ,
14981509 metavar = '<changes-since>' ,
14991510 default = None ,
1500- help = _ ("List only servers changed after a certain point of time."
1501- " The provided time should be an ISO 8061 formatted time"
1502- " (e.g., 2016-03-04T06:27:59Z)." )
1511+ help = _ (
1512+ "List only servers changed after a certain point of time. "
1513+ "The provided time should be an ISO 8061 formatted time "
1514+ "(e.g., 2016-03-04T06:27:59Z)."
1515+ ),
15031516 )
15041517 lock_group = parser .add_mutually_exclusive_group ()
15051518 lock_group .add_argument (
15061519 '--locked' ,
15071520 action = 'store_true' ,
15081521 default = False ,
1509- help = _ ('Only display locked servers. '
1510- 'Requires ``--os-compute-api-version`` 2.73 or greater.' ),
1522+ help = _ (
1523+ 'Only display locked servers '
1524+ '(supported by --os-compute-api-version 2.73 or above)'
1525+ ),
15111526 )
15121527 lock_group .add_argument (
15131528 '--unlocked' ,
15141529 action = 'store_true' ,
15151530 default = False ,
1516- help = _ ('Only display unlocked servers. '
1517- 'Requires ``--os-compute-api-version`` 2.73 or greater.' ),
1531+ help = _ (
1532+ 'Only display unlocked servers '
1533+ '(supported by --os-compute-api-version 2.73 or above)'
1534+ ),
15181535 )
15191536 parser .add_argument (
15201537 '--tags' ,
@@ -1616,18 +1633,25 @@ def take_action(self, parsed_args):
16161633
16171634 search_opts ['not-tags' ] = parsed_args .not_tags
16181635
1619- support_locked = (compute_client .api_version >=
1620- api_versions .APIVersion ('2.73' ))
1621- if not support_locked and (parsed_args .locked or parsed_args .unlocked ):
1622- msg = _ ('--os-compute-api-version 2.73 or greater is required to '
1623- 'use the (un)locked filter option.' )
1624- raise exceptions .CommandError (msg )
1625- elif support_locked :
1626- # Only from 2.73.
1627- if parsed_args .locked :
1628- search_opts ['locked' ] = True
1629- if parsed_args .unlocked :
1630- search_opts ['locked' ] = False
1636+ if parsed_args .locked :
1637+ if compute_client .api_version < api_versions .APIVersion ('2.73' ):
1638+ msg = _ (
1639+ '--os-compute-api-version 2.73 or greater is required to '
1640+ 'support the --locked option'
1641+ )
1642+ raise exceptions .CommandError (msg )
1643+
1644+ search_opts ['locked' ] = True
1645+ elif parsed_args .unlocked :
1646+ if compute_client .api_version < api_versions .APIVersion ('2.73' ):
1647+ msg = _ (
1648+ '--os-compute-api-version 2.73 or greater is required to '
1649+ 'support the --unlocked option'
1650+ )
1651+ raise exceptions .CommandError (msg )
1652+
1653+ search_opts ['locked' ] = False
1654+
16311655 LOG .debug ('search options: %s' , search_opts )
16321656
16331657 if search_opts ['changes-before' ]:
@@ -1834,17 +1858,21 @@ def take_action(self, parsed_args):
18341858 s .flavor_name = ''
18351859 s .flavor_id = ''
18361860
1837- table = (column_headers ,
1838- (utils .get_item_properties (
1839- s , columns ,
1840- mixed_case_fields = mixed_case_fields ,
1841- formatters = {
1842- 'OS-EXT-STS:power_state' :
1843- _format_servers_list_power_state ,
1844- 'Networks' : _format_servers_list_networks ,
1845- 'Metadata' : utils .format_dict ,
1846- },
1847- ) for s in data ))
1861+ table = (
1862+ column_headers ,
1863+ (
1864+ utils .get_item_properties (
1865+ s , columns ,
1866+ mixed_case_fields = mixed_case_fields ,
1867+ formatters = {
1868+ 'OS-EXT-STS:power_state' :
1869+ _format_servers_list_power_state ,
1870+ 'Networks' : _format_servers_list_networks ,
1871+ 'Metadata' : utils .format_dict ,
1872+ },
1873+ ) for s in data
1874+ ),
1875+ )
18481876 return table
18491877
18501878
0 commit comments