Example usage for com.amazonaws.services.ec2.model BlockDeviceMapping setNoDevice

List of usage examples for com.amazonaws.services.ec2.model BlockDeviceMapping setNoDevice

Introduction

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

Prototype


public void setNoDevice(String noDevice) 

Source Link

Document

Suppresses the specified device included in the block device mapping of the AMI.

Usage

From source file:hudson.plugins.ec2.util.DeviceMappingParser.java

License:Open Source License

public static List<BlockDeviceMapping> parse(String customDeviceMapping) {

    List<BlockDeviceMapping> deviceMappings = new ArrayList<BlockDeviceMapping>();

    for (String mapping : customDeviceMapping.split(",")) {
        String[] mappingPair = mapping.split("=");
        String device = mappingPair[0];
        String blockDevice = mappingPair[1];

        BlockDeviceMapping deviceMapping = new BlockDeviceMapping().withDeviceName(device);

        if (blockDevice.equals("none")) {
            deviceMapping.setNoDevice("none");
        } else if (blockDevice.startsWith("ephemeral")) {
            deviceMapping.setVirtualName(blockDevice);
        } else {//from   w  ww . j a va  2s  .c  o m
            deviceMapping.setEbs(parseEbs(blockDevice));
        }

        deviceMappings.add(deviceMapping);
    }

    return deviceMappings;
}

From source file:org.xmlsh.aws.util.AWSEC2Command.java

License:BSD License

protected BlockDeviceMapping parseBlockDeviceMapping(String string) throws InvalidArgumentException {
    BlockDeviceMapping map = new BlockDeviceMapping();
    StringPair pair = new StringPair(string, '=');

    String device = pair.getLeft();
    // if( device.startsWith("/dev/"))
    // device = device.substring(5);

    if (!pair.hasRight()) {
        map.setNoDevice(device);
        return map;
    }//w  w w.ja v  a2s .  c  o m

    String r = pair.getRight();
    if (r.equals("none")) {
        map.setNoDevice(device);
        return map;
    }

    map.setDeviceName(device);

    // Ephemeral = virtual ?
    if (!r.contains(":")) {
        map.setVirtualName(r);
        return map;
    }

    // Parse out the EBS stuff
    // [snapshot-id]:[volume-size]:[delete-on-termination]:[volume-type[:iops]]:[encrypted]

    String aebs[] = r.split(":");

    EbsBlockDevice ebs = new EbsBlockDevice();

    // [snapshot-id]:
    if (aebs.length >= 1) {
        String snapshotId = aebs[0];
        if (!Util.isBlank(snapshotId))
            ebs.setSnapshotId(snapshotId);

    }
    // :[volume-size]:
    if (aebs.length >= 2) {
        if (!Util.isBlank(aebs[1]))
            ebs.setVolumeSize(new Integer(aebs[1]));

    }

    // [delete-on-termination]:
    if (aebs.length >= 3) {
        if (!Util.isBlank(aebs[2]))
            ebs.setDeleteOnTermination(Boolean.valueOf(Util.parseBoolean(aebs[2])));

    }
    if (aebs.length >= 4) {
        // [volume-type[:iops]]:[encrypted]
        int i = 3;
        if (!Util.isBlank(aebs[i])) {
            ebs.setVolumeType(aebs[i]);
            if (aebs[i].equals(VolumeType.Io1.toString())) {
                i++;
                if (aebs.length <= i || Util.isBlank(aebs[i]))
                    throw new InvalidArgumentException(
                            "EBS block mapping with VolumeType :io1 MUST have PIOPS");
                ebs.setIops(Integer.valueOf(aebs[i]));
            }
            i++;
            if (aebs.length > i)
                ebs.setEncrypted(Util.parseBoolean(aebs[i]));
        }
    }

    map.setEbs(ebs);
    return map;

}