ucslib 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,265 +17,264 @@
17
17
 
18
18
  class UCSProvision
19
19
 
20
- def initialize(tokenjson)
20
+ def initialize(tokenjson)
21
21
 
22
22
  @cookie = "#{JSON.parse(tokenjson)['cookie']}"
23
23
  ip = "#{JSON.parse(tokenjson)['ip']}"
24
24
  @url = "https://#{ip}/nuova"
25
25
 
26
- end
26
+ end
27
27
 
28
- def set_power_policy(json)
28
+ def set_power_policy(json)
29
29
 
30
- power_policy = "#{JSON.parse(json)['power_policy']}"
30
+ power_policy = "#{JSON.parse(json)['power_policy']}"
31
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
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
43
41
 
44
- #Post
42
+ set_power_policy_XML = xml_builder.to_xml.to_s
45
43
 
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
44
+ #Post
45
+ begin
46
+ RestClient.post(@url, set_power_policy_XML, :content_type => 'text/xml').body
47
+ rescue Exception => e
48
+ raise "Error #{e}"
49
+ end
51
50
 
52
- end
51
+ end
53
52
 
54
53
  def set_chassis_discovery_policy(json)
55
54
 
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
55
+ chassis_discovery_policy = "#{JSON.parse(json)['chassis_discovery_policy']}"
68
56
 
69
- set_chassis_discovery_policy_XML = xml_builder.to_xml.to_s
57
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
58
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false') {
59
+ xml.inConfigs{
60
+ xml.pair('key' => 'org-root/chassis-discovery'){
61
+ xml.computeChassisDiscPolicy( 'action' => "#{chassis_discovery_policy}", 'descr' => '', 'dn' => 'org-root/chassis-discovery',
62
+ 'name' => '', 'rebalance' => 'user-acknowledged')
63
+ }
64
+ }
65
+ }
66
+ end
70
67
 
71
- #Post
68
+ set_chassis_discovery_policy_XML = xml_builder.to_xml.to_s
72
69
 
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
70
+ #Post
71
+
72
+ begin
73
+ RestClient.post(@url, set_chassis_discovery_policy_XML, :content_type => 'text/xml').body
74
+ rescue Exception => e
75
+ raise "Error #{e}"
76
+ end
78
77
 
79
- end
78
+ end
80
79
 
81
80
 
82
81
  def set_time_zone(json)
83
82
 
84
- time_zone = "#{JSON.parse(json)['time_zone']}"
83
+ time_zone = "#{JSON.parse(json)['time_zone']}"
85
84
 
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
85
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
86
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
87
+ xml.inConfigs{
88
+ xml.pair('key' => 'sys/svc-ext/datetime-svc'){
89
+ xml.commDateTime('adminState' => 'enabled', 'descr' => '', 'dn' => 'sys/svc-ext/datetime-svc', 'port' => '0', 'status' => 'modified',
90
+ 'timezone' => "#{time_zone}")
91
+ }
92
+ }
93
+ }
94
+ end
96
95
 
97
- set_time_zone_XML = xml_builder.to_xml.to_s
96
+ set_time_zone_XML = xml_builder.to_xml.to_s
98
97
 
99
- #Post
98
+ #Post
100
99
 
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
100
+ begin
101
+ RestClient.post(@url, set_time_zone_XML, :content_type => 'text/xml').body
102
+ rescue Exception => e
103
+ raise "Error #{e}"
104
+ end
106
105
 
107
106
  end
108
107
 
109
108
  def set_ntp(json)
110
109
 
111
- ntp_server = "#{JSON.parse(json)['ntp_server']}"
110
+ ntp_server = "#{JSON.parse(json)['ntp_server']}"
112
111
 
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
112
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
113
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
114
+ xml.inConfigs{
115
+ xml.pair('key' => "sys/svc-ext/datetime-svc/ntp-#{ntp_server}"){
116
+ xml.commNtpProvider('descr' => '', 'dn' => "sys/svc-ext/datetime-svc/ntp-#{ntp_server}", 'name' => "#{ntp_server}", 'status' => 'created' )
117
+ }
118
+ }
119
+ }
120
+ end
122
121
 
123
- set_ntp_XML = xml_builder.to_xml.to_s
122
+ set_ntp_XML = xml_builder.to_xml.to_s
124
123
 
125
- #Post
124
+ #Post
126
125
 
127
- begin
128
- RestClient.post(@url, set_ntp_XML, :content_type => 'text/xml').body
129
- rescue Exception => e
130
- raise "Error #{e}"
131
- end
126
+ begin
127
+ RestClient.post(@url, set_ntp_XML, :content_type => 'text/xml').body
128
+ rescue Exception => e
129
+ raise "Error #{e}"
130
+ end
132
131
 
133
132
  end
134
133
 
135
- def create_server_port(json)
134
+ def create_server_port(json)
136
135
 
137
- switch = JSON.parse(json)['switch']
138
- port = JSON.parse(json)['port']
139
- slot = JSON.parse(json)['slot']
136
+ switch = JSON.parse(json)['switch']
137
+ port = JSON.parse(json)['port']
138
+ slot = JSON.parse(json)['slot']
140
139
 
141
140
 
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
141
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
142
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
143
+ xml.inConfigs{
144
+ xml.pair('key' => "fabric/server/SW-#{switch}"){
145
+ xml.fabricDceSwSrv('dn' => "fabric/server/SW-#{switch}", 'status' => 'created,modified'){
146
+ xml.fabricDceSwSrvEp( 'adminState' => 'enabled', 'name' => '', 'portId' => "#{port}",
147
+ 'rn' => "slot" + "-" + "#{slot}" + "-" + "port" + "-" + "#{port}", 'slotId' => "#{slot}",
148
+ 'status' => 'created', 'usrLbl' => '' )
149
+ }
150
+ }
151
+ }
152
+ }
153
+ end
155
154
 
156
- #Create XML
157
- create_server_port_XML = xml_builder.to_xml.to_s
155
+ #Create XML
156
+ create_server_port_XML = xml_builder.to_xml.to_s
158
157
 
159
- #Post
158
+ #Post
160
159
 
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
160
+ begin
161
+ RestClient.post(@url, create_server_port_XML, :content_type => 'text/xml').body
162
+ rescue Exception => e
163
+ raise "Error #{e}"
164
+ end
166
165
 
167
- end
166
+ end
168
167
 
169
168
  def create_network_uplink_port(json)
