示例#1
0
def cli(env, identifier, enabled, port, weight, healthcheck_type, ip_address):
    """Edit the properties of a service group."""

    mgr = SoftLayer.LoadBalancerManager(env.client)

    loadbal_id, service_id = loadbal.parse_id(identifier)

    # check if any input is provided
    if not any([ip_address, enabled, weight, port, healthcheck_type]):
        raise exceptions.CLIAbort(
            'At least one property is required to be changed!')

    # check if the IP is valid
    ip_address_id = None
    if ip_address:
        ip_service = env.client['Network_Subnet_IpAddress']
        ip_record = ip_service.getByIpAddress(ip_address)
        ip_address_id = ip_record['id']

    mgr.edit_service(loadbal_id,
                     service_id,
                     ip_address_id=ip_address_id,
                     enabled=enabled,
                     port=port,
                     weight=weight,
                     hc_type=healthcheck_type)
    env.fout('Load balancer service %s is being modified!' % identifier)
def cli(env, identifier, enabled, port, weight, healthcheck_type, ip_address):
    """Edit the properties of a service group."""

    mgr = SoftLayer.LoadBalancerManager(env.client)

    loadbal_id, service_id = loadbal.parse_id(identifier)

    # check if any input is provided
    if not any([ip_address, enabled, weight, port, healthcheck_type]):
        raise exceptions.CLIAbort(
            'At least one property is required to be changed!')

    # check if the IP is valid
    ip_address_id = None
    if ip_address:
        ip_service = env.client['Network_Subnet_IpAddress']
        ip_record = ip_service.getByIpAddress(ip_address)
        ip_address_id = ip_record['id']

    mgr.edit_service(loadbal_id,
                     service_id,
                     ip_address_id=ip_address_id,
                     enabled=enabled,
                     port=port,
                     weight=weight,
                     hc_type=healthcheck_type)
    env.fout('Load balancer service %s is being modified!' % identifier)
示例#3
0
def cli(env, identifier, enabled, port, weight, healthcheck_type, ip_address):
    """Adds a new load balancer service."""

    mgr = SoftLayer.LoadBalancerManager(env.client)

    loadbal_id, group_id = loadbal.parse_id(identifier)

    # check if the IP is valid
    ip_address_id = None
    if ip_address:
        ip_service = env.client["Network_Subnet_IpAddress"]
        ip_record = ip_service.getByIpAddress(ip_address)
        if len(ip_record) > 0:
            ip_address_id = ip_record["id"]

    mgr.add_service(
        loadbal_id,
        group_id,
        ip_address_id=ip_address_id,
        enabled=enabled,
        port=port,
        weight=weight,
        hc_type=healthcheck_type,
    )
    env.fout("Load balancer service is being added!")
def cli(env, identifier):
    """Reset connections on a certain service group."""
    mgr = SoftLayer.LoadBalancerManager(env.client)

    loadbal_id, group_id = loadbal.parse_id(identifier)

    mgr.reset_service_group(loadbal_id, group_id)
    return 'Load balancer service group connections are being reset!'
def cli(env, identifier):
    """Toggle the status of an existing load balancer service."""

    mgr = SoftLayer.LoadBalancerManager(env.client)
    _, service_id = loadbal.parse_id(identifier)

    if not (env.skip_confirmations or
            formatting.confirm("This action will toggle the status on the "
                               "service. Continue?")):
        raise exceptions.CLIAbort('Aborted.')

    mgr.toggle_service_status(service_id)
    env.fout('Load balancer service %s status updated!' % identifier)
示例#6
0
def cli(env, identifier):
    """Deletes an existing load balancer service."""

    mgr = SoftLayer.LoadBalancerManager(env.client)
    _, service_id = loadbal.parse_id(identifier)

    if not (env.skip_confirmations or formatting.confirm(
            "This action will cancel a service from your "
            "load balancer. Continue?")):
        raise exceptions.CLIAbort('Aborted.')

    mgr.delete_service(service_id)
    return 'Load balancer service %s is being cancelled!' % service_id
