示例#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