zenoss_client 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -26,6 +26,10 @@ string unless you apply this patch:
26
26
 
27
27
  http://gist.github.com/328414
28
28
 
29
+ This has been reported and is filed as a product defect:
30
+
31
+ http://dev.zenoss.com/trac/ticket/6282
32
+
29
33
 
30
34
  == TO USE:
31
35
  A gem is now available. 'gem install zenoss_client'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -1,27 +1,28 @@
1
1
  #############################################################################
2
- # Copyright © 2009 Dan Wanek <dwanek@nd.gov>
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
3
  #
4
4
  #
5
- # This file is part of Zenoss-RubyREST.
5
+ # This file is part of zenoss_client.
6
6
  #
7
- # Zenoss-RubyREST is free software: you can redistribute it and/or
7
+ # zenoss_client is free software: you can redistribute it and/or
8
8
  # modify it under the terms of the GNU General Public License as published
9
9
  # by the Free Software Foundation, either version 3 of the License, or (at
10
10
  # your option) any later version.
11
11
  #
12
- # Zenoss-RubyREST is distributed in the hope that it will be useful,
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
13
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
15
  # Public License for more details.
16
16
  #
17
17
  # You should have received a copy of the GNU General Public License along
18
- # with Zenoss-RubyREST. If not, see <http://www.gnu.org/licenses/>.
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
19
  #############################################################################
20
20
  module Zenoss
21
21
  module Model
22
22
  class Device
23
23
  include Zenoss::Model
24
24
  include Zenoss::Model::EventView
25
+ include Zenoss::Model::DeviceResultInt
25
26
 
26
27
  attr_reader :path, :device, :os, :hw
27
28
 
@@ -33,10 +34,20 @@ module Zenoss
33
34
 
34
35
  @os = OperatingSystem.new(self)
35
36
  @hw = DeviceHW.new(self)
37
+
38
+ # Initialize common things from Model
39
+ model_init
36
40
  end
37
41
 
38
42
  # ------------------ REST Calls ------------------ #
39
43
 
44
+ # Move this Device to the given DeviceClass.
45
+ def change_device_class(device_class)
46
+ reset_cache_vars
47
+ rest("changeDeviceClass?deviceClassPath=#{device_class.organizer_name}")
48
+ end
49
+
50
+
40
51
  # Instead of calling the /getId REST method, this method simply returns
41
52
  # the @device value since it is the same anyway.
42
53
  def get_id()
@@ -1,21 +1,21 @@
1
1
  #############################################################################
2
- # Copyright © 2009 Dan Wanek <dwanek@nd.gov>
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
3
  #
4
4
  #
5
- # This file is part of Zenoss-RubyREST.
5
+ # This file is part of zenoss_client.
6
6
  #
7
- # Zenoss-RubyREST is free software: you can redistribute it and/or
7
+ # zenoss_client is free software: you can redistribute it and/or
8
8
  # modify it under the terms of the GNU General Public License as published
9
9
  # by the Free Software Foundation, either version 3 of the License, or (at
10
10
  # your option) any later version.
11
11
  #
12
- # Zenoss-RubyREST is distributed in the hope that it will be useful,
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
13
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
15
  # Public License for more details.
16
16
  #
17
17
  # You should have received a copy of the GNU General Public License along
18
- # with Zenoss-RubyREST. If not, see <http://www.gnu.org/licenses/>.
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
19
  #############################################################################
20
20
  module Zenoss
21
21
  module Model
@@ -32,10 +32,27 @@ module Zenoss
32
32
  # Like, '/zport/dmd/Devices/Server/Linux'
33
33
  # or, '/Devices/Server/Linux'
34
34
  # or, '/Server/Linux'
