Module: Inventory
- Included in:
- UCS
- Defined in:
- lib/ucslib/service/ucs/inventory.rb
Instance Method Summary collapse
-
#discover ⇒ Object
@cookie = “#'cookie'” ip = “#'ip'” @url = “https://#ip/nuova”.
- #list_blades(ucs_multi_class_xml) ⇒ Object
- #list_cpus(ucs_multi_class_xml) ⇒ Object
- #list_memory(ucs_multi_class_xml) ⇒ Object
- #list_running_firmware(ucs_multi_class_xml) ⇒ Object
- #list_service_profiles(ucs_multi_class_xml) ⇒ Object
- #list_vlans(ucs_multi_class_xml) ⇒ Object
- #list_vsans(ucs_multi_class_xml) ⇒ Object
Instance Method Details
#discover ⇒ Object
@cookie = “#'cookie'”
ip = "#{JSON.parse(tokenjson)['ip']}"
@url = "https://#{ip}/nuova"
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 86 87 88 89 90 91 |
# File 'lib/ucslib/service/ucs/inventory.rb', line 28 def discover #Start Build the Multi-Class XML xml_builder = Nokogiri::XML::Builder.new do |xml| xml.configResolveClasses('cookie' => @cookie, 'inHierarchical' => 'false') { xml.inIds{ xml.classId("value" => "topSystem") xml.classId("value" => "equipmentChassis") xml.classId("value" => "computeBlade") xml.classId("value" => "networkElement") xml.classId("value" => "equipmentSwitchCard") xml.classId("value" => "equipmentIOCard") xml.classId("value" => "equipmentFanModule") xml.classId("value" => "equipmentPsu") xml.classId("value" => "networkElement") xml.classId("value" => "processorUnit") xml.classId("value" => "adaptorHostIf") xml.classId("value" => "memoryArray") xml.classId("value" => "memoryUnit") xml.classId("value" => "storageLocalDisk") xml.classId("value" => "equipmentFan") xml.classId("value" => "firmwareRunning") xml.classId("value" => "lsServer") xml.classId("value" => "orgOrg") xml.classId("value" => "fabricVlan") xml.classId("value" => "vnicEther") xml.classId("value" => "vnicFc") xml.classId("value" => "fabricVsan") xml.classId("value" => "vmAdaptor") xml.classId("value" => "vmCont") xml.classId("value" => "vmDC") xml.classId("value" => "vmDCOrg") xml.classId("value" => "vmDirCont") xml.classId("value" => "vmEp") xml.classId("value" => "vmHba") xml.classId("value" => "vmHv") xml.classId("value" => "vmInstance") xml.classId("value" => "vmLifeCyclePolicy") xml.classId("value" => "vmNic") xml.classId("value" => "vmOrg") xml.classId("value" => "vmSwitch") xml.classId("value" => "vmVif") xml.classId("value" => "vmVirtual") xml.classId("value" => "vmVlan") xml.classId("value" => "vmVnicProfCl") xml.classId("value" => "vmVnicProfInst") xml.classId("value" => "vmVsan") } } end #End Build Multi-Class XML ucs_multi_class_XML = xml_builder.to_xml.to_s ucs_response_multi_class = RestClient.post(@url, ucs_multi_class_XML, :content_type => 'text/xml').body #Uncomment the following to create a dump to review and debug elements # fh = File.new("ucs_response_multiclass.xml", "w") # fh.puts ucs_response_multi_class.inspect # fh.close return Nokogiri::XML(ucs_response_multi_class) end |
#list_blades(ucs_multi_class_xml) ⇒ Object
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/ucslib/service/ucs/inventory.rb', line 94 def list_blades(ucs_multi_class_xml) ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/computeBlade").each do |blade| puts "Blade : #{blade.attributes["serverId"]} model: #{blade.attributes["model"]}" \ " with serial: #{blade.attributes["serial"]} is powered: #{blade.attributes["operPower"]}" end end |
#list_cpus(ucs_multi_class_xml) ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/ucslib/service/ucs/inventory.rb', line 125 def list_cpus(ucs_multi_class_xml) ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/processorUnit").each do |processorunit| puts "CPU model: #{processorunit.attributes["model"]} Architecture: #{processorunit.attributes["arch"]} with #{processorunit.attributes["cores"]}" \ "cores with #{processorunit.attributes["coresEnabled"]} enabled ID: #{processorunit.attributes["id"]} Speed: #{processorunit.attributes["speed"]}" \ "Threads: #{processorunit.attributes["threads"]} Vendor: #{processorunit.attributes["vendor"]}" end end |
#list_memory(ucs_multi_class_xml) ⇒ Object
137 138 139 140 141 142 143 144 145 |
# File 'lib/ucslib/service/ucs/inventory.rb', line 137 def list_memory(ucs_multi_class_xml) ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/computeBlade").each do |blade| puts "Available Memory: #{blade.attributes["availableMemory"]} Total Memory: #{blade.attributes["totalMemory"]} Speed: #{blade.attributes["memorySpeed"]}" end end |
#list_running_firmware(ucs_multi_class_xml) ⇒ Object
158 159 160 161 162 163 164 165 166 167 |
# File 'lib/ucslib/service/ucs/inventory.rb', line 158 def list_running_firmware(ucs_multi_class_xml) ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/firmwareRunning").each do |firmware| puts "Firmware: #{firmware.attributes["dn"]} version #{firmware.attributes["packageVersion"]} package version" \ " #{firmware.attributes["packageVersion"]} type #{firmware.attributes["type"]}" end end |
#list_service_profiles(ucs_multi_class_xml) ⇒ Object
147 148 149 150 151 152 153 154 155 156 |
# File 'lib/ucslib/service/ucs/inventory.rb', line 147 def list_service_profiles(ucs_multi_class_xml) ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/lsServer").each do |serviceprofile| puts "Service Profile: #{serviceprofile.attributes["name"]} in #{serviceprofile.attributes["dn"]} with UUID #{serviceprofile.attributes["uuid"]}" \ " is: #{serviceprofile.attributes["assocState"]}" end end |
#list_vlans(ucs_multi_class_xml) ⇒ Object
115 116 117 118 119 120 121 122 123 |
# File 'lib/ucslib/service/ucs/inventory.rb', line 115 def list_vlans(ucs_multi_class_xml) ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/fabricVlan").each do |fabricvlan| puts "VLAN: #{fabricvlan.attributes["id"]} with name: #{fabricvlan.attributes["name"]}" end end |
#list_vsans(ucs_multi_class_xml) ⇒ Object
105 106 107 108 109 110 111 112 113 |
# File 'lib/ucslib/service/ucs/inventory.rb', line 105 def list_vsans(ucs_multi_class_xml) ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/fabricVsan").each do |fabricvsan| puts "VSAN: #{fabricvsan.attributes["fcoeVlan"]} with FCoE ID: #{fabricvsan.attributes["id"]}" \ " status: #{fabricvsan.attributes["operState"]}" end end |