170
169
 
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
170
+ switch = JSON.parse(json)['switch']
171
+ port = JSON.parse(json)['port']
172
+ slot = JSON.parse(json)['slot']
173
+
174
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
175
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
176
+ xml.inConfigs{
177
+ xml.pair('key' => "fabric/lan/#{switch}"){
178
+ xml.fabricEthLan('dn' => "fabric/lan/#{switch}", 'status' => 'created,modified'){
179
+ xml.fabricEthLanEp('adminSpeed' => '10gbps', 'adminState' => 'enabled', 'flowCtrlPolicy' => 'default',
180
+ 'name' => '', 'portId' => "#{port}",
181
+ 'rn' => "phys" + "-" + "slot" + "-" + "#{slot}" + "-" + "port" + "-" + "#{port}",
182
+ 'slotId' => "#{slot}", 'status' => 'created', 'usrLbl' => '')
183
+ }
184
+ }
185
+ }
186
+ }
187
+ end
189
188
 
190
- #Create XML
191
- create_network_uplink_XML = xml_builder.to_xml.to_s
189
+ #Create XML
190
+ create_network_uplink_XML = xml_builder.to_xml.to_s
192
191
 
193
- #Post
192
+ #Post
194
193
 
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
194
+ begin
195
+ RestClient.post(@url, create_network_uplink_XML, :content_type => 'text/xml').body
196
+ rescue Exception => e
197
+ raise "Error #{e}"
198
+ end
200
199
 
201
200
  end
202
201
 
203
202
 
204
203
  def create_fc_uplink_port(json)
205
204
 
206
- switch = JSON.parse(json)['switch']
207
- port = JSON.parse(json)['port']
208
- slot = JSON.parse(json)['slot']
205
+ switch = JSON.parse(json)['switch']
206
+ port = JSON.parse(json)['port']
207
+ slot = JSON.parse(json)['slot']
209
208
 
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
209
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
210
+ xml.configConfMos('cookie' => "#{@ucs_cookie}", 'inHierarchical' => 'false'){
211
+ xml.inConfigs{
212
+ xml.pair('key' => "fabric/san/#{switch}/phys" + "-" + "slot" + "-" + "#{slot}" + "-" + "port" + "-" + "#{port}"){
213
+ xml.fabricFcSanEp('adminState' => 'enabled', 'dn' => "fabric/san/#{switch}/phys" + "-" + "slot" + "-" + "#{slot}" + "-" +
214
+ "port" + "-" + "#{port}" )
215
+ }
216
+ }
217
+ }
218
+ end
220
219
 
221
- #Create XML
222
- create_fc_uplink_XML = xml_builder.to_xml.to_s
220
+ #Create XML
221
+ create_fc_uplink_XML = xml_builder.to_xml.to_s
223
222
 
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
223
+ #Post
224
+ begin
225
+ RestClient.post(@url, create_fc_uplink_XML, :content_type => 'text/xml').body
226
+ rescue Exception => e
227
+ raise "Error #{e}"
228
+ end
230
229
 
231
230
  end
232
231
 
233
232
 
234
233
  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
- }
234
+ #Parse uplink modules on Expansion Module 2. Minimum 2 ports are required for creating a port channel.
235
+ #As of this implementation, it is assumed that Northboutn uplinks are created using the Expansion Module and not the fixed module
258
236
 
259
- }
260
- }
261
- }
262
- end
237
+ switch = JSON.parse(json)['switch']
238
+ port_ids = JSON.parse(json)['port_ids'].split(',')
239
+ slot = JSON.parse(json)['slot']
240
+ port_channel_id = JSON.parse(json)['port_channel_id']
241
+ name = JSON.parse(json)['name']
263
242
 
264
- #Create XML
265
- create_port_channel_XML = xml_builder.to_xml.to_s
266
243
 
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
244
+ #Create XML
245
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
246
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
247
+ xml.inConfigs{
248
+ xml.pair('key' => "fabric/lan/#{switch}/pc-#{port_channel_id}"){
249
+ xml.fabricEthLanPc('adminSpeed' => '10gbps', 'adminState' => 'enabled', 'dn' => "fabric/lan/#{switch}/pc-#{port_channel_id}",
250
+ 'flowCtrlPolicy' => 'default', 'name' => "#{name}", 'operSpeed' => '10gbps', 'portId' => "#{port_channel_id}",
251
+ 'status' => 'created'){
252
+ port_ids.each do |port_id|
253
+ xml.fabricEthLanPcEp('adminState' => 'enabled', 'name' => '', 'portId' => "#{port_id}",
254
+ 'rn' => "ep-slot-#{slot}-port-#{port_id}")
255
+ end
256
+ }
257
+
258
+ }
259
+ }
260
+ }
261
+ end
262
+
263
+ #Create XML
264
+ create_port_channel_XML = xml_builder.to_xml.to_s
265
+
266
+ #Post
267
+ begin
268
+ RestClient.post(@url, create_port_channel_XML, :content_type => 'text/xml').body
269
+ rescue Exception => e
270
+ raise "Error #{e}"
271
+ end
273
272
 
274
- end
273
+ end
275
274
 
276
275
  def create_org(json)
277
276
 
278
- org = JSON.parse(json)['org']
277
+ org = JSON.parse(json)['org']
279
278
 
280
279
  xml_builder = Nokogiri::XML::Builder.new do |xml|
281
280
  xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true') {
@@ -296,340 +295,380 @@ class UCSProvision
296
295
  RestClient.post(@url, create_org_XML, :content_type => 'text/xml').body
297
296
  rescue Exception => e
298
297
  raise "Error #{e}"
299
- end
300
-
298
+ end
301
299
 
302
300
  end
303
301
 
304
302
  def set_local_disk_policy(json)
305
303
 
306
- local_disk_policy = JSON.parse(json)['local_disk_policy']
307
- org = JSON.parse(json)['org']
304
+ local_disk_policy = JSON.parse(json)['local_disk_policy']
305
+ org = JSON.parse(json)['org']
308
306
 
309
- xml_builder = Nokogiri::XML::Builder.new do |xml|
310
- xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
311
- xml.inConfigs{
312
- xml.pair('key' => "org-root/org-#{org}/local-disk-config-#{org}-localdisk"){
313
- xml.storageLocalDiskConfigPolicy('descr' => '', 'dn' => "org-root/org-#{org}/local-disk-config-#{org}-localdisk",
314
- 'mode' => "#{local_disk_policy}", 'name' => "#{org}-localdisk", 'protectConfig' => 'yes',
315
- 'status' => 'created')
316
- }
317
- }
318
- }
319
- end
307
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
308
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
309
+ xml.inConfigs{
310
+ xml.pair('key' => "org-root/org-#{org}/local-disk-config-#{org}-localdisk"){
311
+ xml.storageLocalDiskConfigPolicy('descr' => '', 'dn' => "org-root/org-#{org}/local-disk-config-#{org}-localdisk",
312
+ 'mode' => "#{local_disk_policy}", 'name' => "#{org}-localdisk", 'protectConfig' => 'yes',
313
+ 'status' => 'created')
314
+ }
315
+ }
316
+ }
317
+ end
320
318
 
