Exemple #1
0
def systems_edit_profile(profile_name, new_profile_name):
    out = subprocess.call_output(
        ["cobbler", "system", "find", "--profile", profile_name])
    system_names = out.strip().split()
    for system_name in system_names:
        subprocess.call(["cobbler", "system", "edit",
                         "--name", system_name, "--profile", new_profile_name])
Exemple #2
0
def stop_container(container):
    _container_action(container, "stop")
    container_id = subprocess.call_output([
        'docker',
        'ps',
        '--filter',
        'name={0}'.format(container),
        '--format',
        '{{.ID}}'
    ]).strip()
    if container_id:
        subprocess.call(["docker", "stop", container_id])
Exemple #3
0
def clone_env(env_id, release):
    LOG.info("Cloning env %s for release %s", env_id, release.data['name'])
    res = subprocess.call_output(
        ["fuel2", "env", "clone", "-f", "json",
         str(env_id), uuid.uuid4().hex, str(release.data['id'])],
    )
    for kv in json.loads(res):
        if kv['Field'] == 'id':
            seed_id = kv['Value']
            break
    else:
        raise Exception("Couldn't find new environment ID in fuel CLI output:"
                        "\n%s" % res)
    return seed_id
Exemple #4
0
def clone_env(env_id, release):
    LOG.info("Cloning env %s for release %s", env_id, release.data['name'])
    res = subprocess.call_output([
        "fuel2", "env", "clone", "-f", "json",
        str(env_id),
        uuid.uuid4().hex,
        str(release.data['id'])
    ], )
    for kv in json.loads(res):
        if kv['Field'] == 'id':
            seed_id = kv['Value']
            break
    else:
        raise Exception("Couldn't find new environment ID in fuel CLI output:"
                        "\n%s" % res)
    return seed_id
def get_not_active_images_uuids():
    fuel_bootstrap_list = ["fuel-bootstrap", "list", "--format", "json"]
    images = json.loads(subprocess.call_output(fuel_bootstrap_list))
    return [img["uuid"] for img in images if img["status"] != "active"]
Exemple #6
0
def call_output(cmd, **kwargs):
    return subprocess.call_output(cmd, popen_class=SSHPopen, **kwargs)
Exemple #7
0
def profile_exists(name):
    out = subprocess.call_output(
        ["cobbler", "profile", "find", "--name", name])
    return bool(out.strip())
Exemple #8
0
def fuel2_env_call(args, output=False):
    cmd = ["fuel2", "--debug", "env"] + args
    if output:
        return subprocess.call_output(cmd)
    else:
        subprocess.call(cmd)
Exemple #9
0
def run_psql(sql, db):
    output = subprocess.call_output(
        ["sudo", "-u", "postgres", "psql", db, "--tuples-only", "--no-align",
         "-c", sql])
    return output.strip().splitlines()