def agent_settings(name, contact, location, services=None):
 ret = {'name': name, 'changes': {}, 'comment': str(), 'result': None}
 ret_settings = {'changes': dict(), 'failures': dict()}
 if (not services):
  services = ['None']
 services = sorted(set(services))
 settings = {'contact': contact, 'location': location, 'services': services}
 current_settings = __salt__['win_snmp.get_agent_settings']()
 for setting in settings:
  if (str(settings[setting]) != str(current_settings[setting])):
   ret_settings['changes'][setting] = {'old': current_settings[setting], 'new': settings[setting]}
 if (not ret_settings['changes']):
  ret['comment'] = 'Agent settings already contain the provided values.'
  ret['result'] = True
  return ret
 elif __opts__['test']:
  ret['comment'] = 'Agent settings will be changed.'
  ret['changes'] = ret_settings
  return ret
 __salt__['win_snmp.set_agent_settings'](**settings)
 new_settings = __salt__['win_snmp.get_agent_settings']()
 for setting in settings:
  if (settings[setting] != new_settings[setting]):
   ret_settings['failures'][setting] = {'old': current_settings[setting], 'new': new_settings[setting]}
   ret_settings['changes'].pop(setting, None)
 if ret_settings['failures']:
  ret['comment'] = 'Some agent settings failed to change.'
  ret['changes'] = ret_settings
  ret['result'] = False
 else:
  ret['comment'] = 'Set agent settings to contain the provided values.'
  ret['changes'] = ret_settings['changes']
  ret['result'] = True
 return ret

def agent_settings ( name , contact , location , services = None ) : ret = { 'name' : name , 'changes' : { } , 'comment' : str ( ) , 'result' : None } ret_settings = { 'changes' : dict ( ) , 'failures' : dict ( ) } if ( not services ) : services = [ 'None' ] services = sorted ( set ( services ) ) settings = { 'contact' : contact , 'location' : location , 'services' : services } current_settings = __salt__ [ 'win_snmp.get_agent_settings' ] ( ) for setting in settings : if ( str ( settings [ setting ] ) != str ( current_settings [ setting ] ) ) : ret_settings [ 'changes' ] [ setting ] = { 'old' : current_settings [ setting ] , 'new' : settings [ setting ] } if ( not ret_settings [ 'changes' ] ) : ret [ 'comment' ] = 'Agent settings already contain the provided values.' ret [ 'result' ] = True return ret elif __opts__ [ 'test' ] : ret [ 'comment' ] = 'Agent settings will be changed.' ret [ 'changes' ] = ret_settings return ret __salt__ [ 'win_snmp.set_agent_settings' ] ( ** settings ) new_settings = __salt__ [ 'win_snmp.get_agent_settings' ] ( ) for setting in settings : if ( settings [ setting ] != new_settings [ setting ] ) : ret_settings [ 'failures' ] [ setting ] = { 'old' : current_settings [ setting ] , 'new' : new_settings [ setting ] } ret_settings [ 'changes' ] . pop ( setting , None ) if ret_settings [ 'failures' ] : ret [ 'comment' ] = 'Some agent settings failed to change.' ret [ 'changes' ] = ret_settings ret [ 'result' ] = False else : ret [ 'comment' ] = 'Set agent settings to contain the provided values.' ret [ 'changes' ] = ret_settings [ 'changes' ] ret [ 'result' ] = True return ret
manage the snmp syscontact .