invoracle 0.0.3 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 430f4ef1a790bb55a8b3732adb355af3fc2bb863
4
+ data.tar.gz: 99b6db6f1d85f0568874f052b1bde9506b1141bb
5
+ SHA512:
6
+ metadata.gz: 255dceda0c35ef7a1f3132da41a35d583f1059d07def38fb6c14ceec8a2bfb7ce0ac2588f0d6079e5ff20c5565940af50f5b989a1368c792d4cb42ff3b8c35aa
7
+ data.tar.gz: 519f0ce27cf247057644ed4bf5cd6b57a9b2feb4733702f34d307179706a3e2c572cb2352d763622b04dfc8f00926207a83914a4d774a5c8fa19c3a5d23b54fa
@@ -1,5 +1,8 @@
1
1
  CHANGELOG
2
2
  ---------
3
+ - **2014-03-08**: 0.0.4
4
+ - Add Invoracle::SystemsSet to manage sets of systems
5
+
3
6
  - **2014-03-05**: 0.0.3
4
7
  - Retreive Systems from Cluster via SysRoles
5
8
  - Inflate System SysRoles
data/README.md CHANGED
@@ -13,13 +13,16 @@ Primary use cases include use as a core document object that various parsers can
13
13
  Installing
14
14
  ----------
15
15
 
16
- To install SalesforceCache, use the following command:
16
+ To install Invoracle, use the following command:
17
17
 
18
18
  $ gem install invoracle
19
19
 
20
20
  #Examples
21
21
  ---------
22
22
 
23
+ System
24
+ ------
25
+
23
26
  require 'invoracle'
24
27
 
25
28
  system = Invoracle::System.new
@@ -32,6 +35,26 @@ To install SalesforceCache, use the following command:
32
35
  system_hash = system.asHash
33
36
  system_json = system.asJson
34
37
 
38
+ Systems Set
39
+ -----------
40
+
41
+ require 'invoracle'
42
+
43
+ systemsSet = Invoracle::SystemsSet.new
44
+
45
+ system = Invoracle::System.new
46
+ system.setAttr(:sSysUid,'foo.bar.com') # System UID
47
+ system.setAttr(:sCluUid,'foo-bar-cluster') # Cluster UID
48
+
49
+ systemsSet.addSystem( system )
50
+
51
+ clusterCount = systemsSet.getClusterCount
52
+ clusterUids = systemsSet.getClusterUids
53
+ systemCount = systemsSet.getSystemCount
54
+
55
+ system = systemsSet.getSystem( systemUid )
56
+ systems = systemsset.getSystemsForClusterUid( clusterUid )
57
+
35
58
  #Documentation
36
59
  --------------
37
60
 
@@ -49,16 +72,7 @@ Notes
49
72
 
50
73
  2. Schema Property Formats
51
74
 
52
- The default properties, which can be overridden, use a short form of "Hungarian CamelCase" where properties are prefixed with type abbreviations including ['a','d','f','i','j','s','x'] for:
53
-
54
- a = array,
55
- d = dictionary / hash,
56
- f = float / number,
57
- h = html / string,
58
- i = integer / number,
59
- j = JSON / string,
60
- s = string,
61
- x = XML / string
75
+ The default properties, which can be overridden, use a short form of "Hungarian CamelCase" where properties are prefixed with type abbreviations including ['a','d','f','i','j','s','x'] for: a = array, d = dictionary / hash, f = float / number, h = html / string, i = integer / number, j = JSON / string, s = string, x = XML / string
62
76
 
63
77
  3. Subclassing
64
78
 
@@ -71,14 +85,14 @@ Notes
71
85
  #Change Log
72
86
  -----------
73
87
 
88
+ - **2014-03-08**: 0.0.4
89
+ - Add Invoracle::SystemsSet to manage sets of systems
74
90
  - **2014-03-05**: 0.0.3
75
91
  - Retreive Systems from Cluster via SysRoles
76
92
  - Inflate System SysRoles
77
-
78
93
  - **2014-02-15**: 0.0.2
79
94
  - Invoracle::Cluster is now a JsonDoc subclass
80
95
  - Inforacle::Infra::IostatParser added
81
-
82
96
  - **2014-01-01**: 0.0.1
83
97
  - Initial release
84
98
  - JsonDoc subclass for Invoracle::System
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -1,4 +1,5 @@
1
1
  module Invoracle
2
- autoload :System, 'invoracle/system'
3
- autoload :Cluster, 'invoracle/cluster'
2
+ autoload :Cluster , 'invoracle/cluster'
3
+ autoload :System , 'invoracle/system'
4
+ autoload :SystemsSet, 'invoracle/systems_set'
4
5
  end
