コード例 #1
0
def get_port_id_ipv4_of_server(mgr_or_client, server_id,
                               ip_addr=None, **kwargs):
    ports = Q.port_list(mgr_or_client,
                        device_id=server_id, fixed_ip=ip_addr)
    # TODO(akang): assume only ONE from ports match server_id
    #              need to handle server given 1+ network.
    port0 = ports[0]
    for ip4 in port0['fixed_ips']:
        ip = ip4['ip_address']
        if Q.netaddr.valid_ipv4(ip):
            return (port0['id'], ip)
コード例 #2
0
def get_ports_of_server(mgr_or_client, server_id, **kwargs):
    ports = Q.port_list(mgr_or_client, device_id=server_id)
    return ports