321
- #Create XML
322
- set_local_disk_policy_XML = xml_builder.to_xml.to_s
319
+ #Create XML
320
+ set_local_disk_policy_XML = xml_builder.to_xml.to_s
323
321
 
324
- #Post
325
- begin
326
- RestClient.post(@url, set_local_disk_policy_XML, :content_type => 'text/xml').body
327
- rescue Exception => e
328
- raise "Error #{e}"
329
- end
322
+ #Post
323
+ begin
324
+ RestClient.post(@url, set_local_disk_policy_XML, :content_type => 'text/xml').body
325
+ rescue Exception => e
326
+ raise "Error #{e}"
327
+ end
330
328
 
331
329
  end
332
330
 
333
331
  def create_local_boot_policy(json)
334
332
 
335
- name = JSON.parse(json)['name']
336
- description = JSON.parse(json)['description']
337
- org = JSON.parse(json)['org']
338
-
339
- xml_builder = Nokogiri::XML::Builder.new do |xml|
340
- xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
341
- xml.inConfigs{
342
- xml.pair('key' => "org-root/org-#{org}/boot-policy-#{name}"){
343
- xml.lsbootPolicy('descr' => "#{description}", 'dn' => "org-root/org-#{org}/boot-policy-#{name}",
344
- 'enforceVnicName' => 'no', 'name' => "#{name}", 'rebootOnUpdate' => 'no',
345
- 'status' => 'created'){
346
- xml.lsbootVirtualMedia('access' => 'read-only', 'order' => '1', 'rn' => 'read-only-vm', 'status' => 'created')
347
- xml.lsbootStorage('order' => '2', 'rn' => 'storage', 'status' => 'created'){
348
- xml.lsbootLocalStorage('rn' => 'local-storage', 'status' => 'created')
349
- }
350
- }
351
- }
352
- }
353
- }
354
- end
333
+ name = JSON.parse(json)['name']
334
+ description = JSON.parse(json)['description']
335
+ org = JSON.parse(json)['org']
355
336
 
356
- #Create XML
357
- create_local_boot_policy_XML = xml_builder.to_xml.to_s
337
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
338
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
339
+ xml.inConfigs{
340
+ xml.pair('key' => "org-root/org-#{org}/boot-policy-#{name}"){
341
+ xml.lsbootPolicy('descr' => "#{description}", 'dn' => "org-root/org-#{org}/boot-policy-#{name}",
342
+ 'enforceVnicName' => 'no', 'name' => "#{name}", 'rebootOnUpdate' => 'no',
343
+ 'status' => 'created'){
344
+ xml.lsbootVirtualMedia('access' => 'read-only', 'order' => '1', 'rn' => 'read-only-vm', 'status' => 'created')
345
+ xml.lsbootStorage('order' => '2', 'rn' => 'storage', 'status' => 'created'){
346
+ xml.lsbootLocalStorage('rn' => 'local-storage', 'status' => 'created')
347
+ }
348
+ }
349
+ }
350
+ }
351
+ }
352
+ end
358
353
 
359
- #Post
360
- begin
361
- RestClient.post(@url, create_local_boot_policy_XML, :content_type => 'text/xml').body
362
- rescue Exception => e
363
- raise "Error #{e}"
364
- end
354
+ #Create XML
355
+ create_local_boot_policy_XML = xml_builder.to_xml.to_s
356
+
357
+ #Post
358
+ begin
359
+ RestClient.post(@url, create_local_boot_policy_XML, :content_type => 'text/xml').body
360
+ rescue Exception => e
361
+ raise "Error #{e}"
362
+ end
365
363
 
366
364
  end
367
365
 
368
366
  def create_pxe_boot_policy(json)
369
367
 
370
- name = JSON.parse(json)['name']
371
- description = JSON.parse(json)['description']
372
- org = JSON.parse(json)['org']
373
- vnic_a = JSON.parse(json)['vnic_a']
374
- vnic_b = JSON.parse(json)['vnic_b']
375
-
376
- xml_builder = Nokogiri::XML::Builder.new do |xml|
377
- xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
378
- xml.inConfigs{
379
- xml.pair('key' => "org-root/org-#{org}/boot-policy-#{name}"){
380
- xml.lsbootPolicy('descr' => "#{description}", 'dn' => "org-root/org-#{org}/boot-policy-#{name}",
381
- 'enforceVnicName' => 'no', 'name' => "#{name}", 'rebootOnUpdate' => 'no',
382
- 'status' => 'created'){
383
- xml.lsbootLan('order' => '1', 'rn' => 'lan'){
384
- xml.lsbootLanImagePath('rn' => 'path-primary', 'status' => 'created',
385
- 'type' => 'primary', 'vnicName' => "#{vnic_a}")
386
- xml.lsbootLanImagePath('rn' => 'path-secondary', 'status' => 'created',
387
- 'type' => 'secondary', 'vnicName' => "#{vnic_b}")
388
- }
389
- xml.lsbootStorage('order' => '2', 'rn' => 'storage', 'status' => 'created'){
390
- xml.lsbootLocalStorage('rn' => 'local-storage', 'status' => 'created')
391
- }
392
- }
393
- }
394
- }
395
- }
396
- end
368
+ name = JSON.parse(json)['name']
369
+ description = JSON.parse(json)['description']
370
+ org = JSON.parse(json)['org']
371
+ vnic_a = JSON.parse(json)['vnic_a']
372
+ vnic_b = JSON.parse(json)['vnic_b']
397
373
 
398
- #Create XML
399
- create_pxe_boot_policy_XML = xml_builder.to_xml.to_s
374
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
375
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
376
+ xml.inConfigs{
377
+ xml.pair('key' => "org-root/org-#{org}/boot-policy-#{name}"){
378
+ xml.lsbootPolicy('descr' => "#{description}", 'dn' => "org-root/org-#{org}/boot-policy-#{name}",
379
+ 'enforceVnicName' => 'no', 'name' => "#{name}", 'rebootOnUpdate' => 'no',
380
+ 'status' => 'created'){
381
+ xml.lsbootLan('order' => '1', 'rn' => 'lan'){
382
+ xml.lsbootLanImagePath('rn' => 'path-primary', 'status' => 'created',
383
+ 'type' => 'primary', 'vnicName' => "#{vnic_a}")
384
+ xml.lsbootLanImagePath('rn' => 'path-secondary', 'status' => 'created',
385
+ 'type' => 'secondary', 'vnicName' => "#{vnic_b}")
386
+ }
387
+ xml.lsbootStorage('order' => '2', 'rn' => 'storage', 'status' => 'created'){
388
+ xml.lsbootLocalStorage('rn' => 'local-storage', 'status' => 'created')
389
+ }
390
+ }
391
+ }
392
+ }
393
+ }
394
+ end
400
395
 
