Add the ability to specify multiple disks on the SoftLayer driver

Refs #19954
This commit is contained in:
rallytime 2015-09-16 16:46:02 -06:00
parent 0e04588d58
commit fe74d203f5
2 changed files with 57 additions and 5 deletions

View file

@ -140,7 +140,40 @@ instance.
disk_size
---------
The amount of disk space that will be allocated to this image, in megabytes.
The amount of disk space that will be allocated to this image, in gigabytes.
.. code-block:: yaml
base_softlayer_ubuntu:
disk_size: 100
Using Multiple Disks
~~~~~~~~~~~~~~~~~~~~
.. versionadded:: 2015.8.1
SoftLayer allows up to 5 disks to be specified for a virtual machine upon
creation. Multiple disks can be specified either as a list or a comma-delimited
string. The first ``disk_size`` specified in the string or list will be the first
disk size assigned to the VM.
List Example:
.. code-block:: yaml
base_softlayer_ubuntu:
disk_size: ['100', '20', '20']
String Example:
.. code-block:: yaml
base_softlayer_ubuntu:
disk_size: '100, 20, 20'
.. note::
All disks listed in the ``disk_size`` configuration will be created either as
SAN disks or local disks, depending on if the ``local_disk`` configuration
is set to ``true`` or not. See ``local_disk`` parameter below.
local_disk
----------

View file

@ -281,10 +281,29 @@ def create(vm_):
if 'image' in vm_:
kwargs['operatingSystemReferenceCode'] = vm_['image']
kwargs['blockDevices'] = [{
'device': '0',
'diskImage': {'capacity': vm_['disk_size']},
}]
kwargs['blockDevices'] = []
disks = vm_['disk_size']
if isinstance(disks, int):
disks = [str(disks)]
elif isinstance(disks, str):
disks = [size.strip() for size in disks.split(',')]
count = 0
for disk in disks:
block_device = {'device': str(count),
'diskImage': {'capacity': str(disk)}}
kwargs['blockDevices'].append(block_device)
count += 1
if count > 4:
log.warning('More that 5 disks were specified for {0} .'
'The first 5 disks will be applied to the VM, '
'but the remaining disks will be ignored.\n'
'Please adjust your cloud configuration to only '
'specify a maximum of 5 disks.'.format(vm_['name']))
break
elif 'global_identifier' in vm_:
kwargs['blockDeviceTemplateGroup'] = {
'globalIdentifier': vm_['global_identifier']