0
jclouds를 사용하여 EC2 인스턴스를 조작하기 시작합니다.jclouds의 기존 securityGroup 및 pem 파일 사용 - Java
private ComputeService compute;
public void add(Integer instances) {
try {
logger.info("------------------------------------------------------");
logger.info(String.format(">> adding node to group %s%n", this.groupname));
// Default template chooses the smallest size on an operating system
// that tested to work with java, which tends to be Ubuntu or CentOS
TemplateBuilder templateBuilder = this.compute.templateBuilder();
// note this will create a user with the same name as you on the
// node. ex. you can connect via ssh publicip
Statement bootInstructions = AdminAccess.standard();
// to run commands as root, we use the runScript option in the template.
templateBuilder.options(runScript(bootInstructions));
Template template = templateBuilder.build();
// add a custom security group
NodeMetadata node = getOnlyElement(this.compute.createNodesInGroup(this.groupname, instances, template));
logger.info(String.format("<< node %s: %s%n", node.getId(),
concat(node.getPrivateAddresses(), node.getPublicAddresses())));
logger.info("------------------------------------------------------");
} catch (Exception e) {
logger.error(e.getMessage());
logger.info("------------------------------------------------------");
}
}
인증이 올바른지 가정 groupname = default
하십시오 : 따라서, 나는 다음과 같은 방법이있다. 나는 하나 개의 인스턴스가 생성하더라도
this.compute.add(1);
을 실행하면
jclouds
새로운
security group
및
key pair
때마다 생성됩니다. 기존의
foo.pem
파일과
default
보안 그룹이 있습니다. 예 :
security group = jclouds#default
. 기존 보안 그룹과 핵심 가치를 어떻게 활용할 수 있습니까? 보안 그룹이나 키 쌍을 기존 사용하려면