예제 #1
0
def uninstall(jazz_stackprefix, jenkins_url, jenkins_user, jenkins_api_token,
              jazz_apiendpoint, jazz_username, jazz_password,
              azure_subscription_id, azure_location, azure_client_id,
              azure_client_secret, azure_tenant_id, azure_company_name,
              azure_company_email):
    if not azure_installed(jazz_username, jazz_password, jazz_apiendpoint):
        print(
            "Azure is not added to this Jazz installation. Uninstall impossible."
        )
        sys.exit(1)

    click.secho(
        '\n\nThis will remove {0} functionality from your Jazz deployment'.
        format(featureName),
        fg='blue')
    terraformStateSanityCheck("extensions/azure")
    destroy_terraform(jazz_stackprefix, azure_location, azure_subscription_id,
                      azure_client_id, azure_client_secret, azure_tenant_id,
                      azure_company_name, azure_company_email)
    update_config("AZURE", {}, jazz_username, jazz_password, jazz_apiendpoint)
    for creds in [
            'AZ_CLIENTID', 'AZ_PASSWORD', 'AZ_SUBSCRIPTIONID', 'AZ_TENANTID'
    ]:
        deleteCredential(jenkins_url, jenkins_user, jenkins_api_token, creds)
    # Trigger create-serverless-service api
    createSSJobUrl = "job/build-pack-api/buildWithParameters?token=jazz-101-job&service_name" \
                     "=create-serverless-service&domain=jazz&scm_branch=master"
    startJob(jenkins_url, jenkins_user, jenkins_api_token, createSSJobUrl)
    # Trigger metrics api
    metricJobUrl = "job/build-pack-api/buildWithParameters?token=jazz-101-job&service_name=metrics&domain" \
                   "=jazz&scm_branch=master"
    startJob(jenkins_url, jenkins_user, jenkins_api_token, metricJobUrl)
    # Trigger jazz ui
    startJob(jenkins_url, jenkins_user, jenkins_api_token,
             "job/jazz_ui/buildWithParameters?token=jazz-101-job")
예제 #2
0
def uninstall(region, stackprefix, jazz_userpass, jazz_apiendpoint,
              jenkins_url, jenkins_userpass):
    click.secho(
        '\n\nThis will remove {0} functionality from your Jazz deployment'.
        format(featureName),
        fg='blue')
    terraformStateSanityCheck("extensions/tvault")

    jazz_userpass_list = ''.join(list(jazz_userpass)).split()
    jazz_username, jazz_password = jazz_userpass_list[0], jazz_userpass_list[1]
    jenkins_userpass_list = ''.join(list(jenkins_userpass)).split()
    jenkins_username, jenkins_password = jenkins_userpass_list[
        0], jenkins_userpass_list[1]
    tvault_username = re.sub('[^a-zA-Z0-9_-]', '-', jazz_username)
    runTerraform(region, stackprefix, jazz_password, tvault_username, False)
    deleteCredential(jenkins_url, jenkins_username, jenkins_password,
                     "TVAULT_ADMIN")
    update_config("TVAULT", reset_tvault_json(), jazz_username, jazz_password,
                  jazz_apiendpoint)
    # Trigger t-vault, usermanagement, acl api
    for jobs in ["t-vault", "usermanagement", "acl"]:
        jobUrl = "job/build-pack-api/buildWithParameters?token=jazz-101-job&service_name=" + jobs + "&domain" \
                 "=jazz&scm_branch=master"
        startJob(jenkins_url, jenkins_username, jenkins_password, jobUrl)

    # Trigger environment-event-handler function
    for jobs in ["environment-event-handler"]:
        jobUrl = "job/build-pack-function/buildWithParameters?token=jazz-101-job&service_name=" + jobs + "&domain" \
                 "=jazz&scm_branch=master"
        startJob(jenkins_url, jenkins_username, jenkins_password, jobUrl)
    # Trigger jazz ui
    startJob(jenkins_url, jenkins_username, jenkins_password,
             "job/jazz_ui/buildWithParameters?token=jazz-101-job")
