예제 #1
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--deploy-namespace",
                        type=lambda x: (str(x).lower() == 'true'),
                        default=True)
    deploy_options = deployment_options.load_deployment_options(parser)

    utils.verify_build_directory(deploy_options.namespace)

    if deploy_options.deploy_namespace is False:
        print("Not deploying namespace")
        return
    src_file = os.path.join(os.getcwd(), 'deploy/namespace/namespace.yaml')
    dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                            'namespace.yaml')
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE',
                                f'"{deploy_options.namespace}"')
            print("Deploying {}".format(dst_file))
            dst.write(data)

    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                profile=deploy_options.profile,
                file=dst_file)
def deploy_controller(deploy_options):
    src_file = os.path.join(
        os.getcwd(),
        'deploy/assisted-installer-controller-ocp/assisted-controller-deployment.yaml'
    )
    dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                            'assisted-controller-deployment.yaml')
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_CONTROLLER_OCP_IMAGE',
                                f'"{deploy_options.controller_image}"')
            data = data.replace('REPLACE_INVENTORY_URL',
                                f'"{deploy_options.inventory_url}"')
            data = data.replace('REPLACE_CLUSTER_ID',
                                f'"{deploy_options.cluster_id}"')
            data = data.replace('REPLACE_NAMESPACE',
                                f'"{deploy_options.namespace}"')
            print("Deploying {}".format(dst_file))
            dst.write(data)

    log.info('Deploying %s', dst_file)
    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                profile=deploy_options.profile,
                file=dst_file)
def main():
    utils.verify_build_directory(deploy_options.namespace)

    with open(SRC_FILE, "r") as src:
        log.info(
            f"Loading source template file for assisted-image-service: {SRC_FILE}"
        )
        raw_data = src.read()
        raw_data = raw_data.replace('REPLACE_NAMESPACE',
                                    f'"{deploy_options.namespace}"')
        raw_data = raw_data.replace('REPLACE_IMAGE_SERVICE_IMAGE',
                                    os.environ.get("IMAGE_SERVICE"))
        data = yaml.safe_load(raw_data)
        log.info(data)

    with open(DST_FILE, "w+") as dst:
        yaml.dump(data, dst, default_flow_style=False)

    if not deploy_options.apply_manifest:
        return

    log.info(f"Deploying {DST_FILE}")
    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                file=DST_FILE)
예제 #4
0
def main():
    deploy_options = deployment_options.load_deployment_options()

    utils.verify_build_directory(deploy_options.namespace)

    if deploy_options.target == 'ocp':
        src_file = os.path.join(os.getcwd(), 'deploy/roles/ocp_role.yaml')
        dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                                'ocp_role.yaml')
    else:
        src_file = os.path.join(os.getcwd(), 'deploy/roles/default_role.yaml')
        dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                                'default_role.yaml')

    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE',
                                f'"{deploy_options.namespace}"')
            print("Deploying {}".format(dst_file))
            dst.write(data)

    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                profile=deploy_options.profile,
                file=dst_file)
예제 #5
0
def main():
    utils.verify_build_directory(deploy_options.namespace)

    ocm_secret = deploy_options.secret
    if ocm_secret == "":
        ocm_secret = '""'
    ocm_id = deploy_options.id
    if ocm_id == "":
        ocm_id = '""'

    src_file = os.path.join(os.getcwd(), 'deploy/assisted-installer-sso.yaml')
    dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                            'assisted-installer-sso.yaml')
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE',
                                f'"{deploy_options.namespace}"')
            data = data.replace('REPLACE_OCM_SECRET', ocm_secret)
            data = data.replace('REPLACE_OCM_ID', ocm_id)
            print("Deploying {}".format(dst_file))
            dst.write(data)

    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                profile=deploy_options.profile,
                file=dst_file)