def cli(env, identifier):
    """Deletes an existing load balancer service group."""
    mgr = SoftLayer.LoadBalancerManager(env.client)

    _, group_id = loadbal.parse_id(identifier)

    if not (env.skip_confirmations
            or formatting.confirm("This action will cancel a service group. "
                                  "Continue?")):
        raise exceptions.CLIAbort('Aborted.')

    mgr.delete_service_group(group_id)
    env.fout('Service group %s is being deleted!' % identifier)
def cli(env, identifier):
    """Toggle the status of an existing load balancer service."""

    mgr = SoftLayer.LoadBalancerManager(env.client)
    _, service_id = loadbal.parse_id(identifier)

    if not (env.skip_confirmations
            or formatting.confirm("This action will toggle the status on the "
                                  "service. Continue?")):
        raise exceptions.CLIAbort('Aborted.')

    mgr.toggle_service_status(service_id)
    return 'Load balancer service %s status updated!' % identifier
def cli(env, identifier):
    """Deletes an existing load balancer service."""

    mgr = SoftLayer.LoadBalancerManager(env.client)
    _, service_id = loadbal.parse_id(identifier)

    if not (env.skip_confirmations or
            formatting.confirm("This action will cancel a service from your "
                               "load balancer. Continue?")):
        raise exceptions.CLIAbort('Aborted.')

    mgr.delete_service(service_id)
    env.fout('Load balancer service %s is being cancelled!' % service_id)
示例#10
0
def cli(env, identifier):
    """Deletes an existing load balancer service group."""
    mgr = SoftLayer.LoadBalancerManager(env.client)

    _, group_id = loadbal.parse_id(identifier)

    if not (env.skip_confirmations or
            formatting.confirm("This action will cancel a service group. "
                               "Continue?")):
        raise exceptions.CLIAbort('Aborted.')

    mgr.delete_service_group(group_id)
    env.fout('Service group %s is being deleted!' % identifier)
示例#11
0
def cli(env, identifier, allocation, port, routing_type, routing_method):
    """Adds a new load_balancer service."""

    mgr = SoftLayer.LoadBalancerManager(env.client)

    _, loadbal_id = loadbal.parse_id(identifier)

    mgr.add_service_group(loadbal_id,
                          allocation=allocation,
                          port=port,
                          routing_type=routing_type,
                          routing_method=routing_method)

    return 'Load balancer service group is being added!'
示例#12
0
def cli(env, identifier):
    """Cancel an existing load balancer."""

    mgr = SoftLayer.LoadBalancerManager(env.client)

    _, loadbal_id = loadbal.parse_id(identifier)

    if not (env.skip_confirmations
            or formatting.confirm("This action will cancel a load balancer. "
                                  "Continue?")):
        raise exceptions.CLIAbort('Aborted.')

    mgr.cancel_lb(loadbal_id)
    env.fout('Load Balancer with id %s is being cancelled!' % identifier)
示例#13
0
def cli(env, identifier, allocation, port, routing_type, routing_method):
    """Adds a new load_balancer service."""

    mgr = SoftLayer.LoadBalancerManager(env.client)

    _, loadbal_id = loadbal.parse_id(identifier)

    mgr.add_service_group(loadbal_id,
                          allocation=allocation,
                          port=port,
                          routing_type=routing_type,
                          routing_method=routing_method)

    env.fout('Load balancer service group is being added!')
示例#14
0
def cli(env, identifier):
    """Cancel an existing load balancer."""

    mgr = SoftLayer.LoadBalancerManager(env.client)

    _, loadbal_id = loadbal.parse_id(identifier)

    if any([env.skip_confirmations,
            formatting.confirm("This action will cancel a load balancer. "
                               "Continue?")]):
        mgr.cancel_lb(loadbal_id)
        return 'Load Balancer with id %s is being cancelled!' % identifier
    else:
        raise exceptions.CLIAbort('Aborted.')
def cli(env, identifier, allocation, port, routing_type, routing_method):
    """Edit an existing load balancer service group."""
    mgr = SoftLayer.LoadBalancerManager(env.client)

    loadbal_id, group_id = loadbal.parse_id(identifier)

    # check if any input is provided
    if not any([allocation, port, routing_type, routing_method]):
        raise exceptions.CLIAbort("At least one property is required to be changed!")

    mgr.edit_service_group(
        loadbal_id, group_id, allocation=allocation, port=port, routing_type=routing_type, routing_method=routing_method
    )

    env.fout("Load balancer service group %s is being updated!" % identifier)
