def get_aws_info(): LOG.info("Collecting AWS info") aws = AwsInstance() info = {} if aws.is_aws_instance(): LOG.info("Machine is an AWS instance") info = \ { 'instance_id': aws.get_instance_id() } else: LOG.info("Machine is NOT an AWS instance") return info
class AwsEnvironment(Environment): def __init__(self): super(AwsEnvironment, self).__init__() self.aws_info = AwsInstance() self._instance_id = self._get_instance_id() self.region = self._get_region() def _get_instance_id(self): return self.aws_info.get_instance_id() def _get_region(self): return self.aws_info.get_region() def get_auth_users(self): return [ monkey_island.cc.auth.User(1, 'monkey', self.hash_secret(self._instance_id)) ]
class AwsEnvironment(Environment): def __init__(self): super(AwsEnvironment, self).__init__() # Not suppressing error here on purpose. This is critical if we're on AWS env. self.aws_info = AwsInstance() self._instance_id = self._get_instance_id() self.region = self._get_region() def _get_instance_id(self): return self.aws_info.get_instance_id() def _get_region(self): return self.aws_info.get_region() def get_auth_users(self): return [ monkey_island.cc.auth.User(1, 'monkey', self.hash_secret(self._instance_id)) ]