使用Apache JClouds时,如何启动具有公共IP的计算实例?这不同于弹性IP。使用官方的AWS API,您可以执行以下操作:
//create network information
InstanceNetworkInterfaceSpecification networkWithPublicIp = new InstanceNetworkInterfaceSpecification()
.withSubnetId(subnetId)
.withAssociatePublicIpAddress(true)
.withGroups( securityGroupIds )
.withDeviceIndex(0);
一旦启动该节点,它将有一个随机分配的公共IP(非弹性)。有没有办法使用Jclouds和AWSEC2TemplateOptions做到这一点?
答案 0 :(得分:0)
文档中有一个示例,"We have a problem with promises"
// ex. to get an ip and associate it with a node
String ip = ec2Client.getElasticIPAddressServices().allocateAddressInRegion(node.getLocation().getId());
ec2Client.getElasticIPAddressServices().associateAddressInRegion(node.getLocation().getId(),ip, node.getProviderId());