本文整理汇总了Java中com.amazonaws.services.ec2.model.CreateKeyPairRequest类的典型用法代码示例。如果您正苦于以下问题:Java CreateKeyPairRequest类的具体用法?Java CreateKeyPairRequest怎么用?Java CreateKeyPairRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CreateKeyPairRequest类属于com.amazonaws.services.ec2.model包,在下文中一共展示了CreateKeyPairRequest类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: main
import com.amazonaws.services.ec2.model.CreateKeyPairRequest; //导入依赖的package包/类
public static void main(String[] args)
{
final String USAGE =
"To run this example, supply a key pair name\n" +
"Ex: CreateKeyPair <key-pair-name>\n";
if (args.length != 1) {
System.out.println(USAGE);
System.exit(1);
}
String key_name = args[0];
final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient();
CreateKeyPairRequest request = new CreateKeyPairRequest()
.withKeyName(key_name);
CreateKeyPairResult response = ec2.createKeyPair(request);
System.out.printf(
"Successfulyl created key pair named %s",
key_name);
}
开发者ID:awsdocs,项目名称:aws-doc-sdk-examples,代码行数:25,代码来源:CreateKeyPair.java
示例2: createKeyPair
import com.amazonaws.services.ec2.model.CreateKeyPairRequest; //导入依赖的package包/类
private void createKeyPair() throws IOException, FileNotFoundException {
DescribeKeyPairsResult response = ec2.describeKeyPairs();
boolean check_key=false;
for(KeyPairInfo key_pair : response.getKeyPairs()) {
if(key_pair.getKeyName().equalsIgnoreCase(MY_KEY))
{
check_key=true;
break;
}
}
if(!check_key)
{
File file=new File(System.getProperty("user.home")+"/.aws/"+MY_KEY+".pem");
if(!file.exists()) file.createNewFile();
else{
System.err.println("Connot create the key pair to access to the cluster!");
System.exit(1);
}
System.out.println("Create new key pair ~/.aws/"+MY_KEY+".pem");
CreateKeyPairRequest request = new CreateKeyPairRequest()
.withKeyName(MY_KEY);
CreateKeyPairResult responsetocreate = ec2.createKeyPair(request);
PrintWriter print = new PrintWriter(file);
print.print(responsetocreate.getKeyPair().getKeyMaterial());
print.close();
Runtime.getRuntime().exec("chmod 0400 "+System.getProperty("user.home")+"/.aws/"+MY_KEY+".pem");
}
}
开发者ID:spagnuolocarmine,项目名称:aws-cluster-toolkit,代码行数:32,代码来源:AwsClusterManager.java
示例3: create
import com.amazonaws.services.ec2.model.CreateKeyPairRequest; //导入依赖的package包/类
@Override
public String create(Instance instance) {
CreateKeyPairRequest createKeyPairRequest = new CreateKeyPairRequest();
createKeyPairRequest.withKeyName(instance.getKeyName());
CreateKeyPairResult createKeyPairResult = ec2UserClient.amazonEC2Async().createKeyPair(createKeyPairRequest);
KeyPair keyPair = createKeyPairResult.getKeyPair();
return keyPair.getKeyMaterial();
}
开发者ID:peavers,项目名称:swordfish-service,代码行数:11,代码来源:EC2KeyPairImpl.java
示例4: doGenerateKey
import com.amazonaws.services.ec2.model.CreateKeyPairRequest; //导入依赖的package包/类
public FormValidation doGenerateKey(StaplerResponse rsp, URL ec2EndpointUrl, boolean useInstanceProfileForCredentials, String accessId, String secretKey)
throws IOException, ServletException {
try {
AWSCredentialsProvider credentialsProvider = createCredentialsProvider(useInstanceProfileForCredentials, accessId, secretKey);
AmazonEC2 ec2 = connect(credentialsProvider, ec2EndpointUrl);
List<KeyPairInfo> existingKeys = ec2.describeKeyPairs().getKeyPairs();
int n = 0;
while (true) {
boolean found = false;
for (KeyPairInfo k : existingKeys) {
if (k.getKeyName().equals("hudson-" + n)) {
found = true;
}
}
if (!found) {
break;
}
n++;
}
CreateKeyPairRequest request = new CreateKeyPairRequest("hudson-" + n);
KeyPair key = ec2.createKeyPair(request).getKeyPair();
rsp.addHeader("script", "findPreviousFormItem(button,'privateKey').value='" + key.getKeyMaterial().replace("\n", "\\n") + "'");
return FormValidation.ok(Messages.EC2Cloud_Success());
} catch (AmazonClientException e) {
LOGGER.log(Level.WARNING, "Failed to check EC2 credential", e);
return FormValidation.error(e.getMessage());
}
}
开发者ID:hudson3-plugins,项目名称:ec2-plugin,代码行数:33,代码来源:EC2Cloud.java
示例5: createKeyValuePair
import com.amazonaws.services.ec2.model.CreateKeyPairRequest; //导入依赖的package包/类
/***
* Creates a 2048-bit RSA key pair with the specified name
*
* @param keyName Key name to use
* @return Unencrypted PEM encoded PKCS#8 private key
*/
public String createKeyValuePair(String keyName) {
final AmazonEC2 amazonEC2 = getEc2Client();
final CreateKeyPairRequest createKeyPairRequest = new CreateKeyPairRequest().withKeyName(keyName);
final CreateKeyPairResult createKeyPairResult = amazonEC2.createKeyPair(createKeyPairRequest);
final KeyPair keyPair = createKeyPairResult.getKeyPair();
final String material = keyPair.getKeyMaterial();
LOGGER.info("Created key: " + keyName);
LOGGER.debug("Created material: " + material);
return material;
}
开发者ID:apache,项目名称:incubator-gobblin,代码行数:20,代码来源:AWSSdkClient.java
示例6: createKeyPair
import com.amazonaws.services.ec2.model.CreateKeyPairRequest; //导入依赖的package包/类
@Override
public KeyPair createKeyPair(CreateKeyPairRequest request,
ResultCapture<CreateKeyPairResult> extractor) {
ActionResult result = service.performAction("CreateKeyPair", request,
extractor);
if (result == null) return null;
return new KeyPairImpl(result.getResource());
}
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:11,代码来源:EC2Impl.java
示例7: execute
import com.amazonaws.services.ec2.model.CreateKeyPairRequest; //导入依赖的package包/类
/**
* Creates a key-pair with a randomly generated name, and sets the generated
* name to the specified property.
*/
public void execute() {
checkParams();
AmazonEC2Client client = getOrCreateClient(AmazonEC2Client.class);
try {
String keyName = Long.toString(System.currentTimeMillis());
client.createKeyPair(new CreateKeyPairRequest()
.withKeyName(keyName));
getProject().setProperty(propertyNameForKeyName, keyName);
} catch (Exception e) {
throw new BuildException(e.getMessage(), e);
}
}
开发者ID:awslabs,项目名称:aws-ant-tasks,代码行数:17,代码来源:SetUpCloudFormationTestsTask.java
示例8: createKeyPair
import com.amazonaws.services.ec2.model.CreateKeyPairRequest; //导入依赖的package包/类
@Override
public CreateKeyPairResult createKeyPair(CreateKeyPairRequest createKeyPairRequest) throws AmazonServiceException, AmazonClientException {
throw new UnsupportedOperationException("Not supported in mock");
}
开发者ID:justor,项目名称:elasticsearch_my,代码行数:5,代码来源:AmazonEC2Mock.java
示例9: createKeyPair
import com.amazonaws.services.ec2.model.CreateKeyPairRequest; //导入依赖的package包/类
public KeyPair createKeyPair(String keyName) {
logger.info("create key pair, keyName={}", keyName);
CreateKeyPairResult result = ec2.createKeyPair(new CreateKeyPairRequest().withKeyName(keyName));
return result.getKeyPair();
}
开发者ID:neowu,项目名称:cmn-project,代码行数:6,代码来源:EC2.java
示例10: createKeyPair
import com.amazonaws.services.ec2.model.CreateKeyPairRequest; //导入依赖的package包/类
public CreateKeyPairResult createKeyPair(AmazonEC2Client client, String keyName) {
CreateKeyPairRequest createKeyPairRequest = new CreateKeyPairRequest().withKeyName(keyName);
CreateKeyPairResult createKeyPairResult = client.createKeyPair(createKeyPairRequest);
return createKeyPairResult;
}
开发者ID:sequenceiq,项目名称:sequenceiq-samples,代码行数:6,代码来源:SimpleKeyPairService.java
示例11: createKeyPair
import com.amazonaws.services.ec2.model.CreateKeyPairRequest; //导入依赖的package包/类
/**
* Performs the <code>CreateKeyPair</code> action.
*
* <p>
*
* @return The <code>KeyPair</code> resource object associated with the
* result of this action.
* @see CreateKeyPairRequest
*/
com.amazonaws.resources.ec2.KeyPair createKeyPair(CreateKeyPairRequest
request);
开发者ID:awslabs,项目名称:aws-sdk-java-resources,代码行数:12,代码来源:EC2.java
注:本文中的com.amazonaws.services.ec2.model.CreateKeyPairRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论