invoracle 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +3 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +84 -0
- data/Rakefile +22 -0
- data/VERSION +1 -0
- data/lib/invoracle.rb +3 -0
- data/lib/invoracle/cluster.rb +47 -0
- data/lib/invoracle/system.rb +80 -0
- data/test/test_setup.rb +14 -0
- metadata +52 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b48f47f224c20458725773006013f46277f82d10
|
4
|
+
data.tar.gz: ac8fe16cb61a9c23afbc6bd4f6d49e6cb047860d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 954723ecc43678077287d44e3075b7bbdfc6af09407c1973040e9d741337b50ce9c0d8b715fd9f5e689b502b7698daa7a1a13abd2283d67061b90e591d147a89
|
7
|
+
data.tar.gz: f194155279830e9fb96cc17de425211df97cecac5a4735de3349ab74f222d48f79bcf9c2c46767a76adfb57aef2cb06b3b5353ae59426e5bad3fac627e539098
|
data/CHANGELOG
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 John Wang
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
= Invoracle
|
2
|
+
|
3
|
+
Invoracle (short for Inventory Oracle), is the basis of a flexible inventory reporting system that can be used to build custom reports for managing large numbers of computer systems. It is designed to provide a basis of reporting for thousands of systems using a generic, extensible JSON schema.
|
4
|
+
|
5
|
+
The Invoracle::System class is a subclass of the JsonDoc Ruby gem and adds a default JSON schema for computer systems to the functionality available in JsonDoc. It can be used as is or it can be further subclassed to add additional custom attributes.
|
6
|
+
|
7
|
+
Primary use cases include use as a core document object that various parsers can leverage to populate a strict schema JSON document and to build reporting systems such as CSV/Excel reports.
|
8
|
+
|
9
|
+
== Installation
|
10
|
+
|
11
|
+
=== Gem Installation
|
12
|
+
|
13
|
+
Download and install invoracle with the following:
|
14
|
+
|
15
|
+
gem install invoracle
|
16
|
+
|
17
|
+
== Usage
|
18
|
+
|
19
|
+
require 'invoracle'
|
20
|
+
|
21
|
+
system = Invoracle::System.new()
|
22
|
+
|
23
|
+
schema = generic_system.dSchema
|
24
|
+
|
25
|
+
system.setAttr(:sSysFqdn, system_fqdn)
|
26
|
+
|
27
|
+
system_fqdn = system.getAttr(:sSysFqdn)
|
28
|
+
system_hash = system.asHash
|
29
|
+
system_json = system.asJson
|
30
|
+
|
31
|
+
== Notes
|
32
|
+
|
33
|
+
=== Default Schema
|
34
|
+
|
35
|
+
To view the default schema, you can use pretty print the default schema using the dSchema accessor. The default schema uses Hungarian CamelCase (HCC) names which are described below. These names are still in development so please provide feedback.
|
36
|
+
|
37
|
+
=== Schema Property Formats
|
38
|
+
|
39
|
+
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:
|
40
|
+
|
41
|
+
a = array
|
42
|
+
d = dictionary / hash
|
43
|
+
f = float / number
|
44
|
+
h = html / string
|
45
|
+
i = integer / number
|
46
|
+
j = JSON / string
|
47
|
+
s = string
|
48
|
+
x = XML / string
|
49
|
+
|
50
|
+
=== Subclassing
|
51
|
+
|
52
|
+
To subclass this module, override the getDefaultSchema() method and add your own schema. To add a schema on to the default schema see the Usage section above.
|
53
|
+
|
54
|
+
=== Schema Validation
|
55
|
+
|
56
|
+
Schema validation is not provided in this version.
|
57
|
+
|
58
|
+
== Links
|
59
|
+
|
60
|
+
JSON
|
61
|
+
|
62
|
+
http://www.json.org/
|
63
|
+
|
64
|
+
JSON Schema
|
65
|
+
|
66
|
+
http://json-schema.org/
|
67
|
+
|
68
|
+
== Problems, Comments, Suggestions?
|
69
|
+
|
70
|
+
All of the above are most welcome. mailto:johncwang@gmail.com
|
71
|
+
|
72
|
+
== Credits
|
73
|
+
|
74
|
+
John Wang - http://johnwang.com
|
75
|
+
|
76
|
+
== License
|
77
|
+
|
78
|
+
JsonDoc is available under an MIT-style license.
|
79
|
+
|
80
|
+
:include: MIT-LICENSE
|
81
|
+
|
82
|
+
== Warranty
|
83
|
+
|
84
|
+
This software is provided "as is" and without any express or implied warranties, including, without limitation, the implied warranties of merchantibility and fitness for a particular purpose.
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rdoc/task'
|
4
|
+
|
5
|
+
desc 'Default: run unit tests.'
|
6
|
+
task :default => :test
|
7
|
+
|
8
|
+
desc 'Test the JsonDoc library.'
|
9
|
+
Rake::TestTask.new do |t|
|
10
|
+
t.libs << 'lib'
|
11
|
+
t.pattern = 'test/**/test_*.rb'
|
12
|
+
t.verbose = false
|
13
|
+
end
|
14
|
+
|
15
|
+
desc 'Generate RDoc documentation.'
|
16
|
+
RDoc::Task.new do |rdoc|
|
17
|
+
rdoc.rdoc_dir = 'rdoc'
|
18
|
+
rdoc.title = 'jsondoc'
|
19
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
20
|
+
rdoc.rdoc_files.include('README.rdoc')
|
21
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
22
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/lib/invoracle.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'invoracle/system'
|
2
|
+
|
3
|
+
module Invoracle
|
4
|
+
class Cluster
|
5
|
+
attr_accessor :sCluUid
|
6
|
+
attr_accessor :dSystems
|
7
|
+
|
8
|
+
def initialize(sCluUid='')
|
9
|
+
@sCluUid = sCluUid || ''
|
10
|
+
@dSystems = {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def setSystem(oSystem=nil)
|
14
|
+
if ! oSystem.nil? && oSystem.is_a?( Invoracle::System )
|
15
|
+
sSysUid = oSystem.getAttr(:sSysUid)
|
16
|
+
if sSysUid.nil? || ! sSysUid
|
17
|
+
raise ArgumentError, "E_NO_SYSTEM_UID"
|
18
|
+
end
|
19
|
+
@dSystems[sSysUid] = oSystem
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def getSystem(sSysUid=nil)
|
24
|
+
if ! sSysUid.nil? && sSysUid && @dSystems.has_key?( sSysUid )
|
25
|
+
return @dSystems[ sSysUid ]
|
26
|
+
end
|
27
|
+
return nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def getOrCreateSystem(sSysUid=nil)
|
31
|
+
if ! sSysUid.nil? && sSysUid && @dSystems.has_key?( sSysUid )
|
32
|
+
return @dSystems[ sSysUid ]
|
33
|
+
end
|
34
|
+
oSystem = Invoracle::System.new()
|
35
|
+
oSystem.setAttr(:sSysUid,sSysUid)
|
36
|
+
return oSystem
|
37
|
+
end
|
38
|
+
|
39
|
+
def getOneSystem()
|
40
|
+
oSystem = nil
|
41
|
+
@dSystems.each do |sSysUid,oSystemThis|
|
42
|
+
oSystem = oSystemThis
|
43
|
+
end
|
44
|
+
return oSystem
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require 'jsondoc'
|
2
|
+
|
3
|
+
module Invoracle
|
4
|
+
class System < JsonDoc::Document
|
5
|
+
attr_accessor :dSchema
|
6
|
+
def initialize(dSchema=nil,bDefaultifyDoc=true,bIsStrict=true)
|
7
|
+
@dSchema = dSchema || self.getDefaultSchema()
|
8
|
+
@bDefaultifyDoc = bDefaultifyDoc ? true : false
|
9
|
+
@bIsStrict = bIsStrict ? true : false
|
10
|
+
@dDocument = self.getDefaultDocument()
|
11
|
+
end
|
12
|
+
|
13
|
+
def getDefaultSchema()
|
14
|
+
dSchema = {
|
15
|
+
:type => 'system',
|
16
|
+
:properties => {
|
17
|
+
:sCluUid => { :default => '', :type => 'string', :description => 'Cluster UID' },
|
18
|
+
|
19
|
+
:sSysUid => { :default => '', :type => 'string', :description => 'System UID' },
|
20
|
+
:sSysFqdn => { :default => '', :type => 'string', :description => 'FQDN' },
|
21
|
+
:sSysIpAddress => { :default => '', :type => 'string', :description => 'IP' },
|
22
|
+
|
23
|
+
:aSysRoles => { :default => [], :type => 'array' , :description => 'Roles' },
|
24
|
+
:dSysRoles => { :default => {}, :type => 'object', :description => 'Roles' },
|
25
|
+
:sSysRoles => { :default => '', :type => 'string', :description => 'Roles' },
|
26
|
+
|
27
|
+
:sDcUid => { :default => '', :type => 'string', :description => 'DC' },
|
28
|
+
:sDcCageCode => { :default => '', :type => 'string', :description => 'Cage' },
|
29
|
+
:sDcRackCode => { :default => '', :type => 'string', :description => 'Rack' },
|
30
|
+
|
31
|
+
:sMfgName => { :default => '', :type => 'string', :description => 'Mfg Name' },
|
32
|
+
:sMfgProductName => { :default => '', :type => 'string', :description => 'Mfg Product' },
|
33
|
+
|
34
|
+
:sBiosVersion => { :default => '', :type => 'string', :description => 'Bios' },
|
35
|
+
|
36
|
+
:sCpuModelName => { :default => '', :type => 'string', :description => 'CPU Model' },
|
37
|
+
:iCpuMhz => { :default => -1, :type => 'number', :description => 'CPU MHz' },
|
38
|
+
:iCpuCount => { :default => -1, :type => 'number', :description => 'CPU Count' },
|
39
|
+
:iCpuCoresCount => { :default => -1, :type => 'number', :description => 'CPU Cores' },
|
40
|
+
:fCpuIdleAvg => { :default => -1, :type => 'number', :description => 'CPU Idle' },
|
41
|
+
|
42
|
+
:iDiskUsedKb => { :default => -1, :type => 'number', :description => 'Dsk KB Used' },
|
43
|
+
:fDiskUsedGb => { :default => -1, :type => 'number', :description => 'Dsk GB Used' },
|
44
|
+
:fDiskAvailableGb => { :default => -1, :type => 'number', :description => 'Dsk GB Avail' },
|
45
|
+
:fDiskTotalGb => { :default => -1, :type => 'number', :description => 'Dsk GB Total' },
|
46
|
+
:fDiskUtilMax => { :default => -1, :type => 'number', :description => 'Dsk Util Max' },
|
47
|
+
|
48
|
+
:iIpmHasIpm => { :default => -1, :type => 'number', :description => 'IPM Present' },
|
49
|
+
:sIpmType => { :default => '', :type => 'string', :description => 'IPM Type' },
|
50
|
+
:sIpmVersion => { :default => '', :type => 'string', :description => 'IPM Version' },
|
51
|
+
:sIpmIpAddress => { :default => '', :type => 'string', :description => 'IPM IP' },
|
52
|
+
:sIpmMacAddress => { :default => '', :type => 'string', :description => 'IPM MAC' },
|
53
|
+
|
54
|
+
:sNetMacAddress => { :default => '', :type => 'string', :description => 'MAC' },
|
55
|
+
|
56
|
+
:sOsName => { :default => '', :type => 'string', :description => 'OS' },
|
57
|
+
:sOsVersion => { :default => '', :type => 'string', :description => 'OS Version' },
|
58
|
+
:sOsKernelRelease => { :default => '', :type => 'string', :description => 'OS Kernel' },
|
59
|
+
|
60
|
+
:sRaidControllerName => { :default => '', :type => 'string', :description => 'RAID Controler' },
|
61
|
+
:iRaidDrivesNumAll => { :default => -1, :type => 'number', :description => 'RAID Drives All' },
|
62
|
+
:iRaidDrivesNumBad => { :default => -1, :type => 'number', :description => 'RAID Drives Bad' },
|
63
|
+
|
64
|
+
:sVirType => { :default => '', :type => 'string', :description => 'VM Type' },
|
65
|
+
:sVirHostFqdn => { :default => '', :type => 'string', :description => 'VM Host FQDN' },
|
66
|
+
:iVirHostFqdnDiff => { :default => -1, :type => 'number', :description => 'VM Host FQDN Diff' },
|
67
|
+
:iVirHostIsVmware => { :default => -1, :type => 'number', :description => 'Is VMWare' },
|
68
|
+
:iVirHostIsKvm => { :default => -1, :type => 'number', :description => 'Is KVM' },
|
69
|
+
:iVirIsGuest => { :default => -1, :type => 'number', :description => 'Is Guest' },
|
70
|
+
:iVirIsHost => { :default => -1, :type => 'number', :description => 'Is Host' },
|
71
|
+
:sVirVmwareSwInfo => { :default => '', :type => 'string', :description => 'VMware Info' },
|
72
|
+
|
73
|
+
:sXDellSvcTag => { :default => '', :type => 'string', :description => 'Svc Tag' },
|
74
|
+
:sXSfIdAct => { :default => '', :type => 'string', :description => 'SFID' },
|
75
|
+
}
|
76
|
+
}
|
77
|
+
return dSchema
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
data/test/test_setup.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'invoracle'
|
3
|
+
|
4
|
+
class InvoracleSystemTest < Test::Unit::TestCase
|
5
|
+
def testSetup
|
6
|
+
|
7
|
+
oSystem = Invoracle::System.new(nil,true,true)
|
8
|
+
|
9
|
+
oSystem.setAttr(:sSysFqdn,'demo.example.com')
|
10
|
+
|
11
|
+
assert_equal 'demo.example.com', oSystem.getAttr(:sSysFqdn)
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: invoracle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John Wang
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-01-01 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: A simple generic inventory system for managing computer systems.
|
14
|
+
email: john@johnwang.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- CHANGELOG
|
20
|
+
- MIT-LICENSE
|
21
|
+
- README.rdoc
|
22
|
+
- Rakefile
|
23
|
+
- VERSION
|
24
|
+
- lib/invoracle.rb
|
25
|
+
- lib/invoracle/cluster.rb
|
26
|
+
- lib/invoracle/system.rb
|
27
|
+
- test/test_setup.rb
|
28
|
+
homepage: http://johnwang.com/
|
29
|
+
licenses:
|
30
|
+
- MIT
|
31
|
+
metadata: {}
|
32
|
+
post_install_message:
|
33
|
+
rdoc_options: []
|
34
|
+
require_paths:
|
35
|
+
- lib
|
36
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - ">="
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
requirements: []
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 2.2.1
|
49
|
+
signing_key:
|
50
|
+
specification_version: 4
|
51
|
+
summary: Inventory Oracle - inventory management system
|
52
|
+
test_files: []
|