def create(vm_):
    '''
    if configuration parameter ``deploy`` is ``True``,

        Provision a single machine, adding its keys to the salt master

    else,

        Test ssh connections to the machine

    Configuration parameters:

    - deploy:  (see above)
    - provider:  name of entry in ``salt/cloud.providers.d/???`` file
    - ssh_host: IP address or DNS name of the new machine
    - ssh_username:  name used to log in to the new machine
    - ssh_password:  password to log in (unless key_filename is used)
    - key_filename:  (optional) SSH private key for passwordless login
    - ssh_port: (default=22) TCP port for SSH connection
    - wake_on_lan_mac:  (optional) hardware (MAC) address for wake on lan
    - wol_sender_node:  (optional) salt minion to send wake on lan command
    - wol_boot_wait:  (default=30) seconds to delay while client boots
    - force_minion_config: (optional) replace the minion configuration files on the new machine

    See also
    :ref:`Miscellaneous Salt Cloud Options <misc-salt-cloud-options>`
    and
    :ref:`Getting Started with Saltify <getting-started-with-saltify>`

    CLI Example:

    .. code-block:: bash

        salt-cloud -p mymachine my_new_id
    '''
    deploy_config = config.get_cloud_config_value(
        'deploy', vm_, __opts__, default=False)

    # If ssh_host is not set, default to the minion name
    if not config.get_cloud_config_value('ssh_host', vm_, __opts__, default=''):
        vm_['ssh_host'] = vm_['name']

    if deploy_config:
        wol_mac = config.get_cloud_config_value(
            'wake_on_lan_mac', vm_, __opts__, default='')
        wol_host = config.get_cloud_config_value(
            'wol_sender_node', vm_, __opts__, default='')
        if wol_mac and wol_host:
            good_ping = False
            local = salt.client.LocalClient()
            ssh_host = config.get_cloud_config_value(
                'ssh_host', vm_, __opts__, default='')
            if ssh_host:
                log.info('trying to ping %s', ssh_host)
                count = 'n' if salt.utils.platform.is_windows() else 'c'
                cmd = 'ping -{} 1 {}'.format(count, ssh_host)
                good_ping = local.cmd(wol_host, 'cmd.retcode', [cmd]) == 0
            if good_ping:
                log.info('successful ping.')
            else:
                log.info('sending wake-on-lan to %s using node %s',
                         wol_mac, wol_host)

                if isinstance(wol_mac, six.string_types):
                    wol_mac = [wol_mac]  # a smart user may have passed more params
                ret = local.cmd(wol_host, 'network.wol', wol_mac)
                log.info('network.wol returned value %s', ret)
                if ret and ret[wol_host]:
                    sleep_time = config.get_cloud_config_value(
                        'wol_boot_wait', vm_, __opts__, default=30)
                    if sleep_time > 0.0:
                        log.info('delaying %d seconds for boot', sleep_time)
                        time.sleep(sleep_time)
        log.info('Provisioning existing machine %s', vm_['name'])
        ret = __utils__['cloud.bootstrap'](vm_, __opts__)
    else:
        ret = _verify(vm_)

    return ret
def create ( vm_ ) : deploy_config = config . get_cloud_config_value ( 'deploy' , vm_ , __opts__ , default = False ) if not config . get_cloud_config_value ( 'ssh_host' , vm_ , __opts__ , default = '' ) : vm_ [ 'ssh_host' ] = vm_ [ 'name' ] if deploy_config : wol_mac = config . get_cloud_config_value ( 'wake_on_lan_mac' , vm_ , __opts__ , default = '' ) wol_host = config . get_cloud_config_value ( 'wol_sender_node' , vm_ , __opts__ , default = '' ) if wol_mac and wol_host : good_ping = False local = salt . client . LocalClient ( ) ssh_host = config . get_cloud_config_value ( 'ssh_host' , vm_ , __opts__ , default = '' ) if ssh_host : log . info ( 'trying to ping %s' , ssh_host ) count = 'n' if salt . utils . platform . is_windows ( ) else 'c' cmd = 'ping -{} 1 {}' . format ( count , ssh_host ) good_ping = local . cmd ( wol_host , 'cmd.retcode' , [ cmd ] ) == 0 if good_ping : log . info ( 'successful ping.' ) else : log . info ( 'sending wake-on-lan to %s using node %s' , wol_mac , wol_host ) if isinstance ( wol_mac , six . string_types ) : wol_mac = [ wol_mac ] ret = local . cmd ( wol_host , 'network.wol' , wol_mac ) log . info ( 'network.wol returned value %s' , ret ) if ret and ret [ wol_host ] : sleep_time = config . get_cloud_config_value ( 'wol_boot_wait' , vm_ , __opts__ , default = 30 ) if sleep_time > 0.0 : log . info ( 'delaying %d seconds for boot' , sleep_time ) time . sleep ( sleep_time ) log . info ( 'Provisioning existing machine %s' , vm_ [ 'name' ] ) ret = __utils__ [ 'cloud.bootstrap' ] ( vm_ , __opts__ ) else : ret = _verify ( vm_ ) return ret
if configuration parameter ``deploy`` is ``True``,

        Provision a single machine, adding its keys to the salt master

    else,

        Test ssh connections to the machine

    Configuration parameters:

    - deploy:  (see above)
    - provider:  name of entry in ``salt/cloud.providers.d/???`` file
    - ssh_host: IP address or DNS name of the new machine
    - ssh_username:  name used to log in to the new machine
    - ssh_password:  password to log in (unless key_filename is used)
    - key_filename:  (optional) SSH private key for passwordless login
    - ssh_port: (default=22) TCP port for SSH connection
    - wake_on_lan_mac:  (optional) hardware (MAC) address for wake on lan
    - wol_sender_node:  (optional) salt minion to send wake on lan command
    - wol_boot_wait:  (default=30) seconds to delay while client boots
    - force_minion_config: (optional) replace the minion configuration files on the new machine

    See also
    :ref:`Miscellaneous Salt Cloud Options <misc-salt-cloud-options>`
    and
    :ref:`Getting Started with Saltify <getting-started-with-saltify>`

    CLI Example:

    .. code-block:: bash

        salt-cloud -p mymachine my_new_id