예제 #6
0
def main():
    utils.verify_build_directory(deploy_options.namespace)

    ## Main OLM Manifest for K8s
    if deploy_options.target != "oc-ingress":
        # K8s
        deployed = utils.check_if_exists(k8s_object='namespace',
                                         k8s_object_name='olm',
                                         target=deploy_options.target,
                                         namespace='olm',
                                         profile=deploy_options.profile)
        if not deployed:
            olm_manifests = [
                "https://github.com/operator-framework/operator-lifecycle-manager/releases/download/0.15.1/crds.yaml",
                "https://github.com/operator-framework/operator-lifecycle-manager/releases/download/0.15.1/olm.yaml"
            ]
            for manifest_url in olm_manifests:
                dst_file = os.path.join(
                    os.getcwd(), 'build', deploy_options.namespace,
                    os.path.basename(urlparse(manifest_url).path))
                print("Deploying {}".format(dst_file))
                urlretrieve(manifest_url, dst_file)
                utils.apply(target=deploy_options.target,
                            namespace=None,
                            profile=deploy_options.profile,
                            file=dst_file)

            check_deployment()

    else:
        # OCP
        print("OLM Deployment not necessary")
예제 #7
0
def deploy_prometheus_route():
    '''Deploy Prometheus Route'''
    topic = 'Prometheus Operator Route'
    src_file = os.path.join(os.getcwd(),\
            "deploy/monitoring/prometheus/assisted-installer-ocp-prometheus-route.yaml")
    dst_file = os.path.join(os.getcwd(),\
            "build/assisted-installer-ocp-prometheus-route.yaml")
    try:
        # I have permissions
        ingress_domain = utils.get_domain()
    except:
        # I have not permissions, yes it's ugly...
        # This ingress should be there because of UI deployment
        json_path_ingress = '{.spec.rules[0].host}'
        cmd = "{} -n {} get ingress assisted-installer -o jsonpath='{}'".format(
            CMD_BIN, deploy_options.namespace, json_path_ingress)
        assisted_installer_ingress_domain = utils.check_output(cmd)
        if assisted_installer_ingress_domain.split(
                ".")[0] != 'assisted-installer':
            print("Error recovering the ingress route")
            sys.exit(1)

        ingress_domain = assisted_installer_ingress_domain.split(".",
                                                                 maxsplit=1)[1]
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE', deploy_options.namespace)
            data = data.replace("INGRESS_DOMAIN", ingress_domain)
            print("Deploying {}: {}".format(topic, dst_file))
            dst.write(data)
    utils.apply(dst_file)
def deploy_postgres_storage(deploy_options):
    docs = utils.load_yaml_file_docs('deploy/postgres/postgres-storage.yaml')

    utils.set_namespace_in_yaml_docs(docs, deploy_options.namespace)

    log.info('Updating pvc size for postgres-pv-claim')
    pvc_size_utils.update_size_in_yaml_docs(
        target=deploy_options.target,
        ns=deploy_options.namespace,
        profile=deploy_options.profile,
        name='postgres-pv-claim',
        docs=docs
    )

    dst_file = utils.dump_yaml_file_docs(
        basename=f'build/{deploy_options.namespace}/postgres-storage.yaml',
        docs=docs
    )

    if not deploy_options.apply_manifest:
        return
    log.info('Deploying %s', dst_file)
    utils.apply(
        target=deploy_options.target,
        namespace=deploy_options.namespace,
        profile=deploy_options.profile,
        file=dst_file
    )
예제 #9
0
def main():

    parser = argparse.ArgumentParser()
    parser.add_argument("--target")
    parser.add_argument("--domain")
    parser.add_argument("--subsystem-test", help='deploy in subsystem mode', action='store_true')
    deploy_options = deployment_options.load_deployment_options(parser)

    dst_file = os.path.join(os.getcwd(), "build/deploy_ui.yaml")
    image_fqdn = deployment_options.get_image_override(deploy_options, "ocp-metal-ui", "UI_IMAGE")
    runtime_cmd = utils.get_runtime_command()
    utils.check_output(f'{runtime_cmd} pull {image_fqdn}')
    cmd = f'{runtime_cmd} run {image_fqdn} /deploy/deploy_config.sh -i {image_fqdn} -n {deploy_options.namespace}'
    cmd += ' > {}'.format(dst_file)
    utils.check_output(cmd)
    print("Deploying {}".format(dst_file))
    utils.apply(dst_file)

    # in case of openshift deploy ingress as well
    if deploy_options.target == "oc-ingress":
        src_file = os.path.join(os.getcwd(), "deploy/ui/ui_ingress.yaml")
        dst_file = os.path.join(os.getcwd(), "build/ui_ingress.yaml")
        with open(src_file, "r") as src:
            with open(dst_file, "w+") as dst:
                data = src.read()
                data = data.replace('REPLACE_NAMESPACE', deploy_options.namespace)
                data = data.replace("REPLACE_HOSTNAME",
                                    utils.get_service_host("assisted-installer-ui", deploy_options.target, deploy_options.domain, deploy_options.namespace))
                print("Deploying {}".format(dst_file))
                dst.write(data)
        utils.apply(dst_file)
