refactored nova-manage list (-all, <name>) and fixed docs

This commit is contained in:
Ken Pepple
2011-02-28 13:16:07 -08:00
parent 0bc9cb29cb
commit aa489d433c
3 changed files with 65 additions and 21 deletions

View File

@@ -666,8 +666,9 @@ class InstanceTypeCommands(object):
"""Class for managing instance types / flavors.""" """Class for managing instance types / flavors."""
def _print_instance_types(self, n, val): def _print_instance_types(self, n, val):
deleted = ('', ', inactive')[val["deleted"] == 1]
print ("%s: Memory: %sMB, VCPUS: %s, Storage: %sGB, FlavorID: %s, " 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, n,
val["memory_mb"], val["memory_mb"],
val["vcpus"], val["vcpus"],
@@ -675,7 +676,8 @@ class InstanceTypeCommands(object):
val["flavorid"], val["flavorid"],
val["swap"], val["swap"],
val["rxtx_quota"], val["rxtx_quota"],
val["rxtx_cap"]) val["rxtx_cap"],
deleted)
def create( def create(
self, self,
@@ -688,8 +690,8 @@ class InstanceTypeCommands(object):
rxtx_quota=0, rxtx_quota=0,
rxtx_cap=0): rxtx_cap=0):
"""Creates instance types / flavors """Creates instance types / flavors
arguments: name memory vcpus local_gb flavorid swap rxtx_quota arguments: name memory vcpus local_gb flavorid [swap] [rxtx_quota]
rxtx_cap [rxtx_cap]
""" """
try: try:
instance_types.create( instance_types.create(
@@ -736,25 +738,22 @@ class InstanceTypeCommands(object):
print "%s %s" % (name, verb) print "%s %s" % (name, verb)
def list(self, name=None): def list(self, name=None):
"""Lists all or specific instance types / flavors """Lists all active or specific instance types / flavors
arguments: [name]""" arguments: [name]"""
if name == None: try:
try: if name == None:
inst_types = instance_types.get_all_types() inst_types = instance_types.get_all_types()
except exception.NotFound, e: elif name == "--all":
print e inst_types = instance_types.get_all_types(1)
sys.exit(1)
else: else:
for k, v in inst_types.iteritems():
self._print_instance_types(k, v)
else:
try:
inst_types = instance_types.get_instance_type(name) inst_types = instance_types.get_instance_type(name)
except exception.NotFound, e: except exception.DBError, e:
print e _db_error(e)
sys.exit(1) if isinstance(inst_types.values()[0], dict):
else: for k, v in inst_types.iteritems():
self._print_instance_types(name, inst_types) self._print_instance_types(k, v)
else:
self._print_instance_types(name, inst_types)
CATEGORIES = [ CATEGORIES = [

View File

@@ -179,6 +179,41 @@ Nova Floating IPs
Displays a list of all floating IP addresses. 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 FILES
======== ========

View File

@@ -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 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 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.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.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.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 # nova-manage instance_type delete m1.xxlarge --purge
m1.xxlarge deleted 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