def update_stack(name=None, template_file=None, enviroment=None, parameters=None, poll=0, rollback=False, timeout=60, profile=None):
 h_client = _auth(profile)
 ret = {'result': True, 'comment': ''}
 if (not name):
  ret['result'] = False
  ret['comment'] = 'Parameter name missing or None'
  return ret
 if (not parameters):
  parameters = {}
 if template_file:
  template_tmp_file = salt.utils.files.mkstemp()
  (tsfn, source_sum, comment_) = __salt__['file.get_managed'](name=template_tmp_file, template=None, source=template_file, source_hash=None, user=None, group=None, mode=None, saltenv='base', context=None, defaults=None, skip_verify=False, kwargs=None)
  template_manage_result = __salt__['file.manage_file'](name=template_tmp_file, sfn=tsfn, ret=None, source=template_file, source_sum=source_sum, user=None, group=None, mode=None, saltenv='base', backup=None, makedirs=True, template=None, show_changes=False, contents=None, dir_mode=None)
  if template_manage_result['result']:
   with salt.utils.fopen(template_tmp_file, 'r') as tfp_:
    tpl = tfp_.read()
    salt.utils.safe_rm(template_tmp_file)
    try:
     if isinstance(tpl, six.binary_type):
      tpl = tpl.decode('utf-8')
     template = _parse_template(tpl)
    except ValueError as ex:
     ret['result'] = False
     ret['comment'] = 'Error parsing template {0}'.format(ex)
  else:
   ret['result'] = False
   ret['comment'] = 'Can not open template: {0} {1}'.format(template_file, comment_)
 else:
  ret['result'] = False
  ret['comment'] = 'Can not open template'
 if (ret['result'] is False):
  return ret
 kwargs = {}
 kwargs['template'] = template
 try:
  h_client.stacks.validate(**kwargs)
 except Exception as ex:
  log.exception('Template not valid {0}'.format(ex))
  ret['result'] = False
  ret['comment'] = 'Template not valid {0}'.format(ex)
  return ret
 env = {}
 if enviroment:
  enviroment_tmp_file = salt.utils.files.mkstemp()
  (esfn, source_sum, comment_) = __salt__['file.get_managed'](name=enviroment_tmp_file, template=None, source=enviroment, source_hash=None, user=None, group=None, mode=None, saltenv='base', context=None, defaults=None, skip_verify=False, kwargs=None)
  enviroment_manage_result = __salt__['file.manage_file'](name=enviroment_tmp_file, sfn=esfn, ret=None, source=enviroment, source_sum=source_sum, user=None, group=None, mode=None, saltenv='base', backup=None, makedirs=True, template=None, show_changes=False, contents=None, dir_mode=None)
  if enviroment_manage_result['result']:
   with salt.utils.fopen(enviroment_tmp_file, 'r') as efp_:
    env_str = efp_.read()
    salt.utils.safe_rm(enviroment_tmp_file)
    try:
     env = _parse_enviroment(env_str)
    except ValueError as ex:
     ret['result'] = False
     ret['comment'] = 'Error parsing template {0}'.format(ex)
  else:
   ret['result'] = False
   ret['comment'] = 'Can not open enviroment: {0}, {1}'.format(enviroment, comment_)
 if (ret['result'] is False):
  return ret
 fields = {'disable_rollback': (not rollback), 'parameters': parameters, 'template': template, 'environment': env, 'timeout_mins': timeout}
 try:
  h_client.stacks.update(name, **fields)
 except Exception as ex:
  log.exception('Update failed {0}'.format(ex))
  ret['result'] = False
  ret['comment'] = 'Update failed {0}'.format(ex)
  return ret
 if (poll > 0):
  (stack_status, msg) = _poll_for_events(h_client, name, action='UPDATE', poll_period=poll, timeout=timeout)
  if (stack_status == 'UPDATE_FAILED'):
   ret['result'] = False
   ret['comment'] = "Updated stack FAILED'{0}'{1}.".format(name, msg)
 if (ret['result'] is True):
  ret['comment'] = ("Updated stack '{0}'.".format(name),)
 return ret

