forked from p15670423/monkey
* Fixed the aws env class to not be static anymore after itay's change.
* Added aws region getter
This commit is contained in:
parent
8e6ab5b9f5
commit
bf29cddf4d
|
@ -7,11 +7,15 @@ class AWS(object):
|
|||
def __init__(self):
|
||||
try:
|
||||
self.instance_id = urllib2.urlopen('http://169.254.169.254/latest/meta-data/instance-id').read()
|
||||
self.region = urllib2.urlopen('http://169.254.169.254/latest/meta-data/placement/availability-zone').read()[:-1]
|
||||
except urllib2.URLError:
|
||||
self.instance_id = None
|
||||
|
||||
def get_instance_id(self):
|
||||
return self.instance_id
|
||||
|
||||
def get_region(self):
|
||||
return self.region
|
||||
|
||||
def is_aws_instance(self):
|
||||
return self.instance_id is not None
|
||||
|
|
|
@ -8,15 +8,15 @@ __author__ = 'itay.mizeretz'
|
|||
class AwsEnvironment(Environment):
|
||||
def __init__(self):
|
||||
super(AwsEnvironment, self).__init__()
|
||||
self._instance_id = AwsEnvironment._get_instance_id()
|
||||
self.aws_info = AWS()
|
||||
self._instance_id = self._get_instance_id()
|
||||
self.region = self._get_region()
|
||||
|
||||
@staticmethod
|
||||
def _get_instance_id():
|
||||
return AWS.get_instance_id()
|
||||
def _get_instance_id(self):
|
||||
return self.aws_info.get_instance_id()
|
||||
|
||||
@staticmethod
|
||||
def _get_region():
|
||||
return urllib2.urlopen('http://169.254.169.254/latest/meta-data/placement/availability-zone').read()[:-1]
|
||||
def _get_region(self):
|
||||
return self.aws_info.get_region()
|
||||
|
||||
def is_auth_enabled(self):
|
||||
return True
|
||||
|
|
Loading…
Reference in New Issue