예제 #3
0
def install(regions, stackprefix, aws_accesskey, aws_secretkey,
            jazz_apiendpoint, jazz_userpass, jenkins_url, jenkins_userpass):
    click.secho(
        '\n\nThis will install {0} functionality into your Jazz deployment'.
        format(featureName),
        fg='blue')
    tags = [{
        'Key': 'Name',
        'Value': stackprefix
    }, {
        'Key': 'Application',
        'Value': 'Jazz'
    }, {
        'Key': 'JazzInstance',
        'Value': stackprefix
    }]
    regions_list = ' '.join(list(regions)).split()
    jazz_userpass_list = ''.join(list(jazz_userpass)).split()
    jazz_username, jazz_password = jazz_userpass_list[0], jazz_userpass_list[1]
    jenkins_userpass_list = ''.join(list(jenkins_userpass)).split()
    jenkins_username, jenkins_password = jenkins_userpass_list[
        0], jenkins_userpass_list[1]
    account_json, credential_id = deploy_core_service(
        aws_accesskey, aws_secretkey, jazz_username, jazz_password,
        jazz_apiendpoint, regions_list, stackprefix, tags)
    if account_json != '':
        # Store the CREDENTIAL_ID in jenkins
        setCredential(jenkins_url, jenkins_username, jenkins_password,
                      credential_id, aws_accesskey, aws_secretkey, "aws")
        update_config("AWS.ACCOUNTS", account_json, jazz_username,
                      jazz_password, jazz_apiendpoint)
    # Trigger jazz ui
    startJob(jenkins_url, jenkins_username, jenkins_password,
             "job/jazz_ui/buildWithParameters?token=jazz-101-job")
예제 #4
0
def uninstall(region, stackprefix, jazz_userpass, jazz_apiendpoint,
              jenkins_url, jenkins_userpass):
    click.secho(
        '\n\nThis will remove {0} functionality from your Jazz deployment'.
        format(featureName),
        fg='blue')
    terraformStateSanityCheck()

    # TODO remove this entire module when the terraform bug is fixed
    click.secho('\nRestoring old role to gateway function', fg='blue')

    # Restore old role first, before we destroy the Terraform resources
    restoreOldRoleToExistingFunctionWithCLI(stackprefix + "-" +
                                            gatewayFunctionName)
    jazz_userpass_list = ''.join(list(jazz_userpass)).split()
    jazz_username, jazz_password = jazz_userpass_list[0], jazz_userpass_list[1]
    jenkins_userpass_list = ''.join(list(jenkins_userpass)).split()
    jenkins_username, jenkins_password = jenkins_userpass_list[
        0], jenkins_userpass_list[1]
    runTerraform(region, stackprefix, False)
    update_config("APIGEE.ENABLE_APIGEE", 'false', jazz_username,
                  jazz_password, jazz_apiendpoint)
    # Trigger metrics api
    metricJobUrl = "job/build-pack-api/buildWithParameters?token=jazz-101-job&service_name=metrics&domain" \
                   "=jazz&scm_branch=master"
    startJob(jenkins_url, jenkins_username, jenkins_password, metricJobUrl)
    # Trigger jazz ui
    startJob(jenkins_url, jenkins_username, jenkins_password,
             "job/jazz_ui/build?token=jazz-101-job")
예제 #5
0
def install(splunk_endpoint, splunk_token, splunk_index, jazz_apiendpoint,
            jazz_userpass):
    click.secho(
        '\n\nThis will install {0} functionality into your Jazz deployment'.
        format(featureName),
        fg='blue')
    jazz_userpass_list = ''.join(list(jazz_userpass)).split()
    jazz_username, jazz_password = jazz_userpass_list[0], jazz_userpass_list[1]
    splunk_json = prepare_splunk_json(splunk_endpoint, splunk_token,
                                      splunk_index)
    update_config("SPLUNK", splunk_json, jazz_username, jazz_password,
                  jazz_apiendpoint)
