Attaches this volume to the cloud server instance at the
        specified mountpoint. This requires a call to the cloud servers
        API; it cannot be done directly.
184886
def attach_to_instance(self, instance, mountpoint):
        
        instance_id = _resolve_id(instance)
        try:
            resp = self._nova_volumes.create_server_volume(instance_id,
                    self.id, mountpoint)
        except Exception as e:
            raise exc.VolumeAttachmentFailed("%s" % e)
881175
def mount(self, mount_point=None):
        
        cmd = ["podman", "mount", self._id or self.get_id()]
        output = run_cmd(cmd, return_output=True).rstrip("\n\r")
        return output
105101
public OvhVolume project_serviceName_volume_volumeId_attach_POST(String serviceName, String volumeId, String instanceId) throws IOException {
		String qPath = "/cloud/project/{serviceName}/volume/{volumeId}/attach";
		StringBuilder sb = path(qPath, serviceName, volumeId);
		HashMap<String, Object>o = new HashMap<String, Object>();
		addBody(o, "instanceId", instanceId);
		String resp = exec(qPath, "POST", sb.toString(), o);
		return convertTo(resp, OvhVolume.class);
	}
1365112
def _attach(cls, iface_id, vm_id):
        
        oper = cls.call('hosting.vm.iface_attach', vm_id, iface_id)
        return oper
580880
def detach(self):
        
        self._client.post('{}/detach'.format(Volume.api_endpoint), model=self)

        return True
1348906
function(id, callback) {
        var self = this;

        var requestOptions = {
            uri: '/volumes/' + id,
            endpoint: rackspace.Endpoints.CloudBlockStorage
        };

        self.authorizedRequest(requestOptions, function(err, res, body) {
            if (err || !body.volume) {
                callback(err ? err : body);
                return;
            }

            callback(err, new rackspace.Volume(self, body.volume));
        });
    }
949382
def create_attach_volumes(name, kwargs, call=None, wait_to_finish=True):
    '''
    
    '''
    if call != 'action':
        raise SaltCloudSystemExit(
            'The create_attach_volumes action must be called with '
            '-a or --action.'
        )

    if 'instance_id' not in kwargs:
        kwargs['instance_id'] = _get_node(name)['instanceId']

    if isinstance(kwargs['volumes'], six.string_types):
        volumes = salt.utils.yaml.safe_load(kwargs['volumes'])
    else:
        volumes = kwargs['volumes']

    ret = []
    for volume in volumes:
        created = False
        volume_name = '{0} on {1}'.format(volume['device'], name)

        volume_dict = {
            'volume_name': volume_name,
            'zone': kwargs['zone']
        }
        if 'volume_id' in volume:
            volume_dict['volume_id'] = volume['volume_id']
        elif 'snapshot' in volume:
            volume_dict['snapshot'] = volume['snapshot']
        elif 'size' in volume:
            volume_dict['size'] = volume['size']
        else:
            raise SaltCloudConfigError(
                'Cannot create volume.  Please define one of \'volume_id\', '
                '\'snapshot\', or \'size\''
            )

        if 'tags' in volume:
            volume_dict['tags'] = volume['tags']
        if 'type' in volume:
            volume_dict['type'] = volume['type']
        if 'iops' in volume:
            volume_dict['iops'] = volume['iops']
        if 'encrypted' in volume:
            volume_dict['encrypted'] = volume['encrypted']
        if 'kmskeyid' in volume:
            volume_dict['kmskeyid'] = volume['kmskeyid']

        if 'volume_id' not in volume_dict:
            created_volume = create_volume(volume_dict, call='function', wait_to_finish=wait_to_finish)
            created = True
            if 'volumeId' in created_volume:
                volume_dict['volume_id'] = created_volume['volumeId']

        attach = attach_volume(
            name,
            {'volume_id': volume_dict['volume_id'],
             'device': volume['device']},
            instance_id=kwargs['instance_id'],
            call='action'
        )

        # Update the delvol parameter for this volume
        delvols_on_destroy = kwargs.get('del_all_vols_on_destroy', None)

        if attach and created and delvols_on_destroy is not None:
            _toggle_delvol(instance_id=kwargs['instance_id'],
                           device=volume['device'],
                           value=delvols_on_destroy)

        if attach:
            msg = (
                '{0} attached to {1} (aka {2}) as device {3}'.format(
                    volume_dict['volume_id'],
                    kwargs['instance_id'],
                    name,
                    volume['device']
                )
            )
            log.info(msg)
            ret.append(msg)
    return ret
