diff --git a/moganclient/osc/v1/flavor.py b/moganclient/osc/v1/flavor.py index ef48a8b..2c52f7f 100644 --- a/moganclient/osc/v1/flavor.py +++ b/moganclient/osc/v1/flavor.py @@ -62,12 +62,19 @@ class CreateFlavor(command.ShowOne): help=_("Flavor description"), ) parser.add_argument( - "--resources", + "--resource", metavar="", 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="", + 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, ) diff --git a/moganclient/tests/unit/osc/v1/test_flavor.py b/moganclient/tests/unit/osc/v1/test_flavor.py index e3fe4b4..15127e0 100644 --- a/moganclient/tests/unit/osc/v1/test_flavor.py +++ b/moganclient/tests/unit/osc/v1/test_flavor.py @@ -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 diff --git a/moganclient/v1/flavor.py b/moganclient/v1/flavor.py index 8627ede..42077fa 100644 --- a/moganclient/v1/flavor.py +++ b/moganclient/v1/flavor.py @@ -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):