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])
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])
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 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"]
def call_output(cmd, **kwargs): return subprocess.call_output(cmd, popen_class=SSHPopen, **kwargs)
def profile_exists(name): out = subprocess.call_output( ["cobbler", "profile", "find", "--name", name]) return bool(out.strip())
def fuel2_env_call(args, output=False): cmd = ["fuel2", "--debug", "env"] + args if output: return subprocess.call_output(cmd) else: subprocess.call(cmd)
def run_psql(sql, db): output = subprocess.call_output( ["sudo", "-u", "postgres", "psql", db, "--tuples-only", "--no-align", "-c", sql]) return output.strip().splitlines()