Merge "Remove the nova-manage flavor sub-command"

This commit is contained in:
Jenkins 2014-10-02 18:38:42 +00:00 committed by Gerrit Code Review
commit c66d610799
3 changed files with 0 additions and 257 deletions

View File

@ -115,44 +115,6 @@ Nova Floating IPs
Displays a list of all floating IP addresses.
Nova Flavor
~~~~~~~~~~~
**DEPRECATED** Use the nova flavor-* commands from python-novaclient instead.
The flavor subcommand will be removed in the 2015.1 release.
``nova-manage flavor list``
Outputs a list of all active flavors to the screen.
``nova-manage flavor list --all``
Outputs a list of all flavors (active and inactive) to the screen.
``nova-manage flavor create <name> <memory> <vCPU> <local_storage> <flavorID> <(optional) swap> <(optional) RXTX Quota> <(optional) RXTX Cap>``
creates a flavor with the following positional arguments:
* memory (expressed in megabytes)
* vcpu(s) (integer)
* local storage (expressed in gigabytes)
* flavorid (unique integer)
* swap space (expressed in megabytes, defaults to zero, optional)
* RXTX quotas (expressed in gigabytes, defaults to zero, optional)
* RXTX cap (expressed in gigabytes, defaults to zero, optional)
``nova-manage flavor delete <name>``
Delete the flavor with the name <name>. This marks the flavor as inactive and cannot be launched. However, the record stays in the database for archival and billing purposes.
``nova-manage flavor delete <name> --purge``
Purges the flavor with the name <name>. This removes this flavor from the database.
Nova Instance_type
~~~~~~~~~~~~~~~~~~
The instance_type command is provided as an alias for the flavor command. All the same subcommands and arguments from nova-manage flavor can be used.
Nova Images
~~~~~~~~~~~

View File