def cli(env, identifier, allocation, port, routing_type, routing_method):
    """Edit an existing load balancer service group."""
    mgr = SoftLayer.LoadBalancerManager(env.client)

    loadbal_id, group_id = loadbal.parse_id(identifier)

    # check if any input is provided
    if not any([allocation, port, routing_type, routing_method]):
        return 'At least one property is required to be changed!'

    mgr.edit_service_group(loadbal_id,
                           group_id,
                           allocation=allocation,
                           port=port,
                           routing_type=routing_type,
                           routing_method=routing_method)

    return 'Load balancer service group %s is being updated!' % identifier
示例#17
0
def cli(env, identifier, enabled, port, weight, healthcheck_type, ip_address):
    """Adds a new load balancer service."""

    mgr = SoftLayer.LoadBalancerManager(env.client)

    loadbal_id, group_id = loadbal.parse_id(identifier)

    # check if the IP is valid
    ip_address_id = None
    if ip_address:
        ip_service = env.client['Network_Subnet_IpAddress']
        ip_record = ip_service.getByIpAddress(ip_address)
        ip_address_id = ip_record['id']

    mgr.add_service(loadbal_id,
                    group_id,
                    ip_address_id=ip_address_id,
                    enabled=enabled,
                    port=port,
                    weight=weight,
                    hc_type=healthcheck_type)
    return 'Load balancer service is being added!'
示例#18
0
def cli(env, identifier):
    """Get Load balancer details."""
    mgr = SoftLayer.LoadBalancerManager(env.client)

    _, loadbal_id = loadbal.parse_id(identifier)

    load_balancer = mgr.get_local_lb(loadbal_id)

    table = formatting.KeyValueTable(['Name', 'Value'])
    table.align['Name'] = 'l'
    table.align['Value'] = 'l'
    table.add_row(['General properties', '----------'])
    table.add_row([' ID', 'local:%s' % load_balancer['id']])
    table.add_row([' IP Address', load_balancer['ipAddress']['ipAddress']])
    name = load_balancer['loadBalancerHardware'][0]['datacenter']['name']
    table.add_row([' Datacenter', name])
    table.add_row([' Connections limit', load_balancer['connectionLimit']])
    table.add_row([' Dedicated', load_balancer['dedicatedFlag']])
    table.add_row([' HA', load_balancer['highAvailabilityFlag']])
    table.add_row([' SSL Enabled', load_balancer['sslEnabledFlag']])
    table.add_row([' SSL Active', load_balancer['sslActiveFlag']])
    index0 = 1
    for virtual_server in load_balancer['virtualServers']:
        table.add_row(['Service group %s' % index0,
                       '**************'])
        index0 += 1
        table2 = formatting.Table(['Service group ID',
                                   'Port',
                                   'Allocation',
                                   'Routing type',
                                   'Routing Method'])

        for group in virtual_server['serviceGroups']:
            table2.add_row([
                '%s:%s' % (load_balancer['id'], virtual_server['id']),
                virtual_server['port'],
                '%s %%' % virtual_server['allocation'],
                '%s:%s' % (group['routingTypeId'],
                           group['routingType']['name']),
                '%s:%s' % (group['routingMethodId'],
                           group['routingMethod']['name'])
            ])

            table.add_row([' Group Properties', table2])

            table3 = formatting.Table(['Service_ID',
                                       'IP Address',
                                       'Port',
                                       'Health Check',
                                       'Weight',
                                       'Enabled',
                                       'Status'])
            service_exist = False
            for service in group['services']:
                service_exist = True
                health_check = service['healthChecks'][0]
                table3.add_row([
                    '%s:%s' % (load_balancer['id'], service['id']),
                    service['ipAddress']['ipAddress'],
                    service['port'],
                    '%s:%s' % (health_check['healthCheckTypeId'],
                               health_check['type']['name']),
                    service['groupReferences'][0]['weight'],
                    service['enabled'],
                    service['status']
                ])
            if service_exist:
                table.add_row([' Services', table3])
            else:
                table.add_row([' Services', 'None'])
    return table