@@ -1,6 +1,10 @@
1
1
  require 'jsondoc'
2
2
 
3
3
  module Invoracle
4
+
5
+ # The Invoracle::System object is a JsonDoc::Document subclass with a default schema
6
+ # included in the #getDefaultSchema method and some systems specific methods.
7
+
4
8
  class System < JsonDoc::Document
5
9
  attr_accessor :dSchema
6
10
  def initialize(dSchema=nil,bDefaultifyDoc=true,bIsStrict=true)
@@ -18,6 +22,7 @@ module Invoracle
18
22
 
19
23
  :sSysUid => { :default => '', :type => 'string', :description => 'System UID' },
20
24
  :sSysFqdn => { :default => '', :type => 'string', :description => 'FQDN' },
25
+ :sSysHostFqdn => { :default => '', :type => 'string', :description => 'FQDN Host' },
21
26
  :sSysIpAddress => { :default => '', :type => 'string', :description => 'IP' },
22
27
 
23
28
  :aSysRoles => { :default => [], :type => 'array' , :description => 'Roles' },
@@ -79,6 +84,11 @@ module Invoracle
79
84
  return dSchema
80
85
  end
81
86
 
87
+ def inflate()
88
+ self.inflateFqdn
89
+ self.inflateSysRoles
90
+ end
91
+
82
92
  def inflateSysRoles()
83
93
  sSysRoles = self.getAttr(:sSysRoles)
84
94
  aSysRoles = self.getAttr(:aSysRoles)
@@ -101,5 +111,12 @@ module Invoracle
101
111
  end
102
112
  return false
103
113
  end
114
+
115
+ def inflateFqdn()
116
+ sVirHostFqdn = self.getAttr(:sVirHostFqdn)
117
+ sVirHostFqdn.strip!
118
+ sSysHostFqdn = sVirHostFqdn.length > 0 ? sVirHostFqdn : self.getAttr(:sSysFqdn)
119
+ self.setAttr(:sSysHostFqdn,sSysHostFqdn)
120
+ end
104
121
  end
105
122
  end
@@ -0,0 +1,126 @@
1
+ module Invoracle
2
+
3
+ # Invoracle::SystemsSet maintains a group of Invoracle::System objects and
4
+ # their associated cluster UIDs.
5
+ #
6
+ # Initial use case is to create sets of Invoracle::Systems and then retrieve
7
+ # them by Cluster UID.
8
+ #
9
+ # Examples
10
+ #
11
+ # systemsSet = Invoracle::SystemsSet.new
12
+ # systemsSet.addSystem( system )
13
+ # systemsSet.getSystem( systemUid )
14
+ # systemsSet.exists?( system )
15
+ #
16
+ # systemsSet.getClusterCount
17
+ # systemsSet.getSystemCount
18
+ #
19
+ # systemsSet.getClusterUids
20
+ #
21
+ # systemsSet.inflateSystems
22
+ #
23
+ # systemsSet.getSystemsForClusterUid( clusterUid )
24
+
25
+ class SystemsSet
26
+ attr_reader :dSystemsBySysUid
27
+ attr_reader :dSysUidsbyCluUid
28
+ def initialize()
29
+ @dSystemsBySysUid = {}
30
+ @dSysUidsbyCluUid = {}
31
+ end
32
+
33
+ def getClusterCount()
34
+ return @dSysUidsbyCluUid.keys.length
35
+ end
36
+
37
+ def getSystemCount()
38
+ return @dSystemsBySysUid.keys.length
39
+ end
40
+
41
+ def getClusterUids()
42
+ aClusterUids = @dSysUidsbyCluUid.keys
43
+ aClusterUids.sort!
44
+ return aClusterUids
45
+ end
46
+
47
+ # Given an Invoracle::System, returns true or false if the system is
48
+ # within the set
49
+
50
+ def exists?(oSystem=nil)
51
+ unless oSystem.is_a?(Invoracle::System)
52
+ raise ArgumentError, "E_BAD_SYSTEM_OBJECT #{oSystem.class}]"
53
+ end
54
+
55
+ sSysUid = oSystem.getAttr(:sSysUid)
56
+ unless sSysUid.kind_of?(String) && sSysUid.length > 0
57
+ raise ArgumentError, 'E_BAD_SYSTEM_UID'
58
+ end
59
+
60
+ bHasSys = @dSystemsBySysUid.has_key?(sSysUid) ? true : false
61
+
62
+ return bHasSys
63
+ end
64
+
65
+ def getSystem(sSysUid=nil)
66
+ unless sSysUid.kind_of?(String) && sSysUid.length > 0
67
+ raise ArgumentError, 'E_BAD_SYSTEM_UID'
68
+ end
69
+
70
+ oSystem = @dSystemsBySysUid.has_key( sSysUid ) \
71
+ ? @dSystemsBySysUid[ sSysUid ] : nil
72
+
73
+ return oSystem
74
+ end
75
+
76
+ def setSystem(oSystem=nil)
77
+ unless oSystem.is_a?(Invoracle::System)
78
+ raise ArgumentError, 'E_BAD_SYSTEM_OBJECT'
79
+ end
80
+
81
+ sSysUid = oSystem.getAttr(:sSysUid)
82
+ unless sSysUid.kind_of?(String)
83
+ raise ArgumentError, 'E_BAD_SYSTEM_UID'
84
+ end
85
+
86
+ sSysUid.strip!
87
+ unless sSysUid.length > 0
88
+ raise ArgumentError, 'E_BAD_SYSTEM_UID'
89
+ end
90
+
91
+ @dSystemsBySysUid[ sSysUid ] = oSystem
92
+
93
+ sCluUid = oSystem.getAttr(:sCluUid)
94
+ if sCluUid.kind_of?(String) && sCluUid.length > 0
95
+ @dSysUidsbyCluUid[ sCluUid ] ||= {}
96
+ @dSysUidsbyCluUid[ sCluUid ][ sSysUid ] = 1
97
+ end
98
+ end
99
+
100
+ # Calls the #inflate method on each system in the set.
101
+
102
+ def inflateSystems()
103
+ @dSystemsBySysUid.keys.each do |sSysUid|
104
+ @dSystemsBySysUid[ sSysUid ].inflate
105
+ end
106
+ end
107
+
108
+ def getSystemsForClusterUid(sCluUid=nil)
109
+ unless sCluUid.kind_of?(String) && sCluUid.length > 0
110
+ raise ArgumentError, 'E_BAD_CLUSTER_UID'
111
+ end
112
+
113
+ aSystems = []
114
+ if @dSysUidsbyCluUid.has_key?( sCluUid )
115
+ @dSysUidsbyCluUid[ sCluUid ].keys.each do |sSysUid|
116
+ if @dSystemsBySysUid.has_key?( sSysUid )
117
+ oSystem = @dSystemsBySysUid[ sSysUid ]
118
+ aSystems.push( oSystem )
119
+ end
120
+ end
121
+ end
122
+ return aSystems
123
+ end
124
+
125
+ end
126
+ end
metadata CHANGED
@@ -1,27 +1,21 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: invoracle
3
- version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.0.3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.4
6
5
  platform: ruby
