示例#1
0
def list(client, datacenterid, networkdomainid, networkid, vlanid,
         sourceimageid, deployed, name, state, started, ipv6, privateipv4,
         idsonly, query):
    node_list = client.node.list_nodes(ex_location=datacenterid,
                                       ex_name=name,
                                       ex_network=networkid,
                                       ex_network_domain=networkdomainid,
                                       ex_vlan=vlanid,
                                       ex_image=sourceimageid,
                                       ex_deployed=deployed,
                                       ex_started=started,
                                       ex_state=state,
                                       ex_ipv6=ipv6,
                                       ex_ipv4=privateipv4)
    response = DiDataCLIFilterableResponse()
    for node in node_list:
        if idsonly:
            click.secho(node.id)
        else:
            response.add(_node_to_dict(node))
    if not response.is_empty():
        if query is not None:
            response.do_filter(query)
        click.secho(response.to_string(client.output_type))
    else:
        click.secho("No nodes found", fg='red', bold=True)
示例#2
0
def list_public_ip_blocks(client, networkdomainid, query):
    try:
        network_domain = client.node.ex_get_network_domain(networkdomainid)
        ip_blocks = client.node.ex_list_public_ip_blocks(network_domain)
        response = DiDataCLIFilterableResponse()
        for ip_block in ip_blocks:
            response.add(_ip_block_to_dict(ip_block))
        if not response.is_empty():
            if query is not None:
                response.do_filter(query)
            click.secho(response.to_string(client.output_type))
        else:
            click.secho("No public ip blocks found", fg='red', bold=True)
    except DimensionDataAPIException as e:
        handle_dd_api_exception(e)
示例#3
0
def list_firewall_rules(client, networkdomainid, query):
    try:
        network_domain = client.node.ex_get_network_domain(networkdomainid)
        rules = client.node.ex_list_firewall_rules(network_domain)
        response = DiDataCLIFilterableResponse()
        for rule in rules:
            response.add(_firewall_rule_to_dict(rule))
        if not response.is_empty():
            if query is not None:
                response.do_filter(query)
            click.secho(response.to_string(client.output_type))
        else:
            click.secho("No firewall rules found", fg='red', bold=True)
    except DimensionDataAPIException as e:
        handle_dd_api_exception(e)
示例#4
0
def list_network_domains(client, datacenterid, query):
    try:
        network_domains = client.node.ex_list_network_domains(
            location=datacenterid)
        response = DiDataCLIFilterableResponse()
        for network_domain in network_domains:
            response.add(_network_domain_to_dict(network_domain))
        if not response.is_empty():
            if query is not None:
                response.do_filter(query)
            click.secho(response.to_string(client.output_type))
        else:
            click.secho("No network domains found", fg='red', bold=True)
    except DimensionDataAPIException as e:
        handle_dd_api_exception(e)
示例#5
0
def info(client, serverid, query):
    node = client.node.ex_get_node_by_id(serverid)
    if node:
        response = DiDataCLIFilterableResponse()
        response.add(_node_to_dict(node))
        if query is not None:
            response.do_filter(query)
        click.secho(response.to_string(client.output_type))
    else:
        click.secho("No node found for id {0}".format(serverid),
                    fg='red',
                    bold=True)
def info(client, serverid, query):
    node = client.node.ex_get_node_by_id(serverid)
    if node:
        response = DiDataCLIFilterableResponse()
        response.add(_node_to_dict(node))
        if query is not None:
            response.do_filter(query)
        click.secho(response.to_string(client.output_type))
    else:
        click.secho("No node found for id {0}".format(serverid), fg='red', bold=True)
def list_network_domains(client, datacenterid, query):
    try:
        network_domains = client.node.ex_list_network_domains(location=datacenterid)
        response = DiDataCLIFilterableResponse()
        for network_domain in network_domains:
            response.add(_network_domain_to_dict(network_domain))
        if not response.is_empty():
            if query is not None:
                response.do_filter(query)
            click.secho(response.to_string(client.output_type))
        else:
            click.secho("No network domains found", fg='red', bold=True)
    except DimensionDataAPIException as e:
        handle_dd_api_exception(e)
def list_public_ip_blocks(client, networkdomainid, query):
    try:
        network_domain = client.node.ex_get_network_domain(networkdomainid)
        ip_blocks = client.node.ex_list_public_ip_blocks(network_domain)
        response = DiDataCLIFilterableResponse()
        for ip_block in ip_blocks:
            response.add(_ip_block_to_dict(ip_block))
        if not response.is_empty():
            if query is not None:
                response.do_filter(query)
            click.secho(response.to_string(client.output_type))
        else:
            click.secho("No public ip blocks found", fg='red', bold=True)
    except DimensionDataAPIException as e:
        handle_dd_api_exception(e)
def list_firewall_rules(client, networkdomainid, query):
    try:
        network_domain = client.node.ex_get_network_domain(networkdomainid)
        rules = client.node.ex_list_firewall_rules(network_domain)
        response = DiDataCLIFilterableResponse()
        for rule in rules:
            response.add(_firewall_rule_to_dict(rule))
        if not response.is_empty():
            if query is not None:
                response.do_filter(query)
            click.secho(response.to_string(client.output_type))
        else:
            click.secho("No firewall rules found", fg='red', bold=True)
    except DimensionDataAPIException as e:
        handle_dd_api_exception(e)
def list(client, datacenterid, networkdomainid, networkid,
         vlanid, sourceimageid, deployed, name,
         state, started, ipv6, privateipv4, idsonly, query):
    node_list = client.node.list_nodes(ex_location=datacenterid, ex_name=name, ex_network=networkid,
                                       ex_network_domain=networkdomainid, ex_vlan=vlanid,
                                       ex_image=sourceimageid, ex_deployed=deployed, ex_started=started,
                                       ex_state=state, ex_ipv6=ipv6, ex_ipv4=privateipv4)
    response = DiDataCLIFilterableResponse()
    for node in node_list:
        if idsonly:
            click.secho(node.id)
        else:
            response.add(_node_to_dict(node))
    if not response.is_empty():
        if query is not None:
            response.do_filter(query)
        click.secho(response.to_string(client.output_type))
    else:
        click.secho("No nodes found", fg='red', bold=True)