Exemplo n.º 1
0
def _get_api_params():
    ca_certificate = None
    api_token = None
    if not variables.K8S_API_SERVER:
        k8s_api_server = ovs_vsctl("--if-exists", "get", "Open_vSwitch", ".",
                                   "external_ids:k8s-api-server").strip('"')
    else:
        k8s_api_server = variables.K8S_API_SERVER

    if k8s_api_server.startswith("https://"):
        if not path.isfile(CA_CERTIFICATE):
            vlog.info("Going to look for k8s-ca-certificate in OVSDB")
            k8s_ca_crt = ovs_vsctl("--if-exists", "get", "Open_vSwitch",
                                   ".", "external_ids:k8s-ca-certificate"
                                   ).strip('"')
            if k8s_ca_crt:
                k8s_ca_crt = k8s_ca_crt.replace("\\n", "\n")
                ca_file = open(CA_CERTIFICATE, 'w+')
                ca_file.write(k8s_ca_crt)
                ca_certificate = CA_CERTIFICATE
        else:
            ca_certificate = CA_CERTIFICATE

    k8s_api_token = ovs_vsctl("--if-exists", "get", "Open_vSwitch", ".",
                              "external_ids:k8s-api-token").strip('"')
    if k8s_api_token:
        api_token = k8s_api_token

    return ca_certificate, api_token
Exemplo n.º 2
0
def _get_api_params():
    ca_certificate = None
    api_token = None
    if not variables.K8S_API_SERVER:
        k8s_api_server = ovs_vsctl("--if-exists", "get", "Open_vSwitch", ".",
                                   "external_ids:k8s-api-server").strip('"')
    else:
        k8s_api_server = variables.K8S_API_SERVER

    if k8s_api_server.startswith("https://"):
        if not path.isfile(CA_CERTIFICATE):
            vlog.info("Going to look for k8s-ca-certificate in OVSDB")
            k8s_ca_crt = ovs_vsctl("--if-exists", "get", "Open_vSwitch",
                                   ".", "external_ids:k8s-ca-certificate"
                                   ).strip('"')
            if k8s_ca_crt:
                k8s_ca_crt = k8s_ca_crt.replace("\\n", "\n")
                ca_file = open(CA_CERTIFICATE, 'w+')
                ca_file.write(k8s_ca_crt)
                ca_certificate = CA_CERTIFICATE
        else:
            ca_certificate = CA_CERTIFICATE

    k8s_api_token = ovs_vsctl("--if-exists", "get", "Open_vSwitch", ".",
                              "external_ids:k8s-api-token").strip('"')
    if k8s_api_token:
        api_token = k8s_api_token

    return ca_certificate, api_token
Exemplo n.º 3
0
def ovn_init_overlay():
    OVN_NB = ovs_vsctl("--if-exists", "get", "Open_vSwitch", ".", "external_ids:ovn-nb").strip('"')
    if not OVN_NB:
        sys.exit("OVN central database's ip address not set")
    variables.OVN_NB = OVN_NB

    K8S_API_SERVER = ovs_vsctl("--if-exists", "get", "Open_vSwitch", ".", "external_ids:k8s-api-server").strip('"')
    if not K8S_API_SERVER:
        sys.exit("K8S_API_SERVER not set")
    if not K8S_API_SERVER.startswith("http"):
        variables.K8S_API_SERVER = "http://%s" % K8S_API_SERVER
    else:
        variables.K8S_API_SERVER = K8S_API_SERVER

    K8S_CLUSTER_ROUTER = ovn_nbctl(
        "--data=bare",
        "--no-heading",
        "--columns=_uuid",
        "find",
        "logical_router",
        "external_ids:k8s-cluster-router=yes",
    )
    if not K8S_CLUSTER_ROUTER:
        sys.exit("K8S_CLUSTER_ROUTER not set")
    variables.K8S_CLUSTER_ROUTER = K8S_CLUSTER_ROUTER

    K8S_CLUSTER_LB_TCP = ovn_nbctl(
        "--data=bare", "--no-heading", "--columns=_uuid", "find", "load_balancer", "external_ids:k8s-cluster-lb-tcp=yes"
    )
    if not K8S_CLUSTER_LB_TCP:
        sys.exit("K8S_CLUSTER_LB_TCP not set")
    variables.K8S_CLUSTER_LB_TCP = K8S_CLUSTER_LB_TCP

    K8S_CLUSTER_LB_UDP = ovn_nbctl(
        "--data=bare", "--no-heading", "--columns=_uuid", "find", "load_balancer", "external_ids:k8s-cluster-lb-udp=yes"
    )
    if not K8S_CLUSTER_LB_UDP:
        sys.exit("K8S_CLUSTER_LB_UDP not set")
    variables.K8S_CLUSTER_LB_UDP = K8S_CLUSTER_LB_UDP

    K8S_NS_LB_TCP = ovn_nbctl(
        "--data=bare", "--no-heading", "--columns=_uuid", "find", "load_balancer", "external_ids:k8s-ns-lb-tcp=yes"
    )
    variables.K8S_NS_LB_TCP = K8S_NS_LB_TCP

    K8S_NS_LB_UDP = ovn_nbctl(
        "--data=bare", "--no-heading", "--columns=_uuid", "find", "load_balancer", "external_ids:k8s-ns-lb-udp=yes"
    )
    variables.K8S_NS_LB_UDP = K8S_NS_LB_UDP

    variables.OVN_MODE = "overlay"