예제 #10
0
def deploy_scality_storage(deploy_options):
    docs = utils.load_yaml_file_docs('deploy/s3/scality-storage.yaml')

    utils.set_namespace_in_yaml_docs(docs, deploy_options.namespace)

    log.info('Updating pvc size for scality-pv-claim')
    pvc_size_utils.update_size_in_yaml_docs(
        target=deploy_options.target,
        ns=deploy_options.namespace,
        profile=deploy_options.profile,
        name='scality-pv-claim',
        docs=docs
    )

    dst_file = utils.dump_yaml_file_docs(
        basename=f'build/{deploy_options.namespace}/scality-storage.yaml',
        docs=docs
    )

    log.info('Deploying %s', dst_file)
    utils.apply(
        target=deploy_options.target,
        namespace=deploy_options.namespace,
        profile=deploy_options.profile,
        file=dst_file
    )
예제 #11
0
def deploy_prometheus_sub(olm_ns, cat_src):
    '''Deploy Operator Subscription'''
    topic = 'Prometheus Operator Subscription'
    src_file = os.path.join(os.getcwd(),\
            'deploy/monitoring/prometheus/assisted-installer-operator-subscription.yaml')
    dst_file = os.path.join(os.getcwd(),\
            'build', deploy_options.namespace, 'assisted-installer-operator-subscription.yaml')
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE', f'"{deploy_options.namespace}"')
            data = data.replace("CAT_SRC", cat_src).replace("OLM_NAMESPACE", olm_ns)
            print("Deploying {}: {}".format(topic, dst_file))
            dst.write(data)
    utils.apply(
        target=deploy_options.target,
        namespace=deploy_options.namespace,
        file=dst_file
    )
    utils.wait_for_rollout(
        k8s_object='deployment',
        k8s_object_name='prometheus-operator',
        target=deploy_options.target,
        namespace=deploy_options.namespace
    )
예제 #12
0
def main():
    deploy_options = handle_arguments()
    # TODO: delete once rename everything to assisted-installer
    if deploy_options.target == "oc-ingress":
        service_host = "assisted-installer.{}".format(
            utils.get_domain(deploy_options.domain))
        service_port = "80"
    else:
        service_host = utils.get_service_host(
            SERVICE, deploy_options.target, namespace=deploy_options.namespace)
        service_port = utils.get_service_port(
            SERVICE, deploy_options.target, namespace=deploy_options.namespace)

    with open(SRC_FILE, "r") as src:
        with open(DST_FILE, "w+") as dst:
            data = src.read()
            data = data.replace("REPLACE_URL", '"{}"'.format(service_host))
            data = data.replace("REPLACE_PORT", '"{}"'.format(service_port))
            data = data.replace("REPLACE_DOMAINS",
                                '"{}"'.format(deploy_options.base_dns_domains))
            data = data.replace('REPLACE_NAMESPACE', deploy_options.namespace)
            print("Deploying {}".format(DST_FILE))

            versions = {
                "IMAGE_BUILDER": "installer-image-build",
                "AGENT_DOCKER_IMAGE": "agent",
                "KUBECONFIG_GENERATE_IMAGE":
                "ignition-manifests-and-kubeconfig-generate",
                "INSTALLER_IMAGE": "assisted-installer",
                "CONTROLLER_IMAGE": "assisted-installer-controller",
                "CONNECTIVITY_CHECK_IMAGE": "connectivity_check",
                "INVENTORY_IMAGE": "inventory"
            }
            for env_var_name, image_short_name in versions.items():
                image_fqdn = deployment_options.get_image_override(
                    deploy_options, image_short_name, env_var_name)
                versions[env_var_name] = image_fqdn

            # Edge case for controller image override
            if os.environ.get("INSTALLER_IMAGE"
                              ) and not os.environ.get("CONTROLLER_IMAGE"):
                versions[
                    "CONTROLLER_IMAGE"] = deployment_options.IMAGE_FQDN_TEMPLATE.format(
                        "assisted-installer-controller",
                        deployment_options.get_tag(
                            versions["INSTALLER_IMAGE"]))

            versions["SELF_VERSION"] = deployment_options.get_image_override(
                deploy_options, "assisted-service", "SERVICE")
            deploy_tag = get_deployment_tag(deploy_options)
            if deploy_tag:
                versions["RELEASE_TAG"] = deploy_tag

            y = yaml.load(data)
            y['data'].update(versions)
            data = yaml.dump(y)
            dst.write(data)

    utils.apply(DST_FILE)
