当前位置: 首页>>代码示例>>Python>>正文


Python VPCConnection.get_all_addresses方法代码示例

本文整理汇总了Python中boto.vpc.VPCConnection.get_all_addresses方法的典型用法代码示例。如果您正苦于以下问题:Python VPCConnection.get_all_addresses方法的具体用法?Python VPCConnection.get_all_addresses怎么用?Python VPCConnection.get_all_addresses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在boto.vpc.VPCConnection的用法示例。


在下文中一共展示了VPCConnection.get_all_addresses方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: DiscoEIP

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_addresses [as 别名]
class DiscoEIP(object):
    """
    A simple class to manage EIP's
    """

    def __init__(self):
        self.vpc_conn = VPCConnection()

    def list(self):
        """Returns all of our currently allocated EIPs"""
        return self.vpc_conn.get_all_addresses()

    def allocate(self):
        """Allocates a new VPC EIP"""
        return self.vpc_conn.allocate_address(domain='vpc')

    def release(self, eip_address, force=False):
        """
        Releases an EIP.

        If it is currently associated with a machine we do not release it unless
        the force param is set.
        """
        eip = self.vpc_conn.get_all_addresses([eip_address])[0]

        if eip.association_id:
            if force:
                eip.disassociate()
            else:
                return False

        return eip.release()
开发者ID:Angakkuit,项目名称:asiaq-aws,代码行数:34,代码来源:disco_eip.py

示例2: DiscoEIP

# 需要导入模块: from boto.vpc import VPCConnection [as 别名]
# 或者: from boto.vpc.VPCConnection import get_all_addresses [as 别名]
class DiscoEIP(object):
    """
    A simple class to manage EIP's
    """

    def __init__(self):
        self.vpc_conn = VPCConnection()
        self.ec2_conn = boto3.client('ec2')

    def list(self):
        """Returns all of our currently allocated EIPs"""
        return self.vpc_conn.get_all_addresses()

    def allocate(self):
        """Allocates a new VPC EIP"""
        return self.vpc_conn.allocate_address(domain='vpc')

    def tag_dynamic(self, eip_allocation_id):
        """
        Tag an EIP as dynamic
        "Tags": [
            {
                "Key": "dynamic",
                "Value": "true"
            }
        ]
        """
        return throttled_call(self.ec2_conn.create_tags, Resources=[eip_allocation_id],
                              Tags=[{'Key': 'dynamic', 'Value': 'true'}])

    def release(self, eip_address, force=False):
        """
        Releases an EIP.

        If it is currently associated with a machine we do not release it unless
        the force param is set.
        """
        eip = self.vpc_conn.get_all_addresses([eip_address])[0]

        if eip.association_id:
            if force:
                eip.disassociate()
            else:
                return False

        return eip.release()

    def find_eip_address(self, eip):
        """ Finds the EIP Address for the public eip specified. """
        address_filter = {'public-ip': eip}
        try:
            return self.vpc_conn.get_all_addresses(filters=address_filter)[0]
        except IndexError:
            return None
开发者ID:amplifylitco,项目名称:asiaq,代码行数:56,代码来源:disco_eip.py


注:本文中的boto.vpc.VPCConnection.get_all_addresses方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。