Beispiel #1
0
def clean_up():
    # Connect to the ComodIT API
    client = Client(config.endpoint, config.username, config.password)
    org = client.get_organization(config.organization)

    print "Cleaning up ComodIT..."

    # Delete environment (if empty)
    env = org.environments().delete('Openshift')

    # Delete applications
    org.applications().delete('openshift-bind-server')
    org.applications().delete('openshift-broker')
    org.applications().delete('openshift-client')
    org.applications().delete('openshift-dhcp-dns-config')
    org.applications().delete('openshift-mcollective-client')
    org.applications().delete('openshift-mcollective-node')
    org.applications().delete('openshift-mongodb')
    org.applications().delete('openshift-cartridges')
    org.applications().delete('openshift-node')
    org.applications().delete('openshift-rabbitmq-server')



    print "Done."
Beispiel #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")

    # 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)
Beispiel #3
0
def clean_up():
    # Connect to the ComodIT API
    client = Client(config.endpoint, config.username, config.password)
    org = client.get_organization(config.organization)

    print "Cleaning up ComodIT..."

    # Delete environment (if empty)
    env = org.environments().delete('Render Farm')

    # Delete applications
    org.applications().delete('NFS Server')
    org.applications().delete('NFS Client')
    org.applications().delete('Blender')

    print "Done."
Beispiel #4
0
def cleanup():
    # Connect to the ComodIT API
    client = Client(config['api'], config['username'], config['password'])
    org = client.get_organization(config['organization'])

    print "Cleaning up ComodIT..."

    # Delete applications
    for app in config['applications']:
        print "Removing application %s" % app["name"]
        app_name = app['name'].split('/')[-1]
        try:
            org.applications().delete(app_name)
        except Exception as e:
            print "Failed to remove application %s with error %s." % app['name'], e

    print "Done."
Beispiel #5
0
def clean_up():
    # Connect to the ComodIT API
    client = Client(config.endpoint, config.username, config.password)
    org = client.get_organization(config.organization)

    print "Cleaning up ComodIT..."

    # Delete environment (if empty)
    env = org.environments().delete('Cluster')

    # Delete applications
    org.applications().delete('Ceph Configuration')
    org.applications().delete('Ceph Monitor')
    org.applications().delete('Ceph Metadata')
    org.applications().delete('Ceph Object Store')
    org.applications().delete('Ceph Client')

    print "Done."
Beispiel #6
0
def setup_organization():
    # Connect to the ComodIT API
    client = Client(config['api'], config['username'], config['password'])
    org = None

    if config['organization']:
        org = client.get_organization(config['organization'])
    else:
        orgs = client.organizations().list()
        if orgs == 1:
            org = orgs[0]
        elif orgs == 0:
            raise FatalException("No organization found.")
        else:
            raise FatalException("Multiple organization defined. "
                    "Please specify one in your ~/.comoditrc with the key "
                    "\"default_organization\"")
    return org
Beispiel #7
0
def setup():
    # Connect to the ComodIT API
    client = Client(config.endpoint, config.username, config.password)
    org = client.get_organization(config.organization)

    print "Setting up ComodIT..."

    # Create environment (if not already present)
    try:
        org.environments().create("Cluster", "Environment containing the web cluster.")
    except:
        pass

    # Import applications
    importer = Import()
    importer.import_application(org, 'db')
    importer.import_application(org, 'lb')
    importer.import_application(org, 'web')

    print "Done."
Beispiel #8
0
def setup():
    # Connect to the ComodIT API
    client = Client(config.endpoint, config.username, config.password)
    org = client.get_organization(config.organization)

    print "Setting up ComodIT..."

    # Create environment (if not already present)
    try:
        org.environments().create("Render Farm", "Environment containing the render farm.")
    except:
        pass

    # Import applications
    importer = Import()
    importer.import_application(org, 'nfs-server')
    importer.import_application(org, 'nfs-client')
    importer.import_application(org, 'blender')

    print "Done."
Beispiel #9
0
def clean_up():
    # Connect to the ComodIT API
    client = Client(config.endpoint, config.username, config.password)
    org = client.get_organization(config.organization)

    print "Cleaning up ComodIT..."

    # Delete environment (if empty)
    try:
        env = org.get_environment('Cluster')
        if len(env.hosts().list()) == 0:
            env.delete()
    except EntityNotFoundException:
        pass

    # Delete applications
    org.applications().delete(data.db['name'])
    org.applications().delete(data.lb['name'])
    org.applications().delete(data.web['name'])

    print "Done."
Beispiel #10
0
def setup():
    # Connect to the ComodIT API
    client = Client(config.endpoint, config.username, config.password)
    org = client.get_organization(config.organization)

    print "Setting up ComodIT..."

    # Create environment (if not already present)
    try:
        org.environments().create("Openshift", "Environment containing the openshift cluster.")
    except:
        pass

    # Import applications
    importer = Import()
    importer.import_application(org, 'openshift-bind-server')
    importer.import_application(org, 'openshift-broker')
    importer.import_application(org, 'openshift-client')
    importer.import_application(org, 'openshift-dhcp-dns-config')
    importer.import_application(org, 'openshift-mcollective-client')
    importer.import_application(org, 'openshift-mcollective-node')
    importer.import_application(org, 'openshift-mongodb')
    importer.import_application(org, 'openshift-node')
    importer.import_application(org, 'openshift-cartridges')
    importer.import_application(org, 'openshift-rabbitmq-server')

    # Update repositories
    if hasattr(config, "repo"):
      updaterepo(org.get_application("openshift-broker"), config.repo)
      updaterepo(org.get_application("openshift-node"), config.repo)
      updaterepo(org.get_application("openshift-client"), config.repo)

    # Append cartridges
    if hasattr(config, "cartridges"):
        app = org.get_application("openshift-cartridges")
        for cart in config.cartridges:
          app.add_package(Package({"name": cart}))
        app.update()

    print "Done."
Beispiel #11
0
def setup():
    # Connect to the ComodIT API
    client = Client(config['api'], config['username'], config['password'])
    org = client.get_organization(config['organization'])

    print "Setting up ComodIT..."

    # Create environment (if not already present)
    try:
        org.environments().create("Development", "Development environment.")
    except:
        pass

    importer = Import()
    for app in config['applications']:
        print "Uploading application %s" % app["name"]
        try:
            importer.import_application(org, app['name'])
        except Exception as e:
            print "Failed to upload applicatin %s with error %s." % (app['name'], e)

    print "Done."
Beispiel #12
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)