7
- authors:
6
+ authors:
8
7
  - John Wang
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
-
13
- date: 2014-03-05 00:00:00 Z
11
+ date: 2014-03-08 00:00:00.000000000 Z
14
12
  dependencies: []
15
-
16
13
  description: A simple generic inventory system for managing computer systems.
17
14
  email: john@johnwang.com
18
15
  executables: []
19
-
20
16
  extensions: []
21
-
22
17
  extra_rdoc_files: []
23
-
24
- files:
18
+ files:
25
19
  - CHANGELOG.md
26
20
  - LICENSE
27
21
  - README.md
@@ -29,36 +23,33 @@ files:
29
23
  - VERSION
30
24
  - lib/invoracle.rb
31
25
  - lib/invoracle/cluster.rb
32
- - lib/invoracle/system.rb
33
26
  - lib/invoracle/infra.rb
34
27
  - lib/invoracle/infra/iostat_parser.rb
28
+ - lib/invoracle/system.rb
29
+ - lib/invoracle/systems_set.rb
35
30
  - test/test_setup.rb
36
31
  homepage: http://johnwang.com/
37
- licenses:
32
+ licenses:
38
33
  - MIT
34
+ metadata: {}
39
35
  post_install_message:
40
36
  rdoc_options: []
41
-
42
- require_paths:
37
+ require_paths:
43
38
  - lib
44
- required_ruby_version: !ruby/object:Gem::Requirement
45
- none: false
46
- requirements:
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
47
41
  - - ">="
48
- - !ruby/object:Gem::Version
49
- version: "0"
50
- required_rubygems_version: !ruby/object:Gem::Requirement
51
- none: false
52
- requirements:
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
53
46
  - - ">="
54
- - !ruby/object:Gem::Version
55
- version: "0"
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
56
49
  requirements: []
57
-
58
50
  rubyforge_project:
59
- rubygems_version: 1.8.11
51
+ rubygems_version: 2.2.1
60
52
  signing_key:
61
- specification_version: 3
53
+ specification_version: 4
62
54
  summary: Inventory Oracle - inventory management system
63
55
  test_files: []
64
-