Creates the KeyPair for this test run

 @param region [Aws::EC2::Region] region to create the key pair in
 @return [Aws::EC2::KeyPair] created key_pair
 @api private
340553
def ensure_key_pair(region)
      pair_name = key_name()
      delete_key_pair(region, pair_name)
      create_new_key_pair(region, pair_name)
    end
1326923
def DistributeKeyToRegions(src_region, dst_regions, private_keypair,
                           aws_id, aws_secret):
  
  private_key = RSA.importKey(private_keypair.material)
  public_key_material = PrivateToPublicOpenSSH(private_key,
                                               private_keypair.name)
  for dst_region in dst_regions:
    if dst_region == src_region:
      continue
    logging.info( 'distributing key %s to region %s' % (private_keypair.name,
                                                        dst_region))
    dst_region_ec2 = CreateTestedEc2Connection(aws_id, aws_secret,
                                                    dst_region)
    try:
      dst_region_ec2.delete_key_pair(private_keypair.name)
    except:
      raise
    dst_region_ec2.import_key_pair(private_keypair.name, public_key_material)
  return
539344
public byte[][] keypair()
    {
        byte[][] pair = new byte[2][];

        byte[] publicKey = new byte[Size.PUBLICKEY.bytes()];
        byte[] secretKey = new byte[Size.SECRETKEY.bytes()];

        int rc = curve25519xsalsa20poly1305.crypto_box_keypair(publicKey, secretKey);
        assert (rc == 0);

        pair[0] = publicKey;
        pair[1] = secretKey;

        return pair;
    }
806749
public static KeyPair newKeyPair(final PublicKey publicKey, final PrivateKey privateKey)
	{
		final KeyPair keyPair = new KeyPair(publicKey, privateKey);
		return keyPair;
	}
502431
public static JsonWebKey fromEC(KeyPair keyPair, Provider provider) {

        ECPublicKey apub = (ECPublicKey) keyPair.getPublic();
        ECPoint point = apub.getW();
        ECPrivateKey apriv = (ECPrivateKey) keyPair.getPrivate();

        if (apriv != null) {
            return new JsonWebKey().withKty(JsonWebKeyType.EC).withCrv(getCurveFromKeyPair(keyPair, provider))
                    .withX(point.getAffineX().toByteArray()).withY(point.getAffineY().toByteArray())
                    .withD(apriv.getS().toByteArray()).withKty(JsonWebKeyType.EC);
        } else {
            return new JsonWebKey().withKty(JsonWebKeyType.EC).withCrv(getCurveFromKeyPair(keyPair, provider))
                    .withX(point.getAffineX().toByteArray()).withY(point.getAffineY().toByteArray())
                    .withKty(JsonWebKeyType.EC);
        }
    }
889234
def create_ecdsap256_key_pair():
    
    pub  = ECDSAP256PublicKey()
    priv = ECDSAP256PrivateKey()
    rc = _lib.xtt_crypto_create_ecdsap256_key_pair(pub.native, priv.native)
    if rc == RC.SUCCESS:
        return (pub, priv)
    else:
        raise error_from_code(rc)
713088
def get_zones(region, auth_kwargs):
    
    ec2_conn = boto.ec2.connect_to_region(region, **auth_kwargs)
    return [zone.name for zone in ec2_conn.get_all_zones()]
1213519
public static BaseLocale createInstance(String language, String region) {
        BaseLocale base = new BaseLocale(language, region);
        CACHE.put(new Key(language, region), base);
        return base;
    }
1223429
def get_elasticache_replication_groups_by_region(self, region):
        ''' '''

        # ElastiCache boto module doesn't provide a get_all_intances method,
        # that's why we need to call describe directly (it would be called by
        # the shorthand method anyway...)
        try:
            conn = elasticache.connect_to_region(region)
            if conn:
                response = conn.describe_replication_groups()

        except boto.exception.BotoServerError as e:
            error = e.reason

            if e.error_code == 'AuthFailure':
                error = self.get_auth_error_message()
            if not e.reason == "Forbidden":
                error = "Looks like AWS ElastiCache [Replication Groups] is down:\n%s" % e.message
            self.fail_with_error(error, 'getting ElastiCache clusters')

        try:
            # Boto also doesn't provide wrapper classes to ReplicationGroups
            # Because of that wo can't make use of the get_list method in the
            # AWSQueryConnection. Let's do the work manually
            replication_groups = response['DescribeReplicationGroupsResponse']['DescribeReplicationGroupsResult']['ReplicationGroups']

        except KeyError as e:
            error = "ElastiCache [Replication Groups] query to AWS failed (unexpected format)."
            self.fail_with_error(error, 'getting ElastiCache clusters')

        for replication_group in replication_groups:
            self.add_elasticache_replication_group(replication_group, region)
975
protected KeyPair generateKeyPair() {
        KeyPair keyPair = null;
        DHParameterSpec keySpec = new DHParameterSpec(DH_MODULUS, DH_BASE);
        try {
            KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DH");
            keyGen.initialize(keySpec);
            keyPair = keyGen.generateKeyPair();
            keyAgreement = KeyAgreement.getInstance("DH");
            // key agreement is initialized with "this" ends private key
            keyAgreement.init(keyPair.getPrivate());
        } catch (Exception e) {
            log.error("Error generating keypair", e);
        }
        return keyPair;
    }