def main():
    with open(SRC_FILE, "r") as src:
        with open(DST_FILE, "w+") as dst:
            data = src.read()
            print("Deploying {}:\n{}".format(DST_FILE, data))
            dst.write(data)

    utils.apply(DST_FILE)
예제 #14
0
def main():
    with open(SRC_FILE, "r") as src:
        with open(DST_FILE, "w+") as dst:
            data = src.read()
            data = data.replace("REPLACE_IMAGE", os.environ.get("OBJEXP"))
            print("Deploying {}:\n{}".format(DST_FILE, data))
            dst.write(data)

    utils.apply(DST_FILE)
def main():
    utils.verify_build_directory(deploy_options.namespace)

    with open(SRC_FILE, "r") as src:
        raw_data = src.read()
        raw_data = raw_data.replace('REPLACE_NAMESPACE', f'"{deploy_options.namespace}"')
        raw_data = raw_data.replace('REPLACE_IMAGE_PULL_POLICY', f'"{deploy_options.image_pull_policy}"')
        data = yaml.safe_load(raw_data)

        image_fqdn = deployment_options.get_image_override(deploy_options, "assisted-service", "SERVICE")
        data["spec"]["replicas"] = deploy_options.replicas_count
        data["spec"]["template"]["spec"]["containers"][0]["image"] = image_fqdn
        if deploy_options.subsystem_test:
            if data["spec"]["template"]["spec"]["containers"][0].get("env", None) is None:
                data["spec"]["template"]["spec"]["containers"][0]["env"] = []
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'CLUSTER_MONITOR_INTERVAL', 'value': TEST_CLUSTER_MONITOR_INTERVAL})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'HOST_MONITOR_INTERVAL', 'value': TEST_HOST_MONITOR_INTERVAL})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name': 'JWKS_CERT', 'value': load_key()})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'SUBSYSTEM_RUN', 'value': 'True'})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'DUMMY_IGNITION', 'value': 'True'})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'OCM_BASE_URL', 'value': WIREMOCK_SERVICE})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'OCM_TOKEN_URL', 'value': WIREMOCK_SERVICE + '/token'})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'OCM_SERVICE_CLIENT_ID', 'value': 'mock-ocm-client-id'})
            data["spec"]["template"]["spec"]["containers"][0]["env"].append({'name':'OCM_SERVICE_CLIENT_SECRET', 'value': 'mock-ocm-client-secret'})

            if deploy_options.target == deployment_options.OPENSHIFT_TARGET:
                # Images built on infra cluster but needed on ephemeral cluster
                data["spec"]["template"]["spec"]["containers"][0]["imagePullPolicy"] = "IfNotPresent"
            else:
                data["spec"]["template"]["spec"]["containers"][0]["imagePullPolicy"] = "Never"

        if deploy_options.target == deployment_options.OCP_TARGET:
            data["spec"]["replicas"] = 1 # force single replica
            spec = data["spec"]["template"]["spec"]
            service_container = spec["containers"][0]
            service_container["env"].append({'name': 'DEPLOY_TARGET', 'value': "ocp"})
            service_container["env"].append({'name': 'STORAGE', 'value': "filesystem"})
            service_container["env"].append({'name': 'ISO_WORKSPACE_BASE_DIR', 'value': '/data'})
            service_container["env"].append({'name': 'ISO_CACHE_DIR', 'value': '/data/cache'})

        if deploy_options.port:
            for port_option in deploy_options.port:
                port = {"containerPort": int(port_option[0])}
                data["spec"]["template"]["spec"]["containers"][0]["ports"].append(port)

    with open(DST_FILE, "w+") as dst:
        yaml.dump(data, dst, default_flow_style=False)

    if not deploy_options.apply_manifest:
        return

    log.info(f"Deploying {DST_FILE}")
    utils.apply(
        target=deploy_options.target,
        namespace=deploy_options.namespace,
        file=DST_FILE
    )