203467
def _AddVolume(self, volume):
    
    if volume.identifier in self._volumes:
      raise KeyError(
          'Volume object already set for volume identifier: {0:s}'.format(
              volume.identifier))

    self._volumes[volume.identifier] = volume
    self._volume_identifiers.append(volume.identifier)
1068125
def volume_create_attach(name, call=None, **kwargs):
    '''
    
    '''
    if call == 'function':
        raise SaltCloudSystemExit(
            'The create_attach_volumes action must be called with '
            '-a or --action.'
        )

    if type(kwargs['volumes']) is str:
        volumes = salt.utils.yaml.safe_load(kwargs['volumes'])
    else:
        volumes = kwargs['volumes']

    ret = []
    for volume in volumes:
        created = False

        volume_dict = {
            'name': volume['name'],
        }
        if 'volume_id' in volume:
            volume_dict['volume_id'] = volume['volume_id']
        elif 'snapshot' in volume:
            volume_dict['snapshot'] = volume['snapshot']
        else:
            volume_dict['size'] = volume['size']

            if 'type' in volume:
                volume_dict['type'] = volume['type']
            if 'iops' in volume:
                volume_dict['iops'] = volume['iops']

        if 'id' not in volume_dict:
            created_volume = create_volume(**volume_dict)
            created = True
            volume_dict.update(created_volume)

        attach = attach_volume(
            name=volume['name'],
            server_name=name,
            device=volume.get('device', None),
            call='action'
        )

        if attach:
            msg = (
                '{0} attached to {1} (aka {2})'.format(
                    volume_dict['id'],
                    name,
                    volume_dict['name'],
                )
            )
            log.info(msg)
            ret.append(msg)
    return ret
810503
def init_volumes(self, single=None, only_mount=None, skip_mount=None, swallow_exceptions=True):
        """"""

        for disk in self.disks:
            logger.info("Mounting volumes in {0}".format(disk))
            for volume in disk.init_volumes(single, only_mount, skip_mount, swallow_exceptions=swallow_exceptions):
                yield volume
1277224
def manage_volume_device_assignment(mapping)

      # only managed volumes should be in an attached state ready for assignment.
      unless 'attached' == mapping[:management_status]
        raise VolumeManagement::UnexpectedState.new("The volume #{mapping[:volume_id]} was in an unexpected managed state: #{mapping.inspect}")
      end

      # check for changes in disks.
      last_disks = InstanceState.planned_volume_state.disks
      last_volumes = InstanceState.planned_volume_state.volumes
      vm = RightScale::Platform.volume_manager
      current_disks = vm.disks
      current_volumes = vm.volumes

      # correctly managing device assignment requires expecting precise changes
      # to disks and volumes. any deviation from this requires a retry.
      succeeded = false
      if new_disk = find_distinct_item(current_disks, last_disks, :index)
        # if the new disk as no partitions, then we will format and assign device.
        if vm.partitions(new_disk[:index]).empty?
          # FIX: ignore multiple mount points for simplicity and only only create
          # a single primary partition for the first mount point.
          # if we had the UI for it, then the user would probably specify
          # partition sizes as a percentage of disk size and associate those with
          # mount points formatted optionally specifying file system, label, etc.
          @audit.append_info("Creating primary partition and formatting \"#{mapping[:mount_points].first}\".")
          vm.format_disk(new_disk[:index], mapping[:mount_points].first)
          succeeded = true
        else
          # FIX: ignoring multiple existing partitiions on a disk (which should
          # result in multiple new volumes appearing when the disk comes online)
          # for simplicity until we have a UI supporting multiple mount points.
          @audit.append_info("Preparing \"#{mapping[:mount_points].first}\" for use.")
          new_volume = find_distinct_item(current_volumes, last_volumes, :device)
          unless new_volume
            vm.online_disk(new_disk[:index])
            current_volumes = vm.volumes
            new_volume = find_distinct_item(current_volumes, last_volumes, :device)
          end
          if new_volume
            # prefer selection by existing device because it is more reliable in Windows 2003 case.
            unless new_volume[:device] && (0 == new_volume[:device].casecmp(mapping[:mount_points].first))
              device_or_index_to_select = new_volume[:device] || new_volume[:index]
              vm.assign_device(device_or_index_to_select, mapping[:mount_points].first)
            end
            succeeded = true
          end
        end
      end

      # retry only if still not assigned.
      if succeeded
        # volume is (finally!) assigned to correct device name.
        mapping[:management_status] = 'assigned'
        mapping[:attempts] = nil

        # reset cached volumes/disks for next attempt (to attach), if any.
        InstanceState.planned_volume_state.disks = nil
        InstanceState.planned_volume_state.volumes = nil

        # continue.
        yield if block_given?
      else
        mapping[:attempts] ||= 0
        mapping[:attempts] += 1
        if mapping[:attempts] >= VolumeManagement::MAX_VOLUME_ATTEMPTS
          strand("Exceeded maximum of #{VolumeManagement::MAX_VOLUME_ATTEMPTS} attempts waiting for volume #{mapping[:volume_id]} to be in a managable state.")
        else
          yield if block_given?
        end
      end
    rescue Exception => e
      strand(e)
    end