1053882
def create_alias(alias_name, target_key_id, region=None, key=None, keyid=None,
                 profile=None):
    '''
    
    '''
    conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)

    r = {}
    try:
        conn.create_alias(alias_name, target_key_id)
        r['result'] = True
    except boto.exception.BotoServerError as e:
        r['result'] = False
        r['error'] = __utils__['boto.get_error'](e)
    return r
825127
def GetRegion(region_name):
  
  regions = boto_ec2.regions()
  region = None
  valid_region_names = []
  for r in regions:
    valid_region_names.append(r.name)
    if r.name == region_name:
        region = r
        break
  if not region:
    logging.info( 'invalid region name: %s ' % (region_name))
    logging.info( 'Try one of these:\n %s' % ('\n'.join(valid_region_names)))
    assert(False)
  return  region
1274765
public static final KeyPair createKeyPair(AlgorithmParameterSpec spec) throws GeneralSecurityException {
		KeyPairGenerator keyGen = KeyPairGenerator.getInstance(ALGORITHM);
	    keyGen.initialize(spec, new SecureRandom());
		return keyGen.generateKeyPair();
	}
746536
def init_region_config(self, region):
        
        self.regions[region] = self.region_config_class(region_name = region, resource_types = self.resource_types)
578248
protected Signer createSigner(final Request<?> request,
                                  final String bucketName,
                                  final String key,
                                  final boolean isAdditionalHeadRequestToFindRegion) {

        // Instead of using request.getEndpoint() for this parameter, we use endpoint which is because
        // in accelerate mode, the endpoint in request is regionless. We need the client-wide endpoint
        // to fetch the region information and pick the correct signer.
        URI uri = clientOptions.isAccelerateModeEnabled() ? endpoint : request.getEndpoint();
        final Signer signer = getSignerByURI(uri);

        if(this.awsCredentialsProvider.getCredentials() instanceof IBMOAuthCredentials) {
        	IBMOAuthCredentials oAuthCreds = (IBMOAuthCredentials)this.awsCredentialsProvider.getCredentials();
    		if (oAuthCreds.getApiKey() != null || oAuthCreds.getTokenManager() != null) {
            	return new IBMOAuthSigner(clientConfiguration);	
    		}
        }
        
        if (!isSignerOverridden()) {

            if ((signer instanceof AWSS3V4Signer) && bucketRegionShouldBeCached(request)) {

                String region = bucketRegionCache.get(bucketName);
                if (region != null) {
                     // If cache contains the region for the bucket, create an endpoint for the region and
                     // update the request with that endpoint.
                     resolveRequestEndpoint(request, bucketName, key, RuntimeHttpUtils.toUri(RegionUtils.getRegion(region).getServiceEndpoint(S3_SERVICE_NAME), clientConfiguration));
                     return updateSigV4SignerWithRegion((AWSS3V4Signer) signer, region);
                } else if (request.getOriginalRequest() instanceof GeneratePresignedUrlRequest) {
                    return createSigV2Signer(request, bucketName, key);
                } else if (isAdditionalHeadRequestToFindRegion) {
                    return updateSigV4SignerWithRegion((AWSS3V4Signer) signer, "us-east-1");
                }
            }

            String regionOverride = getSignerRegionOverride();
            if (regionOverride != null) {
                return updateSigV4SignerWithRegion(new AWSS3V4Signer(), regionOverride);
            }
        }
        if (signer instanceof S3Signer) {
            // The old S3Signer needs a method and path passed to its
            // constructor; if that's what we should use, getSigner()
            // will return a dummy instance and we need to create a
            // new one with the appropriate values for this request.
            return createSigV2Signer(request, bucketName, key);
        }

        return signer;
    }
87787
public void create() {
        RunInstancesRequest runInstancesRequest =
                        new RunInstancesRequest().withImageId(amiId).withInstanceType(size).withKeyName(keyPair)
                                        .withMinCount(1).withSecurityGroupIds(securityGroupId).withMaxCount(numBoxes);
        AmazonEC2 ec2 = getEc2();
        ec2.setRegion(com.amazonaws.regions.Region.getRegion(regions));
        List<Instance> boxes = ec2.runInstances(runInstancesRequest).getReservation().getInstances();
        if (boxesCreated == null) {
            boxesCreated = new ArrayList<>();
            for (Instance i : boxes)
                boxesCreated.add(i.getInstanceId());



            log.info("Boxes created " + boxesCreated);
        } else {
            blowupBoxes();
            boxesCreated.clear();
            for (Instance i : boxes)
                boxesCreated.add(i.getInstanceId());

        }
    }
895361
public ArrayList<OvhSshKey> project_serviceName_sshkey_GET(String serviceName, String region) throws IOException {
		String qPath = "/cloud/project/{serviceName}/sshkey";
		StringBuilder sb = path(qPath, serviceName);
		query(sb, "region", region);
		String resp = exec(qPath, "GET", sb.toString(), null);
		return convertTo(resp, t17);
	}