com.amazonaws.services.ec2.model.KeyPairInfo Java Examples
The following examples show how to use
com.amazonaws.services.ec2.model.KeyPairInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AwsIaasGatewayScriptService.java From primecloud-controller with GNU General Public License v2.0 | 6 votes |
@Override public void importKeyPair(String keyName, String publicKey) throws AutoException { // キーペアがすでに登録されていたら何もしない DescribeKeyPairsRequest request = new DescribeKeyPairsRequest(); DescribeKeyPairsResult result = ec2Client.describeKeyPairs(request); List<KeyPairInfo> keyPairs = result.getKeyPairs(); for (KeyPairInfo keyPair : keyPairs) { if (keyPair.getKeyName().equals(keyName)) { log.info(platform.getPlatformName() + " の " + keyName + " はすでに登録されている為、キーのインポートをスキップします"); System.out.println("IMPORT_SKIPPED"); return; } } // インポート ImportKeyPairRequest request2 = new ImportKeyPairRequest(); request2.withKeyName(keyName); request2.withPublicKeyMaterial(publicKey); ec2Client.importKeyPair(request2); log.info(keyName + "のキーをインポートしました。"); }
Example #2
Source File: DescribeKeyPairs.java From aws-doc-sdk-examples with Apache License 2.0 | 5 votes |
public static void main(String[] args) { final AmazonEC2 ec2 = AmazonEC2ClientBuilder.defaultClient(); DescribeKeyPairsResult response = ec2.describeKeyPairs(); for(KeyPairInfo key_pair : response.getKeyPairs()) { System.out.printf( "Found key pair with name %s " + "and fingerprint %s", key_pair.getKeyName(), key_pair.getKeyFingerprint()); } }
Example #3
Source File: MockAwsDescribeService.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
@Override public List<KeyPairInfo> getKeyPairs(Long userNo, Long platformNo) { List<KeyPairInfo> infos = new ArrayList<KeyPairInfo>(); infos.add(new KeyPairInfo().withKeyName("key01")); infos.add(new KeyPairInfo().withKeyName("key02")); infos.add(new KeyPairInfo().withKeyName("key03")); return infos; }
Example #4
Source File: KeyPairInfoConverter.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
@Override protected KeyPairInfo convertObject(com.xerox.amazonws.ec2.KeyPairInfo from) { KeyPairInfo to = new KeyPairInfo(); to.setKeyName(from.getKeyName()); to.setKeyFingerprint(from.getKeyFingerprint()); return to; }
Example #5
Source File: AwsDescribeServiceImpl.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public List<KeyPairInfo> getKeyPairs(Long userNo, Long platformNo) { // キーペアを取得 AwsProcessClient awsProcessClient = awsProcessClientFactory.createAwsProcessClient(userNo, platformNo); DescribeKeyPairsRequest request = new DescribeKeyPairsRequest(); DescribeKeyPairsResult result = awsProcessClient.getEc2Client().describeKeyPairs(request); List<KeyPairInfo> keyPairs = result.getKeyPairs(); // ソート Collections.sort(keyPairs, Comparators.COMPARATOR_KEY_PAIR_INFO); return keyPairs; }
Example #6
Source File: EditInstanceAws.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
private boolean checkKeyName(Long userNo, Long platformNo, String keyName) { List<KeyPairInfo> keyPairs = awsDescribeService.getKeyPairs(userNo, platformNo); for (KeyPairInfo keyPair : keyPairs) { if (StringUtils.equals(keyName, keyPair.getKeyName())) { return true; } } return false; }
Example #7
Source File: SimpleKeyPairService.java From sequenceiq-samples with Apache License 2.0 | 5 votes |
private String describeKeyPairFingerPrint(AmazonEC2Client client, String keyName) { DescribeKeyPairsResult describeKeyPairsResult = client.describeKeyPairs(); for (KeyPairInfo keyPairInfo : describeKeyPairsResult.getKeyPairs()) { if (keyPairInfo.getKeyName().equals(keyName)) { return keyPairInfo.getKeyFingerprint(); } } return ""; }
Example #8
Source File: AwsPlatformResources.java From cloudbreak with Apache License 2.0 | 5 votes |
@Override public CloudSshKeys sshKeys(CloudCredential cloudCredential, Region region, Map<String, String> filters) { Map<String, Set<CloudSshKey>> result = new HashMap<>(); for (Region actualRegion : regions(cloudCredential, region, new HashMap<>(), true).getCloudRegions().keySet()) { // If region is provided then should filter for those region if (regionMatch(actualRegion, region)) { Set<CloudSshKey> cloudSshKeys = new HashSet<>(); AmazonEC2Client ec2Client = awsClient.createAccess(new AwsCredentialView(cloudCredential), actualRegion.value()); //create sshkey filter view PlatformResourceSshKeyFilterView filter = new PlatformResourceSshKeyFilterView(filters); DescribeKeyPairsRequest describeKeyPairsRequest = new DescribeKeyPairsRequest(); // If the filtervalue is provided then we should filter only for those securitygroups if (!Strings.isNullOrEmpty(filter.getKeyName())) { describeKeyPairsRequest.withKeyNames(filter.getKeyName()); } for (KeyPairInfo keyPairInfo : ec2Client.describeKeyPairs(describeKeyPairsRequest).getKeyPairs()) { Map<String, Object> properties = new HashMap<>(); properties.put("fingerPrint", keyPairInfo.getKeyFingerprint()); cloudSshKeys.add(new CloudSshKey(keyPairInfo.getKeyName(), properties)); } result.put(actualRegion.value(), cloudSshKeys); } } return new CloudSshKeys(result); }
Example #9
Source File: WinServerEdit.java From primecloud-controller with GNU General Public License v2.0 | 4 votes |
private void loadData() { AwsDescribeService awsDescribeService = BeanContext.getBean(AwsDescribeService.class); Long platformNo = platform.getPlatform().getPlatformNo(); // キーペア情報を取得 List<KeyPairInfo> keyPairInfos = awsDescribeService.getKeyPairs(ViewContext.getUserNo(), platformNo); List<String> keyNames = new ArrayList<String>(); for (KeyPairInfo keyPairInfo : keyPairInfos) { keyNames.add(keyPairInfo.getKeyName()); } this.keyNames = keyNames; // セキュリティグループ情報を取得 List<String> groupNames = new ArrayList<String>(); List<SecurityGroup> securityGroups = awsDescribeService.getSecurityGroups(ViewContext.getUserNo(), platformNo); for (SecurityGroup securityGroup : securityGroups) { groupNames.add(securityGroup.getGroupName()); } this.groupNames = groupNames; // VPCの場合 if (BooleanUtils.isTrue(platform.getPlatformAws().getVpc())) { // サブネット情報の取得 List<Subnet> subnets = awsDescribeService.getSubnets(ViewContext.getUserNo(), platformNo); this.subnets = subnets; } // 非VPCの場合 else { // ゾーン情報の取得 List<AvailabilityZone> zones = awsDescribeService.getAvailabilityZones(ViewContext.getUserNo(), platformNo); if (BooleanUtils.isNotTrue(platform.getPlatformAws().getEuca())) { // EC2の場合、空行を先頭に追加してゾーンを無指定にできるようにする zones.add(0, new AvailabilityZone()); } this.zones = zones; } // ElasticIp情報の取得 List<AwsAddress> elasticIps = awsDescribeService.getAddresses(ViewContext.getUserNo(), platformNo); this.elasticIps = elasticIps; }
Example #10
Source File: Comparators.java From primecloud-controller with GNU General Public License v2.0 | 4 votes |
@Override public int compare(KeyPairInfo o1, KeyPairInfo o2) { return o1.getKeyName().compareTo(o2.getKeyName()); }
Example #11
Source File: SimpleKeyPairService.java From sequenceiq-samples with Apache License 2.0 | 4 votes |
private List<KeyPairInfo> listKeyPairs(AmazonEC2Client client) { DescribeKeyPairsResult describeKeyPairsResult = client.describeKeyPairs(); return describeKeyPairsResult.getKeyPairs(); }
Example #12
Source File: SimpleKeyPairService.java From sequenceiq-samples with Apache License 2.0 | 4 votes |
@Override public List<KeyPairInfo> listKeyPairs(AWSCredentials credentials) { return listKeyPairs(amazonEC2ClientFactory.createAmazonEC2Client(credentials)); }
Example #13
Source File: KeyPairsConroller.java From sequenceiq-samples with Apache License 2.0 | 4 votes |
@RequestMapping(method = RequestMethod.GET, value = {"/keypairs"}) @ResponseBody public List<KeyPairInfo> listKeyPairs(ModelMap model, @RequestParam("accessKey") String accessKey, @RequestParam("secretKey") String secretKey) { return awsec2Service.listKeyPairs(awsCredentialsFactory.createSimpleAWSCredentials(accessKey, secretKey)); }
Example #14
Source File: AwsDescribeService.java From primecloud-controller with GNU General Public License v2.0 | votes |
public List<KeyPairInfo> getKeyPairs(Long userNo, Long platformNo);
Example #15
Source File: KeyPairService.java From sequenceiq-samples with Apache License 2.0 | votes |
List<KeyPairInfo> listKeyPairs(AWSCredentials credentials);