def template_instantiate(call=None, kwargs=None):
 if (call != 'function'):
  raise SaltCloudSystemExit('The template_instantiate function must be called with -f or --function.')
 if (kwargs is None):
  kwargs = {}
 vm_name = kwargs.get('vm_name', None)
 template_id = kwargs.get('template_id', None)
 template_name = kwargs.get('template_name', None)
 if (vm_name is None):
  raise SaltCloudSystemExit("The template_instantiate function requires a 'vm_name' to be provided.")
 if template_id:
  if template_name:
   log.warning("Both the 'template_id' and 'template_name' arguments were provided. 'template_id' will take precedence.")
 elif template_name:
  template_id = get_template_id(kwargs={'name': template_name})
 else:
  raise SaltCloudSystemExit("The template_instantiate function requires either a 'template_id' or a 'template_name' to be provided.")
 (server, user, password) = _get_xml_rpc()
 auth = ':'.join([user, password])
 response = server.one.template.instantiate(auth, int(template_id), vm_name)
 data = {'action': 'template.instantiate', 'instantiated': response[0], 'instantiated_vm_id': response[1], 'vm_name': vm_name, 'error_code': response[2]}
 return data

def template_instantiate ( call = None , kwargs = None ) : if ( call != 'function' ) : raise SaltCloudSystemExit ( 'The template_instantiate function must be called with -f or --function.' ) if ( kwargs is None ) : kwargs = { } vm_name = kwargs . get ( 'vm_name' , None ) template_id = kwargs . get ( 'template_id' , None ) template_name = kwargs . get ( 'template_name' , None ) if ( vm_name is None ) : raise SaltCloudSystemExit ( "The template_instantiate function requires a 'vm_name' to be provided." ) if template_id : if template_name : log . warning ( "Both the 'template_id' and 'template_name' arguments were provided. 'template_id' will take precedence." ) elif template_name : template_id = get_template_id ( kwargs = { 'name' : template_name } ) else : raise SaltCloudSystemExit ( "The template_instantiate function requires either a 'template_id' or a 'template_name' to be provided." ) ( server , user , password ) = _get_xml_rpc ( ) auth = ':' . join ( [ user , password ] ) response = server . one . template . instantiate ( auth , int ( template_id ) , vm_name ) data = { 'action' : 'template.instantiate' , 'instantiated' : response [ 0 ] , 'instantiated_vm_id' : response [ 1 ] , 'vm_name' : vm_name , 'error_code' : response [ 2 ] } return data
instantiates a new virtual machine from a template .