@@ -1390,9 +1390,11 @@ def get_parser(self, prog_name):
13901390 parser .add_argument (
13911391 '--ip6' ,
13921392 metavar = '<ip-address-regex>' ,
1393- help = _ ('Regular expression to match IPv6 addresses. Note '
1394- 'that this option only applies for non-admin users '
1395- 'when using ``--os-compute-api-version`` 2.5 or greater.' ),
1393+ help = _ (
1394+ 'Regular expression to match IPv6 addresses. Note '
1395+ 'that this option only applies for non-admin users '
1396+ 'when using ``--os-compute-api-version`` 2.5 or greater.'
1397+ ),
13961398 )
13971399 parser .add_argument (
13981400 '--name' ,
@@ -1443,6 +1445,12 @@ def get_parser(self, prog_name):
14431445 help = _ ('Search by user (admin only) (name or ID)' ),
14441446 )
14451447 identity_common .add_user_domain_option_to_parser (parser )
1448+ parser .add_argument (
1449+ '--deleted' ,
1450+ action = 'store_true' ,
1451+ default = False ,
1452+ help = _ ('Only display deleted servers (admin only)' ),
1453+ )
14461454 parser .add_argument (
14471455 '--long' ,
14481456 action = 'store_true' ,
@@ -1454,74 +1462,83 @@ def get_parser(self, prog_name):
14541462 '-n' , '--no-name-lookup' ,
14551463 action = 'store_true' ,
14561464 default = False ,
1457- help = _ ('Skip flavor and image name lookup.'
1458- 'Mutually exclusive with "--name-lookup-one-by-one"'
1459- ' option.' ),
1465+ help = _ (
1466+ 'Skip flavor and image name lookup. '
1467+ 'Mutually exclusive with "--name-lookup-one-by-one" option.'
1468+ ),
14601469 )
14611470 name_lookup_group .add_argument (
14621471 '--name-lookup-one-by-one' ,
14631472 action = 'store_true' ,
14641473 default = False ,
1465- help = _ ('When looking up flavor and image names, look them up'
1466- 'one by one as needed instead of all together (default). '
1467- 'Mutually exclusive with "--no-name-lookup|-n" option.' ),
1474+ help = _ (
1475+ 'When looking up flavor and image names, look them up'
1476+ 'one by one as needed instead of all together (default). '
1477+ 'Mutually exclusive with "--no-name-lookup|-n" option.'
1478+ ),
14681479 )
14691480 parser .add_argument (
14701481 '--marker' ,
14711482 metavar = '<server>' ,
14721483 default = None ,
1473- help = _ ('The last server of the previous page. Display '
1474- 'list of servers after marker. Display all servers if not '
1475- 'specified. When used with ``--deleted``, the marker must '
1476- 'be an ID, otherwise a name or ID can be used.' ),
1484+ help = _ (
1485+ 'The last server of the previous page. Display '
1486+ 'list of servers after marker. Display all servers if not '
1487+ 'specified. When used with ``--deleted``, the marker must '
1488+ 'be an ID, otherwise a name or ID can be used.'
1489+ ),
14771490 )
14781491 parser .add_argument (
14791492 '--limit' ,
14801493 metavar = '<num-servers>' ,
14811494 type = int ,
14821495 default = None ,
1483- help = _ ("Maximum number of servers to display. If limit equals -1, "
1484- "all servers will be displayed. If limit is greater than "
1485- "'osapi_max_limit' option of Nova API, "
1486- "'osapi_max_limit' will be used instead." ),
1487- )
1488- parser .add_argument (
1489- '--deleted' ,
1490- action = "store_true" ,
1491- default = False ,
1492- help = _ ('Only display deleted servers (Admin only).' )
1496+ help = _ (
1497+ "Maximum number of servers to display. If limit equals -1, "
1498+ "all servers will be displayed. If limit is greater than "
1499+ "'osapi_max_limit' option of Nova API, "
1500+ "'osapi_max_limit' will be used instead."
1501+ ),
14931502 )
14941503 parser .add_argument (
14951504 '--changes-before' ,
14961505 metavar = '<changes-before>' ,
14971506 default = None ,
1498- help = _ ("List only servers changed before a certain point of time. "
1499- "The provided time should be an ISO 8061 formatted time "
1500- "(e.g., 2016-03-05T06:27:59Z). "
1501- "(Supported by API versions '2.66' - '2.latest')" )
1507+ help = _ (
1508+ "List only servers changed before a certain point of time. "
1509+ "The provided time should be an ISO 8061 formatted time "
1510+ "(e.g., 2016-03-05T06:27:59Z). "
1511+ '(supported by --os-compute-api-version 2.66 or above)'
1512+ ),
15021513 )
15031514 parser .add_argument (
15041515 '--changes-since' ,
15051516 metavar = '<changes-since>' ,
15061517 default = None ,
1507- help = _ ("List only servers changed after a certain point of time."
1508- " The provided time should be an ISO 8061 formatted time"
1509- " (e.g., 2016-03-04T06:27:59Z)." )
1518+ help = _ (
1519+ "List only servers changed after a certain point of time. "
1520+ "The provided time should be an ISO 8061 formatted time "
1521+ "(e.g., 2016-03-04T06:27:59Z)."
1522+ ),
15101523 )
15111524 lock_group = parser .add_mutually_exclusive_group ()
15121525 lock_group .add_argument (
15131526 '--locked' ,
15141527 action = 'store_true' ,
15151528 default = False ,
1516- help = _ ('Only display locked servers. '
1517- 'Requires ``--os-compute-api-version`` 2.73 or greater.' ),
1529+ help = _ (
1530+ 'Only display locked servers '
1531+ '(supported by --os-compute-api-version 2.73 or above)'
1532+ ),
15181533 )
15191534 lock_group .add_argument (
15201535 '--unlocked' ,
15211536 action = 'store_true' ,
15221537 default = False ,
1523- help = _ ('Only display unlocked servers. '
1524- 'Requires ``--os-compute-api-version`` 2.73 or greater.' ),
1538+ help = _ (
1539+ 'Only display unlocked servers '
1540+ '(supported by --os-compute-api-version 2.73 or above)'
1541+ ),
15251542 )
15261543 parser .add_argument (
15271544 '--tags' ,
@@ -1624,18 +1641,25 @@ def take_action(self, parsed_args):
16241641
16251642 search_opts ['not-tags' ] = parsed_args .not_tags
16261643
1627- support_locked = (compute_client .api_version >=
1628- api_versions .APIVersion ('2.73' ))
1629- if not support_locked and (parsed_args .locked or parsed_args .unlocked ):
1630- msg = _ ('--os-compute-api-version 2.73 or greater is required to '
1631- 'use the (un)locked filter option.' )
1632- raise exceptions .CommandError (msg )
1633- elif support_locked :
1634- # Only from 2.73.
1635- if parsed_args .locked :
1636- search_opts ['locked' ] = True
1637- if parsed_args .unlocked :
1638- search_opts ['locked' ] = False
1644+ if parsed_args .locked :
1645+ if compute_client .api_version < api_versions .APIVersion ('2.73' ):
1646+ msg = _ (
1647+ '--os-compute-api-version 2.73 or greater is required to '
1648+ 'support the --locked option'
1649+ )
1650+ raise exceptions .CommandError (msg )
1651+
1652+ search_opts ['locked' ] = True
1653+ elif parsed_args .unlocked :
1654+ if compute_client .api_version < api_versions .APIVersion ('2.73' ):
1655+ msg = _ (
1656+ '--os-compute-api-version 2.73 or greater is required to '
1657+ 'support the --unlocked option'
1658+ )
1659+ raise exceptions .CommandError (msg )
1660+
1661+ search_opts ['locked' ] = False
1662+
16391663 LOG .debug ('search options: %s' , search_opts )
16401664
16411665 if search_opts ['changes-before' ]:
@@ -1842,17 +1866,21 @@ def take_action(self, parsed_args):
18421866 s .flavor_name = ''
18431867 s .flavor_id = ''
18441868
1845- table = (column_headers ,
1846- (utils .get_item_properties (
1847- s , columns ,
1848- mixed_case_fields = mixed_case_fields ,
1849- formatters = {
1850- 'OS-EXT-STS:power_state' :
1851- _format_servers_list_power_state ,
1852- 'Networks' : _format_servers_list_networks ,
1853- 'Metadata' : utils .format_dict ,
1854- },
1855- ) for s in data ))
1869+ table = (
1870+ column_headers ,
1871+ (
1872+ utils .get_item_properties (
1873+ s , columns ,
1874+ mixed_case_fields = mixed_case_fields ,
1875+ formatters = {
1876+ 'OS-EXT-STS:power_state' :
1877+ _format_servers_list_power_state ,
1878+ 'Networks' : _format_servers_list_networks ,
1879+ 'Metadata' : utils .format_dict ,
1880+ },
1881+ ) for s in data
1882+ ),
1883+ )
18561884 return table
18571885
18581886
0 commit comments