예제 #6
0
def install(region, stackprefix, jazz_apiendpoint, jazz_userpass, jenkins_url,
            jenkins_userpass, apigee_host, apigee_org, apigee_prod_env,
            apigee_dev_env, apigee_svc_prod_host, apigee_svc_dev_host,
            apigee_userpass):
    click.secho('\n\nThis will install {0} functionality into your Jazz \
                deployment'.format(featureName),
                fg='blue')
    click.secho(
        '\nThis installer will use whatever AWS credentials you have configured by \
                running `aws configure`',
        fg='green')
    click.secho(
        '\nPlease make sure you are using the same AWS credentials you used to \
                install your Jazz deployment',
        fg='green')
    # Run terraform first, as we need it's output
    runTerraform(region, stackprefix, True)
    # TODO remove this entire module when the terraform bug is fixed
    click.secho('\nLinking new role to existing gateway function', fg='blue')
    linkNewRoleToExistingFunctionWithCLI(stackprefix + "-" +
                                         gatewayFunctionName)
    jazz_userpass_list = ''.join(list(jazz_userpass)).split()
    jazz_username, jazz_password = jazz_userpass_list[0], jazz_userpass_list[1]
    jenkins_userpass_list = ''.join(list(jenkins_userpass)).split()
    jenkins_username, jenkins_password = jenkins_userpass_list[
        0], jenkins_userpass_list[1]
    apigee_userpass_list = ''.join(list(apigee_userpass)).split()
    apigee_username, apigee_password = apigee_userpass_list[
        0], apigee_userpass_list[1]
    install_proxy(getTerraformOutputVar("apigee-lambda-user-secret-key"),
                  getTerraformOutputVar("apigee-lambda-user-id"), region,
                  getTerraformOutputVar("apigee-lambda-gateway-func-arn"),
                  apigee_host, apigee_org, apigee_prod_env, apigee_dev_env,
                  "1.0", apigee_username, apigee_password)
    credential_id = "ApigeeforJazz"
    apigee_json = prepare_apigee_json(apigee_host, credential_id,
                                      apigee_prod_env, apigee_dev_env,
                                      apigee_svc_prod_host,
                                      apigee_svc_dev_host, apigee_org)

    update_config("APIGEE", apigee_json, jazz_username, jazz_password,
                  jazz_apiendpoint)

    # Store the CREDENTIAL_ID in jenkins
    setCredential(jenkins_url, jenkins_username, jenkins_password,
                  credential_id, apigee_username, apigee_password)
    # Trigger metrics api
    metricJobUrl = "job/build-pack-api/buildWithParameters?token=jazz-101-job&service_name=metrics&domain" \
                   "=jazz&scm_branch=master"
    startJob(jenkins_url, jenkins_username, jenkins_password, metricJobUrl)
    # Trigger jazz ui
    startJob(jenkins_url, jenkins_username, jenkins_password,
             "job/jazz_ui/build?token=jazz-101-job")
예제 #7
0
def install(region, stackprefix, jazz_apiendpoint, jazz_userpass, jenkins_url,
            jenkins_userpass, network_range):
    click.secho('\n\nThis will install {0} functionality into your Jazz \
                deployment'.format(featureName),
                fg='blue')
    click.secho(
        '\nThis installer will use whatever AWS credentials you have configured by \
                running `aws configure`',
        fg='green')
    click.secho(
        '\nPlease make sure you are using the same AWS credentials you used to \
                install your Jazz deployment',
        fg='green')
    jazz_userpass_list = ''.join(list(jazz_userpass)).split()
    jazz_username, jazz_password = jazz_userpass_list[0], jazz_userpass_list[1]
    jenkins_userpass_list = ''.join(list(jenkins_userpass)).split()
    jenkins_username, jenkins_password = jenkins_userpass_list[
        0], jenkins_userpass_list[1]
    tvault_username = re.sub('[^a-zA-Z0-9_-]', '-', jazz_username)
    # Run terraform first, as we need it's output
    runTerraform(region, stackprefix, jazz_password, tvault_username, True,
                 network_range)
    # Store the CREDENTIAL_ID in jenkins
    setCredential(jenkins_url, jenkins_username, jenkins_password,
                  "TVAULT_ADMIN", tvault_username, jazz_password)
    update_config("TVAULT", prepare_tvault_json(), jazz_username,
                  jazz_password, jazz_apiendpoint)
    # Trigger t-vault, usermanagement, acl api
    for jobs in ["t-vault", "usermanagement", "acl"]:
        jobUrl = "job/build-pack-api/buildWithParameters?token=jazz-101-job&service_name=" + jobs + "&domain" \
                 "=jazz&scm_branch=master"
        startJob(jenkins_url, jenkins_username, jenkins_password, jobUrl)
    # Trigger environment-event-handler function
    for jobs in ["environment-event-handler"]:
        jobUrl = "job/build-pack-function/buildWithParameters?token=jazz-101-job&service_name=" + jobs + "&domain" \
                 "=jazz&scm_branch=master"
        startJob(jenkins_url, jenkins_username, jenkins_password, jobUrl)
    # Trigger jazz ui
    startJob(jenkins_url, jenkins_username, jenkins_password,
             "job/jazz_ui/buildWithParameters?token=jazz-101-job")
