def get_volume_mountpoint(self): volume = create_nova_volume_client(self.context).volumes.get(volume_id) mountpoint = volume.attachments[0]['device'] if mountpoint[0] is not "/": return "/%s" % mountpoint else: return mountpoint
def load(context): client = create_nova_volume_client(context) rdstorages = client.rdstorage.list() for rdstorage in rdstorages: LOG.debug("rdstorage=" + str(rdstorage)) return [StorageDevice(storage_info) for storage_info in rdstorages]
def load(cls, context, id): instance = load_mgmt_instance(cls, context, id) client = remote.create_nova_volume_client(context) try: instance.volume = client.volumes.get(instance.volume_id) except Exception: instance.volume = None # Populate the volume_used attribute from the guest agent. instance_models.load_guest_info(instance, context, id) instance.root_history = mysql_models.RootHistory.load(context=context, instance_id=id) return instance
def _create_volume(self, volume_size): LOG.info("Entering create_volume") LOG.debug(_("Starting to create the volume for the instance")) volume_client = create_nova_volume_client(self.context) volume_desc = ("mysql volume for %s" % self.id) volume_ref = volume_client.volumes.create( volume_size, display_name="mysql-%s" % self.id, display_description=volume_desc) # Record the volume ID in case something goes wrong. self.update_db(volume_id=volume_ref.id) utils.poll_until( lambda: volume_client.volumes.get(volume_ref.id), lambda v_ref: v_ref.status in ['available', 'error'], sleep_time=2, time_out=VOLUME_TIME_OUT) v_ref = volume_client.volumes.get(volume_ref.id) if v_ref.status in ['error']: raise VolumeCreationFailure() LOG.debug(_("Created volume %s") % v_ref) # The mapping is in the format: # <id>:[<type>]:[<size(GB)>]:[<delete_on_terminate>] # setting the delete_on_terminate instance to true=1 mapping = "%s:%s:%s:%s" % (v_ref.id, '', v_ref.size, 1) bdm = CONF.block_device_mapping block_device = {bdm: mapping} volumes = [{'id': v_ref.id, 'size': v_ref.size}] LOG.debug("block_device = %s" % block_device) LOG.debug("volume = %s" % volumes) device_path = CONF.device_path mount_point = CONF.mount_point LOG.debug(_("device_path = %s") % device_path) LOG.debug(_("mount_point = %s") % mount_point) volume_info = {'block_device': block_device, 'device_path': device_path, 'mount_point': mount_point, 'volumes': volumes} return volume_info
def volume_client(self): if not self._volume_client: self._volume_client = create_nova_volume_client(self.context) return self._volume_client