Mount an EBS volume

    Args:
        volume (str): EBS volume ID
        device (str): default /dev/xvdf
        mountpoint (str): default /mnt/data
        fstype (str): default ext4
10856
def mount_volume(volume, device='/dev/xvdf', mountpoint='/mnt/data', fstype='ext4'):
    '''
    
    '''
    _ec2().attach_volume(volume, _host_node()['id'], device)
    time.sleep(1)
    sudo('mkdir -p "%s"' % mountpoint)
    sudo('mount -t "%s" "%s" "%s"' % (fstype, device, mountpoint))
933279
def add_volume(volume)
      raise ArgumentError, "Invalid argument 'volume'. Expected DoseVolume, got #{volume.class}." unless volume.is_a?(DoseVolume)
      @volumes << volume unless @associated_volumes[volume.uid]
      @associated_volumes[volume.uid] = volume
    end
746376
def update(self, volume, display_name=None, display_description=None):
        
        return volume.update(display_name=display_name,
                display_description=display_description)
1284666
def set_volume(self, volume):
        
        volume = min(max(0, volume), 1)
        self.logger.info("Receiver:setting volume to %.1f", volume)
        self.send_message({MESSAGE_TYPE: 'SET_VOLUME',
                           'volume': {'level': volume}})
        return volume
812591
def mount(self,
              fstype=None,
              options=None,
              auth_no_user_interaction=None):
        """"""
        return self._M.Filesystem.Mount(
            '(a{sv})',
            filter_opt({
                'fstype': ('s', fstype),
                'options': ('s', ','.join(options or [])),
                'auth.no_user_interaction': ('b', auth_no_user_interaction),
            })
        )
490495
def create_volume(self, availability_zone, size=None, snapshot_id=None):
        """"""
        params = {"AvailabilityZone": availability_zone}
        if ((snapshot_id is None and size is None) or
            (snapshot_id is not None and size is not None)):
            raise ValueError("Please provide either size or snapshot_id")
        if size is not None:
            params["Size"] = str(size)
        if snapshot_id is not None:
            params["SnapshotId"] = snapshot_id
        query = self.query_factory(
            action="CreateVolume", creds=self.creds, endpoint=self.endpoint,
            other_params=params)
        d = query.submit()
        return d.addCallback(self.parser.create_volume)
182629
def logical_volume(cls, file_path, sudo=False):
		
		mp = WMountPoint.mount_point(file_path)
		if mp is not None:
			name_file = '/sys/block/%s/dm/name' % mp.device_name()
			if os.path.exists(name_file):
				lv_path = '/dev/mapper/%s' % open(name_file).read().strip()
				return WLogicalVolume(lv_path, sudo=sudo)
373486
def fstab_mount(mountpoint):
    """"""
    cmd_args = ['mount', mountpoint]
    try:
        subprocess.check_output(cmd_args)
    except subprocess.CalledProcessError as e:
        log('Error unmounting {}\n{}'.format(mountpoint, e.output))
        return False
    return True
95498
def bindmount(self, mountpoint):
        

        if not self.mountpoint:
            raise NotMountedError(self)
        try:
            _util.check_call_(['mount', '--bind', self.mountpoint, mountpoint], stdout=subprocess.PIPE)
            if 'bindmounts' in self._paths:
                self._paths['bindmounts'].append(mountpoint)
            else:
                self._paths['bindmounts'] = [mountpoint]
            return True
        except Exception as e:
            logger.exception("Error bind mounting {0}.".format(self))
            raise SubsystemError(e)
1122881
def init_volume(self, fstype=None):
        

        logger.debug("Initializing volume {0}".format(self))

        if not self._should_mount():
            return False

        if self.flag != 'alloc':
            return False

        if self.info.get('raid_status') == 'waiting':
            logger.info("RAID array %s not ready for mounting", self)
            return False

        if self.is_mounted:
            logger.info("%s is currently mounted, not mounting it again", self)
            return False

        logger.info("Mounting volume {0}".format(self))
        self.mount(fstype=fstype)
        self.detect_mountpoint()

        return True
