Add flavor resource aggregates support
1. Allow to specify resource aggregates when creating a flavor. 2. Replace --resources with --resource. Change-Id: I6d41d02b5ec1881d662a578a1380a223a27df055
This commit is contained in:
parent
a473f6a541
commit
c3d71e14cc
@ -62,12 +62,19 @@ class CreateFlavor(command.ShowOne):
|
||||
help=_("Flavor description"),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--resources",
|
||||
"--resource",
|
||||
metavar="<key=value>",
|
||||
action=parseractions.KeyValueAction,
|
||||
help=_("Resources to add to this flavor "
|
||||
help=_("Resource to add to this flavor "
|
||||
"(repeat option to set multiple resources)")
|
||||
)
|
||||
parser.add_argument(
|
||||
"--resource-aggregate",
|
||||
metavar="<key=value>",
|
||||
action=parseractions.KeyValueAction,
|
||||
help=_("Aggregate metadata to add to this flavor "
|
||||
"(repeat option to set multiple aggregate metadata)")
|
||||
)
|
||||
return parser
|
||||
|
||||
def take_action(self, parsed_args):
|
||||
@ -83,7 +90,8 @@ class CreateFlavor(command.ShowOne):
|
||||
data = bc_client.flavor.create(
|
||||
name=parsed_args.name,
|
||||
description=parsed_args.description,
|
||||
resources=parsed_args.resources,
|
||||
resource=parsed_args.resource,
|
||||
resource_aggregate=parsed_args.resource_aggregate,
|
||||
is_public=is_public,
|
||||
disabled=parsed_args.disabled,
|
||||
)
|
||||
|
@ -60,11 +60,11 @@ class TestFlavorCreate(TestFlavor):
|
||||
def test_flavor_create(self, mock_create):
|
||||
arglist = [
|
||||
'flavor1',
|
||||
'--resources', 'k1=v1'
|
||||
'--resource', 'k1=v1'
|
||||
]
|
||||
verifylist = [
|
||||
('name', 'flavor1'),
|
||||
('resources', {'k1': 'v1'}),
|
||||
('resource', {'k1': 'v1'}),
|
||||
]
|
||||
mock_create.return_value = self.fake_flavor
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
@ -152,11 +152,11 @@ class TestFlavorCreate(TestFlavor):
|
||||
def test_flavor_create_with_resources(self, mock_update, mock_get,
|
||||
mock_create):
|
||||
arglist = [
|
||||
'--resources', 'k1=v1',
|
||||
'--resource', 'k1=v1',
|
||||
'flavor1',
|
||||
]
|
||||
verifylist = [
|
||||
('resources', {'k1': 'v1'}),
|
||||
('resource', {'k1': 'v1'}),
|
||||
('name', 'flavor1'),
|
||||
]
|
||||
mock_create.return_value = self.fake_flavor
|
||||
|
@ -23,7 +23,8 @@ class Flavor(base.Resource):
|
||||
class FlavorManager(base.ManagerWithFind):
|
||||
resource_class = Flavor
|
||||
|
||||
def create(self, name, resources, is_public, disabled, description=None):
|
||||
def create(self, name, resource, resource_aggregate, is_public,
|
||||
disabled, description=None):
|
||||
url = '/flavors'
|
||||
data = {
|
||||
'name': name,
|
||||
@ -31,8 +32,10 @@ class FlavorManager(base.ManagerWithFind):
|
||||
'is_public': is_public,
|
||||
'disabled': disabled,
|
||||
}
|
||||
if resources:
|
||||
data['resources'] = resources
|
||||
if resource:
|
||||
data['resources'] = resource
|
||||
if resource_aggregate:
|
||||
data['resource_aggregates'] = resource_aggregate
|
||||
return self._create(url, data=data)
|
||||
|
||||
def delete(self, flavor):
|
||||
|
Loading…
x
Reference in New Issue
Block a user