350125
def create(self, volume_id, ip=None):
        
        if ip:
            return self.http_put('/volumes/%s/export?ip=%s' % (volume_id, ip))
        return self.http_put('/volumes/%s/export' % volume_id)
509145
def RegisterMountPoint(cls, mount_point, path_spec):
    
    if mount_point in cls._mount_points:
      raise KeyError('Mount point: {0:s} already set.'.format(mount_point))

    cls._mount_points[mount_point] = path_spec
96998
def mount(device, mountpoint, options=None, persist=False, filesystem="ext3"):
    """"""
    cmd_args = ['mount']
    if options is not None:
        cmd_args.extend(['-o', options])
    cmd_args.extend([device, mountpoint])
    try:
        subprocess.check_output(cmd_args)
    except subprocess.CalledProcessError as e:
        log('Error mounting {} at {}\n{}'.format(device, mountpoint, e.output))
        return False

    if persist:
        return fstab_add(device, mountpoint, filesystem, options=options)
    return True
83425
def attach_virtual_server(self, ticket_id=None, virtual_id=None):
        
        return self.ticket.addAttachedVirtualGuest(virtual_id, id=ticket_id)
1363615
def AddNewVolumeToInstance(self, instance_id, vol_size_gb):
    
    assert(vol_size_gb >= 1)
    if vol_size_gb > 1000: # probably spending too much if you go bigger
      raise RuntimeError('Adding volumes this large has not been tested.')
    instance = self.__GetInstanceById(instance_id)
    assert(instance)
    # select an unused device
    # see http://askubuntu.com/questions/47617/
    # how-to-attach-new-ebs-volume-to-ubuntu-machine-on-aws
    potential_device_names = ['/dev/xvdf',
                              '/dev/xvdg',
                              '/dev/xvdh', 
                              '/dev/xvdi']
    device_name = None
    for name in potential_device_names:
      if not self.DeviceExists(name, instance):
        device_name = name
        break
    if not device_name:
      raise RuntimeError('No suitable device names available')
    # Attach volume
    volume = self.ec2.create_volume(vol_size_gb, instance.placement)
    volume.attach(instance.id, device_name)
    # wait for volume to attach
    core.WaitForVolumeAttached(volume)
    while not self.DeviceExists(device_name, instance):
        logging.info( 'waiting for device to be attached...')
        time.sleep(5)
    assert(volume.id)
    assert(volume.attach_data.device == device_name)
    # format file system, mount the file system, update fstab to automount
    hostname = instance.dns_name
    add_ebs_volume_playbook = pkg_resources.resource_filename(__name__,
      'ami/playbooks/workstation/add_ebs_volume.yml')
    extra_vars = {}
    extra_vars['volume_name'] = volume.id
    extra_vars['volume_device'] = device_name
    assert(core.RunPlaybookOnHost(add_ebs_volume_playbook, hostname, 
                                  self.ssh_key, extra_vars))      
    return volume.id
340647
def add_file_or_directory_volume(self,
                                     runtime,         # type: List[Text]
                                     volume,          # type: MapperEnt
                                     host_outdir_tgt  # type: Optional[Text]
                                     ):  # type: (...) -> None
        """"""
        if not volume.resolved.startswith("_:"):
            _check_docker_machine_path(docker_windows_path_adjust(
                volume.resolved))
            self.append_volume(runtime, volume.resolved, volume.target)