コード例 #1
0
ファイル: registry.py プロジェクト: raghavendra-talur/ocs-ci
def enable_route_and_create_ca_for_registry_access():
    """
    Function to enable route and to create ca,
    copy to respective location for registry access

    Raises:
        AssertionError: When failure in enabling registry default route

    """
    ocp_obj = ocp.OCP(
        kind=constants.CONFIG, namespace=constants.OPENSHIFT_IMAGE_REGISTRY_NAMESPACE
    )
    assert ocp_obj.patch(
        resource_name=constants.IMAGE_REGISTRY_RESOURCE_NAME,
        params='{"spec": {"defaultRoute": true}}', format_type='merge'
    ), f"Registry pod defaultRoute enable is not success"
    logger.info(f"Enabled defaultRoute to true")
    ocp_obj = ocp.OCP()
    crt_cmd = f"get secret {constants.DEFAULT_ROUTE_CRT} " \
              f"-n {constants.OPENSHIFT_INGRESS_NAMESPACE} -o yaml"
    crt_dict = ocp_obj.exec_oc_cmd(command=crt_cmd)
    crt = crt_dict.get('data').get('tls.crt')
    route = get_default_route_name()
    if not os.path.exists('/tmp/secret'):
        run_cmd(cmd='mkdir /tmp/secret')
    with open(f"/tmp/secret/{route}.crt", "wb") as temp:
        temp.write(base64.b64decode(crt))
    master_list = helpers.get_master_nodes()
    ocp.rsync(
        src=f"/tmp/secret/", dst='/etc/pki/ca-trust/source/anchors',
        node=master_list[0], dst_node=True
    )
    ocp_obj.exec_oc_debug_cmd(node=master_list[0], cmd_list=['update-ca-trust enable'])
    logger.info(f"Created base64 secret, copied to source location and enabled ca-trust")
コード例 #2
0
ファイル: helpers.py プロジェクト: gklein/ocs-ci
def rsync_kubeconf_to_node(node):
    """
    Function to copy kubeconfig to OCP node

    Args:
        node (str): OCP node to copy kubeconfig if not present

    """
    # ocp_obj = ocp.OCP()
    filename = os.path.join(config.ENV_DATA['cluster_path'],
                            config.RUN['kubeconfig_location'])
    file_path = os.path.dirname(filename)
    master_list = get_master_nodes()
    ocp_obj = ocp.OCP()
    check_auth = 'auth'
    check_conf = 'kubeconfig'
    node_path = '/home/core/'
    if check_auth not in ocp_obj.exec_oc_debug_cmd(
            node=master_list[0], cmd_list=[f"ls {node_path}"]):
        ocp.rsync(src=file_path, dst=f"{node_path}", node=node, dst_node=True)
    elif check_conf not in ocp_obj.exec_oc_debug_cmd(
            node=master_list[0], cmd_list=[f"ls {node_path}auth"]):
        ocp.rsync(src=file_path, dst=f"{node_path}", node=node, dst_node=True)