From eda8349d3de80a878a8b8b4a152f8c8d39c74ded Mon Sep 17 00:00:00 2001 From: unicell Date: Mon, 13 Aug 2012 20:19:54 +0800 Subject: [PATCH] Implement project specific flavors API blueprint project-specific-flavors This change implements API extension to manage project specific flavor types, so that non-public flavor type can only see by projects with access rights. Change-Id: Ie2d2c605065b0c76897f843a4548a0c984a05f1a --- bin/nova-manage | 12 ++++++++---- nova/tests/policy.json | 1 + 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index 264c1342..7b376962 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -828,11 +828,12 @@ class InstanceTypeCommands(object): def _print_instance_types(self, name, val): deleted = ('', ', inactive')[val["deleted"] == 1] + 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, ExtraSpecs %s") % ( + "FlavorID: %s, Swap: %sMB, RXTX Factor: %s, %s, ExtraSpecs %s") % ( name, val["memory_mb"], val["vcpus"], val["root_gb"], val["ephemeral_gb"], val["flavorid"], val["swap"], - val["rxtx_factor"], val["extra_specs"]) + val["rxtx_factor"], is_public, val["extra_specs"]) @args('--name', dest='name', metavar='', help='Name of instance type/flavor') @@ -848,12 +849,15 @@ class InstanceTypeCommands(object): @args('--swap', dest='swap', metavar='', help='Swap') @args('--rxtx_factor', dest='rxtx_factor', metavar='', help='rxtx_factor') + @args('--is_public', dest="is_public", metavar='', + help='Make flavor accessible to the public') def create(self, name, memory, vcpus, root_gb, ephemeral_gb, flavorid, - swap=0, rxtx_factor=1): + swap=0, rxtx_factor=1, is_public=True): """Creates instance types / flavors""" try: instance_types.create(name, memory, vcpus, root_gb, - ephemeral_gb, flavorid, swap, rxtx_factor) + ephemeral_gb, flavorid, swap, rxtx_factor, + is_public) except exception.InvalidInput, e: print "Must supply valid parameters to create instance_type" print e diff --git a/nova/tests/policy.json b/nova/tests/policy.json index 61ec0152..08577ed0 100644 --- a/nova/tests/policy.json +++ b/nova/tests/policy.json @@ -92,6 +92,7 @@ "compute_extension:disk_config": [], "compute_extension:extended_server_attributes": [], "compute_extension:extended_status": [], + "compute_extension:flavor_access": [], "compute_extension:flavorextradata": [], "compute_extension:flavorextraspecs": [], "compute_extension:flavormanage": [],