예제 #1
0
파일: gce.py 프로젝트: nixargh/dnswatch
class GCE:

    def __init__(self):
        self.logger = logging.getLogger("DNSWatch.GCE")
        metadata = { 
                "url": "http://169.254.169.254/computeMetadata/v1/instance",
                "headers": { "Metadata-Flavor": "Google" }
            }
        self.cloud = Cloud(metadata)

    def is_inside(self):
        return self.cloud.is_inside()

    def get_private_ip(self):
        return self.cloud.get_data("network-interfaces/0/ip").text

    def get_public_ip(self):
        return self.cloud.get_data("network-interfaces/0/access-configs/0/external-ip").text
예제 #2
0
파일: aws.py 프로젝트: nixargh/dnswatch
class AWS:

    def __init__(self):
        self.logger = logging.getLogger("DNSWatch.AWS")
        metadata = { 
                "url": "http://169.254.169.254/latest/meta-data",
                "headers": ""
            }
        self.cloud = Cloud(metadata)

    def is_inside(self):
        return self.cloud.is_inside()

    def get_private_ip(self):
        return self.cloud.get_data("local-ipv4").text

    def get_public_ip(self):
        return self.cloud.get_data("public-ipv4").text