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


Python ELBConnection.delete_load_balancer方法代码示例

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


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

示例1: BotoBalanceInterface

# 需要导入模块: from boto.ec2.elb import ELBConnection [as 别名]
# 或者: from boto.ec2.elb.ELBConnection import delete_load_balancer [as 别名]
class BotoBalanceInterface(BalanceInterface):
    conn = None
    saveclcdata = False

    def __init__(self, clc_host, access_id, secret_key, token):
        #boto.set_stream_logger('foo')
        path='/services/elb'
        port=8773
        if clc_host[len(clc_host)-13:] == 'amazonaws.com':
            clc_host = clc_host.replace('ec2', 'elasticloadbalancing', 1)
            path = '/'
            reg = None
            port=443
        reg = RegionInfo(name='eucalyptus', endpoint=clc_host)
        self.conn = ELBConnection(access_id, secret_key, region=reg,
                                  port=port, path=path,
                                  is_secure=True, security_token=token, debug=0)
        self.conn.https_validate_certificates = False
        self.conn.http_connection_kwargs['timeout'] = 30

    def __save_json__(self, obj, name):
        f = open(name, 'w')
        json.dump(obj, f, cls=BotoJsonBalanceEncoder, indent=2)
        f.close()

    def create_load_balancer(self, name, zones, listeners, subnets=None,
                             security_groups=None, scheme='internet-facing'):
        return self.conn.create_load_balancer(name, zones, listeners, subnets, security_groups, scheme)
    
    def delete_load_balancer(self, name):
        return self.conn.delete_load_balancer(name)

    def get_all_load_balancers(self, load_balancer_names=None):
        return []
        obj = self.conn.get_all_load_balancers(load_balancer_names)
        if self.saveclcdata:
            self.__save_json__(obj, "mockdata/ELB_Balancers.json")
        return obj

    def deregister_instances(self, load_balancer_name, instances):
        return self.conn.deregister_instances(load_balancer_name, instances)

    def register_instances(self, load_balancer_name, instances):
        return self.conn.register_instances(load_balancer_name, instances)

    def create_load_balancer_listeners(self, name, listeners):
        return self.conn.create_load_balancer_listeners(name, listeners)

    def delete_load_balancer_listeners(self, name, ports):
        return self.conn.delete_load_balancer_listeners(name, ports)

    def configure_health_check(self, name, health_check):
        return self.conn.configure_health_check(name, health_check)

    def describe_instance_health(self, load_balancer_name, instances=None):
        obj = self.conn.describe_instance_health(load_balancer_name, instances)
        if self.saveclcdata:
            self.__save_json__(obj, "mockdata/ELB_Instances.json")
        return obj
开发者ID:aldeka,项目名称:eucalyptus,代码行数:61,代码来源:botobalanceinterface.py

示例2: BotoBalanceInterface

