Module: Zenoss::JSONAPI::DeviceRouter
- Included in:
- Connection
- Defined in:
- lib/zenoss/jsonapi/device_router.rb
Instance Method Summary collapse
-
#find_devices_by_ip(ip, opts = {}) ⇒ Array
This method will find a device for the given IP Address or all matching devices given a partial IP.
-
#find_devices_by_name(name, opts = {}) ⇒ Array
This method will allow you to search for devices by name.
- #get_devices(uid = '/zport/dmd/Devices', opts = {}) ⇒ Object
- #get_info(device_id, keys = nil) ⇒ Object
- #get_templates(device_id) ⇒ Object
-
#remodel(uid, plugins = nil, background = false) ⇒ Object
plugin such as cisco.snmp.Interfaces.
- #set_info(opts = {}) ⇒ Object
Instance Method Details
#find_devices_by_ip(ip, opts = {}) ⇒ Array
This method will find a device for the given IP Address or all matching devices
given a partial IP.
114 115 116 117 |
# File 'lib/zenoss/jsonapi/device_router.rb', line 114 def find_devices_by_ip(ip, opts={}) opts[:ipAddress] = ip get_devices('/zport/dmd/Devices', :params => opts) end |
#find_devices_by_name(name, opts = {}) ⇒ Array
This method will allow you to search for devices by name. If you put a partial name
it will return all matching entries. For example:
find_devices_by_name 'mydev' will return all devices that start with mydev
102 103 104 105 |
# File 'lib/zenoss/jsonapi/device_router.rb', line 102 def find_devices_by_name(name, opts={}) opts[:name] = name get_devices('/zport/dmd/Devices', :params => opts) end |
#get_devices(uid = '/zport/dmd/Devices', opts = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/zenoss/jsonapi/device_router.rb', line 36 def get_devices(uid = '/zport/dmd/Devices', opts = {}) uid = "/zport/dmd#{uid}" unless uid.start_with?('/zport/dmd') data = { :uid => uid } data[:start] = opts[:start] if opts.has_key? :start data[:limit] = opts[:limit] if opts.has_key? :limit data[:sort] = opts[:sort_key] if opts.has_key? :sort_key data[:dir] = opts[:sort_ord] if opts.has_key? :sort_ord data[:params] = opts[:params] || {} resp = json_request('DeviceRouter', 'getDevices', [data]) devs = [] resp['devices'] && resp['devices'].each do |dev| devs << Model::Device.new(self, dev) end devs end |
#get_info(device_id, keys = nil) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/zenoss/jsonapi/device_router.rb', line 57 def get_info(device_id, keys = nil) data = {} data[:uid] = device_id data[:keys] = keys if keys json_request('DeviceRouter', 'getInfo', [data]) end |
#get_templates(device_id) ⇒ Object
53 54 55 |
# File 'lib/zenoss/jsonapi/device_router.rb', line 53 def get_templates(device_id) json_request('DeviceRouter', 'getTemplates', [{:id => device_id}]) end |
#remodel(uid, plugins = nil, background = false) ⇒ Object
plugin such as cisco.snmp.Interfaces
79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/zenoss/jsonapi/device_router.rb', line 79 def remodel(uid, plugins = nil, background = false) if @zenoss_version && @zenoss_version > '6' data = {} data[:deviceUid] = uid data[:collectPlugins] = plugins || '' data[:background] = background json_request('DeviceRouter', 'remodel', [data]) else raise ZenossError, 'remodel method on DeviceRouter is only allowed '\ 'for version 6 and above' end end |
#set_info(opts = {}) ⇒ Object
66 67 68 69 70 71 72 73 |
# File 'lib/zenoss/jsonapi/device_router.rb', line 66 def set_info(opts = {}) if @zenoss_version && @zenoss_version > '6' json_request('DeviceRouter', 'setInfo', [opts]) else raise ZenossError, 'setInfo method on DeviceRouter is only allowed '\ 'for version 6 and above' end end |