ucslib 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +201 -0
  4. data/README.rdoc +106 -0
  5. data/Rakefile +37 -0
  6. data/html/README_rdoc.html +146 -0
  7. data/html/UCSInventory.html +533 -0
  8. data/html/UCSProvision.html +1914 -0
  9. data/html/UCSToken.html +339 -0
  10. data/html/Ucslib.html +173 -0
  11. data/html/created.rid +7 -0
  12. data/html/images/brick.png +0 -0
  13. data/html/images/brick_link.png +0 -0
  14. data/html/images/bug.png +0 -0
  15. data/html/images/bullet_black.png +0 -0
  16. data/html/images/bullet_toggle_minus.png +0 -0
  17. data/html/images/bullet_toggle_plus.png +0 -0
  18. data/html/images/date.png +0 -0
  19. data/html/images/find.png +0 -0
  20. data/html/images/loadingAnimation.gif +0 -0
  21. data/html/images/macFFBgHack.png +0 -0
  22. data/html/images/package.png +0 -0
  23. data/html/images/page_green.png +0 -0
  24. data/html/images/page_white_text.png +0 -0
  25. data/html/images/page_white_width.png +0 -0
  26. data/html/images/plugin.png +0 -0
  27. data/html/images/ruby.png +0 -0
  28. data/html/images/tag_green.png +0 -0
  29. data/html/images/wrench.png +0 -0
  30. data/html/images/wrench_orange.png +0 -0
  31. data/html/images/zoom.png +0 -0
  32. data/html/index.html +193 -0
  33. data/html/js/darkfish.js +116 -0
  34. data/html/js/jquery.js +32 -0
  35. data/html/js/quicksearch.js +114 -0
  36. data/html/js/thickbox-compressed.js +10 -0
  37. data/html/lib/ucslib/inventory_rb.html +75 -0
  38. data/html/lib/ucslib/provision_rb.html +75 -0
  39. data/html/lib/ucslib/session_rb.html +75 -0
  40. data/html/lib/ucslib/version_rb.html +75 -0
  41. data/html/lib/ucslib_rb.html +89 -0
  42. data/html/rdoc.css +763 -0
  43. data/lib/ucslib/inventory.rb +131 -0
  44. data/lib/ucslib/provision.rb +949 -0
  45. data/lib/ucslib/session.rb +108 -0
  46. data/lib/ucslib/version.rb +20 -0
  47. data/lib/ucslib.rb +26 -0
  48. data/ucslib.gemspec +45 -0
  49. metadata +126 -0
@@ -0,0 +1,131 @@
1
+ # Author:: Murali Raju (<murali.raju@appliv.com>)
2
+ # Copyright:: Copyright (c) 2012 Murali Raju.
3
+ # License:: Apache License, Version 2.0
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ #
17
+
18
+
19
+ class UCSInventory
20
+
21
+ def discover(tokenjson)
22
+
23
+ cookie = "#{JSON.parse(tokenjson)['cookie']}"
24
+ ip = "#{JSON.parse(tokenjson)['ip']}"
25
+ url = "https://#{ip}/nuova"
26
+
27
+ #Start Build the Multi-Class XML
28
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
29
+ xml.configResolveClasses('cookie' => cookie, 'inHierarchical' => 'false') {
30
+ xml.inIds{
31
+ xml.classId("value" => "lsServer")
32
+ xml.classId("value" => "computeBlade")
33
+ xml.classId("value" => "firmwareRunning")
34
+ xml.classId("value" => "fabricVsan")
35
+ xml.classId("value" => "fabricVlan")
36
+ xml.classId("value" => "processorUnit")
37
+ }
38
+ }
39
+ end
40
+
41
+ #End Build Multi-Class XML
42
+
43
+ ucs_multi_class_XML = xml_builder.to_xml.to_s
44
+ ucs_response_multi_class = RestClient.post(url, ucs_multi_class_XML, :content_type => 'text/xml').body
45
+
46
+ #Uncomment the following to create a dump to review and debug elements
47
+ # fh = File.new("ucs_response_multiclass.xml", "w")
48
+ # fh.puts ucs_response_multiclass.inspect
49
+ # fh.close
50
+
51
+ return Nokogiri::XML(ucs_response_multi_class)
52
+
53
+ end
54
+
55
+
56
+ def list_blades(ucs_multi_class_xml)
57
+
58
+ ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/computeBlade").each do |blade|
59
+
60
+ puts "Blade : #{blade.attributes["serverId"]} model: #{blade.attributes["model"]}" \
61
+ " with serial: #{blade.attributes["serial"]} is powered: #{blade.attributes["operPower"]}"
62
+
63
+ end
64
+
65
+ end
66
+
67
+ def list_vsans(ucs_multi_class_xml)
68
+
69
+ ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/fabricVsan").each do |fabricvsan|
70
+
71
+ puts "VSAN: #{fabricvsan.attributes["fcoeVlan"]} with FCoE ID: #{fabricvsan.attributes["id"]}" \
72
+ " status: #{fabricvsan.attributes["operState"]}"
73
+ end
74
+
75
+ end
76
+
77
+ def list_vlans(ucs_multi_class_xml)
78
+
79
+ ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/fabricVlan").each do |fabricvlan|
80
+
81
+ puts "VLAN: #{fabricvlan.attributes["id"]} with name: #{fabricvlan.attributes["name"]}"
82
+
83
+ end
84
+
85
+ end
86
+
87
+ def list_cpus(ucs_multi_class_xml)
88
+
89
+ ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/processorUnit").each do |processorunit|
90
+
91
+ puts "CPU model: #{processorunit.attributes["model"]} Architecture: #{processorunit.attributes["arch"]} with #{processorunit.attributes["cores"]}" \
92
+ "cores with #{processorunit.attributes["coresEnabled"]} enabled ID: #{processorunit.attributes["id"]} Speed: #{processorunit.attributes["speed"]}" \
93
+ "Threads: #{processorunit.attributes["threads"]} Vendor: #{processorunit.attributes["vendor"]}"
94
+
95
+ end
96
+
97
+ end
98
+
99
+ def list_memory(ucs_multi_class_xml)
100
+
101
+ ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/computeBlade").each do |blade|
102
+
103
+ puts "Available Memory: #{blade.attributes["availableMemory"]} Total Memory: #{blade.attributes["totalMemory"]} Speed: #{blade.attributes["memorySpeed"]}"
104
+
105
+ end
106
+
107
+ end
108
+
109
+ def list_service_profiles(ucs_multi_class_xml)
110
+
111
+ ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/lsServer").each do |serviceprofile|
112
+
113
+ puts "Service Profile: #{serviceprofile.attributes["name"]} in #{serviceprofile.attributes["dn"]} with UUID #{serviceprofile.attributes["uuid"]}" \
114
+ " is: #{serviceprofile.attributes["assocState"]}"
115
+
116
+ end
117
+
118
+ end
119
+
120
+ def list_running_firmware(ucs_multi_class_xml)
121
+
122
+ ucs_multi_class_xml.xpath("configResolveClasses/outConfigs/firmwareRunning").each do |firmware|
123
+
124
+ puts "Firmware: #{firmware.attributes["dn"]} version #{firmware.attributes["packageVersion"]} package version" \
125
+ " #{firmware.attributes["packageVersion"]} type #{firmware.attributes["type"]}"
126
+
127
+ end
128
+
129
+ end
130
+
131
+ end