示例#19
0
def cli(env, identifier):
    """Get Load balancer details."""
    mgr = SoftLayer.LoadBalancerManager(env.client)

    _, loadbal_id = loadbal.parse_id(identifier)

    load_balancer = mgr.get_local_lb(loadbal_id)

    table = formatting.KeyValueTable(["name", "value"])
    table.align["name"] = "l"
    table.align["value"] = "l"
    table.add_row(["General properties", "----------"])
    table.add_row([" ID", "local:%s" % load_balancer["id"]])
    table.add_row([" IP Address", load_balancer["ipAddress"]["ipAddress"]])
    name = load_balancer["loadBalancerHardware"][0]["datacenter"]["name"]
    table.add_row([" Datacenter", name])
    table.add_row([" Connections limit", load_balancer["connectionLimit"]])
    table.add_row([" Dedicated", load_balancer["dedicatedFlag"]])
    table.add_row([" HA", load_balancer["highAvailabilityFlag"]])
    table.add_row([" SSL Enabled", load_balancer["sslEnabledFlag"]])
    table.add_row([" SSL Active", load_balancer["sslActiveFlag"]])
    index0 = 1
    for virtual_server in load_balancer["virtualServers"]:
        table.add_row(["Service group %s" % index0, "**************"])
        index0 += 1
        table2 = formatting.Table(["Service group ID", "Port", "Allocation", "Routing type", "Routing Method"])

        for group in virtual_server["serviceGroups"]:
            table2.add_row(
                [
                    "%s:%s" % (load_balancer["id"], virtual_server["id"]),
                    virtual_server["port"],
                    "%s %%" % virtual_server["allocation"],
                    "%s:%s" % (group["routingTypeId"], group["routingType"]["name"]),
                    "%s:%s" % (group["routingMethodId"], group["routingMethod"]["name"]),
                ]
            )

            table.add_row([" Group Properties", table2])

            table3 = formatting.Table(
                ["Service_ID", "IP Address", "Port", "Health Check", "Weight", "Enabled", "Status"]
            )
            service_exist = False
            for service in group["services"]:
                service_exist = True
                health_check = service["healthChecks"][0]
                table3.add_row(
                    [
                        "%s:%s" % (load_balancer["id"], service["id"]),
                        service["ipAddress"]["ipAddress"],
                        service["port"],
                        "%s:%s" % (health_check["healthCheckTypeId"], health_check["type"]["name"]),
                        service["groupReferences"][0]["weight"],
                        service["enabled"],
                        service["status"],
                    ]
                )
            if service_exist:
                table.add_row([" Services", table3])
            else:
                table.add_row([" Services", "None"])

    env.fout(table)
