Exemple #1
0
def deploy():

    # Script
    print "Deploying Development Host"
    start_time = time.time()

    # Connect to the ComodIT API
    client = Client(config["api"], config["username"], config["password"])
    org = client.get_organization(config["organization"])
    env = org.get_environment("Development")

    # Deploy host
    host = create_host(env, config["vm"]["name"], config["platform"], config["distribution"], [])
    host.provision()

    # Download gPXE ISO
    if not config["vm"]["iso"] or not os.path.exists(config["vm"]["iso"]):
        config["vm"]["iso"] = download_iso(
            config["gpxe_url"],
            config["vm"]["name"],
            org.access_key,
            org.secret_key,
            org.name,
            urlparse(config["api"]).netloc,
        )

    # Define the vm
    print "Creating the virtual machine"
    success = create_combox(config["vm"])
    if not success:
        sys.exit(-1)

    # Start the vm
    print "Starting the virtual machine"
    fork_cmd('virtualbox --startvm "%s"' % config["vm"]["name"])

    # Wait for server to be ready
    print "Waiting for host to be ready"
    host.wait_for_state("READY", config["time_out"])

    # Wait for hostname to be ready
    print "Waiting for hostname to be ready"
    host.get_instance().wait_for_address()

    # Install applications
    for app in config["applications"]:
        app_name = app["name"].split("/")[-1]
        print "Installing application %s" % app_name
        host.install(app_name, app["settings"])
        host.wait_for_state("READY", config["time_out"])

    # Goodbye
    total_time = time.time() - start_time
    print "Deployment time: " + str(total_time)
Exemple #2
0
def deploy():

    # Script
    print "Deploying Development Host"
    start_time = time.time()

    # Connect to the ComodIT API
    client = Client(config['api'], config['username'], config['password'])
    org = client.get_organization(config['organization'])
    env = org.get_environment('Development')
    try:
        plat = org.get_platform(config['platform']['name'])
    except:
        found_platform = False
        print "Looking for a physical platform..."
        for pl in org.platforms().list():
            if pl.driver.class_name == "com.guardis.cortex.server.driver.PxeDriver":
                config['platform']['name'] = pl.driver.class_name
                print "Found physical platform. Using \"%s\"" % pl.driver.name
                found_platform = True
        if not found_platform:
            sys.exit("Platform not found.")



    # Deploy host
    host = create_host(env, config['vm']['name'], config['platform'], config['distribution'], [])
    host.provision()

    # Download gPXE ISO
    if 'iso' not in config['vm'] or not os.path.exists(config['vm']['iso']):
        config['vm']['iso'] = download_iso(config['gpxe_url'],
                                           config['vm']['name'],
                                           org.access_key,
                                           org.secret_key,
                                           org.name,
                                           urlparse(config['api']).netloc)

    # Define the vm
    print "Creating the virtual machine"
    success = create_combox(config['vm'])
    if not success:
        sys.exit(-1)

    # Start the vm
    print "Starting the virtual machine"
    fork_cmd('virtualbox --startvm "%s"' % config['vm']['name'])

    # Wait for server to be ready
    print "Waiting for host to be ready"
    host.wait_for_state('READY', config['time_out'])

    # Wait for hostname to be ready
    print "Waiting for hostname to be ready"
    host.get_instance().wait_for_address()

    # Install applications
    for app in config['applications']:
        app_name = app['name'].split('/')[-1]
        print "Installing application %s" % app_name
        host.install(app_name, app['settings'])
        host.wait_for_state('READY', config['time_out'])

    # Goodbye
    total_time = time.time() - start_time
    print "Deployment time: " + str(total_time)
Exemple #3
0
def start():
    print "Starting virtual machine"
    fork_cmd('VBoxManage startvm --type headless "%s"' % config["vm"]["name"])