Exemple #1
0
def openstack(env=None, **kwargs):
    """
usage: juice openstack

Launch OpenStack.
    """
    # Generate inventory
    extra_vars = {
        "db": env['db'],
    }
    # use deploy of each role
    extra_vars.update({"enos_action": "deploy"})
    run_ansible('openstack.yml', extra_vars=extra_vars)
Exemple #2
0
def stress(env=None, **kwargs):
    """
usage: juice stress

Launch sysbench tests.
    """
    # Generate inventory
    extra_vars = {
        "registry": env["config"]["registry"],
        "db": env.get('db', 'cockroachdb'),
        "enos_action": "stress"
    }
    # use deploy of each role
    run_ansible('stress.yml', extra_vars=extra_vars)
Exemple #3
0
def openstack(env=None, **kwargs):
    """
usage: juice openstack

Launch OpenStack.
    """
    # Generate inventory
    extra_vars = {
        "registry": env["config"]["registry"],
        "db": env.get('db', 'cockroachdb'),
    }
    # use deploy of each role
    extra_vars.update({"enos_action": "deploy"})
    run_ansible('openstack.yml', extra_vars=extra_vars)
    env["tasks_ran"].append('openstack')
Exemple #4
0
def prepare(env=None, **kwargs):
    """Configure the resources, requires both g5k and inventory
executions

    """
    # Generate inventory
    extra_vars = {
        "registry": env["config"]["registry"],
        "db": env['db'],
        # Set monitoring to True by default
        "enable_monitoring": env['config'].get('enable_monitoring', True)
    }
    # use deploy of each role
    extra_vars.update({"enos_action": "deploy"})
    run_ansible('scaffolding.yml', extra_vars=extra_vars)
    #   run_ansible('scaffolding_rolling.yml', extra_vars=extra_vars)
    env["tasks_ran"].append('prepare')
Exemple #5
0
def rally(files, directory, burst, env=None, **kwargs):
    """
usage: juice rally [--files FILE... | --directory DIRECTORY] [--burst]

Benchmark the Openstack

  --files FILE           Files to use for rally scenarios (name must be a path
from rally scenarios folder).
  --directory DIRECTORY  Directory that contains rally scenarios. [default:
keystone]
  --burst                Use burst or not
    """
    logging.info("Launching rally using scenarios: %s" % (', '.join(files)))
    logging.info("Launching rally using all scenarios in %s directory.",
                 directory)

    if burst:
        rally = list(
            map(
                operator.attrgetter('address'),
                reduce(operator.add, [
                    hosts for role, hosts in env['roles'].items()
                    if role.startswith('database')
                ])))
    else:
        rally = [
            hosts[1].address for role, hosts in env['roles'].items()
            if role.startswith('database')
        ]
    env['rally_nodes'] = rally
    extra_vars = {"registry": env["config"]["registry"], "rally_nodes": rally}
    if files:
        extra_vars.update({"rally_files": files})
    else:
        extra_vars.update({"rally_directory": directory})

    # use deploy of each role
    extra_vars.update({"enos_action": "deploy"})
    run_ansible('rally.yml', extra_vars=extra_vars)
    env["tasks_ran"].append('rally')
Exemple #6
0
def destroy(env=None, **kwargs):
    """
usage: juice destroy

Destroy all the running dockers (not destroying the resources), requires g5k
and inventory executions
    """
    extra_vars = {}
    # Call destroy on each component
    extra_vars.update({
        "enos_action":
        "destroy",
        "db":
        env.get('db', 'cockroachdb'),
        "tasks_ran":
        env["tasks_ran"],
        # Set monitoring to True by default
        "enable_monitoring":
        env['config'].get('enable_monitoring', True),
        "rally_nodes":
        env.get('rally_nodes', [])
    })
    run_ansible('scaffolding.yml', extra_vars=extra_vars)
    run_ansible('openstack.yml', extra_vars=extra_vars)
    run_ansible('rally.yml', extra_vars=extra_vars)
    env["tasks_ran"].append('destroy')
Exemple #7
0
def backup(env=None, **kwargs):
    """
usage: juice backup

Backup the environment, requires g5k, inventory and prepare executions
    """
    db = env.get('db', 'cockroachdb')
    nb_nodes = len(env["roles"]["database"])
    latency = env["latency"]
    extra_vars = {
        "enos_action":
        "backup",
        "db":
        db,
        "backup_dir":
        os.path.join(os.getcwd(),
                     "current/backup/%snodes-%s-%s" % (nb_nodes, db, latency)),
        "tasks_ran":
        env["tasks_ran"],
        # Set monitoring to True by default
        "enable_monitoring":
        env['config'].get('enable_monitoring', True),
        "rally_nodes":
        env.get('rally_nodes', [])
    }
    run_ansible('scaffolding.yml', extra_vars=extra_vars)
    run_ansible('openstack.yml', extra_vars=extra_vars)
    run_ansible('rally.yml', extra_vars=extra_vars)
    env["tasks_ran"].append('backup')
