Class: Invoracle::System

Inherits:
JsonDoc::Document
  • Object
show all
Defined in:
lib/invoracle/system.rb

Overview

The Invoracle::System object is a JsonDoc::Document subclass with a default schema included in the #getDefaultSchema method and some systems specific methods.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dSchema = nil, bDefaultifyDoc = true, bIsStrict = true) ⇒ System

Returns a new instance of System.



10
11
12
13
14
15
# File 'lib/invoracle/system.rb', line 10

def initialize(dSchema=nil,bDefaultifyDoc=true,bIsStrict=true)
  @dSchema        = dSchema || self.getDefaultSchema()
  @bDefaultifyDoc = bDefaultifyDoc ? true : false
  @bIsStrict      = bIsStrict      ? true : false
  @dDocument      = self.getDefaultDocument()
end

Instance Attribute Details

#dSchemaObject

Returns the value of attribute dSchema.



9
10
11
# File 'lib/invoracle/system.rb', line 9

def dSchema
  @dSchema
end

Instance Method Details

#getDefaultSchemaObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/invoracle/system.rb', line 17

def getDefaultSchema()
  dSchema       =  {
    :type       => 'system',
    :properties => {
      :sCluUid             => { :default => '', :type => 'string', :description => 'Cluster UID' },

      :sSysUid             => { :default => '', :type => 'string', :description => 'System UID'  },
      :sSysFqdn            => { :default => '', :type => 'string', :description => 'FQDN' },
      :sSysHostFqdn        => { :default => '', :type => 'string', :description => 'FQDN Host' },
      :sSysIpAddress       => { :default => '', :type => 'string', :description => 'IP'   },

      :aSysRoles           => { :default => [], :type => 'array' , :description => 'Roles' },
      :dSysRoles           => { :default => {}, :type => 'object', :description => 'Roles' },
      :sSysRoles           => { :default => '', :type => 'string', :description => 'Roles' },

      :sDcUid              => { :default => '', :type => 'string', :description => 'DC'   },
      :sDcCageCode         => { :default => '', :type => 'string', :description => 'Cage' },
      :sDcRackCode         => { :default => '', :type => 'string', :description => 'Rack' },

      :sMfgName            => { :default => '', :type => 'string', :description => 'Mfg Name'    },
      :sMfgProductName     => { :default => '', :type => 'string', :description => 'Mfg Product' },

      :sBiosVersion        => { :default => '', :type => 'string', :description => 'Bios' },

      :sCpuModelName       => { :default => '', :type => 'string', :description => 'CPU Model' },
      :iCpuMhz             => { :default => -1, :type => 'number', :description => 'CPU MHz'   },
      :iCpuCount           => { :default => -1, :type => 'number', :description => 'CPU Count' },
      :iCpuCoresCount      => { :default => -1, :type => 'number', :description => 'CPU Cores' },
      :fCpuIdleAvg         => { :default => -1, :type => 'number', :description => 'CPU Idle'  },
      :fCpuIdleMinMin      => { :default => -1, :type => 'number', :description => 'CPU Idle Min Min'  },

      :iDiskUsedKb         => { :default => -1, :type => 'number', :description => 'Dsk KB Used'  },
      :fDiskUsedGb         => { :default => -1, :type => 'number', :description => 'Dsk GB Used'  },
      :fDiskAvailableGb    => { :default => -1, :type => 'number', :description => 'Dsk GB Avail' },
      :fDiskTotalGb        => { :default => -1, :type => 'number', :description => 'Dsk GB Total' },
      :fDiskUtilMaxMax     => { :default => -1, :type => 'number', :description => 'Dsk Util Max Max' },

      :iIpmHasIpm          => { :default => -1, :type => 'number', :description => 'IPM Present' },
      :sIpmType            => { :default => '', :type => 'string', :description => 'IPM Type'    },
      :sIpmVersion         => { :default => '', :type => 'string', :description => 'IPM Version' },
      :sIpmIpAddress       => { :default => '', :type => 'string', :description => 'IPM IP'      },
      :sIpmMacAddress      => { :default => '', :type => 'string', :description => 'IPM MAC'     },

      :sNetMacAddress      => { :default => '', :type => 'string', :description => 'MAC' },

      :sOsName             => { :default => '', :type => 'string', :description => 'OS' },
      :sOsVersion          => { :default => '', :type => 'string', :description => 'OS Version' },
      :sOsKernelRelease    => { :default => '', :type => 'string', :description => 'OS Kernel'  },

      :sRaidControllerName => { :default => '', :type => 'string', :description => 'RAID Controler'  },
      :iRaidDrivesNumAll   => { :default => -1, :type => 'number', :description => 'RAID Drives All' },
      :iRaidDrivesNumBad   => { :default => -1, :type => 'number', :description => 'RAID Drives Bad' },
      :sRaidVolumesRaw     => { :default => '', :type => 'string', :description => 'RAID Volumes Raw'  },

      :sVirType            => { :default => '', :type => 'string', :description => 'VM Type' },
      :sVirHostFqdn        => { :default => '', :type => 'string', :description => 'VM Host FQDN' },
      :iVirHostFqdnDiff    => { :default => -1, :type => 'number', :description => 'VM Host FQDN Diff' },
      :iVirHostIsVmware    => { :default => -1, :type => 'number', :description => 'Is VMWare' },
      :iVirHostIsKvm       => { :default => -1, :type => 'number', :description => 'Is KVM'    },
      :iVirIsGuest         => { :default => -1, :type => 'number', :description => 'Is Guest'  },
      :iVirIsHost          => { :default => -1, :type => 'number', :description => 'Is Host'   },
      :sVirVmwareSwInfo    => { :default => '', :type => 'string', :description => 'VMware Info'  },

      :sXDellSvcTag        => { :default => '', :type => 'string', :description => 'Svc Tag'  },
      :sXSfIdAct           => { :default => '', :type => 'string', :description => 'SFID'     },
    }
  }
  return dSchema