401872
def volumes_from(self, value):
        
        volumes_from = []

        if isinstance(value, list):
            for volume_from in value:
                if not isinstance(volume_from, six.string_types):
                    raise TypeError("each bind must be a str. {0} was passed".format(volume_from))

                volumes_from.append(self._convert_volume_from(volume_from))
        elif isinstance(value, six.string_types):
            volumes_from.append(self._convert_volume_from(value))
        elif value is None:
            pass
        else:
            raise ValueError(
                """When passing binds they must be in one of the
                following formats: container_path, host_path:container_path,
                or host_path:container_path:permissions"""
            )

        self._volumes_from = volumes_from
1238492
def set_extent_location(self, extent):
        # type: (int) -> None
        '''
        
        '''
        if not self._initialized:
            raise pycdlibexception.PyCdlibInternalError('This Volume Descriptor is not yet initialized')
        self.new_extent_loc = extent
1273914
private boolean attachVolumes() {

		// If volume is found in map, it has been successfully created (no need to check here)
		for( Map.Entry<String,String> entry : this.storageIdToVolumeId.entrySet()) {

			String volumeId = entry.getValue();
			String storageId = entry.getKey();

			// Give a name to the volume before attaching
			String nameTemplate = Ec2IaasHandler.findStorageProperty(this.targetProperties, storageId, VOLUME_NAME_PREFIX);
			String name = Ec2IaasHandler.expandVolumeName(
					nameTemplate, this.applicationName, this.scopedInstance.getName());
			if(Utils.isEmptyOrWhitespaces(name)) name = "Created by Roboconf for " + this.tagName;
			tagResource(volumeId, name);

			// Attach volume now
			String mountPoint = Ec2IaasHandler.findStorageProperty(this.targetProperties, storageId, VOLUME_MOUNT_POINT_PREFIX);
			if(Utils.isEmptyOrWhitespaces(mountPoint)) mountPoint = "/dev/sdf";

			AttachVolumeRequest attachRequest = new AttachVolumeRequest()
				.withInstanceId(this.machineId)
				.withDevice(mountPoint)
				.withVolumeId(volumeId);

			try {
				this.ec2Api.attachVolume(attachRequest);
			} catch(Exception e) {
				this.logger.warning("EBS Volume attachment error: " + e);
			}

			// Set deleteOnTermination flag ?
			if(Boolean.parseBoolean(Ec2IaasHandler.findStorageProperty(this.targetProperties, storageId, VOLUME_DELETE_OT_PREFIX))) {
				EbsInstanceBlockDeviceSpecification ebsSpecification = new EbsInstanceBlockDeviceSpecification()
					.withVolumeId(volumeId)
					.withDeleteOnTermination(true);

				InstanceBlockDeviceMappingSpecification mappingSpecification = new InstanceBlockDeviceMappingSpecification()
					.withDeviceName(mountPoint)
					.withEbs(ebsSpecification);

				ModifyInstanceAttributeRequest request = new ModifyInstanceAttributeRequest()
					.withInstanceId(this.machineId)
					.withBlockDeviceMappings(mappingSpecification);

				this.ec2Api.modifyInstanceAttribute(request);
			}
		}

		return true;
	}
227250
def _make_subvolume(self, **args):
        """"""

        from imagemounter.volume import Volume
        v = Volume(disk=self.disk, parent=self.parent,
                   volume_detector=self.volume_detector,
                   **args)  # vstype is not passed down, let it decide for itself.
        self.volumes.append(v)
        return v
1125098
def volume_create(self, name, size=100, snapshot=None, voltype=None,
                      availability_zone=None):
        '''
        
        '''
        if self.volume_conn is None:
            raise SaltCloudSystemExit('No cinder endpoint available')
        nt_ks = self.volume_conn
        response = nt_ks.volumes.create(
            size=size,
            display_name=name,
            volume_type=voltype,
            snapshot_id=snapshot,
            availability_zone=availability_zone
        )

        return self._volume_get(response.id)
327802
def get_volumes_for_instance(self, arg, device=None):
        
        instance = self.get(arg)
        filters = {'attachment.instance-id': instance.id}
        if device is not None:
            filters['attachment.device'] = device
        return self.get_all_volumes(filters=filters)
926534
def attach_volume(self, volume, device="/dev/sdp"):
        
        if hasattr(volume, "id"):
            volume_id = volume.id
        else:
            volume_id = volume
        return self.ec2.attach_volume(volume_id=volume_id, instance_id=self.instance_id, device=device)