Beispiel #1
0
 def test_obscure_string(self):
   result = utils.obscure_string('1234567890')
   self.assertEquals(result, '******7890')
   result = utils.obscure_string(None)
   self.assertTrue(result is None)
   result = utils.obscure_string('123')
   self.assertEquals(result, '123')
   result = utils.obscure_string('abcd')
   self.assertEquals(result, 'abcd')
Beispiel #2
0
 def test_obscure_string(self):
     result = utils.obscure_string('1234567890')
     self.assertEquals(result, '******7890')
     result = utils.obscure_string(None)
     self.assertTrue(result is None)
     result = utils.obscure_string('123')
     self.assertEquals(result, '123')
     result = utils.obscure_string('abcd')
     self.assertEquals(result, 'abcd')
Beispiel #3
0
  def set_environment_variables(self, parameters):
    """
    Set the EC2 specific environment variables. Required values for the
    environment variables are read from the 'credentials' parameter of
    the parameters map. (Also see documentation for the BaseAgent class)

    Args:
      parameters  A dictionary containing the 'credentials' key
    """
    if os.environ.has_key('EC2_JVM_ARGS'):
      del(os.environ['EC2_JVM_ARGS'])

    variables = parameters[self.PARAM_CREDENTIALS]
    for key, value in variables.items():
      if value is None:
        utils.log('None value detected for the credential: {0}.'.format(key))
        continue

      if key.find('KEY') != -1:
        utils.log('Setting {0} to {1} in our environment.'.format(
          key, utils.obscure_string(value)))
      else:
        utils.log('Setting {0} to {1} in our environment.'.format(key, value))
      os.environ[key] = value

    ec2_keys_dir = os.path.abspath('/etc/appscale/keys/cloud1')
    os.environ['EC2_PRIVATE_KEY'] = ec2_keys_dir + '/mykey.pem'
    os.environ['EC2_CERT'] = ec2_keys_dir + '/mycert.pem'
    utils.log('Setting private key to: {0} and certificate to: {1}'.format(
      os.environ['EC2_PRIVATE_KEY'], os.environ['EC2_CERT']))