Class: Zenoss::Model::System
- Inherits:
-
Object
- Object
- Zenoss::Model::System
- Includes:
- Zenoss, Zenoss::Model
- Defined in:
- lib/zenoss/model/systems/system.rb
Instance Attribute Summary collapse
-
#organizer_name ⇒ Object
readonly
Returns the value of attribute organizer_name.
Instance Method Summary collapse
-
#add_subsystem(sys_name) ⇒ Object
Add a device beneath this Device Class.
-
#delete! ⇒ Object
Delete this System.
-
#delete_subsystem(sys_name) ⇒ Object
TODO: Need to add some error checking.
-
#get_id ⇒ Object
Instead of calling the /getId REST method, this method simply returns the @id value since it is the same anyway.
-
#initialize(devclass) ⇒ System
constructor
A new instance of System.
Methods included from Zenoss::Model
Methods included from Zenoss
connect, #parse_array, #pdatetime_to_datetime, #pdict_to_hash, #plist_to_array, #ptuples_to_hash, #sanitize_str
Constructor Details
#initialize(devclass) ⇒ System
Returns a new instance of System.
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/zenoss/model/systems/system.rb', line 28 def initialize(devclass) @base_id = 'Systems' # This confusing little ditty lets us accept a System in a number of ways: # Like, '/zport/dmd/Systems/MyService' # or, '/Systems/MyService' # or, '/MyService' path = devclass.sub(/^(\/zport\/dmd\/)?(#{@base_id}\/)?([\w\/]+)\/?$/,'\3') @id = path.split('/').last @organizer_name = rest('getOrganizerName', "#{@base_id}/#{path}") end |
Instance Attribute Details
#organizer_name ⇒ Object (readonly)
Returns the value of attribute organizer_name.
26 27 28 |
# File 'lib/zenoss/model/systems/system.rb', line 26 def organizer_name @organizer_name end |
Instance Method Details
#add_subsystem(sys_name) ⇒ Object
Add a device beneath this Device Class. It is also typically best to use the fully qualified version of the device name. It returns true if the device is added, false otherwise.
50 51 52 53 |
# File 'lib/zenoss/model/systems/system.rb', line 50 def add_subsystem(sys_name) loader = ZDeviceLoader.instance loader.add_system("#{@organizer_name}/#{sys_name}") end |
#delete! ⇒ Object
Delete this System
62 63 64 |
# File 'lib/zenoss/model/systems/system.rb', line 62 def delete! Zenoss.systems.delete_subsystem(@organizer_name) end |
#delete_subsystem(sys_name) ⇒ Object
TODO: Need to add some error checking. For now we are just returning true
56 57 58 59 |
# File 'lib/zenoss/model/systems/system.rb', line 56 def delete_subsystem(sys_name) rest("manage_deleteOrganizer?orgname=#{sys_name}") true end |
#get_id ⇒ Object
Instead of calling the /getId REST method, this method simply returns the @id value since it is the same anyway.
71 72 73 |
# File 'lib/zenoss/model/systems/system.rb', line 71 def get_id @id end |