Ejemplo n.º 1
0
def show_image(kwargs, call=None):
    """
    Show the details of an image
    """
    if call != 'function':
        raise SaltCloudSystemExit(
            'The show_image action must be called with -f or --function.')

    name = kwargs['image']
    log.info("Showing image %s", name)
    machine = vb_get_machine(name)

    ret = {machine["name"]: treat_machine_dict(machine)}
    del machine["name"]
    return ret
Ejemplo n.º 2
0
def stop(name, call=None):
    """
    Stop a running machine.
    @param name: Machine to stop
    @type name: str
    @param call: Must be "action"
    @type call: str
    """
    if call != 'action':
        raise SaltCloudSystemExit(
            'The instance action must be called with -a or --action.')

    log.info("Stopping machine: %s", name)
    vb_stop_vm(name)
    machine = vb_get_machine(name)
    del machine["name"]
    return treat_machine_dict(machine)
Ejemplo n.º 3
0
def start(name, call=None):
    """
    Start a machine.
    @param name: Machine to start
    @type name: str
    @param call: Must be "action"
    @type call: str
    """
    if call != "action":
        raise SaltCloudSystemExit(
            "The instance action must be called with -a or --action.")

    log.info("Starting machine: %s", name)
    vb_start_vm(name)
    machine = vb_get_machine(name)
    del machine["name"]
    return treat_machine_dict(machine)
Ejemplo n.º 4
0
def show_image(kwargs, call=None):
    """
    Show the details of an image
    """
    if call != 'function':
        raise SaltCloudSystemExit(
            'The show_image action must be called with -f or --function.'
        )

    name = kwargs['image']
    log.info("Showing image %s", name)
    machine = vb_get_machine(name)

    ret = {
        machine["name"]: treat_machine_dict(machine)
    }
    del machine["name"]
    return ret
Ejemplo n.º 5
0
def stop(name, call=None):
    """
    Stop a running machine.
    @param name: Machine to stop
    @type name: str
    @param call: Must be "action"
    @type call: str
    """
    if call != 'action':
        raise SaltCloudSystemExit(
            'The instance action must be called with -a or --action.'
        )

    log.info("Stopping machine: %s", name)
    vb_stop_vm(name)
    machine = vb_get_machine(name)
    del machine["name"]
    return treat_machine_dict(machine)
Ejemplo n.º 6
0
def list_nodes_full(kwargs=None, call=None):
    """
    All information available about all nodes should be returned in this function.
    The fields in the list_nodes() function should also be returned,
    even if they would not normally be provided by the cloud provider.

    This is because some functions both within Salt and 3rd party will break if an expected field is not present.
    This function is normally called with the -F option:


    .. code-block:: bash

        salt-cloud -F


    @param kwargs:
    @type kwargs:
    @param call:
    @type call:
    @return:
    @rtype:
    """
    if call == "action":
        raise SaltCloudSystemExit(
            "The list_nodes_full function must be called " "with -f or --function."
        )

    machines = {}

    # TODO ask for the correct attributes e.g state and private_ips
    for machine in vb_list_machines():
        name = machine.get("name")
        if name:
            machines[name] = treat_machine_dict(machine)
            del machine["name"]

    return machines
Ejemplo n.º 7
0
def list_nodes_full(kwargs=None, call=None):
    """
    All information available about all nodes should be returned in this function.
    The fields in the list_nodes() function should also be returned,
    even if they would not normally be provided by the cloud provider.

    This is because some functions both within Salt and 3rd party will break if an expected field is not present.
    This function is normally called with the -F option:

    .. code-block:: bash
        salt-cloud -F


    @param kwargs:
    @type kwargs:
    @param call:
    @type call:
    @return:
    @rtype:
    """
    if call == 'action':
        raise SaltCloudSystemExit(
            'The list_nodes_full function must be called '
            'with -f or --function.'
        )

    machines = {}

    # TODO ask for the correct attributes e.g state and private_ips
    for machine in vb_list_machines():
        name = machine.get("name")
        if name:
            machines[name] = treat_machine_dict(machine)
            del machine["name"]

    return machines