Revert "Add support for specifying new properties for flavor"
This reverts commit ea513b497f.
Change-Id: I8b18857a588388bc77d28527c3d71c23aec9c076
This commit is contained in:
@@ -39,44 +39,6 @@ class CreateFlavor(command.ShowOne):
|
||||
metavar="<name>",
|
||||
help=_("New baremetal flavor name")
|
||||
)
|
||||
parser.add_argument(
|
||||
"--cpus",
|
||||
type=int,
|
||||
metavar="<cpus>",
|
||||
help=_("Number of cpus")
|
||||
)
|
||||
parser.add_argument(
|
||||
"--cpu-model",
|
||||
metavar="<cpu-model>",
|
||||
help=_("Cpu model of the flavor")
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ram",
|
||||
type=int,
|
||||
metavar="<size-mb>",
|
||||
help=_("Memory size in MB")
|
||||
)
|
||||
parser.add_argument(
|
||||
"--ram-type",
|
||||
metavar="<ram-type>",
|
||||
help=_("Ram type of the flavor")
|
||||
)
|
||||
parser.add_argument(
|
||||
"--nic",
|
||||
metavar="speed=SPEED[,type=PORT_TYPE]",
|
||||
required_keys=['speed', 'type'],
|
||||
action=parseractions.MultiKeyValueAction,
|
||||
help=_("NIC of the flavor. "
|
||||
"Specify option multiple times to create multiple NICs."),
|
||||
)
|
||||
parser.add_argument(
|
||||
"--disk",
|
||||
metavar="size_gb=SIZE[,type=DISK_TYPE]",
|
||||
required_keys=['size_gb', 'type'],
|
||||
action=parseractions.MultiKeyValueAction,
|
||||
help=_("Disk of the flavor. "
|
||||
"Specify option multiple times to create multiple disks."),
|
||||
)
|
||||
public_group = parser.add_mutually_exclusive_group()
|
||||
public_group.add_argument(
|
||||
"--public",
|
||||
@@ -112,24 +74,8 @@ class CreateFlavor(command.ShowOne):
|
||||
if parsed_args.private:
|
||||
is_public = False
|
||||
|
||||
cpus = {}
|
||||
if parsed_args.cpus:
|
||||
cpus['cores'] = parsed_args.cpus
|
||||
if parsed_args.cpu_model:
|
||||
cpus['model'] = parsed_args.cpu_model
|
||||
|
||||
ram = {}
|
||||
if parsed_args.ram:
|
||||
ram['size_mb'] = parsed_args.ram
|
||||
if parsed_args.ram_type:
|
||||
ram['type'] = parsed_args.ram_type
|
||||
|
||||
data = bc_client.flavor.create(
|
||||
name=parsed_args.name,
|
||||
cpus=cpus,
|
||||
memory=ram,
|
||||
nics=parsed_args.nic,
|
||||
disks=parsed_args.disk,
|
||||
is_public=is_public,
|
||||
description=parsed_args.description,
|
||||
)
|
||||
|
||||
@@ -68,10 +68,6 @@ class TestFlavorCreate(TestFlavor):
|
||||
mock_create.assert_called_once_with('/flavors',
|
||||
data={
|
||||
'name': 'flavor1',
|
||||
'cpus': {},
|
||||
'memory': {},
|
||||
'nics': [],
|
||||
'disks': [],
|
||||
'is_public': True,
|
||||
'description': None,
|
||||
})
|
||||
@@ -93,10 +89,6 @@ class TestFlavorCreate(TestFlavor):
|
||||
mock_create.assert_called_once_with('/flavors',
|
||||
data={
|
||||
'name': 'flavor1',
|
||||
'cpus': {},
|
||||
'memory': {},
|
||||
'nics': [],
|
||||
'disks': [],
|
||||
'is_public': True,
|
||||
'description': None,
|
||||
})
|
||||
@@ -118,10 +110,6 @@ class TestFlavorCreate(TestFlavor):
|
||||
mock_create.assert_called_once_with('/flavors',
|
||||
data={
|
||||
'name': 'flavor1',
|
||||
'cpus': {},
|
||||
'memory': {},
|
||||
'nics': [],
|
||||
'disks': [],
|
||||
'is_public': False,
|
||||
'description': None,
|
||||
})
|
||||
@@ -144,10 +132,6 @@ class TestFlavorCreate(TestFlavor):
|
||||
'/flavors',
|
||||
data={
|
||||
'name': 'flavor1',
|
||||
'cpus': {},
|
||||
'memory': {},
|
||||
'nics': [],
|
||||
'disks': [],
|
||||
'is_public': True,
|
||||
'description': 'test description.',
|
||||
})
|
||||
@@ -159,25 +143,11 @@ class TestFlavorCreate(TestFlavor):
|
||||
def test_flavor_create_with_property(self, mock_update, mock_get,
|
||||
mock_create):
|
||||
arglist = [
|
||||
'--cpus', '16',
|
||||
'--cpu-model', 'Intel',
|
||||
'--ram', '4096',
|
||||
'--ram-type', 'DDR3',
|
||||
'--nic', 'speed=10Gbps,type=Ethernet',
|
||||
'--nic', 'speed=100Gbps,type=Infini',
|
||||
'--disk', 'size_gb=1024,type=SSD',
|
||||
'--property', 'key1=value1',
|
||||
'flavor1',
|
||||
]
|
||||
verifylist = [
|
||||
('property', {'key1': 'value1'}),
|
||||
('cpus', 16),
|
||||
('cpu_model', 'Intel'),
|
||||
('ram', 4096),
|
||||
('ram_type', 'DDR3'),
|
||||
('nic', [{'speed': '10Gbps', 'type': 'Ethernet'},
|
||||
{'speed': '100Gbps', 'type': 'Infini'}]),
|
||||
('disk', [{'size_gb': '1024', 'type': 'SSD'}]),
|
||||
('name', 'flavor1'),
|
||||
]
|
||||
mock_create.return_value = self.fake_flavor
|
||||
@@ -187,16 +157,6 @@ class TestFlavorCreate(TestFlavor):
|
||||
mock_create.assert_called_once_with('/flavors',
|
||||
data={
|
||||
'name': 'flavor1',
|
||||
'cpus': {'cores': 16,
|
||||
'model': 'Intel'},
|
||||
'memory': {'size_mb': 4096,
|
||||
'type': 'DDR3'},
|
||||
'nics': [{'speed': '10Gbps',
|
||||
'type': 'Ethernet'},
|
||||
{'speed': '100Gbps',
|
||||
'type': 'Infini'}],
|
||||
'disks': [{'size_gb': '1024',
|
||||
'type': 'SSD'}],
|
||||
'is_public': True,
|
||||
'description': None,
|
||||
})
|
||||
|
||||
@@ -23,19 +23,10 @@ class Flavor(base.Resource):
|
||||
class FlavorManager(base.ManagerWithFind):
|
||||
resource_class = Flavor
|
||||
|
||||
def create(self, name, cpus, memory, nics, disks,
|
||||
is_public, description=None):
|
||||
def create(self, name, is_public, description=None):
|
||||
url = '/flavors'
|
||||
if nics is None:
|
||||
nics = []
|
||||
if disks is None:
|
||||
disks = []
|
||||
data = {
|
||||
'name': name,
|
||||
'cpus': cpus,
|
||||
'memory': memory,
|
||||
'nics': nics,
|
||||
'disks': disks,
|
||||
'is_public': is_public,
|
||||
'description': description,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user