401
- #Post
402
- begin
403
- RestClient.post(@url, create_pxe_boot_policy_XML, :content_type => 'text/xml').body
404
- rescue Exception => e
405
- raise "Error #{e}"
406
- end
396
+ #Create XML
397
+ create_pxe_boot_policy_XML = xml_builder.to_xml.to_s
398
+
399
+ #Post
400
+ begin
401
+ RestClient.post(@url, create_pxe_boot_policy_XML, :content_type => 'text/xml').body
402
+ rescue Exception => e
403
+ raise "Error #{e}"
404
+ end
407
405
 
408
406
  end
409
407
 
410
- def create_san_boot_policy(json)
408
+ def create_san_boot_policy(json)
411
409
 
412
- name = JSON.parse(json)['name']
413
- description = JSON.parse(json)['description']
414
- org = JSON.parse(json)['org']
415
- vnic_a = JSON.parse(json)['vnic_a']
416
- vnic_b = JSON.parse(json)['vnic_b']
417
- target_a_1 = JSON.parse(json)['target_a_1']
418
- target_a_2 = JSON.parse(json)['target_a_2']
419
- target_b_1 = JSON.parse(json)['target_b_1']
420
- target_b_2 = JSON.parse(json)['target_b_2']
410
+ name = JSON.parse(json)['name']
411
+ description = JSON.parse(json)['description']
412
+ org = JSON.parse(json)['org']
413
+ vnic_a = JSON.parse(json)['vnic_a']
414
+ vnic_b = JSON.parse(json)['vnic_b']
415
+ target_a_1 = JSON.parse(json)['target_a_1']
416
+ target_a_2 = JSON.parse(json)['target_a_2']
417
+ target_b_1 = JSON.parse(json)['target_b_1']
418
+ target_b_2 = JSON.parse(json)['target_b_2']
421
419
 
422
- xml_builder = Nokogiri::XML::Builder.new do |xml|
423
- xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
424
- xml.inConfigs{
425
- xml.pair('key' => "org-root/org-#{org}/boot-policy-#{name}"){
426
- xml.lsbootPolicy('descr' => "#{description}", 'dn' => "org-root/org-#{org}/boot-policy-#{name}", 'enforceVnicName' => 'no',
427
- 'name' => "#{name}", 'rebootOnUpdate' => 'no', 'status' => 'created'){
428
- xml.lsbootStorage('order' => '1', 'rn' => 'storage'){
429
- xml.lsbootSanImage('rn' => 'san-primary', 'status' => 'created', 'type' => 'primary', 'vnicName' => "#{vnic_a}"){
430
- xml.lsbootSanImagePath('lun' => '0', 'rn' => 'path-primary', 'status' => 'created', 'type' => 'primary', 'wwn' => "#{target_a_1}")
431
- xml.lsbootSanImagePath('lun' => '0', 'rn' => 'path-secondary', 'status' => 'created', 'type' => 'secondary', 'wwn' => "#{target_a_2}")
432
- }
433
- xml.lsbootSanImage('rn' => 'san-secondary', 'status' => 'created', 'type' => 'secondary', 'vnicName' => "#{vnic_b}"){
434
- xml.lsbootSanImagePath('lun' => '0', 'rn' => 'path-primary', 'status' => 'created', 'type' => 'primary', 'wwn' => "#{target_b_1}")
435
- xml.lsbootSanImagePath('lun' => '0', 'rn' => 'path-secondary', 'status' => 'created', 'type' => 'secondary', 'wwn' => "#{target_b_2}")
436
- }
437
- }
438
- }
439
- }
440
- }
441
- }
442
- end
420
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
421
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
422
+ xml.inConfigs{
423
+ xml.pair('key' => "org-root/org-#{org}/boot-policy-#{name}"){
424
+ xml.lsbootPolicy('descr' => "#{description}", 'dn' => "org-root/org-#{org}/boot-policy-#{name}", 'enforceVnicName' => 'no',
425
+ 'name' => "#{name}", 'rebootOnUpdate' => 'no', 'status' => 'created'){
426
+ xml.lsbootStorage('order' => '1', 'rn' => 'storage'){
427
+ xml.lsbootSanImage('rn' => 'san-primary', 'status' => 'created', 'type' => 'primary', 'vnicName' => "#{vnic_a}"){
428
+ xml.lsbootSanImagePath('lun' => '0', 'rn' => 'path-primary', 'status' => 'created', 'type' => 'primary', 'wwn' => "#{target_a_1}")
429
+ xml.lsbootSanImagePath('lun' => '0', 'rn' => 'path-secondary', 'status' => 'created', 'type' => 'secondary', 'wwn' => "#{target_a_2}")
430
+ }
431
+ xml.lsbootSanImage('rn' => 'san-secondary', 'status' => 'created', 'type' => 'secondary', 'vnicName' => "#{vnic_b}"){
432
+ xml.lsbootSanImagePath('lun' => '0', 'rn' => 'path-primary', 'status' => 'created', 'type' => 'primary', 'wwn' => "#{target_b_1}")
433
+ xml.lsbootSanImagePath('lun' => '0', 'rn' => 'path-secondary', 'status' => 'created', 'type' => 'secondary', 'wwn' => "#{target_b_2}")
434
+ }
435
+ }
436
+ }
437
+ }
438
+ }
439
+ }
440
+ end
443
441
 
444
- #Create XML
445
- create_san_boot_policy_XML = xml_builder.to_xml.to_s
442
+ #Create XML
443
+ create_san_boot_policy_XML = xml_builder.to_xml.to_s
446
444
 
447
- #Post
448
- begin
449
- RestClient.post(@url, create_san_boot_policy_XML, :content_type => 'text/xml').body
450
- rescue Exception => e
451
- raise "Error #{e}"
452
- end
445
+ #Post
446
+ begin
447
+ RestClient.post(@url, create_san_boot_policy_XML, :content_type => 'text/xml').body
448
+ rescue Exception => e
449
+ raise "Error #{e}"
450
+ end
453
451
 
454
- end
452
+ end
455
453
 
456
454
 