示例#20
0
def cli(env, identifier):
    """Get Load balancer details."""
    mgr = SoftLayer.LoadBalancerManager(env.client)

    _, loadbal_id = loadbal.parse_id(identifier)

    load_balancer = mgr.get_local_lb(loadbal_id)

    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'l'
    table.align['value'] = 'l'
    table.add_row(['ID', 'local:%s' % load_balancer['id']])
    table.add_row(['IP Address', load_balancer['ipAddress']['ipAddress']])
    name = load_balancer['loadBalancerHardware'][0]['datacenter']['name']
    table.add_row(['Datacenter', name])
    table.add_row(['Connections limit', load_balancer['connectionLimit']])
    table.add_row(['Dedicated', load_balancer['dedicatedFlag']])
    table.add_row(['HA', load_balancer['highAvailabilityFlag']])
    table.add_row(['SSL Enabled', load_balancer['sslEnabledFlag']])
    table.add_row(['SSL Active', load_balancer['sslActiveFlag']])

    index0 = 1
    for virtual_server in load_balancer['virtualServers']:
        for group in virtual_server['serviceGroups']:
            service_group_table = formatting.KeyValueTable(['name', 'value'])

            table.add_row(['Service Group %s' % index0, service_group_table])
            index0 += 1

            service_group_table.add_row(['Guest ID', virtual_server['id']])
            service_group_table.add_row(['Port', virtual_server['port']])
            service_group_table.add_row(
                ['Allocation',
                 '%s %%' % virtual_server['allocation']])
            service_group_table.add_row([
                'Routing Type',
                '%s:%s' %
                (group['routingTypeId'], group['routingType']['name'])
            ])
            service_group_table.add_row([
                'Routing Method',
                '%s:%s' %
                (group['routingMethodId'], group['routingMethod']['name'])
            ])

            index1 = 1
            for service in group['services']:
                service_table = formatting.KeyValueTable(['name', 'value'])

                service_group_table.add_row(
                    ['Service %s' % index1, service_table])
                index1 += 1

                health_check = service['healthChecks'][0]
                service_table.add_row(['Service ID', service['id']])
                service_table.add_row(
                    ['IP Address', service['ipAddress']['ipAddress']])
                service_table.add_row(['Port', service['port']])
                service_table.add_row([
                    'Health Check',
                    '%s:%s' % (health_check['healthCheckTypeId'],
                               health_check['type']['name'])
                ])
                service_table.add_row(
                    ['Weight', service['groupReferences'][0]['weight']])
                service_table.add_row(['Enabled', service['enabled']])
                service_table.add_row(['Status', service['status']])

    env.fout(table)
示例#21
0
def cli(env, identifier):
    """Get Load balancer details."""
    mgr = SoftLayer.LoadBalancerManager(env.client)

    _, loadbal_id = loadbal.parse_id(identifier)

    load_balancer = mgr.get_local_lb(loadbal_id)

    table = formatting.KeyValueTable(['name', 'value'])
    table.align['name'] = 'l'
    table.align['value'] = 'l'
    table.add_row(['ID', 'local:%s' % load_balancer['id']])
    table.add_row(['IP Address', load_balancer['ipAddress']['ipAddress']])
    name = load_balancer['loadBalancerHardware'][0]['datacenter']['name']
    table.add_row(['Datacenter', name])
    table.add_row(['Connections limit', load_balancer['connectionLimit']])
    table.add_row(['Dedicated', load_balancer['dedicatedFlag']])
    table.add_row(['HA', load_balancer['highAvailabilityFlag']])
    table.add_row(['SSL Enabled', load_balancer['sslEnabledFlag']])
    table.add_row(['SSL Active', load_balancer['sslActiveFlag']])

    index0 = 1
    for virtual_server in load_balancer['virtualServers']:
        for group in virtual_server['serviceGroups']:
            service_group_table = formatting.KeyValueTable(['name', 'value'])

            table.add_row(['Service Group %s' % index0, service_group_table])
            index0 += 1

            service_group_table.add_row(['Guest ID',
                                         virtual_server['id']])
            service_group_table.add_row(['Port', virtual_server['port']])
            service_group_table.add_row(['Allocation',
                                         '%s %%' %
                                         virtual_server['allocation']])
            service_group_table.add_row(['Routing Type',
                                         '%s:%s' %
                                         (group['routingTypeId'],
                                          group['routingType']['name'])])
            service_group_table.add_row(['Routing Method',
                                         '%s:%s' %
                                         (group['routingMethodId'],
                                          group['routingMethod']['name'])])

            index1 = 1
            for service in group['services']:
                service_table = formatting.KeyValueTable(['name', 'value'])

                service_group_table.add_row(['Service %s' % index1,
                                             service_table])
                index1 += 1

                health_check = service['healthChecks'][0]
                service_table.add_row(['Service ID', service['id']])
                service_table.add_row(['IP Address',
                                       service['ipAddress']['ipAddress']])
                service_table.add_row(['Port', service['port']])
                service_table.add_row(['Health Check',
                                       '%s:%s' %
                                       (health_check['healthCheckTypeId'],
                                        health_check['type']['name'])])
                service_table.add_row(
                    ['Weight', service['groupReferences'][0]['weight']])
                service_table.add_row(['Enabled', service['enabled']])
                service_table.add_row(['Status', service['status']])

    env.fout(table)