You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@jclouds.apache.org by Ruben Rubio Rey <tk...@gmail.com> on 2015/02/12 05:30:32 UTC
Can't attach volumes with AMI ebs-io
Hi
I am trying to use
template.getOptions().as(EC2TemplateOptions.class).mapNewVolumeToDeviceName("/dev/sdm",
100, true );
to attach another volume to an instance. But I did realize that if the AMI
is ebs, the volume is created, but if the AMI is ebs-io, the volume is not
created.
Any ideas how to solve this problem ?
Code examples:
AMI EBS (works)
final String POLL_PERIOD_TWENTY_SECONDS =
String.valueOf(SECONDS.toMillis(20));
Properties overrides = new Properties();
overrides.setProperty(ComputeServiceProperties.POLL_INITIAL_PERIOD,
POLL_PERIOD_TWENTY_SECONDS);
overrides.setProperty(ComputeServiceProperties.POLL_MAX_PERIOD,
POLL_PERIOD_TWENTY_SECONDS);
Iterable<Module> modules = ImmutableSet.<Module> of(new
SshjSshClientModule(), new SLF4JLoggingModule());
//Iterable<Module> modules = ImmutableSet.<Module> of(new
SshjSshClientModule());
ComputeServiceContext context = ContextBuilder.newBuilder("aws-ec2")
.credentials("xx", "xx/")
.modules(modules)
.overrides(overrides)
.buildView(ComputeServiceContext.class);
ComputeService computeService = context.getComputeService();
// UBUNTU
Template template = computeService.templateBuilder()
.locationId("us-east-1")
.imageId("us-east-1/ami-7c807d14")
.hardwareId("t1.micro")
.build();
template.getOptions().as(EC2TemplateOptions.class).mapNewVolumeToDeviceName("/dev/sdm",
100, true );
Set<? extends NodeMetadata> nodes =
computeService.createNodesInGroup("m456", 1, template);
for (NodeMetadata nodeMetadata : nodes) {
String publicAddress =
nodeMetadata.getPublicAddresses().iterator().next();
//String privateAddress =
nodeMetadata.getPrivateAddresses().iterator().next();
String username = nodeMetadata.getCredentials().getUser();
String password = nodeMetadata.getCredentials().getPassword();
// [...]
System.out.println(String.format("ssh %s@%s %s",
username, publicAddress, password));
System.out.println(nodeMetadata.getCredentials().getPrivateKey());
}
EBS IO (Does not work)
final String POLL_PERIOD_TWENTY_SECONDS =
String.valueOf(SECONDS.toMillis(20));
Properties overrides = new Properties();
overrides.setProperty(ComputeServiceProperties.POLL_INITIAL_PERIOD,
POLL_PERIOD_TWENTY_SECONDS);
overrides.setProperty(ComputeServiceProperties.POLL_MAX_PERIOD,
POLL_PERIOD_TWENTY_SECONDS);
Iterable<Module> modules = ImmutableSet.<Module> of(new
SshjSshClientModule(), new SLF4JLoggingModule());
//Iterable<Module> modules = ImmutableSet.<Module> of(new
SshjSshClientModule());
ComputeServiceContext context = ContextBuilder.newBuilder("aws-ec2")
.credentials("xx", "yy/")
.modules(modules)
.overrides(overrides)
.buildView(ComputeServiceContext.class);
ComputeService computeService = context.getComputeService();
// UBUNTU
Template template = computeService.templateBuilder()
.locationId("us-east-1")
.imageId("us-east-1/ami-38834650")
.hardwareId("t1.micro")
.build();
template.getOptions().as(EC2TemplateOptions.class).mapNewVolumeToDeviceName("/dev/sdm",
100, true );
Set<? extends NodeMetadata> nodes =
computeService.createNodesInGroup("m456", 1, template);
for (NodeMetadata nodeMetadata : nodes) {
String publicAddress =
nodeMetadata.getPublicAddresses().iterator().next();
//String privateAddress =
nodeMetadata.getPrivateAddresses().iterator().next();
String username = nodeMetadata.getCredentials().getUser();
String password = nodeMetadata.getCredentials().getPassword();
// [...]
System.out.println(String.format("ssh %s@%s %s",
username, publicAddress, password));
System.out.println(nodeMetadata.getCredentials().getPrivateKey());
}
Note: I am using the official ubuntu images at
http://cloud-images.ubuntu.com/releases/14.04/release-20140607.1/published-ec2-release.txt.orig
Any help is appreciated!
Regards,
Ruben