@ -61,7 +61,6 @@ import sys
import decorator
import netaddr
from oslo.config import cfg
from oslo.db import exception as db_exc
from oslo import messaging
import six
@ -920,142 +919,6 @@ class DbCommands(object):
db.archive_deleted_rows(admin_context, max_rows)
class FlavorCommands(object):
"""Class for managing flavors.
Note instance type is a deprecated synonym for flavor.
"""
description = ('DEPRECATED: Use the nova flavor-* commands from '
'python-novaclient instead. The flavor subcommand will be '
'removed in the 2015.1 release')
def _print_flavors(self, val):
is_public = ('private', 'public')[val["is_public"] == 1]
print(("%s: Memory: %sMB, VCPUS: %s, Root: %sGB, Ephemeral: %sGb, "
"FlavorID: %s, Swap: %sMB, RXTX Factor: %s, %s, ExtraSpecs %s") % (
val["name"], val["memory_mb"], val["vcpus"], val["root_gb"],
val["ephemeral_gb"], val["flavorid"], val["swap"],
val["rxtx_factor"], is_public, val["extra_specs"]))
@args('--name', metavar='<name>',
help='Name of flavor')
@args('--memory', metavar='<memory size>', help='Memory size')
@args('--cpu', dest='vcpus', metavar='<num cores>', help='Number cpus')
@args('--root_gb', metavar='<root_gb>', help='Root disk size')
@args('--ephemeral_gb', metavar='<ephemeral_gb>',
help='Ephemeral disk size')
@args('--flavor', dest='flavorid', metavar='<flavor id>',
help='Flavor ID')
@args('--swap', metavar='<swap>', help='Swap')
@args('--rxtx_factor', metavar='<rxtx_factor>', help='rxtx_factor')
@args('--is_public', metavar='<is_public>',
help='Make flavor accessible to the public')
def create(self, name, memory, vcpus, root_gb, ephemeral_gb=0,
flavorid=None, swap=0, rxtx_factor=1.0, is_public=True):
"""Creates flavors."""
try:
flavors.create(name, memory, vcpus, root_gb,
ephemeral_gb=ephemeral_gb, flavorid=flavorid,
swap=swap, rxtx_factor=rxtx_factor,
is_public=is_public)
except exception.InvalidInput as e:
print(_("Must supply valid parameters to create flavor"))
print(e)
return 1
except exception.FlavorExists:
print(_("Flavor exists."))
print(_("Please ensure flavor name and flavorid are "
"unique."))
print(_("Currently defined flavor names and flavorids:"))
print()
self.list()
return 2
except Exception:
print(_("Unknown error"))
return 3
else:
print(_("%s created") % name)
@args('--name', metavar='<name>', help='Name of flavor')
def delete(self, name):
"""Marks flavors as deleted."""
try:
flavors.destroy(name)
except exception.FlavorNotFound:
print(_("Valid flavor name is required"))
return 1
except db_exc.DBError as e:
print(_("DB Error: %s") % e)
return(2)
except Exception:
return(3)
else:
print(_("%s deleted") % name)
@args('--name', metavar='<name>', help='Name of flavor')
def list(self, name=None):
"""Lists all active or specific flavors."""
try:
if name is None:
inst_types = flavors.get_all_flavors()
else:
inst_types = flavors.get_flavor_by_name(name)
except db_exc.DBError as e:
_db_error(e)
if isinstance(inst_types.values()[0], dict):
for k, v in inst_types.iteritems():
self._print_flavors(v)
else:
self._print_flavors(inst_types)
@args('--name', metavar='<name>', help='Name of flavor')
@args('--key', metavar='<key>', help='The key of the key/value pair')
@args('--value', metavar='<value>', help='The value of the key/value pair')
def set_key(self, name, key, value=None):
"""Add key/value pair to specified flavor's extra_specs."""
try:
try:
inst_type = flavors.get_flavor_by_name(name)
except exception.FlavorNotFoundByName as e:
print(e)
return(2)
ctxt = context.get_admin_context()
ext_spec = {key: value}
db.flavor_extra_specs_update_or_create(
ctxt,
inst_type["flavorid"],
ext_spec)
print((_("Key %(key)s set to %(value)s on instance "
"type %(name)s") %
{'key': key, 'value': value, 'name': name}))
except db_exc.DBError as e:
_db_error(e)
@args('--name', metavar='<name>', help='Name of flavor')
@args('--key', metavar='<key>', help='The key to be deleted')
def unset_key(self, name, key):
"""Delete the specified extra spec for flavor."""
try:
try:
inst_type = flavors.get_flavor_by_name(name)
except exception.FlavorNotFoundByName as e:
print(e)
return(2)
ctxt = context.get_admin_context()
db.flavor_extra_specs_delete(
ctxt,
inst_type["flavorid"],
key)
print((_("Key %(key)s on flavor %(name)s unset") %
{'key': key, 'name': name}))
except db_exc.DBError as e:
_db_error(e)
class AgentBuildCommands(object):
"""Class for managing agent builds."""
@ -1269,7 +1132,6 @@ CATEGORIES = {
'cell': CellCommands,
'db': DbCommands,
'fixed': FixedIpCommands,
'flavor': FlavorCommands,
'floating': FloatingIpCommands,
'host': HostCommands,
'logs': GetLogCommands,

View File

@ -305,87 +305,6 @@ class NeutronV2NetworkCommandsTestCase(test.TestCase):
self.assertEqual(2, self.commands.modify('192.168.0.1'))
class FlavorCommandsTestCase(test.TestCase):
def setUp(self):
super(FlavorCommandsTestCase, self).setUp()
values = dict(name="test.small",
memory_mb=220,
vcpus=1,
root_gb=16,
ephemeral_gb=32,
flavorid=105)
ref = db.flavor_create(context.get_admin_context(),
values)
self.instance_type_name = ref["name"]
self.instance_type_id = ref["id"]
self.instance_type_flavorid = ref["flavorid"]
self.set_key = manage.FlavorCommands().set_key
self.unset_key = manage.FlavorCommands().unset_key
def tearDown(self):
db.flavor_destroy(context.get_admin_context(),
"test.small")
super(FlavorCommandsTestCase, self).tearDown()
def _test_extra_specs_empty(self):
empty_specs = {}
actual_specs = db.flavor_extra_specs_get(
context.get_admin_context(),
self.instance_type_id)
self.assertEqual(empty_specs, actual_specs)
def test_extra_specs_set_unset(self):
expected_specs = {'k1': 'v1'}
self._test_extra_specs_empty()
self.set_key(self.instance_type_name, "k1", "v1")
actual_specs = db.flavor_extra_specs_get(
context.get_admin_context(),
self.instance_type_flavorid)
self.assertEqual(expected_specs, actual_specs)
self.unset_key(self.instance_type_name, "k1")
self._test_extra_specs_empty()
def test_extra_specs_update(self):
expected_specs = {'k1': 'v1'}
updated_specs = {'k1': 'v2'}
self._test_extra_specs_empty()
self.set_key(self.instance_type_name, "k1", "v1")
actual_specs = db.flavor_extra_specs_get(
context.get_admin_context(),
self.instance_type_flavorid)
self.assertEqual(expected_specs, actual_specs)
self.set_key(self.instance_type_name, "k1", "v2")
actual_specs = db.flavor_extra_specs_get(
context.get_admin_context(),
self.instance_type_flavorid)
self.assertEqual(updated_specs, actual_specs)
self.unset_key(self.instance_type_name, "k1")
def test_extra_specs_multiple(self):
two_items_extra_specs = {'k1': 'v1',
'k3': 'v3'}
self._test_extra_specs_empty()
self.set_key(self.instance_type_name, "k1", "v1")
self.set_key(self.instance_type_name, "k3", "v3")
actual_specs = db.flavor_extra_specs_get(
context.get_admin_context(),
self.instance_type_flavorid)
self.assertEqual(two_items_extra_specs, actual_specs)
self.unset_key(self.instance_type_name, "k1")
self.unset_key(self.instance_type_name, "k3")
class ProjectCommandsTestCase(test.TestCase):
def setUp(self):
super(ProjectCommandsTestCase, self).setUp()