X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=rwcal%2Fplugins%2Fvala%2Frwcal_openstack%2Frift%2Frwcal%2Fopenstack%2Futils%2Fcompute.py;h=fc053c2276d5f90b25d180d81f3f7cf3eded3a97;hb=812d2ec24829ccc60416bb310dc84114b089405f;hp=55ece65cd4ffbfcb718a4e2aca52343972a691ad;hpb=b6f4d48b4d5226e096bcc91245794cb2679d2472;p=osm%2FSO.git diff --git a/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/utils/compute.py b/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/utils/compute.py index 55ece65c..fc053c22 100644 --- a/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/utils/compute.py +++ b/rwcal/plugins/vala/rwcal_openstack/rift/rwcal/openstack/utils/compute.py @@ -192,24 +192,21 @@ class ComputeUtils(object): %(volume.name)) kwargs['boot_index'] = volume.boot_priority - if "image" in volume: + if volume.has_field("image"): # Support image->volume - if volume.image is not None: - kwargs['source_type'] = "image" - kwargs['uuid'] = self.resolve_image_n_validate(volume.image, volume.image_checksum) - else: - # Support blank->volume - kwargs['source_type'] = "blank" + kwargs['source_type'] = "image" + kwargs['uuid'] = self.resolve_image_n_validate(volume.image, volume.image_checksum) + else: + # Support blank->volume + kwargs['source_type'] = "blank" kwargs['device_name'] = volume.name kwargs['destination_type'] = "volume" kwargs['volume_size'] = volume.size kwargs['delete_on_termination'] = True if volume.has_field('device_type'): - if volume.device_type == 'cdrom': - kwargs['device_type'] = 'cdrom' - elif volume.device_bus == 'ide': - kwargs['disk_bus'] = 'ide' + if volume.device_type in ['cdrom', 'disk']: + kwargs['device_type'] = volume.device_type else: self.log.error("Unsupported device_type <%s> found for volume: %s", volume.device_type, volume.name) @@ -220,6 +217,21 @@ class ComputeUtils(object): volume.name) raise VolumeValidateError("Mandatory field not specified for volume: %s" %(volume.name)) + + if volume.has_field('device_bus'): + if volume.device_bus in ['ide', 'virtio', 'scsi']: + kwargs['disk_bus'] = volume.device_bus + else: + self.log.error("Unsupported device_bus <%s> found for volume: %s", + volume.device_bus, volume.name) + raise VolumeValidateError("Unsupported device_bus <%s> found for volume: %s" + %(volume.device_bus, volume.name)) + else: + self.log.error("Mandatory field not specified for volume: %s", + volume.name) + raise VolumeValidateError("Mandatory field not specified for volume: %s" + %(volume.name)) + return kwargs def make_vdu_storage_args(self, vdu_params): @@ -235,6 +247,8 @@ class ComputeUtils(object): kwargs = dict() if vdu_params.has_field('volumes'): kwargs['block_device_mapping_v2'] = list() + # Ignore top-level image + kwargs['image_id'] = "" for volume in vdu_params.volumes: kwargs['block_device_mapping_v2'].append(self.make_vdu_volume_args(volume, vdu_params)) return kwargs @@ -522,7 +536,6 @@ class ComputeUtils(object): console_url = None if self._parse_vdu_state_info(vm_info) == 'active': try: - console_url = self.driver.nova_server_console(vm_info['id']) serv_console_url = self.driver.nova_server_console(vm_info['id']) if 'console' in serv_console_url: console_url = serv_console_url['console']['url']