# 需要导入模块: from boto.ec2.elb import ELBConnection [as 别名]
# 或者: from boto.ec2.elb.ELBConnection import delete_load_balancer [as 别名]
class BotoBalanceInterface(BalanceInterface):
    conn = None
    saveclcdata = False

    def __init__(self, clc_host, access_id, secret_key, token):
        self.access_id = access_id
        self.secret_key = secret_key
        self.token = token
        self.set_endpoint(clc_host)

    def set_endpoint(self, endpoint):
        #boto.set_stream_logger('foo')
        reg = RegionInfo(name='eucalyptus', endpoint=endpoint)
        path = '/services/LoadBalancing'
        port = 8773
        if endpoint[len(endpoint)-13:] == 'amazonaws.com':
            endpoint = endpoint.replace('ec2', 'elasticloadbalancing', 1)
            path = '/'
            reg = RegionInfo(endpoint=endpoint)
            port = 443
        self.conn = ELBConnection(self.access_id, self.secret_key, region=reg,
                                  port=port, path=path,
                                  is_secure=True, security_token=self.token, debug=0)
        self.conn.https_validate_certificates = False
        self.conn.http_connection_kwargs['timeout'] = 30

    def __save_json__(self, obj, name):
        f = open(name, 'w')
        json.dump(obj, f, cls=BotoJsonBalanceEncoder, indent=2)
        f.close()

    def create_load_balancer(self, name, zones, listeners, subnets=None,
                             security_groups=None, scheme='internet-facing'):
        return self.conn.create_load_balancer(name, zones, listeners, subnets, security_groups, scheme)

    def delete_load_balancer(self, name):
        return self.conn.delete_load_balancer(name)

    def get_all_load_balancers(self, load_balancer_names=None):
        params = {}
        if load_balancer_names:
            self.build_list_params(params, load_balancer_names,
                                   'LoadBalancerNames.member.%d')
        http_request = self.conn.build_base_http_request('GET', '/', None,
                                                         params, {}, '',
                                                         self.conn.server_name())
        http_request.params['Action'] = 'DescribeLoadBalancers'
        http_request.params['Version'] = self.conn.APIVersion
        response = self.conn._mexe(http_request, override_num_retries=2)
        body = response.read()
        boto.log.debug(body)
        if not body:
            boto.log.error('Null body %s' % body)
            raise self.conn.ResponseError(response.status, response.reason, body)
        elif response.status == 200:
            obj = boto.resultset.ResultSet([('member', boto.ec2.elb.loadbalancer.LoadBalancer)])
            h = boto.handler.XmlHandler(obj, self.conn)
            import xml.sax;

            xml.sax.parseString(body, h)
            if self.saveclcdata:
                self.__save_json__(obj, "mockdata/ELB_Balancers.json")
            return obj
        else:
            boto.log.error('%s %s' % (response.status, response.reason))
            boto.log.error('%s' % body)
            raise self.conn.ResponseError(response.status, response.reason, body)


    def deregister_instances(self, load_balancer_name, instances):
        return self.conn.deregister_instances(load_balancer_name, instances)

    def register_instances(self, load_balancer_name, instances):
        return self.conn.register_instances(load_balancer_name, instances)

    def create_load_balancer_listeners(self, name, listeners):
        return self.conn.create_load_balancer_listeners(name, listeners)

    def delete_load_balancer_listeners(self, name, ports):
        return self.conn.delete_load_balancer_listeners(name, ports)

    def configure_health_check(self, name, health_check):
        return self.conn.configure_health_check(name, health_check)

    def describe_instance_health(self, load_balancer_name, instances=None):
        obj = self.conn.describe_instance_health(load_balancer_name, instances)
        if self.saveclcdata:
            self.__save_json__(obj, "mockdata/ELB_Instances.json")
        return obj
开发者ID:avontd2868,项目名称:eucalyptus-console,代码行数:91,代码来源:botobalanceinterface.py

示例3: __init__

# 需要导入模块: from boto.ec2.elb import ELBConnection [as 别名]
# 或者: from boto.ec2.elb.ELBConnection import delete_load_balancer [as 别名]

