Java 类com.amazonaws.services.ec2.model.VolumeAttachment 实例源码

项目:enhanced-snapshots    文件:VolumeDtoConverterTest.java   
private Volume createVolume(String volId, String snapId, Date createDate, String zone, int size, String state, List<Tag> tags, String instance_id) {
    Volume volume = new Volume();
    volume.setVolumeId(volId);
    volume.setSnapshotId(snapId);
    volume.setCreateTime(createDate);
    volume.setAvailabilityZone(zone);
    volume.setState(state);
    volume.setSize(size);
    volume.setTags(tags);
    if (instance_id != null) {
        List<VolumeAttachment> volumeAttachmentList = new ArrayList();
        VolumeAttachment volumeAttachment = new VolumeAttachment();
        volumeAttachment.setInstanceId(instance_id);
        volumeAttachmentList.add(volumeAttachment);
        volume.setAttachments(volumeAttachmentList);
    }
    return volume;
}
项目:primecloud-controller    文件:AwsVolumeProcess.java   
public void detachVolume(AwsProcessClient awsProcessClient, Long instanceNo, Long volumeNo) {
    AwsVolume awsVolume = awsVolumeDao.read(volumeNo);
    String volumeId = awsVolume.getVolumeId();

    //イベントログ出力
    Component component = null;
    if (awsVolume.getComponentNo() != null) {
        component = componentDao.read(awsVolume.getComponentNo());
    }
    Instance instance = instanceDao.read(instanceNo);
    processLogger.debug(component, instance, "AwsEbsDetach",
            new Object[] { instance.getInstanceName(), awsVolume.getVolumeId(), awsVolume.getDevice() });

    // ボリュームのデタッチ
    DetachVolumeRequest request = new DetachVolumeRequest();
    request.withVolumeId(volumeId);
    request.withInstanceId(awsVolume.getInstanceId());
    request.withDevice(awsVolume.getDevice());
    DetachVolumeResult result = awsProcessClient.getEc2Client().detachVolume(request);
    VolumeAttachment attachment = result.getAttachment();

    // ログ出力
    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100125", volumeId, attachment.getInstanceId()));
    }
}
项目:primecloud-controller    文件:VolumeAttachmentConverter.java   
@Override
protected VolumeAttachment convertObject(AttachmentInfo from) {
    VolumeAttachment to = new VolumeAttachment();

    to.setVolumeId(from.getVolumeId());
    to.setInstanceId(from.getInstanceId());
    to.setDevice(from.getDevice());
    to.setState(from.getStatus());
    to.setAttachTime(from.getAttachTime().getTime());

    // 未実装
    to.setDeleteOnTermination(false);

    return to;
}
项目:primecloud-controller    文件:AwsVolumeProcess.java   
public void attachVolume(AwsProcessClient awsProcessClient, Long instanceNo, Long volumeNo) {
    AwsInstance awsInstance = awsInstanceDao.read(instanceNo);
    AwsVolume awsVolume = awsVolumeDao.read(volumeNo);
    String volumeId = awsVolume.getVolumeId();

    //イベントログ出力
    Component component = null;
    if (awsVolume.getComponentNo() != null) {
        component = componentDao.read(awsVolume.getComponentNo());
    }
    Instance instance = instanceDao.read(instanceNo);
    processLogger.debug(component, instance, "AwsEbsAttach",
            new Object[] { instance.getInstanceName(), awsVolume.getVolumeId(), awsVolume.getDevice() });

    // ボリュームのアタッチ
    AttachVolumeRequest request = new AttachVolumeRequest();
    request.withVolumeId(volumeId);
    request.withInstanceId(awsInstance.getInstanceId());
    request.withDevice(awsVolume.getDevice());
    AttachVolumeResult result = awsProcessClient.getEc2Client().attachVolume(request);
    VolumeAttachment attachment = result.getAttachment();

    // ログ出力
    if (log.isInfoEnabled()) {
        log.info(MessageUtils.getMessage("IPROCESS-100123", volumeId, attachment.getInstanceId()));
    }

    // データベースの更新
    awsVolume.setInstanceId(attachment.getInstanceId());
    awsVolumeDao.update(awsVolume);
}
项目:director-aws-plugin    文件:EBSAllocator.java   
/**
 * Wait for the specified list of volumes to be attached within a timeout.
 *
 * @param volumeIds collection of volume ids to wait for
 * @return collection of volumes that were successfully attached
 * @throws InterruptedException if the operation is interrupted
 */
private Collection<String> waitUntilVolumesAttached(Collection<String> volumeIds) throws InterruptedException {
  checkNotNull(volumeIds);
  if (volumeIds.isEmpty()) {
    LOG.info("No volumes are being attached, skipping wait");
    return Collections.emptySet();
  }

  Set<String> unattachedVolumes = Sets.newHashSet(volumeIds);
  Set<String> attachedVolumes = Sets.newHashSet();

  LOG.info("Waiting for a maximum of {} seconds for volumes to be attached",
      attachTimeoutSeconds);

  Stopwatch watch = Stopwatch.createStarted();
  while (watch.elapsed(TimeUnit.SECONDS) < attachTimeoutSeconds) {
    DescribeVolumesRequest volumeRequest = new DescribeVolumesRequest().withVolumeIds(unattachedVolumes);
    List<Volume> volumes = client.describeVolumes(volumeRequest).getVolumes();

    for (Volume volume : volumes) {
      VolumeAttachment attachment = Iterables.getOnlyElement(volume.getAttachments());
      VolumeAttachmentState state = VolumeAttachmentState.fromValue(attachment.getState());

      if (state == VolumeAttachmentState.Attached) {
        unattachedVolumes.remove(volume.getVolumeId());
        attachedVolumes.add(volume.getVolumeId());
      }
    }

    if (unattachedVolumes.isEmpty()) {
      return attachedVolumes;
    }

    LOG.info("Waiting on {} out of {} volumes to be attached, next check in {} seconds",
        unattachedVolumes.size(), volumeIds.size(), WAIT_UNTIL_ATTACHED_INTERVAL_SECONDS);
    TimeUnit.SECONDS.sleep(WAIT_UNTIL_ATTACHED_INTERVAL_SECONDS);
  }

  LOG.error("Timed out while waiting for all volumes to be attached, {} out of {} volumes were attached",
      attachedVolumes.size(), volumeIds.size());
  return attachedVolumes;
}
项目:aws-sdk-java-resources    文件:VolumeImpl.java   
@Override
public List<VolumeAttachment> getAttachments() {
    return (List<VolumeAttachment>) resource.getAttribute("Attachments");
}
项目:aws-sdk-java-resources    文件:Volume.java   
/**
 * Gets the value of the Attachments attribute. If this resource is not yet
 * loaded, a call to {@code load()} is made to retrieve the value of the
 * attribute.
 */
List<VolumeAttachment> getAttachments();