예제 #16
0
def deploy_postgres(deploy_options):
    docs = utils.load_yaml_file_docs('deploy/postgres/postgres-deployment.yaml')

    utils.set_namespace_in_yaml_docs(docs, deploy_options.namespace)

    dst_file = utils.dump_yaml_file_docs('build/postgres-deployment.yaml', docs)

    log.info('Deploying %s', dst_file)
    utils.apply(dst_file)
예제 #17
0
def deploy_oauth_reqs():
    '''oauth Integration in OCP'''
    ## Token generation for session_secret
    session_secret = secrets.token_hex(43)
    secret_name = 'prometheus-k8s-proxy'
    if not utils.check_if_exists(k8s_object='secret',
                                 k8s_object_name=secret_name,
                                 target=deploy_options.target,
                                 namespace=deploy_options.namespace,
                                 profile=deploy_options.profile):
        cmd = "{} -n {} create secret generic {} --from-literal=session_secret={}" \
                .format(CMD_BIN, deploy_options.namespace, secret_name, session_secret)
        utils.check_output(cmd)

    ## Annotate Serviceaccount
    json_manifest = '{"kind":"OAuthRedirectReference","apiVersion":"v1","reference":{"kind":"Route","name":"prometheus-assisted"}}'
    sa_name = 'prometheus-k8s'
    annotation_name = 'serviceaccounts.openshift.io/oauth-redirectreference.assisted-installer-prometheus'
    cmd = "{} -n {} annotate serviceaccount {} --overwrite {}='{}'"\
            .format(CMD_BIN, deploy_options.namespace, sa_name, annotation_name, json_manifest)
    utils.check_output(cmd)

    # Download OCP Certificate as a secret
    cert_secret_name = 'openshift-custom-ca'
    cmd = "{} -n {} get secret {} --no-headers".format(
        CMD_BIN, deploy_options.namespace, cert_secret_name)
    cert_secret = utils.check_output(cmd)
    if not cert_secret:
        # Get OCP Certificate
        secret_name = 'router-certs-default'
        namespace = 'openshift-ingress'
        template = '{{index .data "tls.crt"}}'
        cmd = "{} get secret {} --namespace={} --template '{}'"\
                .format(CMD_BIN, secret_name, namespace, template)
        ca_cert = utils.check_output(cmd)

        # Renderized secret with CA Certificate of the OCP Cluster
        src_file = os.path.join(os.getcwd(), \
                'deploy/monitoring/prometheus/assisted-installer-ocp-prometheus-custom-ca.yaml')
        dst_file = os.path.join(os.getcwd(), \
                'build', deploy_options.namespace, 'assisted-installer-ocp-prometheus-custom-ca.yaml')
        topic = 'OCP Custom CA'
        with open(src_file, "r") as src:
            with open(dst_file, "w+") as dst:
                data = src.read()
                data = data.replace("BASE64_CERT", ca_cert)
                data = data.replace('REPLACE_NAMESPACE',
                                    f'"{deploy_options.namespace}"')
                print("Deploying {}: {}".format(topic, dst_file))
                dst.write(data)
        utils.apply(target=deploy_options.target,
                    namespace=deploy_options.namespace,
                    profile=deploy_options.profile,
                    file=dst_file)
    else:
        print("Secret {} already exists", cert_secret_name)
