コード例 #1
0
ファイル: mayor.py プロジェクト: Chaffelson/whoville
def purgeDeployment():
    horton.cbd = infra.get_cloudbreak(purge=False, create_wait=0, create=False)
    if horton.cbd:
        init_cbreak_infra()
        deploy.purge_cloudbreak(for_reals=True, ns=horton.namespace)
        return "Purge Complete"
    else:
        return Response("", status=404)
コード例 #2
0
ファイル: mayor.py プロジェクト: mikchaos/whoville
def step_2_init_infra(create_wait=0):
    init_start_ts = _dt.utcnow()
    log.info("------------- Getting Environment at [%s]", init_start_ts)
    horton.cbd = infra.get_cloudbreak(purge=horton.global_purge,
                                      create_wait=create_wait)
    log.info("------------- Connecting to Environment")
    public_ip = horton.cbd.public_ips[0]
    cbd_url = 'https://' + public_ip + '/cb/api'
    cad_url = 'https://' + public_ip + ':7189'
    log.info("Setting Cloudbreak endpoint to %s", cbd_url)
    utils.set_endpoint(cbd_url)
    log.info("Setting Altus Director endpoint to %s", cad_url)
    utils.set_endpoint(cad_url)
    log.info("------------- Authenticating to Cloudbreak")
    cbd_auth_success = security.service_login(
        service='cloudbreak',
        username=config.profile['email'],
        password=security.get_secret('ADMINPASSWORD'),
        bool_response=False)
    if not cbd_auth_success:
        raise ConnectionError("Couldn't login to Cloudbreak")
    else:
        log.info('Logged into Cloudbreak at [%s]', cbd_url)
    # log.info("------------- Authenticating to Altus Director")
    # cad_auth_success = security.service_login(
    #     service='director',
    #     username=config.profile['username'],
    #     password=security.get_secret('ADMINPASSWORD'),
    #     bool_response=False
    # )
    # if not cad_auth_success:
    #     raise ConnectionError("Couldn't login to Director")
    # else:
    #     log.info('Logged into Director at [%s]', cad_url)
    # Cloudbreak may have just booted and not be ready for queries yet
    log.info("Waiting for Cloudbreak API Calls to be available")
    utils.wait_to_complete(deploy.list_blueprints,
                           bool_response=True,
                           whoville_delay=5,
                           whoville_max_wait=120)
    # # Director may not be ready for queries yet
    # log.info("Waiting for Altus Director API Calls to be available")
    # utils.wait_to_complete(
    #     director.list_environments,
    #     bool_response=True,
    #     whoville_delay=5,
    #     whoville_max_wait=120
    # )
    log.info("------------- Setting Deployment Credential")
    horton.cred = deploy.get_credential(config.profile['namespace'] +
                                        'credential',
                                        create=True,
                                        purge=horton.global_purge)
    init_finish_ts = _dt.utcnow()
    diff_ts = init_finish_ts - init_start_ts
    log.info("Completed Infrastructure Init at [%s] after [%d] seconds",
             init_finish_ts, diff_ts.seconds)
コード例 #3
0
ファイル: mayor.py プロジェクト: Chaffelson/whoville
def getCredentials():
    horton.cbd = infra.get_cloudbreak(purge=False, create_wait=0, create=False)
    if horton.cbd:
        init_cbreak_infra()
        if horton.cbcred:
            var = {
                'platform': horton.cbcred.cloud_platform,
                'name': horton.cbcred.name
            }
            return json.dumps(var)
        else:
            return Response("", status=404)
    else:
        return Response("", status=404)
コード例 #4
0
ファイル: mayor.py プロジェクト: johnwhitmore/whoville
def init_cbreak_infra(create=True, create_wait=0):
    init_start_ts = _dt.utcnow()
    log.info("------------- Getting Environment at [%s]", init_start_ts)
    horton.cbd = infra.get_cloudbreak(purge=horton.global_purge,
                                      create_wait=create_wait,
                                      create=create)
    if not horton.cbd:
        if create:
            # Create has failed, throw error
            raise ValueError(
                "Cloudbreak Create requested but failed, exiting...")
        else:
            return None
    else:
        log.info("Found existing Cloudbreak in Namespace, connecting...")
    log.info("------------- Connecting to Environment")
    if horton.cbd.public_ips:
        public_ip = horton.cbd.public_ips[0]
    else:
        public_ip = horton.cbd.name + config.profile['platform']['domain']
    cbd_url = 'https://' + public_ip + '/cb/api'
    cad_url = 'https://' + public_ip + ':7189'
    log.info("Setting Cloudbreak endpoint to %s", cbd_url)
    utils.set_endpoint(cbd_url)
    log.info("Setting Altus Director endpoint to %s", cad_url)
    utils.set_endpoint(cad_url)
    log.info("------------- Authenticating to Cloudbreak")
    cbd_auth_success = security.service_login(
        service='cloudbreak',
        username=config.profile['email'],
        password=security.get_secret('ADMINPASSWORD'),
        bool_response=False)
    if not cbd_auth_success:
        raise ConnectionError("Couldn't login to Cloudbreak")
    else:
        log.info('Logged into Cloudbreak at [%s]', cbd_url)
    log.info("------------- Authenticating to Altus Director")
    cad_auth_success = security.service_login(
        service='director',
        username=config.profile['username'],
        password=security.get_secret('ADMINPASSWORD'),
        bool_response=False)
    if not cad_auth_success:
        raise ConnectionError("Couldn't login to Director")
    else:
        log.info('Logged into Director at [%s]', cad_url)
    # Cloudbreak may have just booted and not be ready for queries yet
    log.info("Waiting for Cloudbreak API Calls to be available")
    utils.wait_to_complete(deploy.list_blueprints,
                           bool_response=True,
                           whoville_delay=5,
                           whoville_max_wait=120)
    # Director may not be ready for queries yet
    log.info("Waiting for Altus Director API Calls to be available")
    utils.wait_to_complete(director.list_environments,
                           bool_response=True,
                           whoville_delay=5,
                           whoville_max_wait=120)
    # Validating Cloudbreak version
    if not deploy.check_cloudbreak_version():
        raise ValueError(
            "Cloudbreak server is older than configured minimum version of %s",
            str(config.cb_ver))
    # Creating Environment Credentials
    log.info("------------- Setting Deployment Credential")
    log.info("Ensuring Credential for Cloudbreak")
    horton.cbcred = deploy.get_credential(config.profile['namespace'] +
                                          'credential',
                                          create=True,
                                          purge=horton.global_purge)
    if ((config.profile['platform']['provider'] == 'EC2')
            or (config.profile['platform']['provider'] == 'GCE')):
        log.info("Ensuring Environment Credential for Director")
        horton.cadcred = director.get_environment()
    init_finish_ts = _dt.utcnow()
    diff_ts = init_finish_ts - init_start_ts
    log.info("Completed Infrastructure Init at [%s] after [%d] seconds",
             init_finish_ts, diff_ts.seconds)
コード例 #5
0
ファイル: mayor.py プロジェクト: Chaffelson/whoville
def getCB():
    horton.cbd = infra.get_cloudbreak(purge=False, create_wait=0, create=False)
    if horton.cbd:
        return json.dumps(horton.cbd.public_ips)
    else:
        return Response("", status=404)