List of usage examples for com.amazonaws.services.ec2.model VolumeType Io1
VolumeType Io1
To view the source code for com.amazonaws.services.ec2.model VolumeType Io1.
Click Source Link
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);/*from w ww .j a va 2 s.co m*/ return map; } 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; }