ucslib 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +151 -0
- data/README.rdoc +88 -101
- data/lib/ucslib/Gemfile +4 -0
- data/lib/ucslib/{destroy.rb → service/ucs/destroy.rb} +3 -12
- data/lib/ucslib/{inventory.rb → service/ucs/inventory.rb} +34 -31
- data/lib/ucslib/{manage.rb → service/ucs/manage.rb} +14 -22
- data/lib/ucslib/{parser.rb → service/ucs/parser.rb} +19 -19
- data/lib/ucslib/{provision.rb → service/ucs/provision.rb} +59 -66
- data/lib/ucslib/service/ucs/session.rb +110 -0
- data/lib/ucslib/{stats.rb → service/ucs/stats.rb} +21 -1
- data/lib/ucslib/service/ucs/ucs.rb +70 -0
- data/lib/ucslib/{update.rb → service/ucs/update.rb} +9 -17
- data/lib/ucslib/version.rb +2 -1
- data/lib/ucslib.rb +3 -8
- metadata +26 -71
- data/.gitignore +0 -4
- data/Gemfile +0 -4
- data/html/README_rdoc.html +0 -226
- data/html/UCSInventory.html +0 -533
- data/html/UCSProvision.html +0 -1914
- data/html/UCSToken.html +0 -338
- data/html/Ucslib.html +0 -173
- data/html/created.rid +0 -7
- data/html/images/brick.png +0 -0
- data/html/images/brick_link.png +0 -0
- data/html/images/bug.png +0 -0
- data/html/images/bullet_black.png +0 -0
- data/html/images/bullet_toggle_minus.png +0 -0
- data/html/images/bullet_toggle_plus.png +0 -0
- data/html/images/date.png +0 -0
- data/html/images/find.png +0 -0
- data/html/images/loadingAnimation.gif +0 -0
- data/html/images/macFFBgHack.png +0 -0
- data/html/images/package.png +0 -0
- data/html/images/page_green.png +0 -0
- data/html/images/page_white_text.png +0 -0
- data/html/images/page_white_width.png +0 -0
- data/html/images/plugin.png +0 -0
- data/html/images/ruby.png +0 -0
- data/html/images/tag_green.png +0 -0
- data/html/images/wrench.png +0 -0
- data/html/images/wrench_orange.png +0 -0
- data/html/images/zoom.png +0 -0
- data/html/index.html +0 -273
- data/html/js/darkfish.js +0 -116
- data/html/js/jquery.js +0 -32
- data/html/js/quicksearch.js +0 -114
- data/html/js/thickbox-compressed.js +0 -10
- data/html/lib/ucslib/inventory_rb.html +0 -75
- data/html/lib/ucslib/provision_rb.html +0 -75
- data/html/lib/ucslib/session_rb.html +0 -75
- data/html/lib/ucslib/version_rb.html +0 -75
- data/html/lib/ucslib_rb.html +0 -89
- data/html/rdoc.css +0 -763
- data/lib/ucslib/session.rb +0 -108
- data/ucslib.gemspec +0 -45
@@ -15,22 +15,22 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
18
|
+
require 'nokogiri'
|
19
|
+
|
20
|
+
module Parser
|
21
|
+
class Nokogiri::XML::Node
|
22
|
+
TYPENAMES = {1=>'element',2=>'attribute',3=>'text',4=>'cdata',8=>'comment'}
|
23
|
+
def to_hash
|
24
|
+
{kind:TYPENAMES[node_type],name:name}.tap do |h|
|
25
|
+
h.merge! nshref:namespace.href, nsprefix:namespace.prefix if namespace
|
26
|
+
h.merge! text:text
|
27
|
+
h.merge! attr:attribute_nodes.map(&:to_hash) if element?
|
28
|
+
h.merge! kids:children.map(&:to_hash) if element?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
class Nokogiri::XML::Document
|
33
|
+
def to_hash; root.to_hash; end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
@@ -15,15 +15,8 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
#
|
17
17
|
|
18
|
-
|
18
|
+
module Provision
|
19
19
|
|
20
|
-
def initialize(tokenjson)
|
21
|
-
|
22
|
-
@cookie = "#{JSON.parse(tokenjson)['cookie']}"
|
23
|
-
ip = "#{JSON.parse(tokenjson)['ip']}"
|
24
|
-
@url = "https://#{ip}/nuova"
|
25
|
-
|
26
|
-
end
|
27
20
|
|
28
21
|
def set_org(json)
|
29
22
|
|
@@ -49,12 +42,12 @@ class UCSProvision
|
|
49
42
|
RestClient.post(@url, set_org_xml, :content_type => 'text/xml').body
|
50
43
|
rescue Exception => e
|
51
44
|
raise "Error #{e}"
|
52
|
-
end
|
45
|
+
end
|
53
46
|
|
54
47
|
end
|
55
48
|
|
56
49
|
def set_power_policy(json)
|
57
|
-
|
50
|
+
|
58
51
|
power_policy = "#{JSON.parse(json)['power_policy']}"
|
59
52
|
|
60
53
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
@@ -70,7 +63,7 @@ class UCSProvision
|
|
70
63
|
set_power_policy_xml = xml_builder.to_xml.to_s
|
71
64
|
|
72
65
|
#Post
|
73
|
-
begin
|
66
|
+
begin
|
74
67
|
RestClient.post(@url, set_power_policy_xml, :content_type => 'text/xml').body
|
75
68
|
rescue Exception => e
|
76
69
|
raise "Error #{e}"
|
@@ -79,14 +72,14 @@ class UCSProvision
|
|
79
72
|
end
|
80
73
|
|
81
74
|
def set_chassis_discovery_policy(json)
|
82
|
-
|
75
|
+
|
83
76
|
chassis_discovery_policy = "#{JSON.parse(json)['chassis_discovery_policy']}"
|
84
77
|
|
85
78
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
86
79
|
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false') {
|
87
80
|
xml.inConfigs{
|
88
81
|
xml.pair('key' => 'org-root/chassis-discovery'){
|
89
|
-
xml.computeChassisDiscPolicy( 'action' => "#{chassis_discovery_policy}", 'descr' => '', 'dn' => 'org-root/chassis-discovery',
|
82
|
+
xml.computeChassisDiscPolicy( 'action' => "#{chassis_discovery_policy}", 'descr' => '', 'dn' => 'org-root/chassis-discovery',
|
90
83
|
'name' => '', 'rebalance' => 'user-acknowledged')
|
91
84
|
}
|
92
85
|
}
|
@@ -114,10 +107,10 @@ class UCSProvision
|
|
114
107
|
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
|
115
108
|
xml.inConfigs{
|
116
109
|
xml.pair('key' => 'sys/svc-ext/datetime-svc'){
|
117
|
-
xml.commDateTime('adminState' => 'enabled', 'descr' => '', 'dn' => 'sys/svc-ext/datetime-svc', 'port' => '0', 'status' => 'modified',
|
110
|
+
xml.commDateTime('adminState' => 'enabled', 'descr' => '', 'dn' => 'sys/svc-ext/datetime-svc', 'port' => '0', 'status' => 'modified',
|
118
111
|
'timezone' => "#{time_zone}")
|
119
112
|
}
|
120
|
-
}
|
113
|
+
}
|
121
114
|
}
|
122
115
|
end
|
123
116
|
|
@@ -126,7 +119,7 @@ class UCSProvision
|
|
126
119
|
#Post
|
127
120
|
|
128
121
|
begin
|
129
|
-
RestClient.post(@url, set_time_zone_xml, :content_type => 'text/xml').body
|
122
|
+
RestClient.post(@url, set_time_zone_xml, :content_type => 'text/xml').body
|
130
123
|
rescue Exception => e
|
131
124
|
raise "Error #{e}"
|
132
125
|
end
|
@@ -169,7 +162,7 @@ class UCSProvision
|
|
169
162
|
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
|
170
163
|
xml.inConfigs{
|
171
164
|
xml.pair('key' => "org-root/org-#{org}/local-disk-config-#{org}-localdisk"){
|
172
|
-
xml.storageLocalDiskConfigPolicy('descr' => '', 'dn' => "org-root/org-#{org}/local-disk-config-#{org}-localdisk",
|
165
|
+
xml.storageLocalDiskConfigPolicy('descr' => '', 'dn' => "org-root/org-#{org}/local-disk-config-#{org}-localdisk",
|
173
166
|
'mode' => "#{local_disk_policy}", 'name' => "#{org}-localdisk", 'protectConfig' => 'yes',
|
174
167
|
'status' => 'created')
|
175
168
|
}
|
@@ -186,15 +179,15 @@ class UCSProvision
|
|
186
179
|
rescue Exception => e
|
187
180
|
raise "Error #{e}"
|
188
181
|
end
|
189
|
-
|
182
|
+
|
190
183
|
end
|
191
184
|
|
192
185
|
def set_syslog_server(json)
|
193
|
-
|
186
|
+
|
194
187
|
syslog_server = JSON.parse(json)['syslog_server']
|
195
188
|
facility = JSON.parse(json)['facility']
|
196
189
|
severity = JSON.parse(json)['severity']
|
197
|
-
|
190
|
+
|
198
191
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
199
192
|
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
|
200
193
|
xml.inConfigs{
|
@@ -215,7 +208,7 @@ class UCSProvision
|
|
215
208
|
rescue Exception => e
|
216
209
|
raise "Error #{e}"
|
217
210
|
end
|
218
|
-
|
211
|
+
|
219
212
|
end
|
220
213
|
|
221
214
|
def set_server_port(json)
|
@@ -230,8 +223,8 @@ class UCSProvision
|
|
230
223
|
xml.inConfigs{
|
231
224
|
xml.pair('key' => "fabric/server/SW-#{switch}"){
|
232
225
|
xml.fabricDceSwSrv('dn' => "fabric/server/SW-#{switch}", 'status' => 'created,modified'){
|
233
|
-
xml.fabricDceSwSrvEp( 'adminState' => 'enabled', 'name' => '', 'portId' => "#{port}",
|
234
|
-
'rn' => "slot" + "-" + "#{slot}" + "-" + "port" + "-" + "#{port}", 'slotId' => "#{slot}",
|
226
|
+
xml.fabricDceSwSrvEp( 'adminState' => 'enabled', 'name' => '', 'portId' => "#{port}",
|
227
|
+
'rn' => "slot" + "-" + "#{slot}" + "-" + "port" + "-" + "#{port}", 'slotId' => "#{slot}",
|
235
228
|
'status' => 'created', 'usrLbl' => '' )
|
236
229
|
}
|
237
230
|
}
|
@@ -239,7 +232,7 @@ class UCSProvision
|
|
239
232
|
}
|
240
233
|
end
|
241
234
|
|
242
|
-
#Create xml
|
235
|
+
#Create xml
|
243
236
|
set_server_port_xml = xml_builder.to_xml.to_s
|
244
237
|
|
245
238
|
#Post
|
@@ -256,7 +249,7 @@ class UCSProvision
|
|
256
249
|
|
257
250
|
switch = JSON.parse(json)['switch']
|
258
251
|
port = JSON.parse(json)['port']
|
259
|
-
slot = JSON.parse(json)['slot']
|
252
|
+
slot = JSON.parse(json)['slot']
|
260
253
|
|
261
254
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
262
255
|
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
|
@@ -264,7 +257,7 @@ class UCSProvision
|
|
264
257
|
xml.pair('key' => "fabric/lan/#{switch}"){
|
265
258
|
xml.fabricEthLan('dn' => "fabric/lan/#{switch}", 'status' => 'created,modified'){
|
266
259
|
xml.fabricEthLanEp('adminSpeed' => '10gbps', 'adminState' => 'enabled', 'flowCtrlPolicy' => 'default',
|
267
|
-
'name' => '', 'portId' => "#{port}",
|
260
|
+
'name' => '', 'portId' => "#{port}",
|
268
261
|
'rn' => "phys" + "-" + "slot" + "-" + "#{slot}" + "-" + "port" + "-" + "#{port}",
|
269
262
|
'slotId' => "#{slot}", 'status' => 'created', 'usrLbl' => '')
|
270
263
|
}
|
@@ -273,7 +266,7 @@ class UCSProvision
|
|
273
266
|
}
|
274
267
|
end
|
275
268
|
|
276
|
-
#Create xml
|
269
|
+
#Create xml
|
277
270
|
set_network_uplink_xml = xml_builder.to_xml.to_s
|
278
271
|
|
279
272
|
#Post
|
@@ -291,20 +284,20 @@ class UCSProvision
|
|
291
284
|
|
292
285
|
switch = JSON.parse(json)['switch']
|
293
286
|
port = JSON.parse(json)['port']
|
294
|
-
slot = JSON.parse(json)['slot']
|
287
|
+
slot = JSON.parse(json)['slot']
|
295
288
|
|
296
289
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
297
290
|
xml.configConfMos('cookie' => "#{@ucs_cookie}", 'inHierarchical' => 'false'){
|
298
291
|
xml.inConfigs{
|
299
292
|
xml.pair('key' => "fabric/san/#{switch}/phys" + "-" + "slot" + "-" + "#{slot}" + "-" + "port" + "-" + "#{port}"){
|
300
|
-
xml.fabricFcSanEp('adminState' => 'enabled', 'dn' => "fabric/san/#{switch}/phys" + "-" + "slot" + "-" + "#{slot}" + "-" +
|
293
|
+
xml.fabricFcSanEp('adminState' => 'enabled', 'dn' => "fabric/san/#{switch}/phys" + "-" + "slot" + "-" + "#{slot}" + "-" +
|
301
294
|
"port" + "-" + "#{port}" )
|
302
295
|
}
|
303
296
|
}
|
304
297
|
}
|
305
298
|
end
|
306
299
|
|
307
|
-
#Create xml
|
300
|
+
#Create xml
|
308
301
|
set_fc_uplink_xml = xml_builder.to_xml.to_s
|
309
302
|
|
310
303
|
#Post
|
@@ -337,7 +330,7 @@ class UCSProvision
|
|
337
330
|
'flowCtrlPolicy' => 'default', 'name' => "#{name}", 'operSpeed' => '10gbps', 'portId' => "#{port_channel_id}",
|
338
331
|
'status' => 'created'){
|
339
332
|
port_ids.each do |port_id|
|
340
|
-
xml.fabricEthLanPcEp('adminState' => 'enabled', 'name' => '', 'portId' => "#{port_id}",
|
333
|
+
xml.fabricEthLanPcEp('adminState' => 'enabled', 'name' => '', 'portId' => "#{port_id}",
|
341
334
|
'rn' => "ep-slot-#{slot}-port-#{port_id}")
|
342
335
|
end
|
343
336
|
}
|
@@ -484,7 +477,7 @@ class UCSProvision
|
|
484
477
|
|
485
478
|
|
486
479
|
def set_mgmt_firmware_package(json)
|
487
|
-
|
480
|
+
|
488
481
|
mgmt_firmware_pkg_name = JSON.parse(json)['mgmt_firmware_pkg_name']
|
489
482
|
mgmt_firmware_pkg_description = JSON.parse(json)['mgmt_firmware_pkg_description']
|
490
483
|
hardware_model = JSON.parse(json)['hardware_model'].to_s
|
@@ -493,7 +486,7 @@ class UCSProvision
|
|
493
486
|
firmware_version = JSON.parse(json)['firmware_version'].to_s
|
494
487
|
org = JSON.parse(json)['org']
|
495
488
|
|
496
|
-
|
489
|
+
|
497
490
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
498
491
|
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
|
499
492
|
xml.inConfigs{
|
@@ -526,7 +519,7 @@ class UCSProvision
|
|
526
519
|
end
|
527
520
|
|
528
521
|
def set_host_firmware_package(json)
|
529
|
-
|
522
|
+
|
530
523
|
host_firmware_pkg_name = JSON.parse(json)['host_firmware_pkg_name']
|
531
524
|
host_firmware_pkg_description = JSON.parse(json)['host_firmware_pkg_description']
|
532
525
|
hardware_model = JSON.parse(json)['hardware_model'].to_s
|
@@ -537,7 +530,7 @@ class UCSProvision
|
|
537
530
|
flag = JSON.parse(json)['flag']
|
538
531
|
|
539
532
|
unless flag == 'update'
|
540
|
-
|
533
|
+
|
541
534
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
542
535
|
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
|
543
536
|
xml.inConfigs{
|
@@ -653,15 +646,15 @@ class UCSProvision
|
|
653
646
|
#size = JSON.parse(json)['size']
|
654
647
|
mac_pool_end = JSON.parse(json)['mac_pool_end']
|
655
648
|
org = JSON.parse(json)['org']
|
656
|
-
|
657
|
-
#
|
649
|
+
|
650
|
+
#
|
658
651
|
# def get_mac_pool_suffix(size)
|
659
|
-
# mac_pool_size = size
|
652
|
+
# mac_pool_size = size
|
660
653
|
# octets = mac_pool_start.split(':')
|
661
654
|
# octets[-1] = (mac_pool_size - 1).to_s(base=16)
|
662
655
|
# return mac_pool_end = octets.join(':')
|
663
656
|
# end
|
664
|
-
#
|
657
|
+
#
|
665
658
|
# get_mac_pool_suffix(size)
|
666
659
|
|
667
660
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
@@ -746,7 +739,7 @@ class UCSProvision
|
|
746
739
|
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
|
747
740
|
xml.inConfigs{
|
748
741
|
xml.pair('key' => 'fabric/san/'){
|
749
|
-
xml.fabricVsan('defaultZoning' => 'disabled', 'dn' => 'fabric/san/', 'fcoeVlan' => "#{vsan_fcoe_id}",
|
742
|
+
xml.fabricVsan('defaultZoning' => 'disabled', 'dn' => 'fabric/san/', 'fcoeVlan' => "#{vsan_fcoe_id}",
|
750
743
|
'id' => "#{vsan_id}", 'name' => "#{vsan_name}", 'status' => 'created' )
|
751
744
|
}
|
752
745
|
}
|
@@ -778,7 +771,7 @@ class UCSProvision
|
|
778
771
|
xml.pair('key' => "org-root/org-#{org}/wwn-pool-#{wwnn_name}"){
|
779
772
|
xml.fcpoolInitiators('descr' => '', 'dn' => "org-root/org-#{org}/wwn-pool-#{wwnn_name}", 'name' => "#{wwnn_name}",
|
780
773
|
'purpose' => 'node-wwn-assignment', 'status' => 'created'){
|
781
|
-
xml.fcpoolBlock('from' => "#{wwnn_from}", 'rn' => "block-#{wwnn_from}-#{wwnn_to}",
|
774
|
+
xml.fcpoolBlock('from' => "#{wwnn_from}", 'rn' => "block-#{wwnn_from}-#{wwnn_to}",
|
782
775
|
'status' => 'created', 'to' => "#{wwnn_to}")
|
783
776
|
}
|
784
777
|
}
|
@@ -897,7 +890,7 @@ class UCSProvision
|
|
897
890
|
rescue Exception => e
|
898
891
|
raise "Error #{e}"
|
899
892
|
end
|
900
|
-
|
893
|
+
|
901
894
|
end
|
902
895
|
|
903
896
|
def set_service_profile_template(json)
|
@@ -929,27 +922,27 @@ class UCSProvision
|
|
929
922
|
'mgmtAccessPolicyName' => '', 'mgmtFwPolicyName' => "#{service_profile_template_mgmt_fw_policy}", 'name' => "#{service_profile_template_name}",
|
930
923
|
'powerPolicyName' => 'default', 'scrubPolicyName' => '', 'solPolicyName' => 'default', 'srcTemplName' => '', 'statsPolicyName' => 'default',
|
931
924
|
'status' => 'created', 'type' => 'updating-template', 'usrLbl' => '', 'uuid' => '0', 'vconProfileName' => ''){
|
932
|
-
service_profile_template_vnics_a.each do |vnic_a|
|
925
|
+
service_profile_template_vnics_a.each do |vnic_a|
|
933
926
|
xml.vnicEther('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'mtu' => '1500',
|
934
927
|
'name' => "#{vnic_a}", 'nwCtrlPolicyName' => '', 'nwTemplName' => "#{service_profile_template_vnic_a_template}",
|
935
928
|
'order' => '3', 'pinToGroupName' => '', 'qosPolicyName' => '', 'rn' => "ether-#{vnic_a}",
|
936
929
|
'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'A')
|
937
930
|
end
|
938
|
-
service_profile_template_vnics_b.each do |vnic_b|
|
931
|
+
service_profile_template_vnics_b.each do |vnic_b|
|
939
932
|
xml.vnicEther('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'mtu' => '1500',
|
940
933
|
'name' => "#{vnic_b}", 'nwCtrlPolicyName' => '', 'nwTemplName' => "#{service_profile_template_vnic_b_template}",
|
941
934
|
'order' => '4', 'pinToGroupName' => '', 'qosPolicyName' => '', 'rn' => "ether-#{vnic_b}",
|
942
935
|
'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'B')
|
943
|
-
end
|
936
|
+
end
|
944
937
|
xml.vnicFcNode('addr' => 'pool-derived', 'identPoolName' => "#{service_profile_template_wwnn_pool}", 'rn' => 'fc-node')
|
945
938
|
|
946
939
|
xml.vnicFc('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'maxDataFieldSize' => '2048',
|
947
|
-
'name' => "#{service_profile_template_vhba_a}", 'nwTemplName' => "#{service_profile_template_vhba_a_template}",
|
940
|
+
'name' => "#{service_profile_template_vhba_a}", 'nwTemplName' => "#{service_profile_template_vhba_a_template}",
|
948
941
|
'order' => '1', 'persBind' => 'disabled', 'persBindClear' => 'no', 'pinToGroupName' => '', 'qosPolicyName' => '',
|
949
942
|
'rn' => "fc-#{service_profile_template_vhba_a}", 'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'A')
|
950
943
|
|
951
944
|
xml.vnicFc('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'maxDataFieldSize' => '2048',
|
952
|
-
'name' => "#{service_profile_template_vhba_b}", 'nwTemplName' => "#{service_profile_template_vhba_b_template}",
|
945
|
+
'name' => "#{service_profile_template_vhba_b}", 'nwTemplName' => "#{service_profile_template_vhba_b_template}",
|
953
946
|
'order' => '2', 'persBind' => 'disabled', 'persBindClear' => 'no', 'pinToGroupName' => '', 'qosPolicyName' => '',
|
954
947
|
'rn' => "fc-#{service_profile_template_vhba_b}", 'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'B')
|
955
948
|
|
@@ -969,7 +962,7 @@ class UCSProvision
|
|
969
962
|
rescue Exception => e
|
970
963
|
raise "Error #{e}"
|
971
964
|
end
|
972
|
-
|
965
|
+
|
973
966
|
end
|
974
967
|
|
975
968
|
def set_service_profiles_from_template(json)
|
@@ -997,7 +990,7 @@ class UCSProvision
|
|
997
990
|
rescue Exception => e
|
998
991
|
raise "Error #{e}"
|
999
992
|
end
|
1000
|
-
|
993
|
+
|
1001
994
|
end
|
1002
995
|
|
1003
996
|
|
@@ -1032,9 +1025,9 @@ class UCSProvision
|
|
1032
1025
|
'dynamicConPolicyName' => '', 'extIPState' => 'none', 'hostFwPolicyName' => "#{service_profile_host_fw_policy}",
|
1033
1026
|
'identPoolName' => "#{service_profile_uuid_pool}", 'localDiskPolicyName' => 'default', 'maintPolicyName' => 'default',
|
1034
1027
|
'mgmtAccessPolicyName' => '', 'mgmtFwPolicyName' => "#{service_profile_mgmt_fw_policy}", 'name' => "#{service_profile_name}",
|
1035
|
-
'powerPolicyName' => 'default', 'scrubPolicyName' => '', 'solPolicyName' => 'default', 'srcTemplName' => "#{service_profile_template_to_bind}",
|
1028
|
+
'powerPolicyName' => 'default', 'scrubPolicyName' => '', 'solPolicyName' => 'default', 'srcTemplName' => "#{service_profile_template_to_bind}",
|
1036
1029
|
'statsPolicyName' => 'default', 'status' => 'created', 'usrLbl' => '', 'uuid' => '0', 'vconProfileName' => ''){
|
1037
|
-
service_profile_vnics_a.each do |vnic_a|
|
1030
|
+
service_profile_vnics_a.each do |vnic_a|
|
1038
1031
|
xml.vnicEther('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'mtu' => '1500',
|
1039
1032
|
'name' => "#{vnic_a}", 'nwCtrlPolicyName' => '', 'nwTemplName' => "#{service_profile_vnic_a_template}",
|
1040
1033
|
'order' => '3', 'pinToGroupName' => '', 'qosPolicyName' => '', 'rn' => "ether-#{vnic_a}",
|
@@ -1051,12 +1044,12 @@ class UCSProvision
|
|
1051
1044
|
xml.vnicFcNode('addr' => 'pool-derived', 'identPoolName' => "#{service_profile_wwnn_pool}", 'rn' => 'fc-node')
|
1052
1045
|
|
1053
1046
|
xml.vnicFc('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'maxDataFieldSize' => '2048',
|
1054
|
-
'name' => "#{service_profile_vhba_a}", 'nwTemplName' => "#{service_profile_vhba_a}",
|
1047
|
+
'name' => "#{service_profile_vhba_a}", 'nwTemplName' => "#{service_profile_vhba_a}",
|
1055
1048
|
'order' => '1', 'persBind' => 'disabled', 'persBindClear' => 'no', 'pinToGroupName' => '', 'qosPolicyName' => '',
|
1056
1049
|
'rn' => "fc-#{service_profile_vhba_a}", 'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'A')
|
1057
1050
|
|
1058
1051
|
xml.vnicFc('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'maxDataFieldSize' => '2048',
|
1059
|
-
'name' => "#{service_profile_vhba_b}", 'nwTemplName' => "#{service_profile_vhba_b}",
|
1052
|
+
'name' => "#{service_profile_vhba_b}", 'nwTemplName' => "#{service_profile_vhba_b}",
|
1060
1053
|
'order' => '2', 'persBind' => 'disabled', 'persBindClear' => 'no', 'pinToGroupName' => '', 'qosPolicyName' => '',
|
1061
1054
|
'rn' => "fc-#{service_profile_vhba_b}", 'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'B')
|
1062
1055
|
|
@@ -1080,14 +1073,14 @@ class UCSProvision
|
|
1080
1073
|
end
|
1081
1074
|
|
1082
1075
|
end
|
1083
|
-
|
1076
|
+
|
1084
1077
|
def set_server_pool(json)
|
1085
1078
|
server_pool_name = JSON.parse(json)['server_pool_name'].to_s
|
1086
1079
|
server_pool_description = JSON.parse(json)['server_pool_description']
|
1087
1080
|
server_pool_chassis_ids = JSON.parse(json)['server_pool_chassis_ids'].to_s.split(',')
|
1088
1081
|
server_pool_blades = JSON.parse(json)['server_pool_blades'].to_s.split(',')
|
1089
1082
|
org = JSON.parse(json)['org'].to_s
|
1090
|
-
|
1083
|
+
|
1091
1084
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
1092
1085
|
xml.configConfMos('cookie' => "#{@ucs_cookie}", 'inHierarchical' => 'true'){
|
1093
1086
|
xml.inConfigs{
|
@@ -1097,7 +1090,7 @@ class UCSProvision
|
|
1097
1090
|
server_pool_chassis_ids.each do |chassis_id|
|
1098
1091
|
@current_chassis_id = chassis_id
|
1099
1092
|
server_pool_blades.each do |slot_id|
|
1100
|
-
xml.computePooledSlot('chassisId' => "#{@current_chassis_id}",
|
1093
|
+
xml.computePooledSlot('chassisId' => "#{@current_chassis_id}",
|
1101
1094
|
'rn' => "blade-#{@current_chassis_id}-#{slot_id}", 'slotId' => "#{slot_id}")
|
1102
1095
|
end
|
1103
1096
|
end
|
@@ -1106,9 +1099,9 @@ class UCSProvision
|
|
1106
1099
|
}
|
1107
1100
|
}
|
1108
1101
|
end
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1102
|
+
|
1103
|
+
|
1104
|
+
|
1112
1105
|
# xml_builder = Nokogiri::XML::Builder.new do |xml|
|
1113
1106
|
# xml.configConfMos('cookie' => "#{@ucs_cookie}", 'inHierarchical' => 'true'){
|
1114
1107
|
# xml.inConfigs{
|
@@ -1116,7 +1109,7 @@ class UCSProvision
|
|
1116
1109
|
# xml.computePool('descr' => '', 'dn' => "org-root/org-#{server_pool_org}/compute-pool-#{server_pool_name}",
|
1117
1110
|
# 'status' => 'created,modified'){
|
1118
1111
|
# server_pool_blades.each do |slot_id|
|
1119
|
-
# xml.computePooledSlot('chassisId' => "#{server_pool_chassis_id}",
|
1112
|
+
# xml.computePooledSlot('chassisId' => "#{server_pool_chassis_id}",
|
1120
1113
|
# 'rn' => "blade-#{server_pool_chassis_id}-#{slot_id}", 'slotId' => "#{slot_id}",
|
1121
1114
|
# 'status' => 'created')
|
1122
1115
|
# end
|
@@ -1125,19 +1118,19 @@ class UCSProvision
|
|
1125
1118
|
# }
|
1126
1119
|
# }
|
1127
1120
|
# end
|
1128
|
-
|
1129
|
-
|
1121
|
+
|
1122
|
+
|
1130
1123
|
#Create XML
|
1131
|
-
|
1124
|
+
|
1132
1125
|
set_server_pool_xml = xml_builder.to_xml.to_s
|
1133
|
-
|
1134
|
-
#Post
|
1126
|
+
|
1127
|
+
#Post
|
1135
1128
|
begin
|
1136
1129
|
RestClient.post(@url, set_server_pool_xml, :content_type => 'text/xml').body
|
1137
1130
|
rescue Exception => e
|
1138
1131
|
raise "Error #{e}"
|
1139
1132
|
end
|
1140
|
-
|
1133
|
+
|
1141
1134
|
end
|
1142
1135
|
|
1143
1136
|
end
|
@@ -0,0 +1,110 @@
|
|
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
|
+
#UCSM API Session management
|
19
|
+
|
20
|
+
|
21
|
+
module Session
|
22
|
+
#Accept a JSON object that contains the UCSM username, password, and IP
|
23
|
+
# def get_token(authjson)
|
24
|
+
|
25
|
+
# username = "#{JSON.parse(authjson)['username']}"
|
26
|
+
# password = "#{JSON.parse(authjson)['password']}"
|
27
|
+
# ip = "#{JSON.parse(authjson)['ip']}"
|
28
|
+
# url = "https://#{ip}/nuova"
|
29
|
+
|
30
|
+
# xml_builder = Nokogiri::XML::Builder.new do |xml|
|
31
|
+
# xml.aaaLogin('inName' => username, 'inPassword' => password)
|
32
|
+
# end
|
33
|
+
|
34
|
+
# aaa_login_xml = xml_builder.to_xml.to_s
|
35
|
+
# ucs_response = RestClient.post(url, aaa_login_xml, :content_type => 'text/xml').body
|
36
|
+
# ucs_login_doc = Nokogiri::XML(ucs_response)
|
37
|
+
# ucs_login_root = ucs_login_doc.root
|
38
|
+
# cookie = ucs_login_root.attributes['outCookie']
|
39
|
+
|
40
|
+
# begin
|
41
|
+
# return session = { :cookie => "#{cookie}",
|
42
|
+
# :username => "#{username}",
|
43
|
+
# :password => "#{password}",
|
44
|
+
# :ip => "#{ip}" }.to_json
|
45
|
+
# rescue Exception => e
|
46
|
+
# 'An Error Occured. Please check authentication credentials'
|
47
|
+
# else
|
48
|
+
# Process.exit
|
49
|
+
# end
|
50
|
+
|
51
|
+
# end
|
52
|
+
|
53
|
+
|
54
|
+
def refresh_token(tokenjson)
|
55
|
+
|
56
|
+
cookie = "#{JSON.parse(tokenjson)['cookie']}"
|
57
|
+
username = "#{JSON.parse(tokenjson)['username']}"
|
58
|
+
password = "#{JSON.parse(tokenjson)['password']}"
|
59
|
+
ip = "#{JSON.parse(tokenjson)['ip']}"
|
60
|
+
url = "https://#{ip}/nuova"
|
61
|
+
|
62
|
+
|
63
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
64
|
+
xml.aaaRefresh('inName' => username, 'inPassword' => password, 'inCookie' => cookie)
|
65
|
+
end
|
66
|
+
aaa_refresh_xml = xml_builder.to_xml.to_s
|
67
|
+
|
68
|
+
ucs_response = RestClient.post(url, aaa_refresh_xml, :content_type => 'text/xml').body
|
69
|
+
|
70
|
+
|
71
|
+
ucs_login_doc = Nokogiri::XML(ucs_response)
|
72
|
+
ucs_login_root = ucs_login_doc.root
|
73
|
+
new_cookie = ucs_login_root.attributes['outCookie']
|
74
|
+
|
75
|
+
begin
|
76
|
+
#return ucs_session json containing new cookie, url, ip
|
77
|
+
return session = { :cookie => "#{new_cookie}",
|
78
|
+
:username => "#{username}",
|
79
|
+
:password => "#{password}",
|
80
|
+
:ip => "#{ip}" }.to_json
|
81
|
+
rescue Exception => e
|
82
|
+
'An Error Occured. Please check authentication credentials'
|
83
|
+
else
|
84
|
+
Process.exit
|
85
|
+
end
|
86
|
+
|
87
|
+
end
|
88
|
+
|
89
|
+
def logout(tokenjson)
|
90
|
+
|
91
|
+
cookie = "#{JSON.parse(tokenjson)['cookie']}"
|
92
|
+
ip = "#{JSON.parse(tokenjson)['ip']}"
|
93
|
+
url = "https://#{ip}/nuova"
|
94
|
+
|
95
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
96
|
+
xml.aaaLogout('inCookie' => cookie)
|
97
|
+
end
|
98
|
+
|
99
|
+
aaaLogoutXML = xml_builder.to_xml.to_s
|
100
|
+
|
101
|
+
begin
|
102
|
+
RestClient.post(url, aaaLogoutXML, :content_type => 'text/xml').body
|
103
|
+
rescue Exception => e
|
104
|
+
raise "Error #{e}"
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
110
|
+
|
@@ -1,4 +1,24 @@
|
|
1
|
-
|
1
|
+
# Author:: Murali Raju (<murali.raju@appliv.com>)
|
2
|
+
# License:: Apache License, Version 2.0
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
5
|
+
# you may not use this file except in compliance with the License.
|
6
|
+
# You may obtain a copy of the License at
|
7
|
+
#
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
9
|
+
#
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13
|
+
# See the License for the specific language governing permissions and
|
14
|
+
# limitations under the License.
|
15
|
+
#
|
16
|
+
# This section was contributed by Mark Plaksin https://www.linkedin.com/in/happymcplaksin. Thanks Mark!
|
17
|
+
|
18
|
+
#UCSM API Session management
|
19
|
+
|
20
|
+
module Stats
|
21
|
+
|
2
22
|
STATNAMES = %w(adaptorEthPortStats adaptorEthPortErrStats adaptorEthPortMcastStats adaptorVnicStats computeMbPowerStats computeMbTempStats computePCIeFatalStats computePCIeFatalCompletionStats computePCIeFatalProtocolStats computePCIeFatalReceiveStats equipmentChassisStats equipmentFanStats equipmentFanModuleStats equipmentIOCardStats equipmentNetworkElementFanStats equipmentPsuStats equipmentPsuInputStats etherErrStats etherLossStats etherPauseStats etherRxStats etherTxStats fcStats fcErrStats memoryArrayEnvStats memoryErrorStats memoryUnitEnvStats processorEnvStats processorErrorStats swEnvStats swSystemStats)
|
3
23
|
|
4
24
|
def fetch(tokenjson)
|