455
+ def create_host_firmware_package(json)
456
+
457
+ host_firmware_pkg_name = JSON.parse(json)['host_firmware_pkg_name']
458
+ hardware_model = JSON.parse(json)['hardware_model']
459
+ hardware_type = JSON.parse(json)['hardware_type']
460
+ hardware_vendor = JSON.parse(json)['hardware_vendor']
461
+ firmware_version = JSON.parse(json)['firmware_version']
462
+ org = JSON.parse(json)['org']
463
+
464
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
465
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
466
+ xml.inConfigs{
467
+ xml.pair('key' => "org-root/org-#{org}/fw-host-pack-#{host_firmware_pkg_name}"){
468
+ xml.firmwareComputeHostPack('descr' => '', 'dn' => "org-root/org-#{org}/fw-host-pack-#{host_firmware_pkg_name}",
469
+ 'ignoreCompCheck' => 'yes', 'mode' => 'staged', 'name' => "#{host_firmware_pkg_name}", 'stageSize' => '0',
470
+ 'status' => 'created', 'updateTrigger' => 'immediate'){
471
+ xml.firmwarePackItem('hwModel' => "#{hardware_model}", 'hwVendor' => "#{hardware_vendor}",
472
+ 'rn' => "pack-image-#{hardware_vendor}|#{hardware_model}|#{hardware_type}",
473
+ 'type' => "#{hardware_type}", 'version' => "#{firmware_version}")
474
+ }
475
+ }
476
+ }
477
+ }
478
+ end
479
+
480
+
481
+
482
+ #Create XML
483
+
484
+ create_host_firmware_packageXML = xml_builder.to_xml.to_s
485
+
486
+ #Post
487
+
488
+ begin
489
+ RestClient.post(@url, create_host_firmware_packageXML, :content_type => 'text/xml').body
490
+ rescue Exception => e
491
+ raise "Error #{e}"
492
+ end
493
+
494
+ end
495
+
457
496
  def create_management_ip_pool(json)
458
497
 
459
- start_ip = JSON.parse(json)['start_ip']
460
- end_ip = JSON.parse(json)['end_ip']
461
- subnet_mask = JSON.parse(json)['subnet_mask']
462
- gateway = JSON.parse(json)['gateway']
463
-
464
- xml_builder = Nokogiri::XML::Builder.new do |xml|
465
- xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
466
- xml.inConfigs{
467
- xml.pair('key' => "org-root/ip-pool-ext-mgmt/block-#{start_ip}-#{end_ip}"){
468
- xml.ippoolBlock('defGw' => "#{gateway}", 'dn' => "org-root/ip-pool-ext-mgmt/block-#{start_ip}-#{end_ip}",
469
- 'from' => "#{start_ip}", 'status' => 'created', 'subnet' => "#{subnet_mask}", 'to' => "#{end_ip}")
470
- }
471
- }
472
- }
473
- end
498
+ start_ip = JSON.parse(json)['start_ip']
499
+ end_ip = JSON.parse(json)['end_ip']
500
+ subnet_mask = JSON.parse(json)['subnet_mask']
501
+ gateway = JSON.parse(json)['gateway']
474
502
 
475
- #Create XML
476
- create_management_ip_pool_XML = xml_builder.to_xml.to_s
503
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
504
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
505
+ xml.inConfigs{
506
+ xml.pair('key' => "org-root/ip-pool-ext-mgmt/block-#{start_ip}-#{end_ip}"){
507
+ xml.ippoolBlock('defGw' => "#{gateway}", 'dn' => "org-root/ip-pool-ext-mgmt/block-#{start_ip}-#{end_ip}",
508
+ 'from' => "#{start_ip}", 'status' => 'created', 'subnet' => "#{subnet_mask}", 'to' => "#{end_ip}")
509
+ }
510
+ }
511
+ }
512
+ end
477
513
 
478
- #Post
479
- begin
480
- RestClient.post(@url, create_management_ip_pool_XML, :content_type => 'text/xml').body
481
- rescue Exception => e
482
- raise "Error #{e}"
483
- end
514
+ #Create XML
515
+ create_management_ip_pool_XML = xml_builder.to_xml.to_s
516
+
517
+ #Post
518
+ begin
519
+ RestClient.post(@url, create_management_ip_pool_XML, :content_type => 'text/xml').body
520
+ rescue Exception => e
521
+ raise "Error #{e}"
522
+ end
484
523
 
485
524
  end
486
525
 
487
526
  def create_vlan(json)
488
527
 
489
- vlan_id = JSON.parse(json)['vlan_id']
490
- vlan_name = JSON.parse(json)['vlan_name']
528
+ vlan_id = JSON.parse(json)['vlan_id']
529
+ vlan_name = JSON.parse(json)['vlan_name']
491
530
 
492
- xml_builder = Nokogiri::XML::Builder.new do |xml|
493
- xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
494
- xml.inConfigs{
495
- xml.pair('key' => "fabric/lan/net-#{vlan_name}"){
496
- xml.fabricVlan('defaultNet' => 'no', 'dn' => "fabric/lan/net-#{vlan_name}", 'id' => "#{vlan_id}",
497
- 'name' => "#{vlan_name}", 'status' => 'created')
498
- }
499
- }
500
- }
501
- end
531
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
532
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
533
+ xml.inConfigs{
534
+ xml.pair('key' => "fabric/lan/net-#{vlan_name}"){
535
+ xml.fabricVlan('defaultNet' => 'no', 'dn' => "fabric/lan/net-#{vlan_name}", 'id' => "#{vlan_id}",
536
+ 'name' => "#{vlan_name}", 'status' => 'created')
537
+ }
538
+ }
539
+ }
540
+ end
502
541
 
503
- #Create XML
504
- create_vlan_XML = xml_builder.to_xml.to_s
542
+ #Create XML
543
+ create_vlan_XML = xml_builder.to_xml.to_s
505
544
 
506
- #Post
507
- begin
508
- RestClient.post(@url, create_vlan_XML, :content_type => 'text/xml').body
509
- rescue Exception => e
510
- raise "Error #{e}"
511
- end
545
+ #Post
546
+ begin
547
+ RestClient.post(@url, create_vlan_XML, :content_type => 'text/xml').body
548
+ rescue Exception => e
549
+ raise "Error #{e}"
550
+ end
512
551
 
513
- end
552
+ end
514
553
 
515
554
  def create_mac_pool(json)
516
555
 
