public T fromKeyPair(KeyPair in) { return this .publicKey(in.getPublicKey()) .privateKey(in.getPrivateKey()) .userId(in.getUserId()) .name(in.getName()) .fingerprint(in.getFingerprint()); } }
public KeyPair build() { return new KeyPair(publicKey, privateKey, userId, name, fingerprint); }
@Override public String toString() { return string().toString(); }
public void testCreateAndGetAndDeleteKeyPair() throws Exception { for (String regionId : api.getConfiguredRegions()) { KeyPairApi keyPairApi = api.getKeyPairApi(regionId).get(); KeyPair createdKeyPair = null; try { createdKeyPair = keyPairApi.create(KEYPAIR_NAME); assertNotNull(createdKeyPair); KeyPair keyPair = keyPairApi.get(KEYPAIR_NAME); assertEquals(keyPair.getName(), createdKeyPair.getName()); assertEquals(keyPair.getFingerprint(), createdKeyPair.getFingerprint()); assertEquals(keyPair.getPublicKey(), createdKeyPair.getPublicKey()); } finally { if (createdKeyPair != null) { keyPairApi.delete(KEYPAIR_NAME); } } } }
KeyPair keyPair = keyPairCache.getUnchecked(ZoneAndName.fromZoneAndName(zone, namingConvention.create() .sharedNameForGroup(group))); keyPairCache.asMap().put(ZoneAndName.fromZoneAndName(zone, keyPair.getName()), keyPair); templateOptions.keyPairName(keyPair.getName()); } else if (templateOptions.getKeyPairName() != null) { checkArgument(keyPairExtensionPresent, if (templateOptions.getLoginPrivateKey() != null) { String pem = templateOptions.getLoginPrivateKey(); KeyPair keyPair = KeyPair.builder().name(templateOptions.getKeyPairName()) .fingerprint(fingerprintPrivateKey(pem)).privateKey(pem).build(); keyPairCache.asMap().put(ZoneAndName.fromZoneAndName(zone, keyPair.getName()), keyPair);
templateOptions.overrideLoginPrivateKey(keyPair.getPrivateKey()); templateOptions.keyPairName(keyPair.getName()); registerAutoGeneratedKeyPairCleanupCallbacks(responses, region, keyPair.getName());
@Override @ResponseParser(ParseKeyPairs.class) @Consumes(MediaType.APPLICATION_JSON) public FluentIterable<? extends KeyPair> expected() { return FluentIterable.from(ImmutableSet.of( KeyPair .builder() .publicKey( "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQCy9EC3O7Ff80vPEfAHDQob61PGwcpYc5KE7tEZnZhrB9n0NyHPRm0E0M+ls3fcTa04HDi+R0DzmRwoyhHQJyI658v8kWZZcuvFjKCcsgsSh/dzdX0xTreLIzSOzt5U7RnZYfshP5cmxtF99yrEY3M/swdin0L+fXsTSkR1B42STQ== nova@nv-aw2az1-api0001") .name("default").fingerprint("ab:0c:f4:f3:54:c0:5d:3f:ed:62:ad:d3:94:7c:79:7c").build(), KeyPair .builder() .publicKey( "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001") .name("testkeypair").fingerprint("d2:1f:c9:2b:d8:90:77:5f:15:64:27:e3:9f:77:1d:e4").build())); }
options.keyPairName(templateOptions.getKeyPairName()); KeyPair keyPair = keyPairCache.getIfPresent(ZoneAndName.fromZoneAndName(template.getLocation().getId(), templateOptions.getKeyPairName())); if (keyPair != null && keyPair.getPrivateKey() != null) { privateKey = Optional.of(keyPair.getPrivateKey()); credentialsBuilder.privateKey(privateKey.get());
public void testCreateKeyPair() throws Exception { HttpRequest create = HttpRequest .builder() .method("POST") .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v1.1/3456/os-keypairs") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType("{\"keypair\":{\"name\":\"testkeypair\"}}", "application/json")) .build(); HttpResponse createResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/keypair_created.json")).build(); NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, create, createResponse); assertEquals(apiWhenServersExist.getKeyPairExtensionForZone("az-1.region-a.geo-1").get().create("testkeypair") .toString(), new ParseKeyPairTest().expected().toString()); }
public void testCreateAndDeleteKeyPairWithPublicKey() throws Exception { for (String regionId : api.getConfiguredRegions()) { KeyPairApi keyPairApi = api.getKeyPairApi(regionId).get(); KeyPair createdKeyPair = null; try { createdKeyPair = keyPairApi.createWithPublicKey(KEYPAIR_NAME, PUBLIC_KEY); assertNotNull(createdKeyPair); KeyPair keyPair = keyPairApi.get(KEYPAIR_NAME); assertEquals(keyPair.getName(), createdKeyPair.getName()); assertEquals(keyPair.getFingerprint(), createdKeyPair.getFingerprint()); assertEquals(keyPair.getPublicKey(), createdKeyPair.getPublicKey()); } finally { if (createdKeyPair != null) { keyPairApi.delete(KEYPAIR_NAME); } } } } }
KeyPair keyPair = keyPairCache.getUnchecked(RegionAndName.fromRegionAndName(region, namingConvention.create() .sharedNameForGroup(group))); keyPairCache.asMap().put(RegionAndName.fromRegionAndName(region, keyPair.getName()), keyPair); templateOptions.keyPairName(keyPair.getName()); tagsBuilder.add(JCLOUDS_KP); } else if (templateOptions.getKeyPairName() != null) { if (templateOptions.getLoginPrivateKey() != null) { String pem = templateOptions.getLoginPrivateKey(); KeyPair keyPair = KeyPair.builder().name(templateOptions.getKeyPairName()) .fingerprint(fingerprintPrivateKey(pem)).privateKey(pem).build(); keyPairCache.asMap().put(RegionAndName.fromRegionAndName(region, keyPair.getName()), keyPair);
templateOptions.overrideLoginPrivateKey(keyPair.getPrivateKey()); templateOptions.keyPairName(keyPair.getName()); registerAutoGeneratedKeyPairCleanupCallbacks(responses, region, keyPair.getName());
@Override @ResponseParser(ParseKeyPairs.class) @Consumes(MediaType.APPLICATION_JSON) public FluentIterable<? extends KeyPair> expected() { return FluentIterable.from(ImmutableSet.of( KeyPair .builder() .publicKey( "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQCy9EC3O7Ff80vPEfAHDQob61PGwcpYc5KE7tEZnZhrB9n0NyHPRm0E0M+ls3fcTa04HDi+R0DzmRwoyhHQJyI658v8kWZZcuvFjKCcsgsSh/dzdX0xTreLIzSOzt5U7RnZYfshP5cmxtF99yrEY3M/swdin0L+fXsTSkR1B42STQ== nova@nv-aw2az1-api0001") .name("default").fingerprint("ab:0c:f4:f3:54:c0:5d:3f:ed:62:ad:d3:94:7c:79:7c").build(), KeyPair .builder() .publicKey( "ssh-rsa AAAXB3NzaC1yc2EAAAADAQABAAAAgQDFNyGjgs6c9akgmZ2ou/fJf7Pdrc23hC95/gM/33OrG4GZABACE4DTioa/PGN+7rHv9YUavUCtXrWayhGniKq/wCuI5fo5TO4AmDNv7/sCGHIHFumADSIoLx0vFhGJIetXEWxL9r0lfFC7//6yZM2W3KcGjbMtlPXqBT9K9PzdyQ== nova@nv-aw2az1-api0001") .name("testkeypair").fingerprint("d2:1f:c9:2b:d8:90:77:5f:15:64:27:e3:9f:77:1d:e4").build())); }
options.keyPairName(templateOptions.getKeyPairName()); KeyPair keyPair = keyPairCache.getIfPresent(ZoneAndName.fromZoneAndName(template.getLocation().getId(), templateOptions.getKeyPairName())); if (keyPair != null && keyPair.getPrivateKey() != null) { privateKey = Optional.of(keyPair.getPrivateKey()); credentialsBuilder.privateKey(privateKey.get());
public void testCreateKeyPair() throws Exception { HttpRequest create = HttpRequest .builder() .method("POST") .endpoint("https://az-1.region-a.geo-1.compute.hpcloudsvc.com/v2/3456/os-keypairs") .addHeader("Accept", "application/json") .addHeader("X-Auth-Token", authToken) .payload(payloadFromStringWithContentType("{\"keypair\":{\"name\":\"testkeypair\"}}", "application/json")) .build(); HttpResponse createResponse = HttpResponse.builder().statusCode(200) .payload(payloadFromResource("/keypair_details.json")).build(); NovaApi apiWhenServersExist = requestsSendResponses(keystoneAuthWithUsernameAndPasswordAndTenantName, responseWithKeystoneAccess, extensionsOfNovaRequest, extensionsOfNovaResponse, create, createResponse); assertEquals(apiWhenServersExist.getKeyPairApi("az-1.region-a.geo-1").get().create("testkeypair") .toString(), new ParseKeyPairTest().expected().toString()); }
public T fromKeyPair(KeyPair in) { return this .publicKey(in.getPublicKey()) .privateKey(in.getPrivateKey()) .userId(in.getUserId()) .name(in.getName()) .fingerprint(in.getFingerprint()); } }
KeyPair keyPair = keyPairCache.getUnchecked(ZoneAndName.fromZoneAndName(zone, namingConvention.create() .sharedNameForGroup(group))); keyPairCache.asMap().put(ZoneAndName.fromZoneAndName(zone, keyPair.getName()), keyPair); templateOptions.keyPairName(keyPair.getName()); } else if (templateOptions.getKeyPairName() != null) { checkArgument(keyPairExtensionPresent, if (templateOptions.getLoginPrivateKey() != null) { String pem = templateOptions.getLoginPrivateKey(); KeyPair keyPair = KeyPair.builder().name(templateOptions.getKeyPairName()) .fingerprint(fingerprintPrivateKey(pem)).privateKey(pem).build(); keyPairCache.asMap().put(ZoneAndName.fromZoneAndName(zone, keyPair.getName()), keyPair);