def init(
        name,
        cpu,
        mem,
        image,
        hypervisor='kvm',
        host=None,
        seed=True,
        nic='default',
        install=True,
        start=True,
        disk='default',
        saltenv='base',
        enable_vnc=False,
        seed_cmd='seed.apply',
        enable_qcow=False,
        serial_type='None'):
    '''
    This routine is used to create a new virtual machine. This routines takes
    a number of options to determine what the newly created virtual machine
    will look like.

    name
        The mandatory name of the new virtual machine. The name option is
        also the minion id, all minions must have an id.

    cpu
        The number of cpus to allocate to this new virtual machine.

    mem
        The amount of memory to allocate to this virtual machine. The number
        is interpreted in megabytes.

    image
        The network location of the virtual machine image, commonly a location
        on the salt fileserver, but http, https and ftp can also be used.

    hypervisor
        The hypervisor to use for the new virtual machine. Default is `kvm`.

    host
        The host to use for the new virtual machine, if this is omitted
        Salt will automatically detect what host to use.

    seed
        Set to `False` to prevent Salt from seeding the new virtual machine.

    nic
        The nic profile to use, defaults to the "default" nic profile which
        assumes a single network interface per VM associated with the "br0"
        bridge on the master.

    install
        Set to False to prevent Salt from installing a minion on the new VM
        before it spins up.

    disk
        The disk profile to use

    saltenv
        The Salt environment to use

    enable_vnc
        Whether a VNC screen is attached to resulting VM. Default is `False`.

    seed_cmd
        If seed is `True`, use this execution module function to seed new VM.
        Default is `seed.apply`.

    enable_qcow
        Clone disk image as a copy-on-write qcow2 image, using downloaded
        `image` as backing file.

    serial_type
        Enable serial console. Set to 'pty' for serial console or 'tcp' for
        telnet.
        Default is 'None'
    '''
    __jid_event__.fire_event({'message': 'Searching for hosts'}, 'progress')
    data = query(host, quiet=True)
    # Check if the name is already deployed
    for node in data:
        if 'vm_info' in data[node]:
            if name in data[node]['vm_info']:
                __jid_event__.fire_event(
                    {'message': 'Virtual machine {0} is already deployed'.format(name)},
                    'progress'
                )
                return 'fail'

    if host is None:
        host = _determine_host(data)

    if host not in data or not host:
        __jid_event__.fire_event(
            {'message': 'Host {0} was not found'.format(host)},
            'progress'
        )
        return 'fail'

    pub_key = None
    priv_key = None
    if seed:
        __jid_event__.fire_event({'message': 'Minion will be preseeded'}, 'progress')
        priv_key, pub_key = salt.utils.cloud.gen_keys()
        accepted_key = os.path.join(__opts__['pki_dir'], 'minions', name)
        with salt.utils.files.fopen(accepted_key, 'w') as fp_:
            fp_.write(salt.utils.stringutils.to_str(pub_key))

    client = salt.client.get_local_client(__opts__['conf_file'])

    __jid_event__.fire_event(
        {'message': 'Creating VM {0} on host {1}'.format(name, host)},
        'progress'
    )
    try:
        cmd_ret = client.cmd_iter(
            host,
            'virt.init',
            [
                name,
                cpu,
                mem
            ],
            timeout=600,
            kwarg={
                'image': image,
                'nic': nic,
                'hypervisor': hypervisor,
                'start': start,
                'disk': disk,
                'saltenv': saltenv,
                'seed': seed,
                'install': install,
                'pub_key': pub_key,
                'priv_key': priv_key,
                'seed_cmd': seed_cmd,
                'enable_vnc': enable_vnc,
                'enable_qcow': enable_qcow,
                'serial_type': serial_type,
            })
    except SaltClientError as client_error:
        # Fall through to ret error handling below
        print(client_error)

    ret = next(cmd_ret)
    if not ret:
        __jid_event__.fire_event({'message': 'VM {0} was not initialized.'.format(name)}, 'progress')
        return 'fail'
    for minion_id in ret:
        if ret[minion_id]['ret'] is False:
            print('VM {0} initialization failed. Returned error: {1}'.format(name, ret[minion_id]['ret']))
            return 'fail'

    __jid_event__.fire_event({'message': 'VM {0} initialized on host {1}'.format(name, host)}, 'progress')
    return 'good'
This routine is used to create a new virtual machine. This routines takes
    a number of options to determine what the newly created virtual machine
    will look like.

    name
        The mandatory name of the new virtual machine. The name option is
        also the minion id, all minions must have an id.

    cpu
        The number of cpus to allocate to this new virtual machine.

    mem
        The amount of memory to allocate to this virtual machine. The number
        is interpreted in megabytes.

    image
        The network location of the virtual machine image, commonly a location
        on the salt fileserver, but http, https and ftp can also be used.

    hypervisor
        The hypervisor to use for the new virtual machine. Default is `kvm`.

    host
        The host to use for the new virtual machine, if this is omitted
        Salt will automatically detect what host to use.

    seed
        Set to `False` to prevent Salt from seeding the new virtual machine.

    nic
        The nic profile to use, defaults to the "default" nic profile which
        assumes a single network interface per VM associated with the "br0"
        bridge on the master.

    install
        Set to False to prevent Salt from installing a minion on the new VM
        before it spins up.

    disk
        The disk profile to use

    saltenv
        The Salt environment to use

    enable_vnc
        Whether a VNC screen is attached to resulting VM. Default is `False`.

    seed_cmd
        If seed is `True`, use this execution module function to seed new VM.
        Default is `seed.apply`.

    enable_qcow
        Clone disk image as a copy-on-write qcow2 image, using downloaded
        `image` as backing file.

    serial_type
        Enable serial console. Set to 'pty' for serial console or 'tcp' for
        telnet.
        Default is 'None'