517
- mac_pool_name = JSON.parse(json)['mac_pool_name']
518
- mac_pool_start = JSON.parse(json)['mac_pool_start']
519
- #size = JSON.parse(json)['size']
520
- mac_pool_end = JSON.parse(json)['mac_pool_end']
521
- org = JSON.parse(json)['org']
522
-
523
- #
524
- # def get_mac_pool_suffix(size)
525
- # mac_pool_size = size
526
- # octets = mac_pool_start.split(':')
527
- # octets[-1] = (mac_pool_size - 1).to_s(base=16)
528
- # return mac_pool_end = octets.join(':')
529
- # end
530
- #
531
- # get_mac_pool_suffix(size)
532
-
533
- xml_builder = Nokogiri::XML::Builder.new do |xml|
534
- xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
535
- xml.inConfigs{
536
- xml.pair('key' => "org-root/org-#{org}/mac-pool-#{mac_pool_name}"){
537
- xml.macpoolPool('descr' => '', 'dn' => "org-root/org-#{org}/mac-pool-#{mac_pool_name}", 'name' => "#{mac_pool_name}",
538
- 'status' => 'created'){
539
- xml.macpoolBlock('from' => "#{mac_pool_start}", 'rn' => "block-#{mac_pool_start}-#{mac_pool_end}",
540
- 'status' => 'created', 'to' => "#{mac_pool_end}")
541
- }
542
- }
543
- }
544
- }
556
+ mac_pool_name = JSON.parse(json)['mac_pool_name']
557
+ mac_pool_start = JSON.parse(json)['mac_pool_start']
558
+ #size = JSON.parse(json)['size']
559
+ mac_pool_end = JSON.parse(json)['mac_pool_end']
560
+ org = JSON.parse(json)['org']
561
+
562
+ #
563
+ # def get_mac_pool_suffix(size)
564
+ # mac_pool_size = size
565
+ # octets = mac_pool_start.split(':')
566
+ # octets[-1] = (mac_pool_size - 1).to_s(base=16)
567
+ # return mac_pool_end = octets.join(':')
568
+ # end
569
+ #
570
+ # get_mac_pool_suffix(size)
571
+
572
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
573
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
574
+ xml.inConfigs{
575
+ xml.pair('key' => "org-root/org-#{org}/mac-pool-#{mac_pool_name}"){
576
+ xml.macpoolPool('descr' => '', 'dn' => "org-root/org-#{org}/mac-pool-#{mac_pool_name}", 'name' => "#{mac_pool_name}",
577
+ 'status' => 'created'){
578
+ xml.macpoolBlock('from' => "#{mac_pool_start}", 'rn' => "block-#{mac_pool_start}-#{mac_pool_end}",
579
+ 'status' => 'created', 'to' => "#{mac_pool_end}")
580
+ }
581
+ }
582
+ }
583
+ }
584
+
585
+ end
586
+
587
+ #Create XML
588
+ create_mac_pool_XML = xml_builder.to_xml.to_s
545
589
 
546
- end
547
-
548
- #Create XML
549
- create_mac_pool_XML = xml_builder.to_xml.to_s
550
-
551
- #Post
552
- begin
553
- RestClient.post(@url, create_mac_pool_XML, :content_type => 'text/xml').body
554
- rescue Exception => e
555
- raise "Error #{e}"
556
- end
590
+ #Post
591
+ begin
592
+ RestClient.post(@url, create_mac_pool_XML, :content_type => 'text/xml').body
593
+ rescue Exception => e
594
+ raise "Error #{e}"
595
+ end
557
596
 
558
597
  end
559
598
 
560
599
  def create_vnic_template(json)
561
600
 
562
- vnic_template_name = JSON.parse(json)['vnic_template_name']
563
- vnic_template_mac_pool = JSON.parse(json)['vnic_template_mac_pool']
564
- switch = JSON.parse(json)['switch']
565
- org = JSON.parse(json)['org']
566
- vnic_template_VLANs = JSON.parse(json)['vnic_template_VLANs'].split(',')
567
- vnic_template_native_VLAN = JSON.parse(json)['vnic_template_native_VLAN']
568
- vnic_template_mtu = JSON.parse(json)['vnic_template_mtu']
569
-
570
-
571
- xml_builder = Nokogiri::XML::Builder.new do |xml|
572
- xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
573
- xml.inConfigs{
574
- xml.pair('key' => "org-root/org-#{org}/lan-conn-templ-#{vnic_template_name}"){
575
- xml.vnicLanConnTempl('descr' => '', 'dn' => "org-root/org-#{org}/lan-conn-templ-#{vnic_template_name}",
576
- 'identPoolName' => "#{vnic_template_mac_pool}", 'mtu' => "#{vnic_template_mtu}", 'name' => "#{vnic_template_name}",
577
- 'nwCtrlPolicyName' => '', 'pinToGroupName' => '', 'qosPolicyName' => '', 'statsPolicyName' => '',
578
- 'status' => 'created', 'switchId' => "#{switch}", 'templType' => 'updating-template'){
579
- vnic_template_VLANs.each do |vlan|
580
- if vlan == vnic_template_native_VLAN
581
- xml.vnicEtherIf('defaultNet' => 'yes', 'name' => "#{vlan}", 'rn' => "if-#{vlan}")
582
- else
583
- xml.vnicEtherIf('defaultNet' => 'yes', 'name' => "#{vlan}", 'rn' => "if-#{vlan}")
584
- end
585
- end
586
- }
587
- }
588
- }
589
- }
590
- end
601
+ vnic_template_name = JSON.parse(json)['vnic_template_name']
602
+ vnic_template_mac_pool = JSON.parse(json)['vnic_template_mac_pool']
603
+ switch = JSON.parse(json)['switch']
604
+ org = JSON.parse(json)['org']
605
+ vnic_template_VLANs = JSON.parse(json)['vnic_template_VLANs'].split(',')
606
+ vnic_template_native_VLAN = JSON.parse(json)['vnic_template_native_VLAN']
607
+ vnic_template_mtu = JSON.parse(json)['vnic_template_mtu']
591
608
 
592
- #Create XML
593
- create_vnic_template_XML = xml_builder.to_xml.to_s
594
609
 
595
- #Post
596
- begin
597
- RestClient.post(@url, create_vnic_template_XML, :content_type => 'text/xml').body
598
- rescue Exception => e
599
- raise "Error #{e}"
600
- end
610
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
611
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
612
+ xml.inConfigs{
613
+ xml.pair('key' => "org-root/org-#{org}/lan-conn-templ-#{vnic_template_name}"){
614
+ xml.vnicLanConnTempl('descr' => '', 'dn' => "org-root/org-#{org}/lan-conn-templ-#{vnic_template_name}",
615
+ 'identPoolName' => "#{vnic_template_mac_pool}", 'mtu' => "#{vnic_template_mtu}", 'name' => "#{vnic_template_name}",
616
+ 'nwCtrlPolicyName' => '', 'pinToGroupName' => '', 'qosPolicyName' => '', 'statsPolicyName' => '',
617
+ 'status' => 'created', 'switchId' => "#{switch}", 'templType' => 'updating-template'){
618
+ vnic_template_VLANs.each do |vlan|
619
+ if vlan == vnic_template_native_VLAN
620
+ xml.vnicEtherIf('defaultNet' => 'yes', 'name' => "#{vlan}", 'rn' => "if-#{vlan}")
621
+ else
622
+ xml.vnicEtherIf('defaultNet' => 'yes', 'name' => "#{vlan}", 'rn' => "if-#{vlan}")
623
+ end
624
+ end
625
+ }
626
+ }
627
+ }
628
+ }
629
+ end
630
+
631
+ #Create XML
632
+ create_vnic_template_XML = xml_builder.to_xml.to_s
633
+
634
+ #Post
635
+ begin
636
+ RestClient.post(@url, create_vnic_template_XML, :content_type => 'text/xml').body
637
+ rescue Exception => e
638
+ raise "Error #{e}"
639
+ end
601
640
 