35
- path = devclass.sub(/^(\/zport\/dmd\/)?(@base_id\/)?([^\/]+)\/?$/,'\2')
35
+ path = devclass.sub(/^(\/zport\/dmd\/)?(#{@base_id}\/)?([^\/]+)\/?$/,'\2')
36
36
  @organizer_name = rest('getOrganizerName', "#{@base_id}/#{path}")
37
37
  end
38
38
 
39
+ # ------------------------- Utility Methods ------------------------- #
40
+ # These are methods that do not exist as part of the official Zenoss
41
+ # API, but from an object model they seem to make sense to me.
42
+ # ------------------------------------------------------------------- #
43
+
44
+ # Add a device beneath this Device Class. It is also typically best
45
+ # to use the fully qualified version of the device name.
46
+ # It returns true if the device is added, false otherwise.
47
+ def add_device(fully_qualified_device)
48
+ loader = ZDeviceLoader.instance
49
+ loader.load_device(fully_qualified_device, @organizer_name)
50
+ end
51
+
52
+
53
+
54
+ # --------------------------- REST Methods -------------------------- #
55
+
39
56
  # Name of the device in Zenoss. This method will return the first
40
57
  # match if the device_name is not fully qualified.
41
58
  def find_device_path(device_name)
@@ -48,7 +65,7 @@ module Zenoss
48
65
  end
49
66
 
50
67
 
51
- protected
68
+ private
52
69
 
53
70
  def rest(method, path = "#{@base_id}#{@organizer_name}")
54
71
  super("#{path}/#{method}")
File without changes
@@ -0,0 +1,53 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
+ #
4
+ #
5
+ # This file is part of zenoss_client.
6
+ #
7
+ # zenoss_client is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
20
+
21
+ # This file contains helper modules for minor classes that have to deal
22
+ # with Devices and DeviceClasses.
23
+
24
+ module Zenoss
25
+ module Model
26
+
27
+ module DeviceResultInt
28
+
29
+ # Return the path of the device_class; everything after '/zport/dmd/Devices'
30
+ def get_device_class_name
31
+ @cache_vars[:device_class_name] ||= rest('getDeviceClassName')
32
+ end
33
+
34
+ # Return the path of the device_class; everything after '/zport/dmd/Devices'
35
+ def get_device_class_path
36
+ get_device_class_name
37
+ end
38
+
39
+ # Return the DeviceClass object of this object
40
+ def device_class
41
+ @cache_vars[:device_class] ||= DeviceClass.new(get_device_class_name)
42
+ end
43
+ end # DeviceResultInt
44
+
45
+ end # Model
46
+ end # Zenoss
47
+
48
+
49
+ # Load the main Device related files
50
+ require 'model/devices/device_class'
51
+ require 'model/devices/device'
52
+ require 'model/devices/device_hw'
53
+ require 'model/devices/operating_system'
@@ -0,0 +1,19 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
+ #
4
+ #
5
+ # This file is part of zenoss_client.
6
+ #
7
+ # zenoss_client is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
@@ -0,0 +1,19 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
+ #
4
+ #
5
+ # This file is part of zenoss_client.
6
+ #
7
+ # zenoss_client is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
data/lib/model/model.rb CHANGED
@@ -1,21 +1,21 @@
1
1
  #############################################################################
2
- # Copyright © 2009 Dan Wanek <dwanek@nd.gov>
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
3
  #
4
4
  #
5
- # This file is part of Zenoss-RubyREST.
5
+ # This file is part of zenoss_client.
6
6
  #
7
- # Zenoss-RubyREST is free software: you can redistribute it and/or
7
+ # zenoss_client is free software: you can redistribute it and/or
8
8
  # modify it under the terms of the GNU General Public License as published
9
9
  # by the Free Software Foundation, either version 3 of the License, or (at
10
10
  # your option) any later version.
11
11
  #
12
- # Zenoss-RubyREST is distributed in the hope that it will be useful,
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
13
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
15
  # Public License for more details.
16
16
  #
17
17
  # You should have received a copy of the GNU General Public License along
18
- # with Zenoss-RubyREST. If not, see <http://www.gnu.org/licenses/>.
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
19
  #############################################################################
20
20
  require 'uri'
21
21
  require 'net/http'
@@ -24,21 +24,39 @@ module Zenoss
24
24
  module Model
25
25
  include Zenoss
26
26
 
27
+ # Common initialization for all Model components
28
+ def model_init
27
29
 
28
- # -------- Methods from DeviceResultInt.DeviceResultInt -------- #
30
+ # A place to maintain cached vars to prevent unnecessary REST calls
31
+ @cache_vars = {}
32
+ end
33
+
34
+
35
+ private
29
36
 
30
- def get_device_class_name
31
- rest('getDeviceClassName')
37
+ # Reset the cache variables so the REST calls return the appropriate
38
+ # values after a change has taken place.
39
+ def reset_cache_vars
40
+ @cache_vars.each_key do |key|
41
+ @cache_vars[key] = nil
42
+ end
32
43
  end
33
44
 
34
45
  end # Model
35
46
  end # Zenoss
36
47
 
37
- # Modules
38
48
  require 'model/event_view'
39
49
 
40
- # Classes
41
- require 'model/device'
42
- require 'model/device_class'
43
- require 'model/device_hw'
44
- require 'model/operating_system'
50
+ # Device Loader interface. You can use it directly or use the
51
+ # utility methods in DeviceClass to create devices beneath
52
+ # that class
53
+ require 'model/z_device_loader'
54
+
55
+ # Device Related ( /zport/dmd/Devices )
56
+ require 'model/devices'
57
+
58
+ # Service Related ( /zport/dmd/Services )
59
+ require 'model/services'
60
+
61
+ # Systems Related ( /zport/dmd/Systems )
62
+ require 'model/systems'
@@ -0,0 +1,19 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
+ #
4
+ #
5
+ # This file is part of zenoss_client.
6
+ #
7
+ # zenoss_client is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
@@ -0,0 +1,19 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
+ #
4
+ #
5
+ # This file is part of zenoss_client.
6
+ #
7
+ # zenoss_client is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
@@ -0,0 +1,19 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
+ #
4
+ #
5
+ # This file is part of zenoss_client.
6
+ #
7
+ # zenoss_client is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
@@ -0,0 +1,19 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
+ #
4
+ #
5
+ # This file is part of zenoss_client.
6
+ #
7
+ # zenoss_client is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
@@ -0,0 +1,44 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
+ #
4
+ #
5
+ # This file is part of zenoss_client.
6
+ #
7
+ # zenoss_client is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
20
+ module Zenoss
21
+ module Model
22
+ class ServiceOrganizer
23
+ include Zenoss
24
+ include Zenoss::Model
25
+
26
+ attr_reader :organizer_name
27
+
28
+ def initialize(service_organizer)
29
+ @base_id = 'Services'
30
+
31
+ path = service_organizer.sub(/^(\/zport\/dmd\/)?(@base_id\/)?([^\/]+)\/?$/,'\2')
32
+ @organizer_name = rest('getOrganizerName', "#{@base_id}/#{path}")
33
+ end
34
+
35
+
36
+ protected
37
+
38
+ def rest(method, path = "#{@base_id}#{@organizer_name}")
39
+ super("#{path}/#{method}")
40
+ end
41
+
42
+ end # ServiceOrganizer
43
+ end # Model
44
+ end # Zenoss
@@ -0,0 +1,19 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
+ #
4
+ #
5
+ # This file is part of zenoss_client.
6
+ #
7
+ # zenoss_client is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
@@ -0,0 +1,24 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
+ #
4
+ #
5
+ # This file is part of zenoss_client.
6
+ #
7
+ # zenoss_client is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
20
+ require 'model/services/service_organizer'
21
+ require 'model/services/service_class'
22
+ require 'model/services/service'
23
+ require 'model/services/ip_service'
24
+ require 'model/services/win_service'
@@ -0,0 +1,83 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
+ #
4
+ #
5
+ # This file is part of zenoss_client.
6
+ #
7
+ # zenoss_client is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
20
+ module Zenoss
21
+ module Model
22
+ class System
23
+ include Zenoss
24
+ include Zenoss::Model
25
+
26
+ attr_reader :organizer_name
27
+
28
+ def initialize(devclass)
29
+ @base_id = 'Systems'
30
+
31
+ # This confusing little ditty lets us accept a System in a number of ways:
32
+ # Like, '/zport/dmd/Systems/MyService'
33
+ # or, '/Systems/MyService'
34
+ # or, '/MyService'
35
+ path = devclass.sub(/^(\/zport\/dmd\/)?(#{@base_id}\/)?([\w\/]+)\/?$/,'\3')
36
+
37
+ @id = path.split('/').last
38
+ @organizer_name = rest('getOrganizerName', "#{@base_id}/#{path}")
39
+ end
40
+
41
+
42
+ # ------------------------- Utility Methods ------------------------- #
43
+ # These are methods that do not exist as part of the official Zenoss
44
+ # API, but from an object model they seem to make sense to me.
45
+ # ------------------------------------------------------------------- #
46
+
47
+ # Add a device beneath this Device Class. It is also typically best
48
+ # to use the fully qualified version of the device name.
49
+ # It returns true if the device is added, false otherwise.
50
+ def add_subsystem(sys_name)
51
+ loader = ZDeviceLoader.instance
52
+ loader.add_system("#{@organizer_name}/#{sys_name}")
53
+ end
54
+
55
+ # TODO: Need to add some error checking. For now we are just returning true
56
+ def delete_subsystem(sys_name)
57
+ rest("manage_deleteOrganizer?orgname=#{sys_name}")
58
+ true
59
+ end
60
+
61
+ # Delete this System
62
+ def delete!
63
+ Zenoss.systems.delete_subsystem(@organizer_name)
64
+ end
65
+
66
+
67
+ # --------------------------- REST Methods -------------------------- #
68
+
69
+ # Instead of calling the /getId REST method, this method simply returns
70
+ # the @id value since it is the same anyway.
71
+ def get_id
72
+ @id
73
+ end
74
+
75
+ private
76
+
77
+ def rest(method, path = "#{@base_id}#{@organizer_name}")
78
+ super("#{path}/#{method}")
79
+ end
80
+
81
+ end # System
82
+ end # Model
83
+ end # Zenoss
@@ -0,0 +1,20 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
+ #
4
+ #
5
+ # This file is part of zenoss_client.
6
+ #
7
+ # zenoss_client is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
20
+ require 'model/systems/system'
@@ -0,0 +1,65 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
+ #
4
+ #
5
+ # This file is part of zenoss_client.
6
+ #
7
+ # zenoss_client is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
20
+ require 'singleton'
21
+ module Zenoss
22
+ module Model
23
+ class ZDeviceLoader
24
+ include Model
25
+ include Singleton
26
+
27
+ def initialize
28
+ @path = "DeviceLoader"
29
+ end
30
+
31
+
32
+ # Load a device into the database connecting its major relations and collecting its configuration.
33
+ # loadDevice(self, deviceName, devicePath="/Discovered", tag="", serialNumber="", zSnmpCommunity="",
34
+ # zSnmpPort=161, zSnmpVer=None, rackSlot=0, productionState=1000, comments="", hwManufacturer="",
35
+ # hwProductName="", osManufacturer="", osProductName="", locationPath="", groupPaths=[], systemPaths=[],
36
+ # performanceMonitor="localhost", discoverProto="snmp", priority=3, REQUEST=None)
37
+ #
38
+ # TODO: Enhance this functionality
39
+ # Return: true if the device is added, false if it is not
40
+ def load_device(device_name, device_path)
41
+ method = "loadDevice?deviceName=#{device_name}&devicePath=#{device_path}"
42
+ body = rest(method)
43
+ (body =~ /Navigate to device/) ? true : false
44
+ end
45
+
46
+ #add a system to the database
47
+ # addSystem(self, newSystemPath, REQUEST=None)
48
+ def add_system(system_path)
49
+ method = "addSystem?newSystemPath=#{system_path}"
50
+ rest(method)
51
+ sys = System.new("/Systems/#{system_path}")
52
+ end
53
+
54
+
55
+ private
56
+
57
+ def rest(method)
58
+ super("#{@path}/#{method}")
59
+ end
60
+
61
+
62
+
63
+ end # ZDeviceLoader
64
+ end # Model
65
+ end # Zenoss
@@ -0,0 +1,34 @@
1
+ #############################################################################
2
+ # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
+ #
4
+ #
5
+ # This file is part of zenoss_client.
6
+ #
7
+ # zenoss_client is free software: you can redistribute it and/or
8
+ # modify it under the terms of the GNU General Public License as published
9
+ # by the Free Software Foundation, either version 3 of the License, or (at
10
+ # your option) any later version.
11
+ #
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
+ # Public License for more details.
16
+ #
17
+ # You should have received a copy of the GNU General Public License along
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
+ #############################################################################
20
+ module Zenoss
21
+ module Model
22
+ class ZenPackManager
23
+ include Model
24
+
25
+ def initialize
26
+ model_init
27
+ end
28
+
29
+ def manage_add_zenpack(zenpack_id)
30
+ end
31
+
32
+ end
33
+ end # Model
34
+ end # Zenoss
data/lib/zenoss.rb CHANGED
@@ -2,20 +2,20 @@
2
2
  # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
3
  #
4
4
  #
5
- # This file is part of Zenoss-RubyREST.
5
+ # This file is part of zenoss_client.
6
6
  #
7
- # Zenoss-RubyREST is free software: you can redistribute it and/or
7
+ # zenoss_client is free software: you can redistribute it and/or
8
8
  # modify it under the terms of the GNU General Public License as published
9
9
  # by the Free Software Foundation, either version 3 of the License, or (at
10
10
  # your option) any later version.
11
11
  #
12
- # Zenoss-RubyREST is distributed in the hope that it will be useful,
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
13
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
15
  # Public License for more details.
16
16
  #
17
17
  # You should have received a copy of the GNU General Public License along
18
- # with Zenoss-RubyREST. If not, see <http://www.gnu.org/licenses/>.
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
19
  #############################################################################
20
20
  require 'rubygems'
21
21
  require 'date'
@@ -46,6 +46,17 @@ module Zenoss
46
46
  Model::DeviceClass.new('/zport/dmd/Devices')
47
47
  end
48
48
 
49
+ # Return the base ServiceOrganizer /zport/dmd/Services
50
+ def Zenoss.services
51
+ Model::ServiceOrganizer.new('/zport/dmd/Services')
52
+ end
53
+
54
+ # Return the base System /zport/dmd/Systems
55
+ def Zenoss.systems
56
+ Model::System.new('/zport/dmd/Systems')
57
+ end
58
+
59
+
49
60
 
50
61
  private
51
62
 
data/preamble CHANGED
@@ -2,18 +2,18 @@
2
2
  # Copyright © 2010 Dan Wanek <dwanek@nd.gov>
3
3
  #
4
4
  #
5
- # This file is part of Zenoss-RubyREST.
5
+ # This file is part of zenoss_client.
6
6
  #
7
- # Zenoss-RubyREST is free software: you can redistribute it and/or
7
+ # zenoss_client is free software: you can redistribute it and/or
8
8
  # modify it under the terms of the GNU General Public License as published
9
9
  # by the Free Software Foundation, either version 3 of the License, or (at
10
10
  # your option) any later version.
11
11
  #
12
- # Zenoss-RubyREST is distributed in the hope that it will be useful,
12
+ # zenoss_client is distributed in the hope that it will be useful,
13
13
  # but WITHOUT ANY WARRANTY; without even the implied warranty of
14
14
  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15
15
  # Public License for more details.
16
16
  #
17
17
  # You should have received a copy of the GNU General Public License along
18
- # with Zenoss-RubyREST. If not, see <http://www.gnu.org/licenses/>.
18
+ # with zenoss_client. If not, see <http://www.gnu.org/licenses/>.
19
19
  #############################################################################
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zenoss_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 3
9
+ version: 0.0.3
5
10
  platform: ruby
6
11
  authors:
7
12
  - Dan Wanek
@@ -9,19 +14,21 @@ autorequire:
9
14
  bindir: bin
10
15
  cert_chain: []
11
16
 
12
- date: 2010-03-11 00:00:00 -06:00
17
+ date: 2010-03-29 00:00:00 -05:00
13
18
  default_executable:
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: tzinfo
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
20
24
  requirements:
21
25
  - - ">="
22
26
  - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
23
29
  version: "0"
24
- version:
30
+ type: :runtime
31
+ version_requirements: *id001
25
32
  description: " \tThis is a Ruby library for accessing Zenoss through its REST interface. It is a work in progress and as functionality is testing\n\
26
33
  \tit will be added. For documentation on what the method calls do see the official Zenoss API docs.\n"
27
34
  email: dan.wanek@gmail.com
@@ -37,12 +44,26 @@ files:
37
44
  - README.rdoc
38
45
  - Rakefile
39
46
  - VERSION
40
- - lib/model/device.rb
41
- - lib/model/device_class.rb
42
- - lib/model/device_hw.rb
47
+ - lib/model/devices.rb
48
+ - lib/model/devices/device.rb
49
+ - lib/model/devices/device_class.rb
50
+ - lib/model/devices/device_hw.rb
51
+ - lib/model/devices/operating_system.rb
43
52
  - lib/model/event_view.rb
53
+ - lib/model/events/event_class.rb
54
+ - lib/model/manufacturers/manufacturers.rb
44
55
  - lib/model/model.rb
45
- - lib/model/operating_system.rb
56
+ - lib/model/processes/os_process_organizer.rb
57
+ - lib/model/services.rb
58
+ - lib/model/services/ip_service.rb
59
+ - lib/model/services/service.rb
60
+ - lib/model/services/service_class.rb
61
+ - lib/model/services/service_organizer.rb
62
+ - lib/model/services/win_service.rb
63
+ - lib/model/systems.rb
64
+ - lib/model/systems/system.rb
65
+ - lib/model/z_device_loader.rb
66
+ - lib/model/zenpack/zenpack_manager.rb
46
67
  - lib/zenoss.rb
47
68
  - preamble
48
69
  has_rdoc: true
@@ -63,18 +84,22 @@ required_ruby_version: !ruby/object:Gem::Requirement
63
84
  requirements:
64
85
  - - ">="
65
86
  - !ruby/object:Gem::Version
87
+ segments:
88
+ - 1
89
+ - 8
90
+ - 7
66
91
  version: 1.8.7
67
- version:
68
92
  required_rubygems_version: !ruby/object:Gem::Requirement
69
93
  requirements:
70
94
  - - ">="
71
95
  - !ruby/object:Gem::Version
96
+ segments:
97
+ - 0
72
98
  version: "0"
73
- version:
74
99
  requirements: []
75
100
 
76
101
  rubyforge_project:
77
- rubygems_version: 1.3.5
102
+ rubygems_version: 1.3.6
78
103
  signing_key:
79
104
  specification_version: 3
80
105
  summary: A Ruby API for accessing Zenoss via REST