def surface(symbol, qdate, qtime=None, errors=False, n=False, loc=0, scale=0):
    df = query.vols(["*"], ["Date", "Time", "Tenor", "Strike"], symbol, qdate,
                    qtime)
    st = utils.pack(df)
    del df

    #----------------------------------------------------------------------------------
    f = lambda LST: pricer.norm_weights(LST, loc, scale)
    wgt = utils.apply(f, 1, st, ["Time", "Tenor"],
                      ["LogStrike"])  #retrive weights vector

    sv = pricer.SSVI(errors)
    f = lambda LST, VAR, TNR, VOL: sv.calibrate(LST, VAR, TNR, VOL, wgt)

    if errors == True:
        prm = utils.apply(f,
                          6,
                          st, ["Time"],
                          ["LogStrike", "TotAtmfVar", "Tenor", "SmtVol"],
                          diff=True,
                          fill=False)
        eps = prm[-1]
        prm = np.asarray(prm[:-1]).T
    else:
        prm = utils.apply(f,
                          5,
                          st, ["Time"],
                          ["LogStrike", "TotAtmfVar", "Tenor", "SmtVol"],
                          fill=False)

    #----------------------------------------------------------------------------------
    reduced = [
        "Time", "Group", "Tenor", "SpotMid", "Forward", "CumDivDays", "Div",
        "ImpBor", "Rate", "CallH0", "CallH1", "CallKh", "PutH0", "PutH1",
        "PutKh", "TotAtmfVar"
    ]
    st = utils.unique_nosort(st[reduced])

    prm = utils.restack(prm, st["TotAtmfVar"], tile=False)

    rho = sv.correlation(st["TotAtmfVar"], prm[:, 0], prm[:, 1], prm[:, 2])
    phi = sv.power_law(st["TotAtmfVar"], prm[:, 3], prm[:, 4])
    atm, skw, krt = sv.raw2jw(st["Tenor"] / base, st["TotAtmfVar"], phi, rho)

    arr = unstruct(st)
    arr = np.column_stack([arr, atm, skw, krt, phi, rho])
    df = utils.unpack(arr, qdate, raw=False, symbol=symbol)

    if errors == True and n == False:
        return df, eps
    elif errors == False and n == True:
        return df, n
    elif errors == True and n == True:
        return df, eps, n
    else:
        return df
예제 #19
0
def main():
    SRC_FILE = os.path.join(os.getcwd(), "deploy/namespace/namespace.yaml")
    DST_FILE = os.path.join(os.getcwd(), "build/namespace.yaml")
    with open(SRC_FILE, "r") as src:
        with open(DST_FILE, "w+") as dst:
            data = src.read()
            print("Deploying {}:\n{}".format(DST_FILE, data))
            dst.write(data)

    utils.apply(DST_FILE)
예제 #20
0
def main():
    utils.verify_build_directory(deploy_options.namespace)

    src_file = os.path.join(os.getcwd(),
                            'deploy/assisted-service-service.yaml')
    dst_file = os.path.join(os.getcwd(), 'build', deploy_options.namespace,
                            'assisted-service-service.yaml')
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            raw_data = src.read()
            raw_data = raw_data.replace('REPLACE_NAMESPACE',
                                        f'"{deploy_options.namespace}"')
            data = yaml.safe_load(raw_data)

            if deploy_options.port:
                for port_number_str, port_name in deploy_options.port:
                    port = {
                        "name": port_name,
                        "port": int(port_number_str),
                        "protocol": "TCP",
                        "targetPort": int(port_number_str)
                    }
                    data["spec"]["ports"].append(port)

            print("Deploying {}".format(dst_file))
            dst.write(yaml.dump(data))

    if deploy_options.apply_manifest:
        utils.apply(target=deploy_options.target,
                    namespace=deploy_options.namespace,
                    file=dst_file)
    # in case of OpenShift deploy ingress as well
    if deploy_options.target == "oc-ingress":
        hostname = utils.get_service_host('assisted-installer',
                                          deploy_options.target,
                                          deploy_options.domain,
                                          deploy_options.namespace)

        if deploy_options.disable_tls:
            template = "assisted-installer-ingress.yaml"
        else:
            print(
                "WARNING: On OpenShift, in order to change TLS redirection behavior update "
                "spec/tls/insecureEdgeTerminationPolicy (None|Allow|Redirect) "
                "in the corresponding OpenShift route")
            deploy_tls_secret.generate_secret(
                output_dir=os.path.join(os.getcwd(), "build"),
                service="assisted-service",
                san=hostname,
                namespace=deploy_options.namespace)
            template = "assisted-installer-ingress-tls.yaml"

        deploy_ingress(hostname=hostname,
                       namespace=deploy_options.namespace,
                       template_file=template)
예제 #21
0
def main():
    src_file = os.path.join(os.getcwd(), "deploy/s3/scality-deployment.yaml")
    dst_file = os.path.join(os.getcwd(), "build/scality-deployment.yaml")
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            print("Deploying {}".format(dst_file))
            dst.write(data)

    utils.apply("deploy/s3/scality-storage.yaml")
    utils.apply(dst_file)
