ucslib 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,949 @@
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
+ class UCSProvision
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
+
28
+ def set_power_policy(json)
29
+
30
+ power_policy = "#{JSON.parse(json)['power_policy']}"
31
+
32
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
33
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false') {
34
+ xml.inConfigs{
35
+ xml.pair('key' => 'org-root/psu-policy'){
36
+ xml.computePsuPolicy('descr' => '', 'dn' => 'org-root/psu-policy', 'redundancy' => "#{power_policy}")
37
+ }
38
+ }
39
+ }
40
+ end
41
+
42
+ set_power_policy_XML = xml_builder.to_xml.to_s
43
+
44
+ #Post
45
+
46
+ begin
47
+ RestClient.post(@url, set_power_policy_XML, :content_type => 'text/xml').body
48
+ rescue Exception => e
49
+ raise "Error #{e}"
50
+ end
51
+
52
+ end
53
+
54
+ def set_chassis_discovery_policy(json)
55
+
56
+ chassis_discovery_policy = "#{JSON.parse(json)['chassis_discovery_policy']}"
57
+
58
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
59
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false') {
60
+ xml.inConfigs{
61
+ xml.pair('key' => 'org-root/chassis-discovery'){
62
+ xml.computeChassisDiscPolicy( 'action' => "#{chassis_discovery_policy}", 'descr' => '', 'dn' => 'org-root/chassis-discovery',
63
+ 'name' => '', 'rebalance' => 'user-acknowledged')
64
+ }
65
+ }
66
+ }
67
+ end
68
+
69
+ set_chassis_discovery_policy_XML = xml_builder.to_xml.to_s
70
+
71
+ #Post
72
+
73
+ begin
74
+ RestClient.post(@url, set_chassis_discovery_policy_XML, :content_type => 'text/xml').body
75
+ rescue Exception => e
76
+ raise "Error #{e}"
77
+ end
78
+
79
+ end
80
+
81
+
82
+ def set_time_zone(json)
83
+
84
+ time_zone = "#{JSON.parse(json)['time_zone']}"
85
+
86
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
87
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
88
+ xml.inConfigs{
89
+ xml.pair('key' => 'sys/svc-ext/datetime-svc'){
90
+ xml.commDateTime('adminState' => 'enabled', 'descr' => '', 'dn' => 'sys/svc-ext/datetime-svc', 'port' => '0', 'status' => 'modified',
91
+ 'timezone' => "#{time_zone}")
92
+ }
93
+ }
94
+ }
95
+ end
96
+
97
+ set_time_zone_XML = xml_builder.to_xml.to_s
98
+
99
+ #Post
100
+
101
+ begin
102
+ RestClient.post(@url, set_time_zone_XML, :content_type => 'text/xml').body
103
+ rescue Exception => e
104
+ raise "Error #{e}"
105
+ end
106
+
107
+ end
108
+
109
+ def set_ntp(json)
110
+
111
+ ntp_server = "#{JSON.parse(json)['ntp_server']}"
112
+
113
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
114
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
115
+ xml.inConfigs{
116
+ xml.pair('key' => "sys/svc-ext/datetime-svc/ntp-#{ntp_server}"){
117
+ xml.commNtpProvider('descr' => '', 'dn' => "sys/svc-ext/datetime-svc/ntp-#{ntp_server}", 'name' => "#{ntp_server}", 'status' => 'created' )
118
+ }
119
+ }
120
+ }
121
+ end
122
+
123
+ set_ntp_XML = xml_builder.to_xml.to_s
124
+
125
+ #Post
126
+
127
+ begin
128
+ RestClient.post(@url, set_ntp_XML, :content_type => 'text/xml').body
129
+ rescue Exception => e
130
+ raise "Error #{e}"
131
+ end
132
+
133
+ end
134
+
135
+ def create_server_port(json)
136
+
137
+ switch = JSON.parse(json)['switch']
138
+ port = JSON.parse(json)['port']
139
+ slot = JSON.parse(json)['slot']
140
+
141
+
142
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
143
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
144
+ xml.inConfigs{
145
+ xml.pair('key' => "fabric/server/SW-#{switch}"){
146
+ xml.fabricDceSwSrv('dn' => "fabric/server/SW-#{switch}", 'status' => 'created,modified'){
147
+ xml.fabricDceSwSrvEp( 'adminState' => 'enabled', 'name' => '', 'portId' => "#{port}",
148
+ 'rn' => "slot" + "-" + "#{slot}" + "-" + "port" + "-" + "#{port}", 'slotId' => "#{slot}",
149
+ 'status' => 'created', 'usrLbl' => '' )
150
+ }
151
+ }
152
+ }
153
+ }
154
+ end
155
+
156
+ #Create XML
157
+ create_server_port_XML = xml_builder.to_xml.to_s
158
+
159
+ #Post
160
+
161
+ begin
162
+ RestClient.post(@url, create_server_port_XML, :content_type => 'text/xml').body
163
+ rescue Exception => e
164
+ raise "Error #{e}"
165
+ end
166
+
167
+ end
168
+
169
+ def create_network_uplink_port(json)
170
+
171
+ switch = JSON.parse(json)['switch']
172
+ port = JSON.parse(json)['port']
173
+ slot = JSON.parse(json)['slot']
174
+
175
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
176
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
177
+ xml.inConfigs{
178
+ xml.pair('key' => "fabric/lan/#{switch}"){
179
+ xml.fabricEthLan('dn' => "fabric/lan/#{switch}", 'status' => 'created,modified'){
180
+ xml.fabricEthLanEp('adminSpeed' => '10gbps', 'adminState' => 'enabled', 'flowCtrlPolicy' => 'default',
181
+ 'name' => '', 'portId' => "#{port}",
182
+ 'rn' => "phys" + "-" + "slot" + "-" + "#{slot}" + "-" + "port" + "-" + "#{port}",
183
+ 'slotId' => "#{slot}", 'status' => 'created', 'usrLbl' => '')
184
+ }
185
+ }
186
+ }
187
+ }
188
+ end
189
+
190
+ #Create XML
191
+ create_network_uplink_XML = xml_builder.to_xml.to_s
192
+
193
+ #Post
194
+
195
+ begin
196
+ RestClient.post(@url, create_network_uplink_XML, :content_type => 'text/xml').body
197
+ rescue Exception => e
198
+ raise "Error #{e}"
199
+ end
200
+
201
+ end
202
+
203
+
204
+ def create_fc_uplink_port(json)
205
+
206
+ switch = JSON.parse(json)['switch']
207
+ port = JSON.parse(json)['port']
208
+ slot = JSON.parse(json)['slot']
209
+
210
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
211
+ xml.configConfMos('cookie' => "#{@ucs_cookie}", 'inHierarchical' => 'false'){
212
+ xml.inConfigs{
213
+ xml.pair('key' => "fabric/san/#{switch}/phys" + "-" + "slot" + "-" + "#{slot}" + "-" + "port" + "-" + "#{port}"){
214
+ xml.fabricFcSanEp('adminState' => 'enabled', 'dn' => "fabric/san/#{switch}/phys" + "-" + "slot" + "-" + "#{slot}" + "-" +
215
+ "port" + "-" + "#{port}" )
216
+ }
217
+ }
218
+ }
219
+ end
220
+
221
+ #Create XML
222
+ create_fc_uplink_XML = xml_builder.to_xml.to_s
223
+
224
+ #Post
225
+ begin
226
+ RestClient.post(@url, create_fc_uplink_XML, :content_type => 'text/xml').body
227
+ rescue Exception => e
228
+ raise "Error #{e}"
229
+ end
230
+
231
+ end
232
+
233
+
234
+ def create_port_channel(json)
235
+ #Parse uplink modules on Expansion Module 2. Minimum 2 ports are required for creating a port channel.
236
+ #As of this implementation, it is assumed that Northboutn uplinks are created using the Expansion Module and not the fixed module
237
+
238
+ switch = JSON.parse(json)['switch']
239
+ port_ids = JSON.parse(json)['port_ids'].split(',')
240
+ slot = JSON.parse(json)['slot']
241
+ port_channel_id = JSON.parse(json)['port_channel_id']
242
+ name = JSON.parse(json)['name']
243
+
244
+
245
+ #Create XML
246
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
247
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
248
+ xml.inConfigs{
249
+ xml.pair('key' => "fabric/lan/#{switch}/pc-#{port_channel_id}"){
250
+ xml.fabricEthLanPc('adminSpeed' => '10gbps', 'adminState' => 'enabled', 'dn' => "fabric/lan/#{switch}/pc-#{port_channel_id}",
251
+ 'flowCtrlPolicy' => 'default', 'name' => "#{name}", 'operSpeed' => '10gbps', 'portId' => "#{port_channel_id}",
252
+ 'status' => 'created'){
253
+ port_ids.each do |port_id|
254
+ xml.fabricEthLanPcEp('adminState' => 'enabled', 'name' => '', 'portId' => "#{port_id}",
255
+ 'rn' => "ep-slot-#{slot}-port-#{port_id}")
256
+ end
257
+ }
258
+
259
+ }
260
+ }
261
+ }
262
+ end
263
+
264
+ #Create XML
265
+ create_port_channel_XML = xml_builder.to_xml.to_s
266
+
267
+ #Post
268
+ begin
269
+ RestClient.post(@url, create_port_channel_XML, :content_type => 'text/xml').body
270
+ rescue Exception => e
271
+ raise "Error #{e}"
272
+ end
273
+
274
+ end
275
+
276
+ def create_org(json)
277
+
278
+ org = JSON.parse(json)['org']
279
+
280
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
281
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true') {
282
+ xml.inConfigs{
283
+ xml.pair('key' => "org-root/org-#{org}") {
284
+ xml.orgOrg('descr' => "#{org} org", 'dn' => "org-root/org-#{org}", 'name' => "#{org}", 'status' => 'created')
285
+ }
286
+ }
287
+ }
288
+ end
289
+
290
+ #Create XML
291
+ create_org_XML= xml_builder.to_xml.to_s
292
+
293
+ #Post
294
+
295
+ begin
296
+ RestClient.post(@url, create_org_XML, :content_type => 'text/xml').body
297
+ rescue Exception => e
298
+ raise "Error #{e}"
299
+ end
300
+
301
+ end
302
+
303
+ def set_local_disk_policy(json)
304
+
305
+ local_disk_policy = JSON.parse(json)['local_disk_policy']
306
+ org = JSON.parse(json)['org']
307
+
308
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
309
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
310
+ xml.inConfigs{
311
+ xml.pair('key' => "org-root/org-#{org}/local-disk-config-#{org}-localdisk"){
312
+ xml.storageLocalDiskConfigPolicy('descr' => '', 'dn' => "org-root/org-#{org}/local-disk-config-#{org}-localdisk",
313
+ 'mode' => "#{local_disk_policy}", 'name' => "#{org}-localdisk", 'protectConfig' => 'yes',
314
+ 'status' => 'created')
315
+ }
316
+ }
317
+ }
318
+ end
319
+
320
+ #Create XML
321
+ set_local_disk_policy_XML = xml_builder.to_xml.to_s
322
+
323
+ #Post
324
+ begin
325
+ RestClient.post(@url, set_local_disk_policy_XML, :content_type => 'text/xml').body
326
+ rescue Exception => e
327
+ raise "Error #{e}"
328
+ end
329
+
330
+ end
331
+
332
+ def create_local_boot_policy(json)
333
+
334
+ name = JSON.parse(json)['name']
335
+ description = JSON.parse(json)['description']
336
+ org = JSON.parse(json)['org']
337
+
338
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
339
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
340
+ xml.inConfigs{
341
+ xml.pair('key' => "org-root/org-#{org}/boot-policy-#{name}"){
342
+ xml.lsbootPolicy('descr' => "#{description}", 'dn' => "org-root/org-#{org}/boot-policy-#{name}",
343
+ 'enforceVnicName' => 'no', 'name' => "#{name}", 'rebootOnUpdate' => 'no',
344
+ 'status' => 'created'){
345
+ xml.lsbootVirtualMedia('access' => 'read-only', 'order' => '1', 'rn' => 'read-only-vm', 'status' => 'created')
346
+ xml.lsbootStorage('order' => '2', 'rn' => 'storage', 'status' => 'created'){
347
+ xml.lsbootLocalStorage('rn' => 'local-storage', 'status' => 'created')
348
+ }
349
+ }
350
+ }
351
+ }
352
+ }
353
+ end
354
+
355
+ #Create XML
356
+ create_local_boot_policy_XML = xml_builder.to_xml.to_s
357
+
358
+ #Post
359
+ begin
360
+ RestClient.post(@url, create_local_boot_policy_XML, :content_type => 'text/xml').body
361
+ rescue Exception => e
362
+ raise "Error #{e}"
363
+ end
364
+
365
+ end
366
+
367
+ def create_pxe_boot_policy(json)
368
+
369
+ name = JSON.parse(json)['name']
370
+ description = JSON.parse(json)['description']
371
+ org = JSON.parse(json)['org']
372
+ vnic_a = JSON.parse(json)['vnic_a']
373
+ vnic_b = JSON.parse(json)['vnic_b']
374
+
375
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
376
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
377
+ xml.inConfigs{
378
+ xml.pair('key' => "org-root/org-#{org}/boot-policy-#{name}"){
379
+ xml.lsbootPolicy('descr' => "#{description}", 'dn' => "org-root/org-#{org}/boot-policy-#{name}",
380
+ 'enforceVnicName' => 'no', 'name' => "#{name}", 'rebootOnUpdate' => 'no',
381
+ 'status' => 'created'){
382
+ xml.lsbootLan('order' => '1', 'rn' => 'lan'){
383
+ xml.lsbootLanImagePath('rn' => 'path-primary', 'status' => 'created',
384
+ 'type' => 'primary', 'vnicName' => "#{vnic_a}")
385
+ xml.lsbootLanImagePath('rn' => 'path-secondary', 'status' => 'created',
386
+ 'type' => 'secondary', 'vnicName' => "#{vnic_b}")
387
+ }
388
+ xml.lsbootStorage('order' => '2', 'rn' => 'storage', 'status' => 'created'){
389
+ xml.lsbootLocalStorage('rn' => 'local-storage', 'status' => 'created')
390
+ }
391
+ }
392
+ }
393
+ }
394
+ }
395
+ end
396
+
397
+ #Create XML
398
+ create_pxe_boot_policy_XML = xml_builder.to_xml.to_s
399
+
400
+ #Post
401
+ begin
402
+ RestClient.post(@url, create_pxe_boot_policy_XML, :content_type => 'text/xml').body
403
+ rescue Exception => e
404
+ raise "Error #{e}"
405
+ end
406
+
407
+ end
408
+
409
+ def create_san_boot_policy(json)
410
+
411
+ name = JSON.parse(json)['name']
412
+ description = JSON.parse(json)['description']
413
+ org = JSON.parse(json)['org']
414
+ vnic_a = JSON.parse(json)['vnic_a']
415
+ vnic_b = JSON.parse(json)['vnic_b']
416
+ target_a_1 = JSON.parse(json)['target_a_1']
417
+ target_a_2 = JSON.parse(json)['target_a_2']
418
+ target_b_1 = JSON.parse(json)['target_b_1']
419
+ target_b_2 = JSON.parse(json)['target_b_2']
420
+
421
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
422
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
423
+ xml.inConfigs{
424
+ xml.pair('key' => "org-root/org-#{org}/boot-policy-#{name}"){
425
+ xml.lsbootPolicy('descr' => "#{description}", 'dn' => "org-root/org-#{org}/boot-policy-#{name}", 'enforceVnicName' => 'no',
426
+ 'name' => "#{name}", 'rebootOnUpdate' => 'no', 'status' => 'created'){
427
+ xml.lsbootStorage('order' => '1', 'rn' => 'storage'){
428
+ xml.lsbootSanImage('rn' => 'san-primary', 'status' => 'created', 'type' => 'primary', 'vnicName' => "#{vnic_a}"){
429
+ xml.lsbootSanImagePath('lun' => '0', 'rn' => 'path-primary', 'status' => 'created', 'type' => 'primary', 'wwn' => "#{target_a_1}")
430
+ xml.lsbootSanImagePath('lun' => '0', 'rn' => 'path-secondary', 'status' => 'created', 'type' => 'secondary', 'wwn' => "#{target_a_2}")
431
+ }
432
+ xml.lsbootSanImage('rn' => 'san-secondary', 'status' => 'created', 'type' => 'secondary', 'vnicName' => "#{vnic_b}"){
433
+ xml.lsbootSanImagePath('lun' => '0', 'rn' => 'path-primary', 'status' => 'created', 'type' => 'primary', 'wwn' => "#{target_b_1}")
434
+ xml.lsbootSanImagePath('lun' => '0', 'rn' => 'path-secondary', 'status' => 'created', 'type' => 'secondary', 'wwn' => "#{target_b_2}")
435
+ }
436
+ }
437
+ }
438
+ }
439
+ }
440
+ }
441
+ end
442
+
443
+ #Create XML
444
+ create_san_boot_policy_XML = xml_builder.to_xml.to_s
445
+
446
+ #Post
447
+ begin
448
+ RestClient.post(@url, create_san_boot_policy_XML, :content_type => 'text/xml').body
449
+ rescue Exception => e
450
+ raise "Error #{e}"
451
+ end
452
+
453
+ end
454
+
455
+
456
+ def create_management_ip_pool(json)
457
+
458
+ start_ip = JSON.parse(json)['start_ip']
459
+ end_ip = JSON.parse(json)['end_ip']
460
+ subnet_mask = JSON.parse(json)['subnet_mask']
461
+ gateway = JSON.parse(json)['gateway']
462
+
463
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
464
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
465
+ xml.inConfigs{
466
+ xml.pair('key' => "org-root/ip-pool-ext-mgmt/block-#{start_ip}-#{end_ip}"){
467
+ xml.ippoolBlock('defGw' => "#{gateway}", 'dn' => "org-root/ip-pool-ext-mgmt/block-#{start_ip}-#{end_ip}",
468
+ 'from' => "#{start_ip}", 'status' => 'created', 'subnet' => "#{subnet_mask}", 'to' => "#{end_ip}")
469
+ }
470
+ }
471
+ }
472
+ end
473
+
474
+ #Create XML
475
+ create_management_ip_pool_XML = xml_builder.to_xml.to_s
476
+
477
+ #Post
478
+ begin
479
+ RestClient.post(@url, create_management_ip_pool_XML, :content_type => 'text/xml').body
480
+ rescue Exception => e
481
+ raise "Error #{e}"
482
+ end
483
+
484
+ end
485
+
486
+ def create_vlan(json)
487
+
488
+ vlan_id = JSON.parse(json)['vlan_id']
489
+ vlan_name = JSON.parse(json)['vlan_name']
490
+
491
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
492
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
493
+ xml.inConfigs{
494
+ xml.pair('key' => "fabric/lan/net-#{vlan_name}"){
495
+ xml.fabricVlan('defaultNet' => 'no', 'dn' => "fabric/lan/net-#{vlan_name}", 'id' => "#{vlan_id}",
496
+ 'name' => "#{vlan_name}", 'status' => 'created')
497
+ }
498
+ }
499
+ }
500
+ end
501
+
502
+ #Create XML
503
+ create_vlan_XML = xml_builder.to_xml.to_s
504
+
505
+ #Post
506
+ begin
507
+ RestClient.post(@url, create_vlan_XML, :content_type => 'text/xml').body
508
+ rescue Exception => e
509
+ raise "Error #{e}"
510
+ end
511
+
512
+ end
513
+
514
+ def create_mac_pool(json)
515
+
516
+ mac_pool_name = JSON.parse(json)['mac_pool_name']
517
+ mac_pool_start = JSON.parse(json)['mac_pool_start']
518
+ #size = JSON.parse(json)['size']
519
+ mac_pool_end = JSON.parse(json)['mac_pool_end']
520
+ org = JSON.parse(json)['org']
521
+
522
+ #
523
+ # def get_mac_pool_suffix(size)
524
+ # mac_pool_size = size
525
+ # octets = mac_pool_start.split(':')
526
+ # octets[-1] = (mac_pool_size - 1).to_s(base=16)
527
+ # return mac_pool_end = octets.join(':')
528
+ # end
529
+ #
530
+ # get_mac_pool_suffix(size)
531
+
532
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
533
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
534
+ xml.inConfigs{
535
+ xml.pair('key' => "org-root/org-#{org}/mac-pool-#{mac_pool_name}"){
536
+ xml.macpoolPool('descr' => '', 'dn' => "org-root/org-#{org}/mac-pool-#{mac_pool_name}", 'name' => "#{mac_pool_name}",
537
+ 'status' => 'created'){
538
+ xml.macpoolBlock('from' => "#{mac_pool_start}", 'rn' => "block-#{mac_pool_start}-#{mac_pool_end}",
539
+ 'status' => 'created', 'to' => "#{mac_pool_end}")
540
+ }
541
+ }
542
+ }
543
+ }
544
+
545
+ end
546
+
547
+ #Create XML
548
+ create_mac_pool_XML = xml_builder.to_xml.to_s
549
+
550
+ #Post
551
+ begin
552
+ RestClient.post(@url, create_mac_pool_XML, :content_type => 'text/xml').body
553
+ rescue Exception => e
554
+ raise "Error #{e}"
555
+ end
556
+
557
+ end
558
+
559
+ def create_vnic_template(json)
560
+
561
+ vnic_template_name = JSON.parse(json)['vnic_template_name']
562
+ vnic_template_mac_pool = JSON.parse(json)['vnic_template_mac_pool']
563
+ switch = JSON.parse(json)['switch']
564
+ org = JSON.parse(json)['org']
565
+ vnic_template_VLANs = JSON.parse(json)['vnic_template_VLANs'].split(',')
566
+ vnic_template_native_VLAN = JSON.parse(json)['vnic_template_native_VLAN']
567
+ vnic_template_mtu = JSON.parse(json)['vnic_template_mtu']
568
+
569
+
570
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
571
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
572
+ xml.inConfigs{
573
+ xml.pair('key' => "org-root/org-#{org}/lan-conn-templ-#{vnic_template_name}"){
574
+ xml.vnicLanConnTempl('descr' => '', 'dn' => "org-root/org-#{org}/lan-conn-templ-#{vnic_template_name}",
575
+ 'identPoolName' => "#{vnic_template_mac_pool}", 'mtu' => "#{vnic_template_mtu}", 'name' => "#{vnic_template_name}",
576
+ 'nwCtrlPolicyName' => '', 'pinToGroupName' => '', 'qosPolicyName' => '', 'statsPolicyName' => '',
577
+ 'status' => 'created', 'switchId' => "#{switch}", 'templType' => 'updating-template'){
578
+ vnic_template_VLANs.each do |vlan|
579
+ if vlan == vnic_template_native_VLAN
580
+ xml.vnicEtherIf('defaultNet' => 'yes', 'name' => "#{vlan}", 'rn' => "if-#{vlan}")
581
+ else
582
+ xml.vnicEtherIf('defaultNet' => 'yes', 'name' => "#{vlan}", 'rn' => "if-#{vlan}")
583
+ end
584
+ end
585
+ }
586
+ }
587
+ }
588
+ }
589
+ end
590
+
591
+ #Create XML
592
+ create_vnic_template_XML = xml_builder.to_xml.to_s
593
+
594
+ #Post
595
+ begin
596
+ RestClient.post(@url, create_vnic_template_XML, :content_type => 'text/xml').body
597
+ rescue Exception => e
598
+ raise "Error #{e}"
599
+ end
600
+
601
+ end
602
+
603
+
604
+ def create_vsan(json)
605
+
606
+ vsan_id = JSON.parse(json)['vsan_id']
607
+ vsan_fcoe_id = JSON.parse(json)['vsan_fcoe_id']
608
+ vsan_name = JSON.parse(json)['vsan_name']
609
+
610
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
611
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
612
+ xml.inConfigs{
613
+ xml.pair('key' => 'fabric/san/'){
614
+ xml.fabricVsan('defaultZoning' => 'disabled', 'dn' => 'fabric/san/', 'fcoeVlan' => "#{vsan_fcoe_id}",
615
+ 'id' => "#{vsan_id}", 'name' => "#{vsan_name}", 'status' => 'created' )
616
+ }
617
+ }
618
+ }
619
+ end
620
+
621
+ #Create XML
622
+ create_vsan_XML = xml_builder.to_xml.to_s
623
+
624
+ #Post
625
+ begin
626
+ RestClient.post(@url, create_vsan_XML, :content_type => 'text/xml').body
627
+ rescue Exception => e
628
+ raise "Error #{e}"
629
+ end
630
+
631
+ end
632
+
633
+ def create_wwnn_pool(json)
634
+
635
+ wwnn_name = JSON.parse(json)['wwnn_name']
636
+ wwnn_from = JSON.parse(json)['wwnn_from']
637
+ wwnn_to = JSON.parse(json)['wwnn_to']
638
+ org = JSON.parse(json)['org']
639
+
640
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
641
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
642
+ xml.inConfigs{
643
+ xml.pair('key' => "org-root/org-#{org}/wwn-pool-#{wwnn_name}"){
644
+ xml.fcpoolInitiators('descr' => '', 'dn' => "org-root/org-#{org}/wwn-pool-#{wwnn_name}", 'name' => "#{wwnn_name}",
645
+ 'purpose' => 'node-wwn-assignment', 'status' => 'created'){
646
+ xml.fcpoolBlock('from' => "#{wwnn_from}", 'rn' => "block-#{wwnn_from}-#{wwnn_to}",
647
+ 'status' => 'created', 'to' => "#{wwnn_to}")
648
+ }
649
+ }
650
+ }
651
+ }
652
+ end
653
+ #Create XML
654
+ create_wwnn_pool_XML = xml_builder.to_xml.to_s
655
+
656
+ #Post
657
+ begin
658
+ RestClient.post(@url, create_wwnn_pool_XML, :content_type => 'text/xml').body
659
+ rescue Exception => e
660
+ raise "Error #{e}"
661
+ end
662
+
663
+ end
664
+
665
+ def create_wwpn_pool(json)
666
+
667
+ wwpn_name = JSON.parse(json)['wwpn_name']
668
+ wwpn_from = JSON.parse(json)['wwpn_from']
669
+ wwpn_to = JSON.parse(json)['wwpn_to']
670
+ org = JSON.parse(json)['org']
671
+
672
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
673
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
674
+ xml.inConfigs{
675
+ xml.pair('key' => "org-root/org-#{org}/wwn-pool-#{wwpn_name}"){
676
+ xml.fcpoolInitiators('descr' => '', 'dn' => "org-root/org-#{org}/wwn-pool-#{wwpn_name}",
677
+ 'name' => "#{wwpn_name}", 'purpose' => 'port-wwn-assignment', 'status' => 'created'){
678
+ xml.fcpoolBlock('from' => "#{wwpn_from}", 'rn' => "block-#{wwpn_from}-#{wwpn_to}",
679
+ 'status' => 'created', 'to' => "#{wwpn_to}")
680
+ }
681
+ }
682
+ }
683
+ }
684
+ end
685
+
686
+
687
+ #Create XML
688
+ create_wwpn_pool_XML = xml_builder.to_xml.to_s
689
+
690
+ #Post
691
+ begin
692
+ RestClient.post(@url, create_wwpn_pool_XML, :content_type => 'text/xml').body
693
+ rescue Exception => e
694
+ raise "Error #{e}"
695
+ end
696
+
697
+ end
698
+
699
+ def create_vhba_template(json)
700
+
701
+ vbha_template_name = JSON.parse(json)['vbha_template_name']
702
+ wwpn_pool = JSON.parse(json)['wwpn_pool']
703
+ switch = JSON.parse(json)['switch']
704
+ vsan_name = JSON.parse(json)['vsan_name']
705
+ org = JSON.parse(json)['org']
706
+
707
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
708
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
709
+ xml.inConfigs{
710
+ xml.pair('key' => "org-root/org-#{org}/san-conn-templ-#{vbha_template_name}"){
711
+ xml.vnicSanConnTempl('descr' => '', 'dn' => "org-root/org-#{org}/san-conn-templ-#{vbha_template_name}",
712
+ 'identPoolName' => "#{wwpn_pool}", 'maxDataFieldSize' => '2048', 'name' => "#{vbha_template_name}",
713
+ 'pinToGroupName' => '', 'qosPolicyName' => '', 'statsPolicyName' => 'default', 'status' => 'created',
714
+ 'switchId' => "#{switch}", 'templType' => 'updating-template'){
715
+ xml.vnicFcIf('name' => "#{vsan_name}", 'rn' => 'if-default')
716
+ }
717
+ }
718
+ }
719
+ }
720
+ end
721
+ #Create XML
722
+ create_vhba_template_XML = xml_builder.to_xml.to_s
723
+
724
+ #Post
725
+ begin
726
+ RestClient.post(@url, create_vhba_template_XML, :content_type => 'text/xml').body
727
+ rescue Exception => e
728
+ raise "Error #{e}"
729
+ end
730
+
731
+ end
732
+
733
+ def create_uuid_pool(json)
734
+
735
+ uuid_pool_name = JSON.parse(json)['uuid_pool_name']
736
+ uuid_from = JSON.parse(json)['uuid_from']
737
+ uuid_to = JSON.parse(json)['uuid_to']
738
+ org = JSON.parse(json)['org']
739
+
740
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
741
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
742
+ xml.inConfigs{
743
+ xml.pair('key' => "org-root/org-#{org}/uuid-pool-#{uuid_pool_name}"){
744
+ xml.uuidpoolPool('descr' => '', 'dn' => "org-root/org-#{org}/uuid-pool-#{uuid_pool_name}",
745
+ 'name' => "#{uuid_pool_name}", 'prefix' => 'derived', 'status' => 'created'){
746
+ xml.uuidpoolBlock('from' => "#{uuid_from}", 'rn' => "block-from-#{uuid_from}-to-#{uuid_to}",
747
+ 'status' => 'created', 'to' => "#{uuid_to}")
748
+ }
749
+ }
750
+ }
751
+ }
752
+ end
753
+
754
+ #Create XML
755
+ create_uuid_pool_XML = xml_builder.to_xml.to_s
756
+
757
+ #Post
758
+ begin
759
+ RestClient.post(@url, create_uuid_pool_XML, :content_type => 'text/xml').body
760
+ rescue Exception => e
761
+ raise "Error #{e}"
762
+ end
763
+
764
+ end
765
+
766
+ def create_service_profile_template(json)
767
+
768
+ service_profile_template_name = JSON.parse(json)['service_profile_template_name']
769
+ service_profile_template_boot_policy = JSON.parse(json)['service_profile_template_boot_policy']
770
+ service_profile_template_host_fw_policy = JSON.parse(json)['service_profile_template_host_fw_policy']
771
+ service_profile_template_mgmt_fw_policy = JSON.parse(json)['service_profile_template_mgmt_fw_policy']
772
+ service_profile_template_uuid_pool = JSON.parse(json)['service_profile_template_uuid_pool']
773
+ service_profile_template_vnics_a = JSON.parse(json)['service_profile_template_vnics_a'].split(',')
774
+ service_profile_template_vnic_a_template = JSON.parse(json)['service_profile_template_vnic_a_template']
775
+ service_profile_template_vnics_b = JSON.parse(json)['service_profile_template_vnics_b'].split(',')
776
+ service_profile_template_vnic_b_template = JSON.parse(json)['service_profile_template_vnic_b_template'].to_s
777
+ service_profile_template_wwnn_pool = JSON.parse(json)['service_profile_template_wwnn_pool'].to_s
778
+ service_profile_template_vhba_a = JSON.parse(json)['service_profile_template_vhba_a']
779
+ service_profile_template_vhba_a_template = JSON.parse(json)['service_profile_template_vhba_a_template']
780
+ service_profile_template_vhba_b = JSON.parse(json)['service_profile_template_vhba_b'].to_s
781
+ service_profile_template_vhba_b_template = JSON.parse(json)['service_profile_template_vhba_b_template'].to_s
782
+ org = JSON.parse(json)['org'].to_s
783
+
784
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
785
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
786
+ xml.inConfigs{
787
+ xml.pair('key' => "org-root/org-#{org}/ls-#{service_profile_template_name}"){
788
+ xml.lsServer('agentPolicyName' => '', 'biosProfileName' => '', 'bootPolicyName' => "#{service_profile_template_boot_policy}",
789
+ 'descr' => '', 'dn' => "org-root/org-#{org}/ls-#{service_profile_template_name}",
790
+ 'dynamicConPolicyName' => '', 'extIPState' => 'none', 'hostFwPolicyName' => "#{service_profile_template_host_fw_policy}",
791
+ 'identPoolName' => "#{service_profile_template_uuid_pool}", 'localDiskPolicyName' => 'default', 'maintPolicyName' => 'default',
792
+ 'mgmtAccessPolicyName' => '', 'mgmtFwPolicyName' => "#{service_profile_template_mgmt_fw_policy}", 'name' => "#{service_profile_template_name}",
793
+ 'powerPolicyName' => 'default', 'scrubPolicyName' => '', 'solPolicyName' => 'default', 'srcTemplName' => '', 'statsPolicyName' => 'default',
794
+ 'status' => 'created', 'type' => 'updating-template', 'usrLbl' => '', 'uuid' => '0', 'vconProfileName' => ''){
795
+ service_profile_template_vnics_a.each do |vnic_a|
796
+ xml.vnicEther('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'mtu' => '1500',
797
+ 'name' => "#{vnic_a}", 'nwCtrlPolicyName' => '', 'nwTemplName' => "#{service_profile_template_vnic_a_template}",
798
+ 'order' => '3', 'pinToGroupName' => '', 'qosPolicyName' => '', 'rn' => "ether-#{vnic_a}",
799
+ 'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'A')
800
+ end
801
+ service_profile_template_vnics_b.each do |vnic_b|
802
+ xml.vnicEther('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'mtu' => '1500',
803
+ 'name' => "#{vnic_b}", 'nwCtrlPolicyName' => '', 'nwTemplName' => "#{service_profile_template_vnic_b_template}",
804
+ 'order' => '4', 'pinToGroupName' => '', 'qosPolicyName' => '', 'rn' => "ether-#{vnic_b}",
805
+ 'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'B')
806
+ end
807
+ xml.vnicFcNode('addr' => 'pool-derived', 'identPoolName' => "#{service_profile_template_wwnn_pool}", 'rn' => 'fc-node')
808
+
809
+ xml.vnicFc('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'maxDataFieldSize' => '2048',
810
+ 'name' => "#{service_profile_template_vhba_a}", 'nwTemplName' => "#{service_profile_template_vhba_a_template}",
811
+ 'order' => '1', 'persBind' => 'disabled', 'persBindClear' => 'no', 'pinToGroupName' => '', 'qosPolicyName' => '',
812
+ 'rn' => "fc-#{service_profile_template_vhba_a}", 'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'A')
813
+
814
+ xml.vnicFc('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'maxDataFieldSize' => '2048',
815
+ 'name' => "#{service_profile_template_vhba_b}", 'nwTemplName' => "#{service_profile_template_vhba_b_template}",
816
+ 'order' => '2', 'persBind' => 'disabled', 'persBindClear' => 'no', 'pinToGroupName' => '', 'qosPolicyName' => '',
817
+ 'rn' => "fc-#{service_profile_template_vhba_b}", 'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'B')
818
+
819
+ xml.lsPower('rn' => 'power', 'state' => 'up')
820
+ }
821
+ }
822
+ }
823
+ }
824
+ end
825
+
826
+ #Create Template XML
827
+ create_service_profile_template_XML = xml_builder.to_xml.to_s
828
+
829
+ #Post create Service Profile Template
830
+ begin
831
+ RestClient.post(@url, create_service_profile_template_XML, :content_type => 'text/xml').body
832
+ rescue Exception => e
833
+ raise "Error #{e}"
834
+ end
835
+
836
+ end
837
+
838
+ def create_service_profiles_from_template(json)
839
+
840
+ service_profile_template_name = JSON.parse(json)['service_profile_template_name'].to_s
841
+ org = JSON.parse(json)['org'].to_s
842
+ service_profile_template_sp_prefix = JSON.parse(json)['service_profile_template_sp_prefix'].to_s
843
+ service_profile_template_num_of_sps = JSON.parse(json)['service_profile_template_num_of_sps'].to_i
844
+
845
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
846
+ xml.lsInstantiateNTemplate('dn' => "org-root/org-#{org}/ls-#{service_profile_template_name}",
847
+ 'inTargetOrg' => "org-root/org-#{org}", 'inServerNamePrefixOrEmpty' => "#{service_profile_template_sp_prefix}",
848
+ 'inNumberOf' => "#{service_profile_template_num_of_sps}", 'inHierarchical' => 'false')
849
+
850
+
851
+ end
852
+
853
+
854
+ #Create Template XML
855
+ create_service_profiles_from_template_XML = xml_builder.to_xml.to_s
856
+
857
+ #Post create Service Profiles from Template
858
+ begin
859
+ RestClient.post(@url, create_service_profiles_from_template_XML, :content_type => 'text/xml').body
860
+ rescue Exception => e
861
+ raise "Error #{e}"
862
+ end
863
+
864
+ end
865
+
866
+
867
+
868
+ def create_service_profiles(json)
869
+
870
+ service_profile_names = JSON.parse(json)['service_profile_names'].to_s.split(',')
871
+ service_profile_boot_policy = JSON.parse(json)['service_profile_boot_policy'].to_s
872
+ service_profile_host_fw_policy = JSON.parse(json)['service_profile_host_fw_policy'].to_s
873
+ service_profile_mgmt_fw_policy = JSON.parse(json)['service_profile_mgmt_fw_policy'].to_s
874
+ service_profile_uuid_pool = JSON.parse(json)['service_profile_uuid_pool'].to_s
875
+ service_profile_vnics_a = JSON.parse(json)['service_profile_vnics_a'].to_s.split(',')
876
+ service_profile_vnic_a_template = JSON.parse(json)['service_profile_vnic_a_template'].to_s
877
+ service_profile_vnics_b = JSON.parse(json)['service_profile_vnics_b'].to_s.split(',')
878
+ service_profile_vnic_b_template = JSON.parse(json)['service_profile_vnic_b_template'].to_s
879
+ service_profile_wwnn_pool = JSON.parse(json)['service_profile_wwnn_pool'].to_s
880
+ service_profile_vhba_a = JSON.parse(json)['service_profile_vhba_a'].to_s
881
+ service_profile_vhba_a_template = JSON.parse(json)['service_profile_vhba_a_template'].to_s
882
+ service_profile_vhba_b = JSON.parse(json)['service_profile_vhba_b'].to_s
883
+ service_profile_vhba_b_template = JSON.parse(json)['service_profile_vhba_b_template'].to_s
884
+ org = JSON.parse(json)['org'].to_s
885
+ service_profile_template_to_bind = JSON.parse(json)['service_profile_template_to_bind'].to_s
886
+
887
+
888
+
889
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
890
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
891
+ xml.inConfigs{@service_profile_names.each do |service_profile_name|
892
+ xml.pair('key' => "org-root/org-#{org}/ls-#{service_profile_name}"){
893
+ xml.lsServer('agentPolicyName' => '', 'biosProfileName' => '', 'bootPolicyName' => "#{service_profile_boot_policy}",
894
+ 'descr' => '', 'dn' => "org-root/org-#{service_profile_org}/ls-#{service_profile_name}",
895
+ 'dynamicConPolicyName' => '', 'extIPState' => 'none', 'hostFwPolicyName' => "#{service_profile_host_fw_policy}",
896
+ 'identPoolName' => "#{service_profile_uuid_pool}", 'localDiskPolicyName' => 'default', 'maintPolicyName' => 'default',
897
+ 'mgmtAccessPolicyName' => '', 'mgmtFwPolicyName' => "#{service_profile_mgmt_fw_policy}", 'name' => "#{service_profile_name}",
898
+ 'powerPolicyName' => 'default', 'scrubPolicyName' => '', 'solPolicyName' => 'default', 'srcTemplName' => "#{service_profile_template_to_bind}",
899
+ 'statsPolicyName' => 'default', 'status' => 'created', 'usrLbl' => '', 'uuid' => '0', 'vconProfileName' => ''){
900
+ @service_profile_vnics_a.each do |vnic_a|
901
+ xml.vnicEther('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'mtu' => '1500',
902
+ 'name' => "#{vnic_a}", 'nwCtrlPolicyName' => '', 'nwTemplName' => "#{service_profile_vnic_a_template}",
903
+ 'order' => '3', 'pinToGroupName' => '', 'qosPolicyName' => '', 'rn' => "ether-#{vnic_a}",
904
+ 'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'A')
905
+ end
906
+
907
+ @service_profile_vnics_b.each do |vnic_b|
908
+ xml.vnicEther('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'mtu' => '1500',
909
+ 'name' => "#{vnic_b}", 'nwCtrlPolicyName' => '', 'nwTemplName' => "#{service_profile_vnic_b_template}",
910
+ 'order' => '4', 'pinToGroupName' => '', 'qosPolicyName' => '', 'rn' => "ether-#{vnic_b}",
911
+ 'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'B')
912
+ end
913
+
914
+ xml.vnicFcNode('addr' => 'pool-derived', 'identPoolName' => "#{service_profile_wwnn_pool}", 'rn' => 'fc-node')
915
+
916
+ xml.vnicFc('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'maxDataFieldSize' => '2048',
917
+ 'name' => "#{service_profile_vhba_a}", 'nwTemplName' => "#{service_profile_vhba_a_}",
918
+ 'order' => '1', 'persBind' => 'disabled', 'persBindClear' => 'no', 'pinToGroupName' => '', 'qosPolicyName' => '',
919
+ 'rn' => "fc-#{service_profile_vhba_a}", 'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'A')
920
+
921
+ xml.vnicFc('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'maxDataFieldSize' => '2048',
922
+ 'name' => "#{service_profile_vhba_b}", 'nwTemplName' => "#{service_profile_vhba_b_}",
923
+ 'order' => '2', 'persBind' => 'disabled', 'persBindClear' => 'no', 'pinToGroupName' => '', 'qosPolicyName' => '',
924
+ 'rn' => "fc-#{service_profile_vhba_b}", 'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'B')
925
+
926
+ xml.lsPower('rn' => 'power', 'state' => 'up')
927
+ }
928
+ }
929
+ end}
930
+ }
931
+
932
+ end
933
+
934
+
935
+ #Create Template XML
936
+ create_service_profiles_XML = xml_builder.to_xml.to_s
937
+
938
+ #Post create Service Profile Template
939
+ begin
940
+ RestClient.post(@url, create_service_profiles_XML, :content_type => 'text/xml').body
941
+ rescue Exception => e
942
+ raise "Error #{e}"
943
+ end
944
+
945
+ end
946
+
947
+
948
+
949
+ end