def update_stack ( name = None , template_file = None , enviroment = None , parameters = None , poll = 0 , rollback = False , timeout = 60 , profile = None ) : h_client = _auth ( profile ) ret = { 'result' : True , 'comment' : '' } if ( not name ) : ret [ 'result' ] = False ret [ 'comment' ] = 'Parameter name missing or None' return ret if ( not parameters ) : parameters = { } if template_file : template_tmp_file = salt . utils . files . mkstemp ( ) ( tsfn , source_sum , comment_ ) = __salt__ [ 'file.get_managed' ] ( name = template_tmp_file , template = None , source = template_file , source_hash = None , user = None , group = None , mode = None , saltenv = 'base' , context = None , defaults = None , skip_verify = False , kwargs = None ) template_manage_result = __salt__ [ 'file.manage_file' ] ( name = template_tmp_file , sfn = tsfn , ret = None , source = template_file , source_sum = source_sum , user = None , group = None , mode = None , saltenv = 'base' , backup = None , makedirs = True , template = None , show_changes = False , contents = None , dir_mode = None ) if template_manage_result [ 'result' ] : with salt . utils . fopen ( template_tmp_file , 'r' ) as tfp_ : tpl = tfp_ . read ( ) salt . utils . safe_rm ( template_tmp_file ) try : if isinstance ( tpl , six . binary_type ) : tpl = tpl . decode ( 'utf-8' ) template = _parse_template ( tpl ) except ValueError as ex : ret [ 'result' ] = False ret [ 'comment' ] = 'Error parsing template {0}' . format ( ex ) else : ret [ 'result' ] = False ret [ 'comment' ] = 'Can not open template: {0} {1}' . format ( template_file , comment_ ) else : ret [ 'result' ] = False ret [ 'comment' ] = 'Can not open template' if ( ret [ 'result' ] is False ) : return ret kwargs = { } kwargs [ 'template' ] = template try : h_client . stacks . validate ( ** kwargs ) except Exception as ex : log . exception ( 'Template not valid {0}' . format ( ex ) ) ret [ 'result' ] = False ret [ 'comment' ] = 'Template not valid {0}' . format ( ex ) return ret env = { } if enviroment : enviroment_tmp_file = salt . utils . files . mkstemp ( ) ( esfn , source_sum , comment_ ) = __salt__ [ 'file.get_managed' ] ( name = enviroment_tmp_file , template = None , source = enviroment , source_hash = None , user = None , group = None , mode = None , saltenv = 'base' , context = None , defaults = None , skip_verify = False , kwargs = None ) enviroment_manage_result = __salt__ [ 'file.manage_file' ] ( name = enviroment_tmp_file , sfn = esfn , ret = None , source = enviroment , source_sum = source_sum , user = None , group = None , mode = None , saltenv = 'base' , backup = None , makedirs = True , template = None , show_changes = False , contents = None , dir_mode = None ) if enviroment_manage_result [ 'result' ] : with salt . utils . fopen ( enviroment_tmp_file , 'r' ) as efp_ : env_str = efp_ . read ( ) salt . utils . safe_rm ( enviroment_tmp_file ) try : env = _parse_enviroment ( env_str ) except ValueError as ex : ret [ 'result' ] = False ret [ 'comment' ] = 'Error parsing template {0}' . format ( ex ) else : ret [ 'result' ] = False ret [ 'comment' ] = 'Can not open enviroment: {0}, {1}' . format ( enviroment , comment_ ) if ( ret [ 'result' ] is False ) : return ret fields = { 'disable_rollback' : ( not rollback ) , 'parameters' : parameters , 'template' : template , 'environment' : env , 'timeout_mins' : timeout } try : h_client . stacks . update ( name , ** fields ) except Exception as ex : log . exception ( 'Update failed {0}' . format ( ex ) ) ret [ 'result' ] = False ret [ 'comment' ] = 'Update failed {0}' . format ( ex ) return ret if ( poll > 0 ) : ( stack_status , msg ) = _poll_for_events ( h_client , name , action = 'UPDATE' , poll_period = poll , timeout = timeout ) if ( stack_status == 'UPDATE_FAILED' ) : ret [ 'result' ] = False ret [ 'comment' ] = "Updated stack FAILED'{0}'{1}." . format ( name , msg ) if ( ret [ 'result' ] is True ) : ret [ 'comment' ] = ( "Updated stack '{0}'." . format ( name ) , ) return ret
update a cfn stack .