def deploy_wiremock(deploy_options):
    docs = utils.load_yaml_file_docs(
        'deploy/wiremock/wiremock-deployment.yaml')
    utils.set_namespace_in_yaml_docs(docs, deploy_options.namespace)
    dst_file = utils.dump_yaml_file_docs('build/wiremock-deployment.yaml',
                                         docs)

    log.info('Deploying %s', dst_file)
    utils.apply(target=deploy_options.target,
                namespace=deploy_options.namespace,
                file=dst_file)
def main():
    deploy_options = handle_arguments()
    utils.set_profile(deploy_options.target, deploy_options.profile)

    with open(SRC_FILE, "r") as src:
        with open(DST_FILE, "w+") as dst:
            data = src.read()
            data = data.replace("REPLACE_DOMAINS", '"{}"'.format(deploy_options.base_dns_domains))
            data = data.replace("REPLACE_BASE_URL", utils.get_service_url(service=SERVICE,
                                                                          target=deploy_options.target,
                                                                          domain=deploy_options.domain,
                                                                          namespace=deploy_options.namespace,
                                                                          profile=deploy_options.profile,
                                                                          disable_tls=deploy_options.disable_tls))

            data = data.replace('REPLACE_NAMESPACE', deploy_options.namespace)
            data = data.replace('REPLACE_AUTH_ENABLED_FLAG', '"{}"'.format(deploy_options.enable_auth))
            data = data.replace('REPLACE_JWKS_URL', '"{}"'.format(deploy_options.jwks_url))
            data = data.replace('REPLACE_OCM_BASE_URL', '"{}"'.format(deploy_options.ocm_url))
            print("Deploying {}".format(DST_FILE))

            subsystem_versions = {"IMAGE_BUILDER": "ISO_CREATION",
                                  "IGNITION_GENERATE_IMAGE": "DUMMY_IGNITION"}

            versions = {"IMAGE_BUILDER": "assisted-iso-create",
                        "IGNITION_GENERATE_IMAGE": "assisted-ignition-generator",
                        "INSTALLER_IMAGE": "assisted-installer",
                        "CONTROLLER_IMAGE": "assisted-installer-controller",
                        "AGENT_DOCKER_IMAGE": "assisted-installer-agent",
                        "CONNECTIVITY_CHECK_IMAGE": "assisted-installer-agent",
                        "INVENTORY_IMAGE": "assisted-installer-agent"}
            for env_var_name, image_short_name in versions.items():
                if deploy_options.subsystem_test and env_var_name in subsystem_versions.keys():
                    image_fqdn = deployment_options.get_image_override(deploy_options, image_short_name, subsystem_versions[env_var_name])
                else:
                    image_fqdn = deployment_options.get_image_override(deploy_options, image_short_name, env_var_name)
                versions[env_var_name] = image_fqdn

            # Edge case for controller image override
            if os.environ.get("INSTALLER_IMAGE") and not os.environ.get("CONTROLLER_IMAGE"):
                versions["CONTROLLER_IMAGE"] = deployment_options.IMAGE_FQDN_TEMPLATE.format("assisted-installer-controller",
                    deployment_options.get_tag(versions["INSTALLER_IMAGE"]))

            versions["SELF_VERSION"] = deployment_options.get_image_override(deploy_options, "assisted-service", "SERVICE")
            deploy_tag = get_deployment_tag(deploy_options)
            if deploy_tag:
                versions["RELEASE_TAG"] = deploy_tag

            y = yaml.load(data)
            y['data'].update(versions)
            data = yaml.dump(y)
            dst.write(data)

    utils.apply(DST_FILE)
예제 #24
0
def deployer(src_file, topic):
    '''Wrapper for oc/kubectl apply -f'''
    src_file = os.path.join(os.getcwd(), src_file)
    dst_file = os.path.join(os.getcwd(), 'build', os.path.basename(src_file))
    with open(src_file) as fp:
        data = fp.read()
    data = data.replace('REPLACE_NAMESPACE', deploy_options.namespace)
    with open(dst_file, 'w') as fp:
        fp.write(data)
    print("Deploying {}: {}".format(topic, dst_file))
    utils.apply(dst_file)
예제 #25
0
def main():
    SRC_FILE = os.path.join(os.getcwd(), "deploy/s3/scality-deployment.yaml")
    DST_FILE = os.path.join(os.getcwd(), "build/scality-deployment.yaml")
    with open(SRC_FILE, "r") as src:
        with open(DST_FILE, "w+") as dst:
            data = src.read()
            print("Deploying {}:\n{}".format(DST_FILE, data))
            dst.write(data)

    utils.apply("deploy/s3/scality-storage.yaml")
    utils.apply(DST_FILE)