#.........这里部分代码省略.........
        data_centers_intance_ids = []
        for reservation in reservations:
            for instance in reservation.instances:
                if "Name" in instance.tags and instance.tags["Name"] == name and instance.state == "running":
                    data_centers_intance_ids.append(instance.id)
        if data_centers_intance_ids:
            self.remove_instances(data_centers_intance_ids)

    def create_elb(self, name, zone, project_tag_value, security_group_id, instance_ids=None):
        lbs = [l for l in self.elb_conn.get_all_load_balancers() if l.name == name]
        lb = lbs[0] if lbs else None
        if not lb:
            hc = HealthCheck(
                timeout=50, interval=60, healthy_threshold=2, unhealthy_threshold=8, target="HTTP:80/heartbeat"
            )
            ports = [(80, 80, "http")]
            zones = [zone]
            lb = self.elb_conn.create_load_balancer(name, zones, ports)

            self.elb_conn.apply_security_groups_to_lb(name, [security_group_id])
            lb.configure_health_check(hc)
            if instance_ids:
                lb.register_instances(instance_ids)

            params = {
                "LoadBalancerNames.member.1": lb.name,
                "Tags.member.1.Key": "15619project",
                "Tags.member.1.Value": project_tag_value,
            }
            lb.connection.get_status("AddTags", params, verb="POST")
        return lb

    def remove_elb(self, name):
        self.elb_conn.delete_load_balancer(name)

    def create_launch_configuration(self, name, image, key_name, security_groups, instance_type):
        lcs = [l for l in self.auto_scale_conn.get_all_launch_configurations() if l.name == name]
        lc = lcs[0] if lcs else None
        if not lc:
            lc = LaunchConfiguration(
                name=name,
                image_id=image,
                key_name=key_name,
                security_groups=[security_groups],
                instance_type=instance_type,
            )
            self.auto_scale_conn.create_launch_configuration(lc)
        return lc

    def remove_launch_configuration(self, name):
        self.auto_scale_conn.delete_launch_configuration(name)

    def create_autoscaling_group(self, name, lb_name, zone, tags, instance_ids=None):
        lc = self.create_launch_configuration()
        as_groups = [a for a in self.auto_scale_conn.get_all_groups() if a.name == name]
        as_group = as_groups[0] if as_groups else None
        if not as_group:
            as_group = AutoScalingGroup(
                group_name=name,
                load_balancers=[lb_name],
                availability_zones=[zone],
                launch_config=lc,
                min_size=4,
                max_size=4,
                health_check_type="ELB",
                health_check_period=120,
开发者ID:dsarlis,项目名称:Cloud-Burst,代码行数:70,代码来源:deploy.py

示例4:

# 需要导入模块: from boto.ec2.elb import ELBConnection [as 别名]
# 或者: from boto.ec2.elb.ELBConnection import delete_load_balancer [as 别名]
# ---------------------------Clean UP-------------------------------------------
res = conn.get_all_instances()
ids = []
for r in res:
    ids.append(r.instances[0].id)

for s in ids:
    if s == lg_id:
        continue
    try:
        conn.terminate_instances(instance_ids=[s])
    except:
        continue

time.sleep(100);

con_elb.delete_load_balancer('ELB')
time.sleep(100)

con_as.delete_auto_scaling_group('Project2.2_AutoSacling_Group', force_delete=True)
con_as.delete_launch_configuration('Project2.2_Lauch_Config')

while True:
    try:
        conn.delete_security_group(name='LBAS')
        conn.delete_security_group(name='Load_Generator')
        break
    except:
        time.sleep(5)

开发者ID:ClarKa,项目名称:AWSLoadBalance,代码行数:31,代码来源:autoScale.py

示例5: EC2Connection

# 需要导入模块: from boto.ec2.elb import ELBConnection [as 别名]
# 或者: from boto.ec2.elb.ELBConnection import delete_load_balancer [as 别名]
conn = EC2Connection()
con_l = ELBConnection()
con_a = AutoScaleConnection()

res = conn.get_all_instances()
ids = []
for r in res:
    ids.append(r.instances[0].id)

for s in ids:
    try:
        conn.terminate_instances(instance_ids=[s])
    except:
        continue

try:
    con_l.delete_load_balancer('ELB')
    time.sleep(60)
except:
    pass
con_a.delete_auto_scaling_group('Project2.2_AutoSacling_Group', force_delete=True)
con_a.delete_launch_configuration('Project2.2_Lauch_Config')

while True:
    try:
        conn.delete_security_group(name='LBAS')
        conn.delete_security_group(name='Load_Generator')
        break
    except:
        time.sleep(5)
开发者ID:ClarKa,项目名称:AWSLoadBalance,代码行数:32,代码来源:clearnup.py


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