Example usage for com.amazonaws.services.ec2.model DetachVolumeRequest isForce

List of usage examples for com.amazonaws.services.ec2.model DetachVolumeRequest isForce

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model DetachVolumeRequest isForce.

Prototype


public Boolean isForce() 

Source Link

Document

Forces detachment if the previous detachment attempt did not occur cleanly (for example, logging into an instance, unmounting the volume, and detaching normally).

Usage

From source file:jp.primecloud.auto.aws.typica.EucaEc2Client.java

License:Open Source License

@Override
public DetachVolumeResult detachVolume(DetachVolumeRequest detachVolumeRequest) {
    // Device?? /dev/ ?
    String device = detachVolumeRequest.getDevice();
    if (device != null && device.startsWith("/dev/")) {
        device = device.substring("/dev/".length());
    }//w w w  .jav  a  2s  .  c o  m

    boolean force = detachVolumeRequest.isForce() != null ? detachVolumeRequest.isForce().booleanValue()
            : false;

    try {
        AttachmentInfo info = jec2.detachVolume(detachVolumeRequest.getVolumeId(),
                detachVolumeRequest.getInstanceId(), device, force);
        VolumeAttachment attachment = new VolumeAttachmentConverter().convert(info);
        return new DetachVolumeResult().withAttachment(attachment);
    } catch (EC2Exception e) {
        throw new AmazonClientException(e);
    }
}