Exemplo n.º 4
0
def ovn_init_overlay():
    OVN_NB = ovs_vsctl("--if-exists", "get", "Open_vSwitch", ".",
                       "external_ids:ovn-nb").strip('"')
    if not OVN_NB:
        sys.exit("OVN central database's ip address not set")
    variables.OVN_NB = OVN_NB

    K8S_API_SERVER = ovs_vsctl("--if-exists", "get", "Open_vSwitch", ".",
                               "external_ids:k8s-api-server").strip('"')
    if not K8S_API_SERVER:
        sys.exit("K8S_API_SERVER not set")
    if not K8S_API_SERVER.startswith("http"):
        variables.K8S_API_SERVER = "http://%s" % K8S_API_SERVER
    else:
        variables.K8S_API_SERVER = K8S_API_SERVER

    K8S_CLUSTER_ROUTER = ovn_nbctl("--data=bare", "--no-heading",
                                   "--columns=_uuid", "find", "logical_router",
                                   "external_ids:k8s-cluster-router=yes")
    if not K8S_CLUSTER_ROUTER:
        sys.exit("K8S_CLUSTER_ROUTER not set")
    variables.K8S_CLUSTER_ROUTER = K8S_CLUSTER_ROUTER

    K8S_CLUSTER_LB_TCP = ovn_nbctl("--data=bare", "--no-heading",
                                   "--columns=_uuid", "find", "load_balancer",
                                   "external_ids:k8s-cluster-lb-tcp=yes")
    if not K8S_CLUSTER_LB_TCP:
        sys.exit("K8S_CLUSTER_LB_TCP not set")
    variables.K8S_CLUSTER_LB_TCP = K8S_CLUSTER_LB_TCP

    K8S_CLUSTER_LB_UDP = ovn_nbctl("--data=bare", "--no-heading",
                                   "--columns=_uuid", "find", "load_balancer",
                                   "external_ids:k8s-cluster-lb-udp=yes")
    if not K8S_CLUSTER_LB_UDP:
        sys.exit("K8S_CLUSTER_LB_UDP not set")
    variables.K8S_CLUSTER_LB_UDP = K8S_CLUSTER_LB_UDP

    K8S_NS_LB_TCP = ovn_nbctl("--data=bare", "--no-heading",
                              "--columns=_uuid", "find", "load_balancer",
                              "external_ids:k8s-ns-lb-tcp=yes")
    variables.K8S_NS_LB_TCP = K8S_NS_LB_TCP

    K8S_NS_LB_UDP = ovn_nbctl("--data=bare", "--no-heading",
                              "--columns=_uuid", "find", "load_balancer",
                              "external_ids:k8s-ns-lb-udp=yes")
    variables.K8S_NS_LB_UDP = K8S_NS_LB_UDP

    variables.OVN_MODE = "overlay"
