+ userdata=None
+
+ #Create additional volumes in case these are present in disk_list
+ block_device_mapping = None
+ base_disk_index = ord('b')
+ if disk_list != None:
+ block_device_mapping = dict()
+ for disk in disk_list:
+ if 'image_id' in disk:
+ volume = self.cinder.volumes.create(size = disk['size'],name = name + '_vd' +
+ chr(base_disk_index), imageRef = disk['image_id'])
+ else:
+ volume = self.cinder.volumes.create(size=disk['size'], name=name + '_vd' +
+ chr(base_disk_index))
+ block_device_mapping['_vd' + chr(base_disk_index)] = volume.id
+ base_disk_index += 1
+
+ #wait until volumes are with status available
+ keep_waiting = True
+ elapsed_time = 0
+ while keep_waiting and elapsed_time < volume_timeout:
+ keep_waiting = False
+ for volume_id in block_device_mapping.itervalues():
+ if self.cinder.volumes.get(volume_id).status != 'available':
+ keep_waiting = True
+ if keep_waiting:
+ time.sleep(1)
+ elapsed_time += 1
+
+ #if we exceeded the timeout rollback
+ if elapsed_time >= volume_timeout:
+ #delete the volumes we just created
+ for volume_id in block_device_mapping.itervalues():
+ self.cinder.volumes.delete(volume_id)
+
+ #delete ports we just created
+ for net_item in net_list_vim:
+ if 'port-id' in net_item:
+ self.neutron.delete_port(net_item['port_id'])
+
+ raise vimconn.vimconnException('Timeout creating volumes for instance ' + name,
+ http_code=vimconn.HTTP_Request_Timeout)
+