ucslib 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ucslib/{destroyer.rb → destroy.rb} +0 -0
- data/lib/ucslib/provision.rb +557 -518
- data/lib/ucslib/version.rb +1 -1
- data/lib/ucslib.rb +1 -1
- metadata +9 -9
data/lib/ucslib/provision.rb
CHANGED
@@ -17,265 +17,264 @@
|
|
17
17
|
|
18
18
|
class UCSProvision
|
19
19
|
|
20
|
-
|
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
|
-
|
26
|
+
end
|
27
27
|
|
28
|
-
|
28
|
+
def set_power_policy(json)
|
29
29
|
|
30
|
-
|
30
|
+
power_policy = "#{JSON.parse(json)['power_policy']}"
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
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
|
-
|
42
|
+
set_power_policy_XML = xml_builder.to_xml.to_s
|
45
43
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
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
|
-
|
51
|
+
end
|
53
52
|
|
54
53
|
def set_chassis_discovery_policy(json)
|
55
54
|
|
56
|
-
|
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
|
-
|
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
|
-
|
68
|
+
set_chassis_discovery_policy_XML = xml_builder.to_xml.to_s
|
72
69
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
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
|
-
|
78
|
+
end
|
80
79
|
|
81
80
|
|
82
81
|
def set_time_zone(json)
|
83
82
|
|
84
|
-
|
83
|
+
time_zone = "#{JSON.parse(json)['time_zone']}"
|
85
84
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
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
|
-
|
96
|
+
set_time_zone_XML = xml_builder.to_xml.to_s
|
98
97
|
|
99
|
-
|
98
|
+
#Post
|
100
99
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
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
|
-
|
110
|
+
ntp_server = "#{JSON.parse(json)['ntp_server']}"
|
112
111
|
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
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
|
-
|
122
|
+
set_ntp_XML = xml_builder.to_xml.to_s
|
124
123
|
|
125
|
-
|
124
|
+
#Post
|
126
125
|
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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
|
-
|
134
|
+
def create_server_port(json)
|
136
135
|
|
137
|
-
|
138
|
-
|
139
|
-
|
136
|
+
switch = JSON.parse(json)['switch']
|
137
|
+
port = JSON.parse(json)['port']
|
138
|
+
slot = JSON.parse(json)['slot']
|
140
139
|
|
141
140
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
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
|
-
|
157
|
-
|
155
|
+
#Create XML
|
156
|
+
create_server_port_XML = xml_builder.to_xml.to_s
|
158
157
|
|
159
|
-
|
158
|
+
#Post
|
160
159
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
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
|
-
|
166
|
+
end
|
168
167
|
|
169
168
|
def create_network_uplink_port(json)
|
170
169
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
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
|
-
|
191
|
-
|
189
|
+
#Create XML
|
190
|
+
create_network_uplink_XML = xml_builder.to_xml.to_s
|
192
191
|
|
193
|
-
|
192
|
+
#Post
|
194
193
|
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
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
|
-
|
207
|
-
|
208
|
-
|
205
|
+
switch = JSON.parse(json)['switch']
|
206
|
+
port = JSON.parse(json)['port']
|
207
|
+
slot = JSON.parse(json)['slot']
|
209
208
|
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
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
|
-
|
222
|
-
|
220
|
+
#Create XML
|
221
|
+
create_fc_uplink_XML = xml_builder.to_xml.to_s
|
223
222
|
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
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
|
-
|
236
|
-
|
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
|
-
|
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
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
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
|
-
|
273
|
+
end
|
275
274
|
|
276
275
|
def create_org(json)
|
277
276
|
|
278
|
-
|
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
|
-
|
307
|
-
|
304
|
+
local_disk_policy = JSON.parse(json)['local_disk_policy']
|
305
|
+
org = JSON.parse(json)['org']
|
308
306
|
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
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
|
-
|
322
|
-
|
319
|
+
#Create XML
|
320
|
+
set_local_disk_policy_XML = xml_builder.to_xml.to_s
|
323
321
|
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
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
|
-
|
336
|
-
|
337
|
-
|
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
|
-
|
357
|
-
|
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
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
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
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
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
|
-
|
399
|
-
|
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
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
405
|
-
|
406
|
-
|
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
|
-
|
408
|
+
def create_san_boot_policy(json)
|
411
409
|
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
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
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
441
|
-
|
442
|
-
|
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
|
-
|
445
|
-
|
442
|
+
#Create XML
|
443
|
+
create_san_boot_policy_XML = xml_builder.to_xml.to_s
|
446
444
|
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
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
|
-
|
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
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
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
|
-
|
476
|
-
|
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
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
|
483
|
-
|
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
|
-
|
490
|
-
|
528
|
+
vlan_id = JSON.parse(json)['vlan_id']
|
529
|
+
vlan_name = JSON.parse(json)['vlan_name']
|
491
530
|
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
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
|
-
|
504
|
-
|
542
|
+
#Create XML
|
543
|
+
create_vlan_XML = xml_builder.to_xml.to_s
|
505
544
|
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
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
|
-
|
552
|
+
end
|
514
553
|
|
515
554
|
def create_mac_pool(json)
|
516
555
|
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
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
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
551
|
-
|
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
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
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
|
-
|
596
|
-
|
597
|
-
|
598
|
-
|
599
|
-
|
600
|
-
|
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
|
-
|
608
|
-
|
609
|
-
|
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
|
-
|
623
|
-
|
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
|
-
|
626
|
-
|
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
|
-
|
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
|
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
|
-
|
703
|
-
|
704
|
-
|
705
|
-
|
706
|
-
|
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
|
-
|
726
|
-
|
727
|
-
|
728
|
-
|
729
|
-
|
730
|
-
|
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
|
-
|
737
|
-
|
738
|
-
|
739
|
-
|
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
|
-
|
756
|
-
|
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
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
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
|
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
|
842
|
-
org
|
843
|
-
service_profile_template_sp_prefix
|
844
|
-
service_profile_template_num_of_sps
|
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
|
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-#{
|
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}",
|