예제 #8
0
def install(jazz_stackprefix, jenkins_url, jenkins_user, jenkins_api_token,
            jazz_apiendpoint, jazz_username, jazz_password,
            azure_subscription_id, azure_location, azure_client_id,
            azure_client_secret, azure_tenant_id, azure_company_name,
            azure_company_email, azure_apim_dev_sku, azure_apim_stage_sku,
            azure_apim_prod_sku):
    click.secho(
        '\n\nThis will install {0} functionality into your Jazz deployment'.
        format(featureName),
        fg='blue')
    if azure_installed(jazz_username, jazz_password, jazz_apiendpoint):
        print(
            "You are attempting to install Azure into a Jazz system that already has Azure installed.\n"
            "If this is an error, please run 'setup.py uninstall' to remove the existing installation"
        )
        sys.exit(1)
    click.secho(
        '\nThis installer will use whatever AWS credentials you have configured by \
                running `aws configure`',
        fg='green')
    click.secho(
        '\nPlease make sure you are using the same AWS credentials you used to \
                install your Jazz deployment',
        fg='green')

    # Run terraform first, as we need it's output
    apply_terraform(jazz_stackprefix, azure_location, azure_subscription_id,
                    azure_client_id, azure_client_secret, azure_tenant_id,
                    azure_company_name, azure_company_email,
                    azure_apim_dev_sku, azure_apim_stage_sku,
                    azure_apim_prod_sku)
    azure_json = prepare_azure_json(azure_location, azure_subscription_id)
    update_config("AZURE", azure_json, jazz_username, jazz_password,
                  jazz_apiendpoint)
    for creds in [{
            "id": 'AZ_CLIENTID',
            "value": azure_client_id
    }, {
            "id": 'AZ_PASSWORD',
            "value": azure_client_secret
    }, {
            "id": 'AZ_SUBSCRIPTIONID',
            "value": azure_subscription_id
    }, {
            "id": 'AZ_TENANTID',
            "value": azure_tenant_id
    }]:
        setCredential(jenkins_url, jenkins_user, jenkins_api_token,
                      creds['id'], creds['id'], creds['value'])

    # Trigger create-serverless-service api
    createSSJobUrl = "job/build-pack-api/buildWithParameters?token=jazz-101-job&service_name" \
                     "=create-serverless-service&domain=jazz&scm_branch=master"
    startJob(jenkins_url, jenkins_user, jenkins_api_token, createSSJobUrl)
    # Trigger metrics api
    metricJobUrl = "job/build-pack-api/buildWithParameters?token=jazz-101-job&service_name=metrics&domain" \
                   "=jazz&scm_branch=master"
    startJob(jenkins_url, jenkins_user, jenkins_api_token, metricJobUrl)
    # Trigger jazz ui
    startJob(jenkins_url, jenkins_user, jenkins_api_token,
             "job/jazz_ui/buildWithParameters?token=jazz-101-job")