Exemple #8
0
def rally(files, directory, high, env=None, **kwargs):
    """
usage: juice rally [--files FILE... | --directory DIRECTORY] [--high]

Benchmark the Openstack

  --files FILE           Files to use for rally scenarios (name must be a path
from rally scenarios folder).
  --directory DIRECTORY  Directory that contains rally scenarios. [default:
keystone]
  --high                 Use high mode or not
    """
    logging.info("Launching rally using scenarios: %s" % (', '.join(files)))
    logging.info("Launching rally using all scenarios in %s directory.",
                 directory)

    database_nodes = [
        host.address for role, hosts in env['roles'].items()
        if role.startswith('database') for host in hosts
    ]

    # In high mode: runs rally in all database nodes, in light mode:
    # runs rally on one database node. In light mode, we pick the
    # second database node (ie, `database_node[1]`) to not run rally
    # on the same node than the one that contains mariadb.
    rally_nodes = database_nodes if high else database_nodes[1]
    env['rally_nodes'] = rally_nodes

    extra_vars = {"rally_nodes": rally_nodes}
    if files:
        extra_vars.update({"rally_files": files})
    else:
        extra_vars.update({"rally_directory": directory})

    # use deploy of each role
    extra_vars.update({"enos_action": "deploy"})
    run_ansible('rally.yml', extra_vars=extra_vars)
Exemple #9
0
def destroy(env=None, hard=False, **kwargs):
    """
usage: juice destroy

Destroy all the running dockers (not destroying the resources), requires g5k
and inventory executions
    """
    extra_vars = {}
    # Call destroy on each component
    extra_vars.update({
        'monitoring': env.get('monitoring', True),
        "db": env.get('db', 'cockroachdb'),
        "rally_nodes": env.get('rally_nodes', []),
        "enos_action": "destroy"
    })
    run_ansible('scaffolding.yml', extra_vars=extra_vars)
    run_ansible('openstack.yml', extra_vars=extra_vars)
    run_ansible('rally.yml', extra_vars=extra_vars)
Exemple #10
0
def backup(backup_dir='current/backup', env=None, **kwargs):
    """
usage: juice backup [--backup-dir DIRECTORY]

Backup the experiment
  --backup-dir DIRECTORY  Backup directory [default: current/backup]
    """
    backup_dir = os.path.abspath(backup_dir)
    os.path.isdir(backup_dir) or os.mkdir(backup_dir)

    extra_vars = {
        "enos_action": "backup",
        "db": env['db'],
        "backup_dir": backup_dir,
        "monitoring": env['monitoring'],
        "rally_nodes": env.get('rally_nodes', [])
    }
    run_ansible('scaffolding.yml', extra_vars=extra_vars)
    run_ansible('openstack.yml', extra_vars=extra_vars)
    run_ansible('rally.yml', extra_vars=extra_vars)
Exemple #11
0
def deploy(conf,
           provider='g5k',
           force_deployment=False,
           xp_name=None,
           tags=['provide', 'inventory', 'scaffold'],
           env=None,
           **kwargs):
    """
usage: juice deploy [--conf CONFIG_PATH] [--provider PROVIDER]
                    [--force-deployment]
                    [--xp-name NAME] [--tags TAGS...]

Claim resources from PROVIDER and configure them.

Options:
  --conf CONFIG_PATH    Path to the configuration file describing the
                        deployment [default: ./conf.yaml]
  --provider PROVIDER   Provider to target [default: g5k]
  --force-deployment    Force provider to redo the deployment
  --xp-name NAME        NAME of the folder generated by juice for this
                        new deployment.
  --tags TAGS           Only run tasks relative to the specific tags
                        [default: provide inventory scaffold]
    """
    # Read the configuration
    config = {}

    if isinstance(conf, str):
        # Get the config object from a yaml file
        with open(conf) as f:
            config = yaml.load(f)
    elif isinstance(conf, dict):
        # Get the config object from a dict
        config = conf
    else:
        # Data format error
        raise Exception(
            'conf is type {!r} while it should be a yaml file or a dict'.
            format(type(conf)))

    env['db'] = config.get('database', 'cockroachdb')
    env['monitoring'] = config.get('monitoring', True)
    env['config'] = config

    # Claim resources on Grid'5000
    if 'provide' in tags:
        if provider == 'g5k' and 'g5k' in config:
            env['provider'] = 'g5k'
            updated_env = g5k_deploy(config['g5k'],
                                     env=xp_name,
                                     force_deploy=force_deployment)
            env.update(updated_env)
        else:
            raise Exception(
                'The provider {!r} is not supported or it lacks a configuration'
                .format(provider))

    # Generate the Ansible inventory file
    if 'inventory' in tags:
        env['inventory'] = os.path.join(env['resultdir'], 'hosts')
        generate_inventory(env['roles'],
                           env['networks'],
                           env['inventory'],
                           check_networks=True)
        _save_env(env)

    # Deploy the resources, requires both g5k and inventory executions
    if 'scaffold' in tags:
        run_ansible('scaffolding.yml',
                    extra_vars={
                        'registry': config['registry'],
                        'db': env['db'],
                        'monitoring': env['monitoring'],
                        'enos_action': 'deploy'
                    })