602
641
  end
603
642
 
604
643
 
605
644
  def create_vsan(json)
606
645
 
607
- vsan_id = JSON.parse(json)['vsan_id']
608
- vsan_fcoe_id = JSON.parse(json)['vsan_fcoe_id']
609
- vsan_name = JSON.parse(json)['vsan_name']
610
-
611
- xml_builder = Nokogiri::XML::Builder.new do |xml|
612
- xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
613
- xml.inConfigs{
614
- xml.pair('key' => 'fabric/san/'){
615
- xml.fabricVsan('defaultZoning' => 'disabled', 'dn' => 'fabric/san/', 'fcoeVlan' => "#{vsan_fcoe_id}",
616
- 'id' => "#{vsan_id}", 'name' => "#{vsan_name}", 'status' => 'created' )
617
- }
618
- }
619
- }
620
- end
646
+ vsan_id = JSON.parse(json)['vsan_id']
647
+ vsan_fcoe_id = JSON.parse(json)['vsan_fcoe_id']
648
+ vsan_name = JSON.parse(json)['vsan_name']
621
649
 
622
- #Create XML
623
- create_vsan_XML = xml_builder.to_xml.to_s
650
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
651
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
652
+ xml.inConfigs{
653
+ xml.pair('key' => 'fabric/san/'){
654
+ xml.fabricVsan('defaultZoning' => 'disabled', 'dn' => 'fabric/san/', 'fcoeVlan' => "#{vsan_fcoe_id}",
655
+ 'id' => "#{vsan_id}", 'name' => "#{vsan_name}", 'status' => 'created' )
656
+ }
657
+ }
658
+ }
659
+ end
624
660
 
625
- #Post
626
- begin
627
- RestClient.post(@url, create_vsan_XML, :content_type => 'text/xml').body
628
- rescue Exception => e
629
- raise "Error #{e}"
630
- end
661
+ #Create XML
662
+ create_vsan_XML = xml_builder.to_xml.to_s
631
663
 
632
- end
664
+ #Post
665
+ begin
666
+ RestClient.post(@url, create_vsan_XML, :content_type => 'text/xml').body
667
+ rescue Exception => e
668
+ raise "Error #{e}"
669
+ end
670
+
671
+ end
633
672
 
634
673
  def create_wwnn_pool(json)
635
674
 
@@ -668,7 +707,7 @@ class UCSProvision
668
707
  wwpn_name = JSON.parse(json)['wwpn_name']
669
708
  wwpn_from = JSON.parse(json)['wwpn_from']
670
709
  wwpn_to = JSON.parse(json)['wwpn_to']
671
- org = JSON.parse(json)['org']
710
+ org = JSON.parse(json)['org']
672
711
 
673
712
  xml_builder = Nokogiri::XML::Builder.new do |xml|
674
713
  xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
@@ -699,68 +738,68 @@ class UCSProvision
699
738
 
700
739
  def create_vhba_template(json)
701
740
 
702
- vbha_template_name = JSON.parse(json)['vbha_template_name']
703
- wwpn_pool = JSON.parse(json)['wwpn_pool']
704
- switch = JSON.parse(json)['switch']
705
- vsan_name = JSON.parse(json)['vsan_name']
706
- org = JSON.parse(json)['org']
707
-
708
- xml_builder = Nokogiri::XML::Builder.new do |xml|
709
- xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
710
- xml.inConfigs{
711
- xml.pair('key' => "org-root/org-#{org}/san-conn-templ-#{vbha_template_name}"){
712
- xml.vnicSanConnTempl('descr' => '', 'dn' => "org-root/org-#{org}/san-conn-templ-#{vbha_template_name}",
713
- 'identPoolName' => "#{wwpn_pool}", 'maxDataFieldSize' => '2048', 'name' => "#{vbha_template_name}",
714
- 'pinToGroupName' => '', 'qosPolicyName' => '', 'statsPolicyName' => 'default', 'status' => 'created',
715
- 'switchId' => "#{switch}", 'templType' => 'updating-template'){
716
- xml.vnicFcIf('name' => "#{vsan_name}", 'rn' => 'if-default')
717
- }
718
- }
719
- }
720
- }
721
- end
722
- #Create XML
723
- create_vhba_template_XML = xml_builder.to_xml.to_s
741
+ vbha_template_name = JSON.parse(json)['vbha_template_name']
742
+ wwpn_pool = JSON.parse(json)['wwpn_pool']
743
+ switch = JSON.parse(json)['switch']
744
+ vsan_name = JSON.parse(json)['vsan_name']
745
+ org = JSON.parse(json)['org']
724
746
 
725
- #Post
726
- begin
727
- RestClient.post(@url, create_vhba_template_XML, :content_type => 'text/xml').body
728
- rescue Exception => e
729
- raise "Error #{e}"
730
- end
747
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
748
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
749
+ xml.inConfigs{
750
+ xml.pair('key' => "org-root/org-#{org}/san-conn-templ-#{vbha_template_name}"){
751
+ xml.vnicSanConnTempl('descr' => '', 'dn' => "org-root/org-#{org}/san-conn-templ-#{vbha_template_name}",
752
+ 'identPoolName' => "#{wwpn_pool}", 'maxDataFieldSize' => '2048', 'name' => "#{vbha_template_name}",
753
+ 'pinToGroupName' => '', 'qosPolicyName' => '', 'statsPolicyName' => 'default', 'status' => 'created',
754
+ 'switchId' => "#{switch}", 'templType' => 'updating-template'){
755
+ xml.vnicFcIf('name' => "#{vsan_name}", 'rn' => 'if-default')
756
+ }
757
+ }
758
+ }
759
+ }
760
+ end
761
+ #Create XML
762
+ create_vhba_template_XML = xml_builder.to_xml.to_s
763
+
764
+ #Post
765
+ begin
766
+ RestClient.post(@url, create_vhba_template_XML, :content_type => 'text/xml').body
767
+ rescue Exception => e
768
+ raise "Error #{e}"
769
+ end
731
770
 
