refactored nova-manage list (-all, <name>) and fixed docs
This commit is contained in:
parent
167de65b41
commit
7ad5fe2714
@ -666,8 +666,9 @@ class InstanceTypeCommands(object):
|
||||
"""Class for managing instance types / flavors."""
|
||||
|
||||
def _print_instance_types(self, n, val):
|
||||
deleted = ('', ', inactive')[val["deleted"] == 1]
|
||||
print ("%s: Memory: %sMB, VCPUS: %s, Storage: %sGB, FlavorID: %s, "
|
||||
"Swap: %sGB, RXTX Quota: %sGB, RXTX Cap: %sMB") % (
|
||||
"Swap: %sGB, RXTX Quota: %sGB, RXTX Cap: %sMB%s") % (
|
||||
n,
|
||||
val["memory_mb"],
|
||||
val["vcpus"],
|
||||
@ -675,7 +676,8 @@ class InstanceTypeCommands(object):
|
||||
val["flavorid"],
|
||||
val["swap"],
|
||||
val["rxtx_quota"],
|
||||
val["rxtx_cap"])
|
||||
val["rxtx_cap"],
|
||||
deleted)
|
||||
|
||||
def create(
|
||||
self,
|
||||
@ -688,8 +690,8 @@ class InstanceTypeCommands(object):
|
||||
rxtx_quota=0,
|
||||
rxtx_cap=0):
|
||||
"""Creates instance types / flavors
|
||||
arguments: name memory vcpus local_gb flavorid swap rxtx_quota
|
||||
rxtx_cap
|
||||
arguments: name memory vcpus local_gb flavorid [swap] [rxtx_quota]
|
||||
[rxtx_cap]
|
||||
"""
|
||||
try:
|
||||
instance_types.create(
|
||||
@ -736,25 +738,22 @@ class InstanceTypeCommands(object):
|
||||
print "%s %s" % (name, verb)
|
||||
|
||||
def list(self, name=None):
|
||||
"""Lists all or specific instance types / flavors
|
||||
"""Lists all active or specific instance types / flavors
|
||||
arguments: [name]"""
|
||||
if name == None:
|
||||
try:
|
||||
try:
|
||||
if name == None:
|
||||
inst_types = instance_types.get_all_types()
|
||||
except exception.NotFound, e:
|
||||
print e
|
||||
sys.exit(1)
|
||||
elif name == "--all":
|
||||
inst_types = instance_types.get_all_types(1)
|
||||
else:
|
||||
for k, v in inst_types.iteritems():
|
||||
self._print_instance_types(k, v)
|
||||
else:
|
||||
try:
|
||||
inst_types = instance_types.get_instance_type(name)
|
||||
except exception.NotFound, e:
|
||||
print e
|
||||
sys.exit(1)
|
||||
else:
|
||||
self._print_instance_types(name, inst_types)
|
||||
except exception.DBError, e:
|
||||
_db_error(e)
|
||||
if isinstance(inst_types.values()[0], dict):
|
||||
for k, v in inst_types.iteritems():
|
||||
self._print_instance_types(k, v)
|
||||
else:
|
||||
self._print_instance_types(name, inst_types)
|
||||
|
||||
|
||||
CATEGORIES = [
|
||||
|
@ -179,6 +179,41 @@ Nova Floating IPs
|
||||
|
||||
Displays a list of all floating IP addresses.
|
||||
|
||||
Nova Flavor
|
||||
~~~~~~~~~~~
|
||||
|
||||
``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> <swap> <RXTX Quota> <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
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Nova instance_type is a alias for
|
||||
|
||||
FILES
|
||||
========
|
||||
|
@ -44,9 +44,9 @@ To see all currently active instance types, use the list subcommand::
|
||||
m1.small: Memory: 2048MB, VCPUS: 1, Storage: 20GB, FlavorID: 2, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
|
||||
|
||||
By default, the list subcommand only shows active instance types. To see all instance types
|
||||
(even those deleted), add the argument 1 after the list subcommand like so::
|
||||
(even those deleted), use the listall subcommand::
|
||||
|
||||
# nova-manage instance_type list 1
|
||||
# nova-manage instance_type listall
|
||||
m1.medium: Memory: 4096MB, VCPUS: 2, Storage: 40GB, FlavorID: 3, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
|
||||
m1.large: Memory: 8192MB, VCPUS: 4, Storage: 80GB, FlavorID: 4, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
|
||||
m1.tiny: Memory: 512MB, VCPUS: 1, Storage: 0GB, FlavorID: 1, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
|
||||
@ -81,3 +81,13 @@ type from the database, pass the "--purge" flag after the name::
|
||||
|
||||
# nova-manage instance_type delete m1.xxlarge --purge
|
||||
m1.xxlarge deleted
|
||||
|
||||
To see all instance types (inactive + active), use the list subcommand with the "--all" flag::
|
||||
|
||||
# nova-manage instance_type list --all
|
||||
m1.medium: Memory: 4096MB, VCPUS: 2, Storage: 40GB, FlavorID: 3, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
|
||||
m1.large: Memory: 8192MB, VCPUS: 4, Storage: 80GB, FlavorID: 4, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
|
||||
m1.tiny: Memory: 512MB, VCPUS: 1, Storage: 0GB, FlavorID: 1, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
|
||||
m1.xlarge: Memory: 16384MB, VCPUS: 8, Storage: 160GB, FlavorID: 5, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
|
||||
m1.small: Memory: 2048MB, VCPUS: 1, Storage: 20GB, FlavorID: 2, Swap: 0GB, RXTX Quota: 0GB, RXTX Cap: 0MB
|
||||
|
||||
|
@ -2090,16 +2090,18 @@ def instance_type_create(context, values):
|
||||
@require_context
|
||||
def instance_type_get_all(context, inactive=0):
|
||||
"""
|
||||
Returns a dict describing all non-deleted instance_types with name as key:
|
||||
{'m1.tiny': dict(memory_mb=512, vcpus=1, local_gb=0, flavorid=1),
|
||||
'm1.small': dict(memory_mb=2048, vcpus=1, local_gb=20, flavorid=2),
|
||||
'm1.medium': dict(memory_mb=4096, vcpus=2, local_gb=40, flavorid=3)}
|
||||
Returns a dict describing all instance_types with name as key.
|
||||
"""
|
||||
session = get_session()
|
||||
inst_types = session.query(models.InstanceTypes).\
|
||||
filter_by(deleted=inactive).\
|
||||
order_by("name").\
|
||||
all()
|
||||
if inactive:
|
||||
inst_types = session.query(models.InstanceTypes).\
|
||||
order_by("name").\
|
||||
all()
|
||||
else:
|
||||
inst_types = session.query(models.InstanceTypes).\
|
||||
filter_by(deleted=inactive).\
|
||||
order_by("name").\
|
||||
all()
|
||||
if inst_types:
|
||||
inst_dict = {}
|
||||
for i in inst_types:
|
||||
|
Loading…
x
Reference in New Issue
Block a user