Exemplo n.º 5
0
def ovn_init_overlay():
    if os.path.exists(UNIX_SOCKET):
        OVN_NB = "unix:%s" % UNIX_SOCKET
    else:
        sys.exit("OVN NB database does not have unix socket")
    variables.OVN_NB = OVN_NB

    K8S_API_SERVER = ovs_vsctl("--if-exists", "get", "Open_vSwitch", ".",
                               "external_ids:k8s-api-server").strip('"')
    if not K8S_API_SERVER:
        sys.exit("K8S_API_SERVER not set")
    if not K8S_API_SERVER.startswith("http"):
        variables.K8S_API_SERVER = "http://%s" % K8S_API_SERVER
    else:
        variables.K8S_API_SERVER = K8S_API_SERVER

    K8S_CLUSTER_ROUTER = ovn_nbctl("--data=bare", "--no-heading",
                                   "--columns=_uuid", "find", "logical_router",
                                   "external_ids:k8s-cluster-router=yes")
    if not K8S_CLUSTER_ROUTER:
        sys.exit("K8S_CLUSTER_ROUTER not set")
    variables.K8S_CLUSTER_ROUTER = K8S_CLUSTER_ROUTER

    K8S_CLUSTER_LB_TCP = ovn_nbctl("--data=bare", "--no-heading",
                                   "--columns=_uuid", "find", "load_balancer",
                                   "external_ids:k8s-cluster-lb-tcp=yes")
    if not K8S_CLUSTER_LB_TCP:
        sys.exit("K8S_CLUSTER_LB_TCP not set")
    variables.K8S_CLUSTER_LB_TCP = K8S_CLUSTER_LB_TCP

    K8S_CLUSTER_LB_UDP = ovn_nbctl("--data=bare", "--no-heading",
                                   "--columns=_uuid", "find", "load_balancer",
                                   "external_ids:k8s-cluster-lb-udp=yes")
    if not K8S_CLUSTER_LB_UDP:
        sys.exit("K8S_CLUSTER_LB_UDP not set")
    variables.K8S_CLUSTER_LB_UDP = K8S_CLUSTER_LB_UDP

    variables.OVN_MODE = "overlay"
Exemplo n.º 6
0
def ovn_init_overlay():
    if os.path.exists(UNIX_SOCKET):
        OVN_NB = "unix:%s" % UNIX_SOCKET
    else:
        sys.exit("OVN NB database does not have unix socket")
    variables.OVN_NB = OVN_NB

    K8S_API_SERVER = ovs_vsctl("--if-exists", "get", "Open_vSwitch", ".",
                               "external_ids:k8s-api-server").strip('"')
    if not K8S_API_SERVER:
        sys.exit("K8S_API_SERVER not set")
    if not K8S_API_SERVER.startswith("http"):
        variables.K8S_API_SERVER = "http://%s" % K8S_API_SERVER
    else:
        variables.K8S_API_SERVER = K8S_API_SERVER

    K8S_CLUSTER_ROUTER = ovn_nbctl("--data=bare", "--no-heading",
                                   "--columns=_uuid", "find", "logical_router",
                                   "external_ids:k8s-cluster-router=yes")
    if not K8S_CLUSTER_ROUTER:
        sys.exit("K8S_CLUSTER_ROUTER not set")
    variables.K8S_CLUSTER_ROUTER = K8S_CLUSTER_ROUTER

    K8S_CLUSTER_LB_TCP = ovn_nbctl("--data=bare", "--no-heading",
                                   "--columns=_uuid", "find", "load_balancer",
                                   "external_ids:k8s-cluster-lb-tcp=yes")
    if not K8S_CLUSTER_LB_TCP:
        sys.exit("K8S_CLUSTER_LB_TCP not set")
    variables.K8S_CLUSTER_LB_TCP = K8S_CLUSTER_LB_TCP

    K8S_CLUSTER_LB_UDP = ovn_nbctl("--data=bare", "--no-heading",
                                   "--columns=_uuid", "find", "load_balancer",
                                   "external_ids:k8s-cluster-lb-udp=yes")
    if not K8S_CLUSTER_LB_UDP:
        sys.exit("K8S_CLUSTER_LB_UDP not set")
    variables.K8S_CLUSTER_LB_UDP = K8S_CLUSTER_LB_UDP