X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=rwcal%2Fplugins%2Fvala%2Frwcal_openstack%2Frift%2Frwcal%2Fopenstack%2Futils%2Fcompute.py;h=6a800de39c0c60069652031329ea9b83b01cf04a;hb=761922dae448283c503de4eb1c96ff813a95ce94;hp=55382017dee623142b458bc3e40fcdfff1f9d0e9;hpb=ee71ccf6da85650a8fbd2019293535082f017b78;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 55382017..6a800de3 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 @@ -173,6 +173,30 @@ class ComputeUtils(object): %(image_name, checksum)) return image['id'] + def resolve_volume_n_validate(self, volume_ref): + """ + Resolve the volume reference + + Arguments: + volume_ref (string): Name of volume reference + + Raises VolumeValidateError in case of Errors + """ + + for vol in self.driver._cinder_volume_list: + voldict = vol.to_dict() + if voldict['display_name'] == volume_ref: + if 'status' in voldict and voldict['status'] == 'available': + return voldict['id'] + else: + self.log.error("Volume %s not in available state. Current state: %s", + volume_ref, voldict['status']) + raise VolumeValidateError("Volume with name %s found in incorrect (%s) state" + %(volume_ref, vol['status'])) + + self.log.info("No volume found with matching name: %s ", volume_ref) + raise VolumeValidateError("No volume found with matching name: %s " %(volume_ref)) + def make_vdu_volume_args(self, volume, vdu_params): """ Arguments: @@ -186,23 +210,24 @@ class ComputeUtils(object): """ kwargs = dict() - if volume.has_field('volume_ref'): - self.log.error("Unsupported option found for volume: %s", volume.name) - raise VolumeValidateError("Unsupported option found for volume: %s" - %(volume.name)) - kwargs['boot_index'] = volume.boot_priority if volume.has_field("image"): # Support image->volume kwargs['source_type'] = "image" kwargs['uuid'] = self.resolve_image_n_validate(volume.image, volume.image_checksum) + kwargs['delete_on_termination'] = True + elif "volume_ref" in volume: + # Support volume-ref->volume (only ref) + kwargs['source_type'] = "volume" + kwargs['uuid'] = self.resolve_volume_n_validate(volume.volume_ref) + kwargs['delete_on_termination'] = False else: # Support blank->volume kwargs['source_type'] = "blank" + kwargs['delete_on_termination'] = True 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 in ['cdrom', 'disk']: