Exemplo n.º 1
0
def vm_list(is_control_domain=VALUE_FALSE,
            is_snapshot=VALUE_FALSE,
            other_parameters="",
            work_dir="/tmp"):
    """Run xen vm list command."""
    resp = fab.run_cmd(cmd=__CMD_VM_LIST.format(**locals()))

    vm = {}
    vm_list = {}
    lines = resp.splitlines()
    n_lines = len(lines)
    for index in range(n_lines):
        line = fab.cleanup_text(lines[index])

        # Skip empty lines
        if re.match(r"^$", line):
            continue

        obj = line.split(":")
        if len(obj) > 1:
            key = re.search(re.compile(r"^[^ ]*"), obj[0]).group(0)

            if key in vm:
                # Start over new VM parameters
                uuid = vm[VALUE_UUID]
                del vm[VALUE_UUID]
                vm_list[uuid] = vm
                vm = {}

            if key not in vm:
                # Parameter belongs to same vm
                vm[key] = obj[1].strip()

            if index == n_lines - 1:
                # Last line reached
                uuid = vm[VALUE_UUID]
                del vm[VALUE_UUID]
                vm_list[uuid] = vm

    return vm_list
Exemplo n.º 2
0
def stat(path=".", options=""):
    """Run stat command."""
    return fab.run_cmd(cmd=__CMD_STAT.format(**locals()))
Exemplo n.º 3
0
def ls(path=".", options=""):
    """Run ls command."""
    return fab.run_cmd(cmd=__CMD_RMDIR.format(**locals()))
Exemplo n.º 4
0
def rmdir(path):
    """Run rmdir command."""
    return fab.run_cmd(cmd=__CMD_RMDIR.format(**locals()))
Exemplo n.º 5
0
def mkdir(path, make_parent=True):
    """Run mkdir command."""
    parent = "-p" if make_parent else ""
    return fab.run_cmd(cmd=__CMD_MKDIR.format(**locals()))
Exemplo n.º 6
0
def unmount(mount_point):
    """Run unmount command."""
    return fab.run_cmd(cmd=__CMD_UNMOUNT.format(**locals()))
Exemplo n.º 7
0
def mount(type, remote_target, mount_point):
    """Run mount command."""
    return fab.run_cmd(cmd=__CMD_MOUNT.format(**locals()))
Exemplo n.º 8
0
def mountpoint(path="/", quiet=False):
    """Run mountpoint command."""
    options = "-q" if quiet else ""
    return fab.run_cmd(cmd=__CMD_MOUNTPOINT.format(**locals()))
Exemplo n.º 9
0
def du(path=""):
    """Run du command."""
    resp = fab.run_cmd(cmd=__CMD_DU.format(**locals()))
    resp = resp.strip().split()
    return resp[0] if len(resp) > 1 else None
Exemplo n.º 10
0
def df(path=""):
    """Run df command."""
    return fab.run_cmd(cmd=__CMD_DF.format(**locals()))
Exemplo n.º 11
0
def hostname():
    """Run hostname command."""
    return fab.run_cmd(cmd=__CMD_HOSTNAME)
Exemplo n.º 12
0
def vm_uninstall(uuid, force=VALUE_FALSE):
    """Run xen vm uninstall command."""
    return fab.run_cmd(cmd=__CMD_VM_UNINSTALL.format(**locals()))
Exemplo n.º 13
0
def vm_export(uuid, filename, compress=VALUE_TRUE):
    """Run xen vm export command."""
    # xe vm-export vm={uuid} filename={filename}"
    extension = ".xva.gz" if compress else ".xva"
    filename = filename + extension
    return fab.run_cmd(cmd=__CMD_VM_EXPORT.format(**locals()))
Exemplo n.º 14
0
def template_param_set(uuid,
                       is_a_template=VALUE_FALSE,
                       ha_always_run=VALUE_FALSE):
    """Run xen template-param-set command."""
    return fab.run_cmd(cmd=__CMD_TEMPLATE_PARAM_SET.format(**locals()))
Exemplo n.º 15
0
def vm_snapshot(uuid, new_name_label):
    """Run xen template-param-set command."""
    resp = fab.run_cmd(cmd=__CMD_VM_SNAPSHOT.format(**locals()))
    return resp