Exemple #1
0
def clone(name, source, *varargs, **kwargs):
    '''
    Clone a VM (qvm-clone).
    '''
    # Return if VM already exists
    exists_status = Status(**_state_action('qvm.check', name, *['exists']))
    if exists_status.passed():
        message = "A VM with the name '{0}' already exists.".format(name)
        status = Status()._format(prefix='[SKIP] ', message=message)
        return vars(status._finalize(test_mode=__opts__['test']))
    return _state_action('qvm.clone', source, name, *varargs, **kwargs)
def clone(name, source, *varargs, **kwargs):
    '''
    Clone a VM (qvm-clone).
    '''
    # Return if VM already exists
    exists_status = Status(**_state_action('qvm.check', name, *['exists']))
    if exists_status.passed():
        message = "A VM with the name '{0}' already exists.".format(name)
        status = Status()._format(prefix='[SKIP] ', message=message)
        return vars(status._finalize(test_mode=__opts__['test']))
    return _state_action('qvm.clone', source, name, *varargs, **kwargs)
Exemple #3
0
def kill(name, *varargs, **kwargs):
    '''
    Kill vmname (qvm-kill).
    '''
    # Return if VM already halted (stderr will contain message if VM absent)
    halted_status = Status(**_state_action('qvm.state', name, *['halted']))
    if halted_status.passed():
        message = halted_status.stderr or "'{0}' is already halted.".format(
            name)
        status = Status()._format(prefix='[SKIP] ', message=message)
        return vars(status._finalize(test_mode=__opts__['test']))
    return _state_action('qvm.kill', name, *varargs, **kwargs)
def kill(name, *varargs, **kwargs):
    '''
    Kill vmname (qvm-kill).
    '''
    # Return if VM already halted (stderr will contain message if VM absent)
    halted_status = Status(**_state_action('qvm.state', name, *['halted']))
    if halted_status.passed():
        message = halted_status.stderr or "'{0}' is already halted.".format(
            name)
        status = Status()._format(prefix='[SKIP] ', message=message)
        return vars(status._finalize(test_mode=__opts__['test']))
    return _state_action('qvm.kill', name, *varargs, **kwargs)
Exemple #5
0
def absent(name, *varargs, **kwargs):
    '''
    Make sure the named VM is absent.

    VM will be deleted (removed) if present (qvm-absent).
    '''
    # Return if VM already absent
    missing_status = Status(**_state_action('qvm.check', name, *['missing']))
    if missing_status.passed():
        message = "The VM with the name '{0}' is already missing.".format(name)
        status = Status()._format(prefix='[SKIP] ', message=message)
        return vars(status._finalize(test_mode=__opts__['test']))
    return _state_action('qvm.remove', name, *varargs, **kwargs)
Exemple #6
0
def present(name, *varargs, **kwargs):
    '''
    Make sure the named VM is present.

    VM will be created if missing (qvm-present).
    '''
    # Return if VM already exists
    exists_status = Status(**_state_action('qvm.check', name, *['exists']))
    if exists_status.passed():
        message = "A VM with the name '{0}' already exists.".format(name)
        status = Status()._format(prefix='[SKIP] ', message=message)
        return vars(status._finalize(test_mode=__opts__['test']))
    return _state_action('qvm.create', name, *varargs, **kwargs)
def absent(name, *varargs, **kwargs):
    '''
    Make sure the named VM is absent.

    VM will be deleted (removed) if present (qvm-absent).
    '''
    # Return if VM already absent
    missing_status = Status(**_state_action('qvm.check', name, *['missing']))
    if missing_status.passed():
        message = "The VM with the name '{0}' is already missing.".format(name)
        status = Status()._format(prefix='[SKIP] ', message=message)
        return vars(status._finalize(test_mode=__opts__['test']))
    return _state_action('qvm.remove', name, *varargs, **kwargs)
def present(name, *varargs, **kwargs):
    '''
    Make sure the named VM is present.

    VM will be created if missing (qvm-present).
    '''
    # Return if VM already exists
    exists_status = Status(**_state_action('qvm.check', name, *['exists']))
    if exists_status.passed():
        message = "A VM with the name '{0}' already exists.".format(name)
        status = Status()._format(prefix='[SKIP] ', message=message)
        return vars(status._finalize(test_mode=__opts__['test']))
    return _state_action('qvm.create', name, *varargs, **kwargs)
Exemple #9
0
def halted(name, *varargs, **kwargs):
    '''
    Return True is vmname is halted (qvm-halted).
    '''
    varargs = list(varargs)
    varargs.append('halted')
    # Return if VM already halted (stderr will contain message if VM absent)
    halted_status = Status(
        **_state_action('qvm.state', name, *varargs, **kwargs))
    if halted_status.passed() or halted_status.stderr:
        message = halted_status.stderr or "'{0}' is already halted.".format(
            name)
        status = Status()._format(prefix='[SKIP] ', message=message)
        return vars(status._finalize(test_mode=__opts__['test']))
    return _state_action('qvm.state', name, *varargs, **kwargs)
def halted(name, *varargs, **kwargs):
    '''
    Return True is vmname is halted (qvm-halted).
    '''
    varargs = list(varargs)
    varargs.append('halted')
    # Return if VM already halted (stderr will contain message if VM absent)
    halted_status = Status(**_state_action('qvm.state', name, *varargs,
                                           **kwargs))
    if halted_status.passed() or halted_status.stderr:
        message = halted_status.stderr or "'{0}' is already halted.".format(
            name)
        status = Status()._format(prefix='[SKIP] ', message=message)
        return vars(status._finalize(test_mode=__opts__['test']))
    return _state_action('qvm.state', name, *varargs, **kwargs)