end

#hasSysRole(sSysRole = nil) ⇒ Object



107
108
109
110
111
112
113
# File 'lib/invoracle/system.rb', line 107

def hasSysRole(sSysRole=nil)
  return false if sSysRole.nil?
  if self.getAttr(:dSysRoles).has_key?(sSysRole)
    return true
  end
  return false
end

#inflateObject



87
88
89
90
# File 'lib/invoracle/system.rb', line 87

def inflate()
  self.inflateFqdn
  self.inflateSysRoles
end

#inflateFqdnObject



115
116
117
118
119
120
# File 'lib/invoracle/system.rb', line 115

def inflateFqdn()
  sVirHostFqdn = self.getAttr(:sVirHostFqdn)
  sVirHostFqdn.strip!
  sSysHostFqdn = sVirHostFqdn.length > 0 ? sVirHostFqdn : self.getAttr(:sSysFqdn)
  self.setAttr(:sSysHostFqdn,sSysHostFqdn)
end

#inflateSysRolesObject



92
93
94
95
96
97
98
99
100
101
102
103
104
105
# File 'lib/invoracle/system.rb', line 92

def inflateSysRoles()
  sSysRoles = self.getAttr(:sSysRoles)
  aSysRoles = self.getAttr(:aSysRoles)
  dSysRoles = self.getAttr(:dSysRoles)
  aSysRoles.each do |sSysRole|
    dSysRoles[sSysRole] = 1
  end
  sSysRoles.split(',').each do |sSysRole|
    dSysRoles[sSysRole] = 1
  end
  self.setAttr(:dSysRoles,dSysRoles)
  self.setAttr(:aSysRoles,dSysRoles.keys)
  self.setAttr(:sSysRoles,dSysRoles.keys.join(','))
end