def monitored(name, device_class=None, collector='localhost', prod_state=None):
 ret = {}
 ret['name'] = name
 device = __salt__['zenoss.find_device'](name)
 if device:
  ret['result'] = True
  ret['changes'] = None
  ret['comment'] = '{0} is already monitored'.format(name)
  if prod_state:
   if (device['productionState'] != prod_state):
    __salt__['zenoss.set_prod_state'](prod_state, name)
    ret['changes'] = {'old': 'prodState == {0}'.format(device['productionState']), 'new': 'prodState == {0}'.format(prod_state)}
    ret['comment'] = '{0} is already monitored but prodState was incorrect, setting to Production'.format(name)
  return ret
 if __opts__['test']:
  ret['comment'] = 'The state of "{0}" will be changed.'.format(name)
  ret['changes'] = {'old': 'monitored == False', 'new': 'monitored == True'}
  ret['result'] = None
  return ret
 if __salt__['zenoss.add_device'](name, device_class, collector, prod_state):
  ret['result'] = True
  ret['changes'] = {'old': 'monitored == False', 'new': 'monitored == True'}
  ret['comment'] = '{0} has been added to Zenoss'.format(name)
 else:
  ret['result'] = False
  ret['changes'] = None
  ret['comment'] = 'Unable to add {0} to Zenoss'.format(name)
 return ret

def monitored ( name , device_class = None , collector = 'localhost' , prod_state = None ) : ret = { } ret [ 'name' ] = name device = __salt__ [ 'zenoss.find_device' ] ( name ) if device : ret [ 'result' ] = True ret [ 'changes' ] = None ret [ 'comment' ] = '{0} is already monitored' . format ( name ) if prod_state : if ( device [ 'productionState' ] != prod_state ) : __salt__ [ 'zenoss.set_prod_state' ] ( prod_state , name ) ret [ 'changes' ] = { 'old' : 'prodState == {0}' . format ( device [ 'productionState' ] ) , 'new' : 'prodState == {0}' . format ( prod_state ) } ret [ 'comment' ] = '{0} is already monitored but prodState was incorrect, setting to Production' . format ( name ) return ret if __opts__ [ 'test' ] : ret [ 'comment' ] = 'The state of "{0}" will be changed.' . format ( name ) ret [ 'changes' ] = { 'old' : 'monitored == False' , 'new' : 'monitored == True' } ret [ 'result' ] = None return ret if __salt__ [ 'zenoss.add_device' ] ( name , device_class , collector , prod_state ) : ret [ 'result' ] = True ret [ 'changes' ] = { 'old' : 'monitored == False' , 'new' : 'monitored == True' } ret [ 'comment' ] = '{0} has been added to Zenoss' . format ( name ) else : ret [ 'result' ] = False ret [ 'changes' ] = None ret [ 'comment' ] = 'Unable to add {0} to Zenoss' . format ( name ) return ret
ensure a device is monitored .