732
771
  end
733
772
 
734
773
  def create_uuid_pool(json)
735
774
 
736
- uuid_pool_name = JSON.parse(json)['uuid_pool_name']
737
- uuid_from = JSON.parse(json)['uuid_from']
738
- uuid_to = JSON.parse(json)['uuid_to']
739
- org = JSON.parse(json)['org']
740
-
741
- xml_builder = Nokogiri::XML::Builder.new do |xml|
742
- xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
743
- xml.inConfigs{
744
- xml.pair('key' => "org-root/org-#{org}/uuid-pool-#{uuid_pool_name}"){
745
- xml.uuidpoolPool('descr' => '', 'dn' => "org-root/org-#{org}/uuid-pool-#{uuid_pool_name}",
746
- 'name' => "#{uuid_pool_name}", 'prefix' => 'derived', 'status' => 'created'){
747
- xml.uuidpoolBlock('from' => "#{uuid_from}", 'rn' => "block-from-#{uuid_from}-to-#{uuid_to}",
748
- 'status' => 'created', 'to' => "#{uuid_to}")
749
- }
750
- }
751
- }
752
- }
753
- end
775
+ uuid_pool_name = JSON.parse(json)['uuid_pool_name']
776
+ uuid_from = JSON.parse(json)['uuid_from']
777
+ uuid_to = JSON.parse(json)['uuid_to']
778
+ org = JSON.parse(json)['org']
754
779
 
755
- #Create XML
756
- create_uuid_pool_XML = xml_builder.to_xml.to_s
780
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
781
+ xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
782
+ xml.inConfigs{
783
+ xml.pair('key' => "org-root/org-#{org}/uuid-pool-#{uuid_pool_name}"){
784
+ xml.uuidpoolPool('descr' => '', 'dn' => "org-root/org-#{org}/uuid-pool-#{uuid_pool_name}",
785
+ 'name' => "#{uuid_pool_name}", 'prefix' => 'derived', 'status' => 'created'){
786
+ xml.uuidpoolBlock('from' => "#{uuid_from}", 'rn' => "block-from-#{uuid_from}-to-#{uuid_to}",
787
+ 'status' => 'created', 'to' => "#{uuid_to}")
788
+ }
789
+ }
790
+ }
791
+ }
792
+ end
757
793
 
758
- #Post
759
- begin
760
- RestClient.post(@url, create_uuid_pool_XML, :content_type => 'text/xml').body
761
- rescue Exception => e
762
- raise "Error #{e}"
763
- end
794
+ #Create XML
795
+ create_uuid_pool_XML = xml_builder.to_xml.to_s
796
+
797
+ #Post
798
+ begin
799
+ RestClient.post(@url, create_uuid_pool_XML, :content_type => 'text/xml').body
800
+ rescue Exception => e
801
+ raise "Error #{e}"
802
+ end
764
803
 
765
804
  end
766
805
 
@@ -780,7 +819,7 @@ class UCSProvision
780
819
  service_profile_template_vhba_a_template = JSON.parse(json)['service_profile_template_vhba_a_template']
781
820
  service_profile_template_vhba_b = JSON.parse(json)['service_profile_template_vhba_b'].to_s
782
821
  service_profile_template_vhba_b_template = JSON.parse(json)['service_profile_template_vhba_b_template'].to_s
783
- org = JSON.parse(json)['org'].to_s
822
+ org = JSON.parse(json)['org'].to_s
784
823
 
785
824
  xml_builder = Nokogiri::XML::Builder.new do |xml|
786
825
  xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
@@ -838,10 +877,10 @@ class UCSProvision
838
877
 
839
878
  def create_service_profiles_from_template(json)
840
879
 
841
- service_profile_template_name = JSON.parse(json)['service_profile_template_name'].to_s
842
- org = JSON.parse(json)['org'].to_s
843
- service_profile_template_sp_prefix = JSON.parse(json)['service_profile_template_sp_prefix'].to_s
844
- service_profile_template_num_of_sps = JSON.parse(json)['service_profile_template_num_of_sps'].to_i
880
+ service_profile_template_name = JSON.parse(json)['service_profile_template_name'].to_s
881
+ org = JSON.parse(json)['org'].to_s
882
+ service_profile_template_sp_prefix = JSON.parse(json)['service_profile_template_sp_prefix'].to_s
883
+ service_profile_template_num_of_sps = JSON.parse(json)['service_profile_template_num_of_sps'].to_i
845
884
 
846
885
  xml_builder = Nokogiri::XML::Builder.new do |xml|
847
886
  xml.lsInstantiateNTemplate('dn' => "org-root/org-#{org}/ls-#{service_profile_template_name}",
@@ -882,7 +921,7 @@ class UCSProvision
882
921
  service_profile_vhba_a_template = JSON.parse(json)['service_profile_vhba_a_template'].to_s
883
922
  service_profile_vhba_b = JSON.parse(json)['service_profile_vhba_b'].to_s
884
923
  service_profile_vhba_b_template = JSON.parse(json)['service_profile_vhba_b_template'].to_s
885
- org = JSON.parse(json)['org'].to_s
924
+ org = JSON.parse(json)['org'].to_s
886
925
  service_profile_template_to_bind = JSON.parse(json)['service_profile_template_to_bind'].to_s
887
926
 
888
927
 
@@ -892,7 +931,7 @@ class UCSProvision
892
931
  xml.inConfigs{@service_profile_names.each do |service_profile_name|
893
932
  xml.pair('key' => "org-root/org-#{org}/ls-#{service_profile_name}"){
894
933
  xml.lsServer('agentPolicyName' => '', 'biosProfileName' => '', 'bootPolicyName' => "#{service_profile_boot_policy}",
895
- 'descr' => '', 'dn' => "org-root/org-#{service_profile_org}/ls-#{service_profile_name}",
934
+ 'descr' => '', 'dn' => "org-root/org-#{org}/ls-#{service_profile_name}",
896
935
  'dynamicConPolicyName' => '', 'extIPState' => 'none', 'hostFwPolicyName' => "#{service_profile_host_fw_policy}",
897
936
  'identPoolName' => "#{service_profile_uuid_pool}", 'localDiskPolicyName' => 'default', 'maintPolicyName' => 'default',
898
937
  'mgmtAccessPolicyName' => '', 'mgmtFwPolicyName' => "#{service_profile_mgmt_fw_policy}", 'name' => "#{service_profile_name}",