X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_ro%2Fvimconn_openstack.py;h=7b16515dc8239ddc087865db4fdd9de03dd1208a;hb=1df468d2c3f6c32f2bb703e4732180a8596c48ad;hp=43fdbc516ee6ddbea5b812cddb2f1266e5fd339f;hpb=b42fd9bdcea865bd3c6d4a546a6f294ff69e1ef4;p=osm%2FRO.git diff --git a/osm_ro/vimconn_openstack.py b/osm_ro/vimconn_openstack.py index 43fdbc51..7b16515d 100644 --- a/osm_ro/vimconn_openstack.py +++ b/osm_ro/vimconn_openstack.py @@ -463,7 +463,9 @@ class vimconnector(vimconn.vimconnector): } # Gateway should be set to None if not needed. Otherwise openstack assigns one by default if ip_profile.get('gateway_address'): - subnet['gateway_ip'] = ip_profile.get('gateway_address') + subnet['gateway_ip'] = ip_profile['gateway_address'] + else: + subnet['gateway_ip'] = None if ip_profile.get('dns_address'): subnet['dns_nameservers'] = ip_profile['dns_address'].split(";") if 'dhcp_enabled' in ip_profile: @@ -880,8 +882,8 @@ class vimconnector(vimconn.vimconnector): return True if vm_status == 'ERROR': return False - time.sleep(1) - elapsed_time += 1 + time.sleep(5) + elapsed_time += 5 # if we exceeded the timeout rollback if elapsed_time >= server_timeout: @@ -979,6 +981,7 @@ class vimconnector(vimconn.vimconnector): 'disk_list': (optional) list with additional disks to the VM. Each item is a dict with: 'image_id': (optional). VIM id of an existing image. If not provided an empty disk must be mounted 'size': (mandatory) string with the size of the disk in GB + 'vim_id' (optional) should use this existing volume id availability_zone_index: Index of availability_zone_list to use for this this VM. None if not AV required availability_zone_list: list of availability zones given by user in the VNFD descriptor. Ignore if availability_zone_index is None @@ -1093,31 +1096,34 @@ class vimconnector(vimconn.vimconnector): # Create additional volumes in case these are present in disk_list base_disk_index = ord('b') - if disk_list != None: + if disk_list: block_device_mapping = {} 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']) + if disk.get('vim_id'): + block_device_mapping['_vd' + chr(base_disk_index)] = disk['vim_id'] else: - volume = self.cinder.volumes.create(size=disk['size'], name=name + '_vd' + - chr(base_disk_index)) - created_items["volume:" + str(volume.id)] = True - block_device_mapping['_vd' + chr(base_disk_index)] = volume.id + 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)) + created_items["volume:" + str(volume.id)] = True + block_device_mapping['_vd' + chr(base_disk_index)] = volume.id base_disk_index += 1 - # Wait until volumes are with status available - keep_waiting = True + # Wait until created volumes are with status available 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 - + while elapsed_time < volume_timeout: + for created_item in created_items: + v, _, volume_id = created_item.partition(":") + if v == 'volume': + if self.cinder.volumes.get(volume_id).status != 'available': + break + else: # all ready: break from while + break + time.sleep(5) + elapsed_time += 5 # If we exceeded the timeout rollback if elapsed_time >= volume_timeout: raise vimconn.vimconnException('Timeout creating volumes for instance ' + name,