Clean up deprecated CLI options

Clean up all deprecated CLI options that are marked to
be removed in version 3.3.0 as we are already in
version 4.0.0

Change-Id: Ia9c5602df1be987e7c12f625d4f8359590678a19
This commit is contained in:
Kevin_Zheng 2016-05-18 09:29:37 +08:00
parent d052f2609f
commit 6f8667990c
5 changed files with 63 additions and 304 deletions

View File

@ -449,80 +449,28 @@ class OpenStackComputeShell(object):
action='store_true',
help=_("Print call timing info."))
parser.add_argument(
'--os_username',
action=DeprecatedAction,
use=_('use "%s"; this option will be removed '
'in novaclient 3.3.0.') % '--os-username',
help=argparse.SUPPRESS)
parser.add_argument(
'--os_password',
action=DeprecatedAction,
use=_('use "%s"; this option will be removed '
'in novaclient 3.3.0.') % '--os-password',
help=argparse.SUPPRESS)
parser.add_argument(
'--os_tenant_name',
action=DeprecatedAction,
use=_('use "%s"; this option will be removed '
'in novaclient 3.3.0.') % '--os-tenant-name',
help=argparse.SUPPRESS)
parser.add_argument(
'--os_auth_url',
action=DeprecatedAction,
use=_('use "%s"; this option will be removed '
'in novaclient 3.3.0.') % '--os-auth-url',
help=argparse.SUPPRESS)
parser.add_argument(
'--os-region-name',
metavar='<region-name>',
default=utils.env('OS_REGION_NAME', 'NOVA_REGION_NAME'),
help=_('Defaults to env[OS_REGION_NAME].'))
parser.add_argument(
'--os_region_name',
action=DeprecatedAction,
use=_('use "%s"; this option will be removed '
'in novaclient 3.3.0.') % '--os-region-name',
help=argparse.SUPPRESS)
parser.add_argument(
'--os-auth-system',
metavar='<auth-system>',
default=utils.env('OS_AUTH_SYSTEM'),
help=argparse.SUPPRESS)
parser.add_argument(
'--os_auth_system',
action=DeprecatedAction,
use=_('use "%s"; this option will be removed '
'in novaclient 3.3.0.') % '--os-auth-system',
help=argparse.SUPPRESS)
parser.add_argument(
'--service-type',
metavar='<service-type>',
help=_('Defaults to compute for most actions.'))
parser.add_argument(
'--service_type',
action=DeprecatedAction,
use=_('use "%s"; this option will be removed '
'in novaclient 3.3.0.') % '--service-type',
help=argparse.SUPPRESS)
parser.add_argument(
'--service-name',
metavar='<service-name>',
default=utils.env('NOVA_SERVICE_NAME'),
help=_('Defaults to env[NOVA_SERVICE_NAME].'))
parser.add_argument(
'--service_name',
action=DeprecatedAction,
use=_('use "%s"; this option will be removed '
'in novaclient 3.3.0.') % '--service-name',
help=argparse.SUPPRESS)
parser.add_argument(
'--volume-service-name',
@ -531,12 +479,6 @@ class OpenStackComputeShell(object):
default=utils.env('NOVA_VOLUME_SERVICE_NAME'),
use=_('This option will be removed in novaclient 4.3.0.'),
help=argparse.SUPPRESS)
parser.add_argument(
'--volume_service_name',
action=DeprecatedAction,
use=_('use "%s"; this option will be removed '
'in novaclient 3.3.0.') % '--volume-service-name',
help=argparse.SUPPRESS)
parser.add_argument(
'--os-endpoint-type',
@ -550,19 +492,6 @@ class OpenStackComputeShell(object):
'env[OS_ENDPOINT_TYPE] or ') +
DEFAULT_NOVA_ENDPOINT_TYPE + '.')
parser.add_argument(
'--endpoint-type',
action=DeprecatedAction,
use=_('use "%s"; this option will be removed '
'in novaclient 3.3.0.') % '--os-endpoint-type',
help=argparse.SUPPRESS)
# NOTE(dtroyer): We can't add --endpoint_type here due to argparse
# thinking usage-list --end is ambiguous; but it
# works fine with only --endpoint-type present
# Go figure. I'm leaving this here for doc purposes.
# parser.add_argument('--endpoint_type',
# help=argparse.SUPPRESS)
parser.add_argument(
'--os-compute-api-version',
metavar='<compute-api-ver>',
@ -570,12 +499,6 @@ class OpenStackComputeShell(object):
default=DEFAULT_OS_COMPUTE_API_VERSION),
help=_('Accepts X, X.Y (where X is major and Y is minor part) or '
'"X.latest", defaults to env[OS_COMPUTE_API_VERSION].'))
parser.add_argument(
'--os_compute_api_version',
action=DeprecatedAction,
use=_('use "%s"; this option will be removed '
'in novaclient 3.3.0.') % '--os-compute-api-version',
help=argparse.SUPPRESS)
parser.add_argument(
'--bypass-url',
@ -584,12 +507,6 @@ class OpenStackComputeShell(object):
default=utils.env('NOVACLIENT_BYPASS_URL'),
help=_("Use this API endpoint instead of the Service Catalog. "
"Defaults to env[NOVACLIENT_BYPASS_URL]."))
parser.add_argument(
'--bypass_url',
action=DeprecatedAction,
use=_('use "%s"; this option will be removed '
'in novaclient 3.3.0.') % '--bypass-url',
help=argparse.SUPPRESS)
# The auth-system-plugins might require some extra options
novaclient.auth_plugin.load_auth_system_opts(parser)
@ -710,27 +627,6 @@ class OpenStackComputeShell(object):
def main(self, argv):
# Parse args once to find version and debug settings
parser = self.get_base_parser(argv)
# NOTE(dtroyer): Hackery to handle --endpoint_type due to argparse
# thinking usage-list --end is ambiguous; but it
# works fine with only --endpoint-type present
# Go figure.
if '--endpoint_type' in argv:
spot = argv.index('--endpoint_type')
argv[spot] = '--endpoint-type'
# NOTE(Vek): Not emitting a warning here, as that will
# occur when "--endpoint-type" is processed
# For backwards compat with old os-auth-token parameter
if '--os-auth-token' in argv:
spot = argv.index('--os-auth-token')
argv[spot] = '--os-token'
print(_('WARNING: Option "%(option)s" is deprecated; %(use)s') % {
'option': '--os-auth-token',
'use': _('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--os-token',
}, file=sys.stderr)
(args, args_list) = parser.parse_known_args(argv)
self.setup_debugging(args.debug)

View File

@ -607,7 +607,7 @@ class ShellTest(utils.TestCase):
if version is None:
cmd = 'list'
else:
cmd = ('--service_type %s --os-compute-api-version %s list' %
cmd = ('--service-type %s --os-compute-api-version %s list' %
(service_type, version))
self.make_env()
self.shell(cmd)

View File

@ -158,7 +158,7 @@ class ShellTest(utils.TestCase):
)
def test_boot_key(self):
self.run_command('boot --flavor 1 --image 1 --key_name 1 some-server')
self.run_command('boot --flavor 1 --image 1 --key-name 1 some-server')
self.assert_called_anytime(
'POST', '/servers',
{'server': {
@ -177,7 +177,7 @@ class ShellTest(utils.TestCase):
data = testfile_fd.read().encode('utf-8')
expected_file_data = base64.b64encode(data).decode('utf-8')
self.run_command(
'boot --flavor 1 --image 1 --user_data %s some-server' % testfile)
'boot --flavor 1 --image 1 --user-data %s some-server' % testfile)
self.assert_called_anytime(
'POST', '/servers',
{'server': {
@ -274,7 +274,7 @@ class ShellTest(utils.TestCase):
invalid_file = os.path.join(os.path.dirname(__file__),
'no_such_file')
cmd = ('boot some-server --flavor 1 --image 1'
' --user_data %s' % invalid_file)
' --user-data %s' % invalid_file)
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
def test_boot_no_image_no_bdms(self):
@ -287,7 +287,7 @@ class ShellTest(utils.TestCase):
def test_boot_no_image_bdms(self):
self.run_command(
'boot --flavor 1 --block_device_mapping vda=blah:::0 some-server'
'boot --flavor 1 --block-device-mapping vda=blah:::0 some-server'
)
self.assert_called_anytime(
'POST', '/os-volumes_boot',
@ -669,8 +669,9 @@ class ShellTest(utils.TestCase):
' --file /foo=%s' % invalid_file)
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
def test_boot_num_instances(self):
self.run_command('boot --image 1 --flavor 1 --num-instances 3 server')
def test_boot_max_min_count(self):
self.run_command('boot --image 1 --flavor 1 --min-count 1'
' --max-count 3 server')
self.assert_called_anytime(
'POST', '/servers',
{
@ -683,14 +684,8 @@ class ShellTest(utils.TestCase):
}
})
def test_boot_invalid_num_instances(self):
cmd = 'boot --image 1 --flavor 1 --num-instances 0 server'
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
def test_boot_num_instances_and_count(self):
cmd = 'boot --image 1 --flavor 1 --num-instances 3 --min-count 3 serv'
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
cmd = 'boot --image 1 --flavor 1 --num-instances 3 --max-count 3 serv'
def test_boot_invalid_min_count(self):
cmd = 'boot --image 1 --flavor 1 --min-count 0 server'
self.assertRaises(exceptions.CommandError, self.run_command, cmd)
def test_boot_min_max_count(self):

View File

@ -181,17 +181,6 @@ def _boot(cs, args):
min_count = 1
max_count = 1
# Don't let user mix num_instances and max_count/min_count.
if (args.num_instances is not None and
args.min_count is None and
args.max_count is None):
if args.num_instances < 1:
raise exceptions.CommandError(_("num_instances should be >= 1"))
max_count = args.num_instances
elif (args.num_instances is not None and
(args.min_count is not None or args.max_count is not None)):
raise exceptions.CommandError(_("Don't mix num-instances and "
"max/min-count"))
if args.min_count is not None:
if args.min_count < 1:
raise exceptions.CommandError(_("min_count should be >= 1"))
@ -388,15 +377,6 @@ def _boot(cs, args):
default=None,
metavar="<snapshot_id>",
help=_("Snapshot ID to boot from (will create a volume)."))
@utils.arg(
'--num-instances',
default=None,
type=int,
metavar='<number>',
action=shell.DeprecatedAction,
use=_('use "--min-count" and "--max-count"; this option will be removed '
'in novaclient 3.3.0.'),
help=argparse.SUPPRESS)
@utils.arg(
'--min-count',
default=None,
@ -430,46 +410,22 @@ def _boot(cs, args):
metavar='<key-name>',
help=_("Key name of keypair that should be created earlier with \
the command keypair-add."))
@utils.arg(
'--key_name',
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--key-name',
help=argparse.SUPPRESS)
@utils.arg('name', metavar='<name>', help=_('Name for the new server.'))
@utils.arg(
'--user-data',
default=None,
metavar='<user-data>',
help=_("user data file to pass to be exposed by the metadata server."))
@utils.arg(
'--user_data',
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--user-data',
help=argparse.SUPPRESS)
@utils.arg(
'--availability-zone',
default=None,
metavar='<availability-zone>',
help=_("The availability zone for server placement."))
@utils.arg(
'--availability_zone',
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--availability-zone',
help=argparse.SUPPRESS)
@utils.arg(
'--security-groups',
default=None,
metavar='<security-groups>',
help=_("Comma separated list of security group names."))
@utils.arg(
'--security_groups',
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--security-groups',
help=argparse.SUPPRESS)
@utils.arg(
'--block-device-mapping',
metavar="<dev-name=mapping>",
@ -477,13 +433,6 @@ def _boot(cs, args):
default=[],
help=_("Block device mapping in the format "
"<dev-name>=<id>:<type>:<size(GB)>:<delete-on-terminate>."))
@utils.arg(
'--block_device_mapping',
real_action='append',
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--block-device-mapping',
help=argparse.SUPPRESS)
@utils.arg(
'--block-device',
metavar="key1=value1[,key2=value2...]",
@ -1317,12 +1266,6 @@ def do_image_delete(cs, args):
metavar='<reservation-id>',
default=None,
help=_('Only return servers that match reservation-id.'))
@utils.arg(
'--reservation_id',
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--reservation-id',
help=argparse.SUPPRESS)
@utils.arg(
'--ip',
dest='ip',
@ -1347,12 +1290,6 @@ def do_image_delete(cs, args):
metavar='<name-regexp>',
default=None,
help=_('Search with regular expression match by server name.'))
@utils.arg(
'--instance_name',
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--instance-name',
help=argparse.SUPPRESS)
@utils.arg(
'--status',
dest='status',
@ -1388,15 +1325,6 @@ def do_image_delete(cs, args):
default=int(strutils.bool_from_string(
os.environ.get("ALL_TENANTS", 'false'), True)),
help=_('Display information from all tenants (Admin only).'))
@utils.arg(
'--all_tenants',
nargs='?',
type=int,
const=1,
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--all-tenants',
help=argparse.SUPPRESS)
@utils.arg(
'--tenant',
# nova db searches by project_id
@ -1717,12 +1645,6 @@ def do_reboot(cs, args):
metavar='<rebuild-password>',
default=False,
help=_("Set the provided admin password on the rebuilt server."))
@utils.arg(
'--rebuild_password',
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--rebuild-password',
help=argparse.SUPPRESS)
@utils.arg(
'--poll',
dest='poll',
@ -2486,13 +2408,6 @@ def do_get_rdp_console(cs, args):
'--console-type',
default='serial',
help=_('Type of serial console, default="serial".'))
@utils.arg(
'--console_type',
default='serial',
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--console-type',
help=argparse.SUPPRESS)
def do_get_serial_console(cs, args):
"""Get a serial console to a server."""
if args.console_type not in ('serial',):
@ -2773,12 +2688,6 @@ def do_dns_delete_domain(cs, args):
default=None,
help=_('Limit access to this domain to servers '
'in the specified availability zone.'))
@utils.arg(
'--availability_zone',
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--availability-zone',
help=argparse.SUPPRESS)
def do_dns_create_private_domain(cs, args):
"""Create the specified DNS domain."""
cs.dns_domains.create_private(args.domain,
@ -2957,15 +2866,6 @@ def do_secgroup_delete(cs, args):
default=int(strutils.bool_from_string(
os.environ.get("ALL_TENANTS", 'false'), True)),
help=_('Display information from all tenants (Admin only).'))
@utils.arg(
'--all_tenants',
nargs='?',
type=int,
const=1,
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--all-tenants',
help=argparse.SUPPRESS)
def do_secgroup_list(cs, args):
"""List security groups for the current tenant."""
search_opts = {'all_tenants': args.all_tenants}
@ -3092,12 +2992,6 @@ def _keypair_create(cs, args, name, pub_key):
metavar='<pub-key>',
default=None,
help=_('Path to a public ssh key.'))
@utils.arg(
'--pub_key',
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--pub-key',
help=argparse.SUPPRESS)
@utils.arg(
'--key-type',
metavar='<key-type>',
@ -3746,13 +3640,6 @@ def _print_aggregate_details(aggregate):
default="auto",
help=_('True in case of block_migration. (Default=auto:live_migration)'),
start_version="2.25")
@utils.arg(
'--block_migrate',
real_action='store_true',
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--block-migrate',
help=argparse.SUPPRESS)
@utils.arg(
'--disk-over-commit',
action='store_true',
@ -3760,14 +3647,6 @@ def _print_aggregate_details(aggregate):
default=False,
help=_('Allow overcommit. (Default=False)'),
start_version="2.0", end_version="2.24")
@utils.arg(
'--disk_over_commit',
real_action='store_true',
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--disk-over-commit',
help=argparse.SUPPRESS,
start_version="2.0", end_version="2.24")
@utils.arg(
'--force',
dest='force',
@ -4436,13 +4315,6 @@ def do_quota_defaults(cs, args):
type=int,
default=None,
help=_('New value for the "floating-ips" quota.'))
@utils.arg(
'--floating_ips',
type=int,
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--floating-ips',
help=argparse.SUPPRESS)
@utils.arg(
'--fixed-ips',
metavar='<fixed-ips>',
@ -4455,39 +4327,18 @@ def do_quota_defaults(cs, args):
type=int,
default=None,
help=_('New value for the "metadata-items" quota.'))
@utils.arg(
'--metadata_items',
type=int,
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--metadata-items',
help=argparse.SUPPRESS)
@utils.arg(
'--injected-files',
metavar='<injected-files>',
type=int,
default=None,
help=_('New value for the "injected-files" quota.'))
@utils.arg(
'--injected_files',
type=int,
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--injected-files',
help=argparse.SUPPRESS)
@utils.arg(
'--injected-file-content-bytes',
metavar='<injected-file-content-bytes>',
type=int,
default=None,
help=_('New value for the "injected-file-content-bytes" quota.'))
@utils.arg(
'--injected_file_content_bytes',
type=int,
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--injected-file-content-bytes',
help=argparse.SUPPRESS)
@utils.arg(
'--injected-file-path-bytes',
metavar='<injected-file-path-bytes>',
@ -4589,13 +4440,6 @@ def do_quota_class_show(cs, args):
type=int,
default=None,
help=_('New value for the "floating-ips" quota.'))
@utils.arg(
'--floating_ips',
type=int,
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--floating-ips',
help=argparse.SUPPRESS)
@utils.arg(
'--fixed-ips',
metavar='<fixed-ips>',
@ -4608,39 +4452,18 @@ def do_quota_class_show(cs, args):
type=int,
default=None,
help=_('New value for the "metadata-items" quota.'))
@utils.arg(
'--metadata_items',
type=int,
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--metadata-items',
help=argparse.SUPPRESS)
@utils.arg(
'--injected-files',
metavar='<injected-files>',
type=int,
default=None,
help=_('New value for the "injected-files" quota.'))
@utils.arg(
'--injected_files',
type=int,
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--injected-files',
help=argparse.SUPPRESS)
@utils.arg(
'--injected-file-content-bytes',
metavar='<injected-file-content-bytes>',
type=int,
default=None,
help=_('New value for the "injected-file-content-bytes" quota.'))
@utils.arg(
'--injected_file_content_bytes',
type=int,
action=shell.DeprecatedAction,
use=_('use "%s"; this option will be removed in '
'novaclient 3.3.0.') % '--injected-file-content-bytes',
help=argparse.SUPPRESS)
@utils.arg(
'--injected-file-path-bytes',
metavar='<injected-file-path-bytes>',
@ -4961,14 +4784,6 @@ def do_secgroup_delete_default_rule(cs, args):
default=argparse.SUPPRESS,
nargs='*',
help=_('Policies for the server groups.'))
@utils.arg(
'--policy',
default=[],
real_action='append',
action=shell.DeprecatedAction,
use=_('use positional parameters; this option will be removed in '
'novaclient 3.3.0.'),
help=argparse.SUPPRESS)
def do_server_group_create(cs, args):
"""Create a new server group with the specified details."""
if not args.policy:

View File

@ -0,0 +1,53 @@
---
update:
- The following deprecated options have been removed:
- create instances:
- --num-instance replaced by --min-count and --max-count
- --key_name replaced by --key-name
- --user_data replaced by --user-data
- --availability_zone replaced by -- availability-zone
- --security_groups replaced by --sercurity-groups
- --block_device_mapping replaced by --block-device-mapping
- list servers:
- --reservation_id replaced by --reservation-id
- --instance_name replaced by --instance-name
- --all_tenants replaced by --all-tenants
- rebuild instance:
- --rebuild_password replaced by --rebuild-password
- get serial console:
- --console_type replaced by --console-type
- create dns private domain:
- --availability_zone replaced by --availability-zone
- list security groups:
- --all_tenants replaced by --all-tenants
- add key pairs:
- --pub_key replaced by --pub-key
- live-migrate servers:
- --block_migrate replaced by --block-migrate
- --disk_over_commit replaced by --disk-over-commit
- update quotas:
- --floating_ips replaced by --floating-ips
- --metadata_items replaced by --metadata-items
- --injected_files replaced by --injected-files
- --injected_file_content_bytes replaced by --injected-file-content-bytes
- update quota classes:
- --floating_ips replaced by --floating-ips
- --metadata_items replaced by --metadata-items
- --injected_files replaced by --injected-files
- --injected_file_content_bytes replaced by --injected-file-content-bytes
- create server groups:
- --policy
- Authentication Options:
- --os_username replaced by --os-username
- --os_password replaced by --os-password
- --os_tenant_name replaced by --os-tenant-name
- --os_auth_url replaced by --os-auth-url
- --os_region_name replaced by --os-region-name
- --os_auth_system replaced by --os-auth-system
- --endpoint-type replaced by --os-endpoint-type
- Optional arguments:
- --service_type replaced by --service-type
- --service_name replaced by --service-name
- --volume_service_name replaced by --volume-service-name
- --os_compute_api_version replaced by --os-compute-api-version
- --bypass_url replaced by --bypass-url