def deploy_ingress(hostname, namespace, template_file):
    src_file = os.path.join(os.getcwd(), "deploy", template_file)
    dst_file = os.path.join(os.getcwd(), "build", template_file)
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_NAMESPACE', namespace)
            data = data.replace("REPLACE_HOSTNAME", hostname)
            print("Deploying {}".format(dst_file))
            dst.write(data)
    utils.apply(dst_file)
예제 #27
0
def main():
    src_file = os.path.join(os.getcwd(), "deploy/roles/default_role.yaml")
    dst_file = os.path.join(os.getcwd(), "build/default_role.yaml")

    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            print("Deploying {}".format(dst_file))
            dst.write(data)

    utils.apply(dst_file)
def main():
    src_file = os.path.join(os.getcwd(), "deploy/s3/scality-configmap.yaml")
    dst_file = os.path.join(os.getcwd(), "build/scality-configmap.yaml")
    scality_url = "http://cloudserver-front:8000"
    with open(src_file, "r") as src:
        with open(dst_file, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_URL', scality_url)
            print("Deploying {}".format(dst_file))
            dst.write(data)

    utils.apply(dst_file)
예제 #29
0
def main():
    service_host = utils.get_service_host(SERVICE)
    service_port = utils.get_service_port(SERVICE)
    with open(SRC_FILE, "r") as src:
        with open(DST_FILE, "w+") as dst:
            data = src.read()
            data = data.replace("REPLACE_URL", '"{}"'.format(service_host))
            data = data.replace("REPLACE_PORT", '"{}"'.format(service_port))
            print("Deploying {}:\n{}".format(DST_FILE, data))
            dst.write(data)

    utils.apply(DST_FILE)
def main():
    scality_url = utils.get_service_url(SERVICE)
    scality_host = utils.get_service_host(SERVICE)
    with open(SRC_FILE, "r") as src:
        with open(DST_FILE, "w+") as dst:
            data = src.read()
            data = data.replace('REPLACE_URL', scality_url)
            data = data.replace('REPLACE_HOST_NAME', scality_host)
            print("Deploying {}:\n{}".format(DST_FILE, data))
            dst.write(data)

    utils.apply(DST_FILE)
예제 #31
0
파일: gateway.py 프로젝트: alexeycv/vk4xmpp
	def sendMessages(self, init=False):
		"""
		Sends messages from vk to xmpp and call message01 handlers
		Paramteres:
			init: needed to know if function called at init (add time or not)
		Plugins notice (msg01):
			If plugin returs None then message will not be sent by transport's core, it shall be sent by plugin itself
			Otherwise, if plugin returns string, it will be sent by transport's core
		"""
		with self.__sync:
			date = 0
			messages = self.vk.getMessages(20, self.lastMsgID)
			if not messages or not messages[0]:
				return None
			messages = sorted(messages[1:], sortMsg)
			for message in messages:
				if message["out"]:
					continue
				Stats["msgin"] += 1
				fromjid = vk2xmpp(message["uid"])
				body = uHTML(message["body"])
				iter = Handlers["msg01"].__iter__()
				for func in iter:
					try:
						result = func(self, message)
					except Exception:
						result = None
						crashLog("handle.%s" % func.__name__)
					if result is None:
						for func in iter:
							utils.apply(func, (self, message))
						break
					else:
						body += result
				else:
					if init:
						date = message["date"]
					sendMessage(Component, self.source, fromjid, escape("", body), date)
		if messages:
			self.lastMsgID = messages[-1]["mid"]
			try:
				self.updateLastMsgID(Semaphore)
			except sqlite3.OperationalError, e:
				logger.error("User:sendmessages error %s occurred while updating last message id (jid: %s)" % (str(e), self.source))
예제 #32
0
 def recognize(self, figure):
     self.X = [figure]
     iters = 0
     while iters<MAX_ITERS:
         new = apply(multiply(self.X, self.w), sign)
         if self.X == new:
            break
         self.X = new
         iters+=1
     if iters==MAX_ITERS:
         return (False, self.X, iters)
     return (True, self.X, iters)