ucslib 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/ucslib/destroy.rb +0 -1
- data/lib/ucslib/inventory.rb +1 -0
- data/lib/ucslib/manage.rb +69 -0
- data/lib/ucslib/parser.rb +36 -0
- data/lib/ucslib/provision.rb +292 -169
- data/lib/ucslib/update.rb +67 -0
- data/lib/ucslib/version.rb +1 -1
- data/lib/ucslib.rb +3 -0
- metadata +27 -9
data/lib/ucslib/destroy.rb
CHANGED
data/lib/ucslib/inventory.rb
CHANGED
@@ -35,6 +35,7 @@ class UCSInventory
|
|
35
35
|
xml.classId("value" => "equipmentIOCard")
|
36
36
|
xml.classId("value" => "equipmentFanModule")
|
37
37
|
xml.classId("value" => "equipmentPsu")
|
38
|
+
xml.classId("value" => "networkElement")
|
38
39
|
xml.classId("value" => "processorUnit")
|
39
40
|
xml.classId("value" => "adaptorHostIf")
|
40
41
|
xml.classId("value" => "memoryArray")
|
@@ -0,0 +1,69 @@
|
|
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 UCSManage
|
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 associate_service_profile_template_to_server_pool(json)
|
29
|
+
|
30
|
+
service_profile_boot_policy = JSON.parse(json)['service_profile_boot_policy']
|
31
|
+
service_profile_host_fw_policy = JSON.parse(json)['service_profile_host_fw_policy']
|
32
|
+
service_profile_mgmt_fw_policy = JSON.parse(json)['service_profile_mgmt_fw_policy']
|
33
|
+
service_profile_uuid_pool = JSON.parse(json)['service_profile_uuid_pool']
|
34
|
+
service_profile_template_to_bind = JSON.parse(json)['service_profile_template_to_bind']
|
35
|
+
service_profile_server_pool = JSON.parse(json)['service_profile_server_pool']
|
36
|
+
org = JSON.parse(json)['org']
|
37
|
+
|
38
|
+
|
39
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
40
|
+
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
|
41
|
+
xml.inConfigs{
|
42
|
+
xml.pair('key' => "org-root/org-#{org}/ls-#{service_profile_template_to_bind}"){
|
43
|
+
xml.lsServer('agentPolicyName' => '', 'biosProfileName' => '', 'bootPolicyName' => "#{service_profile_boot_policy}",
|
44
|
+
'descr' => '', 'dn' => "org-root/org-#{org}/ls-#{service_profile_template_to_bind}",
|
45
|
+
'dynamicConPolicyName' => '', 'extIPState' => 'none', 'hostFwPolicyName' => "#{service_profile_host_fw_policy}",
|
46
|
+
'identPoolName' => "#{service_profile_uuid_pool}", 'localDiskPolicyName' => 'default', 'maintPolicyName' => 'default',
|
47
|
+
'mgmtAccessPolicyName' => '', 'mgmtFwPolicyName' => "#{service_profile_mgmt_fw_policy}", 'powerPolicyName' => 'default',
|
48
|
+
'scrubPolicyName' => '', 'solPolicyName' => 'default', 'srcTemplName' => '',
|
49
|
+
'statsPolicyName' => 'default', 'status' => 'created,modified', 'usrLbl' => '', 'uuid' => '0', 'vconProfileName' => ''){
|
50
|
+
xml.lsRequirement('name' => "#{service_profile_server_pool}", 'qualifier' => '', 'restrictMigration' => 'no', 'rn' => 'pn-req')
|
51
|
+
}
|
52
|
+
}
|
53
|
+
}
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
#Create XML
|
58
|
+
|
59
|
+
associate_service_profile_template_to_server_pool_xml = xml_builder.to_xml.to_s
|
60
|
+
|
61
|
+
#Post
|
62
|
+
begin
|
63
|
+
RestClient.post(@url, associate_service_profile_template_to_server_pool_xml, :content_type => 'text/xml').body
|
64
|
+
rescue Exception => e
|
65
|
+
raise "Error #{e}"
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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
|
+
require 'nokogiri'
|
19
|
+
|
20
|
+
class UCSParser
|
21
|
+
class Nokogiri::XML::Node
|
22
|
+
TYPENAMES = {1=>'element',2=>'attribute',3=>'text',4=>'cdata',8=>'comment'}
|
23
|
+
def to_hash
|
24
|
+
{kind:TYPENAMES[node_type],name:name}.tap do |h|
|
25
|
+
h.merge! nshref:namespace.href, nsprefix:namespace.prefix if namespace
|
26
|
+
h.merge! text:text
|
27
|
+
h.merge! attr:attribute_nodes.map(&:to_hash) if element?
|
28
|
+
h.merge! kids:children.map(&:to_hash) if element?
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
class Nokogiri::XML::Document
|
33
|
+
def to_hash; root.to_hash; end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
data/lib/ucslib/provision.rb
CHANGED
@@ -25,6 +25,34 @@ class UCSProvision
|
|
25
25
|
|
26
26
|
end
|
27
27
|
|
28
|
+
def set_org(json)
|
29
|
+
|
30
|
+
org = JSON.parse(json)['org']
|
31
|
+
description = JSON.parse(json)['description']
|
32
|
+
|
33
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
34
|
+
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true') {
|
35
|
+
xml.inConfigs{
|
36
|
+
xml.pair('key' => "org-root/org-#{org}") {
|
37
|
+
xml.orgOrg('descr' => "#{description}", 'dn' => "org-root/org-#{org}", 'name' => "#{org}", 'status' => 'created')
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
end
|
42
|
+
|
43
|
+
#Create xml
|
44
|
+
set_org_xml= xml_builder.to_xml.to_s
|
45
|
+
|
46
|
+
#Post
|
47
|
+
|
48
|
+
begin
|
49
|
+
RestClient.post(@url, set_org_xml, :content_type => 'text/xml').body
|
50
|
+
rescue Exception => e
|
51
|
+
raise "Error #{e}"
|
52
|
+
end
|
53
|
+
|
54
|
+
end
|
55
|
+
|
28
56
|
def set_power_policy(json)
|
29
57
|
|
30
58
|
power_policy = "#{JSON.parse(json)['power_policy']}"
|
@@ -39,11 +67,11 @@ class UCSProvision
|
|
39
67
|
}
|
40
68
|
end
|
41
69
|
|
42
|
-
|
70
|
+
set_power_policy_xml = xml_builder.to_xml.to_s
|
43
71
|
|
44
72
|
#Post
|
45
73
|
begin
|
46
|
-
RestClient.post(@url,
|
74
|
+
RestClient.post(@url, set_power_policy_xml, :content_type => 'text/xml').body
|
47
75
|
rescue Exception => e
|
48
76
|
raise "Error #{e}"
|
49
77
|
end
|
@@ -65,12 +93,12 @@ class UCSProvision
|
|
65
93
|
}
|
66
94
|
end
|
67
95
|
|
68
|
-
|
96
|
+
set_chassis_discovery_policy_xml = xml_builder.to_xml.to_s
|
69
97
|
|
70
98
|
#Post
|
71
99
|
|
72
100
|
begin
|
73
|
-
RestClient.post(@url,
|
101
|
+
RestClient.post(@url, set_chassis_discovery_policy_xml, :content_type => 'text/xml').body
|
74
102
|
rescue Exception => e
|
75
103
|
raise "Error #{e}"
|
76
104
|
end
|
@@ -93,19 +121,19 @@ class UCSProvision
|
|
93
121
|
}
|
94
122
|
end
|
95
123
|
|
96
|
-
|
124
|
+
set_time_zone_xml = xml_builder.to_xml.to_s
|
97
125
|
|
98
126
|
#Post
|
99
127
|
|
100
128
|
begin
|
101
|
-
RestClient.post(@url,
|
129
|
+
RestClient.post(@url, set_time_zone_xml, :content_type => 'text/xml').body
|
102
130
|
rescue Exception => e
|
103
131
|
raise "Error #{e}"
|
104
132
|
end
|
105
133
|
|
106
134
|
end
|
107
135
|
|
108
|
-
def
|
136
|
+
def set_ntp_server(json)
|
109
137
|
|
110
138
|
ntp_server = "#{JSON.parse(json)['ntp_server']}"
|
111
139
|
|
@@ -119,19 +147,50 @@ class UCSProvision
|
|
119
147
|
}
|
120
148
|
end
|
121
149
|
|
122
|
-
|
150
|
+
set_ntp_xml = xml_builder.to_xml.to_s
|
123
151
|
|
124
152
|
#Post
|
125
153
|
|
126
154
|
begin
|
127
|
-
RestClient.post(@url,
|
155
|
+
RestClient.post(@url, set_ntp_xml, :content_type => 'text/xml').body
|
128
156
|
rescue Exception => e
|
129
157
|
raise "Error #{e}"
|
130
158
|
end
|
131
159
|
|
132
160
|
end
|
133
161
|
|
134
|
-
|
162
|
+
|
163
|
+
def set_local_disk_policy(json)
|
164
|
+
|
165
|
+
local_disk_policy = JSON.parse(json)['local_disk_policy']
|
166
|
+
org = JSON.parse(json)['org']
|
167
|
+
|
168
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
169
|
+
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
|
170
|
+
xml.inConfigs{
|
171
|
+
xml.pair('key' => "org-root/org-#{org}/local-disk-config-#{org}-localdisk"){
|
172
|
+
xml.storageLocalDiskConfigPolicy('descr' => '', 'dn' => "org-root/org-#{org}/local-disk-config-#{org}-localdisk",
|
173
|
+
'mode' => "#{local_disk_policy}", 'name' => "#{org}-localdisk", 'protectConfig' => 'yes',
|
174
|
+
'status' => 'created')
|
175
|
+
}
|
176
|
+
}
|
177
|
+
}
|
178
|
+
end
|
179
|
+
|
180
|
+
#Create xml
|
181
|
+
set_local_disk_policy_xml = xml_builder.to_xml.to_s
|
182
|
+
|
183
|
+
#Post
|
184
|
+
begin
|
185
|
+
RestClient.post(@url, set_local_disk_policy_xml, :content_type => 'text/xml').body
|
186
|
+
rescue Exception => e
|
187
|
+
raise "Error #{e}"
|
188
|
+
end
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
|
193
|
+
def set_server_port(json)
|
135
194
|
|
136
195
|
switch = JSON.parse(json)['switch']
|
137
196
|
port = JSON.parse(json)['port']
|
@@ -152,20 +211,20 @@ class UCSProvision
|
|
152
211
|
}
|
153
212
|
end
|
154
213
|
|
155
|
-
#Create
|
156
|
-
|
214
|
+
#Create xml
|
215
|
+
set_server_port_xml = xml_builder.to_xml.to_s
|
157
216
|
|
158
217
|
#Post
|
159
218
|
|
160
219
|
begin
|
161
|
-
RestClient.post(@url,
|
220
|
+
RestClient.post(@url, set_server_port_xml, :content_type => 'text/xml').body
|
162
221
|
rescue Exception => e
|
163
222
|
raise "Error #{e}"
|
164
223
|
end
|
165
224
|
|
166
225
|
end
|
167
226
|
|
168
|
-
def
|
227
|
+
def set_network_uplink_port(json)
|
169
228
|
|
170
229
|
switch = JSON.parse(json)['switch']
|
171
230
|
port = JSON.parse(json)['port']
|
@@ -186,13 +245,13 @@ class UCSProvision
|
|
186
245
|
}
|
187
246
|
end
|
188
247
|
|
189
|
-
#Create
|
190
|
-
|
248
|
+
#Create xml
|
249
|
+
set_network_uplink_xml = xml_builder.to_xml.to_s
|
191
250
|
|
192
251
|
#Post
|
193
252
|
|
194
253
|
begin
|
195
|
-
RestClient.post(@url,
|
254
|
+
RestClient.post(@url, set_network_uplink_xml, :content_type => 'text/xml').body
|
196
255
|
rescue Exception => e
|
197
256
|
raise "Error #{e}"
|
198
257
|
end
|
@@ -200,7 +259,7 @@ class UCSProvision
|
|
200
259
|
end
|
201
260
|
|
202
261
|
|
203
|
-
def
|
262
|
+
def set_fc_uplink_port(json)
|
204
263
|
|
205
264
|
switch = JSON.parse(json)['switch']
|
206
265
|
port = JSON.parse(json)['port']
|
@@ -217,12 +276,12 @@ class UCSProvision
|
|
217
276
|
}
|
218
277
|
end
|
219
278
|
|
220
|
-
#Create
|
221
|
-
|
279
|
+
#Create xml
|
280
|
+
set_fc_uplink_xml = xml_builder.to_xml.to_s
|
222
281
|
|
223
282
|
#Post
|
224
283
|
begin
|
225
|
-
RestClient.post(@url,
|
284
|
+
RestClient.post(@url, set_fc_uplink_xml, :content_type => 'text/xml').body
|
226
285
|
rescue Exception => e
|
227
286
|
raise "Error #{e}"
|
228
287
|
end
|
@@ -230,7 +289,7 @@ class UCSProvision
|
|
230
289
|
end
|
231
290
|
|
232
291
|
|
233
|
-
def
|
292
|
+
def set_port_channel(json)
|
234
293
|
#Parse uplink modules on Expansion Module 2. Minimum 2 ports are required for creating a port channel.
|
235
294
|
#As of this implementation, it is assumed that Northboutn uplinks are created using the Expansion Module and not the fixed module
|
236
295
|
|
@@ -241,7 +300,7 @@ class UCSProvision
|
|
241
300
|
name = JSON.parse(json)['name']
|
242
301
|
|
243
302
|
|
244
|
-
#Create
|
303
|
+
#Create xml
|
245
304
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
246
305
|
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
|
247
306
|
xml.inConfigs{
|
@@ -260,75 +319,19 @@ class UCSProvision
|
|
260
319
|
}
|
261
320
|
end
|
262
321
|
|
263
|
-
#Create
|
264
|
-
|
322
|
+
#Create xml
|
323
|
+
set_port_channel_xml = xml_builder.to_xml.to_s
|
265
324
|
|
266
325
|
#Post
|
267
326
|
begin
|
268
|
-
RestClient.post(@url,
|
327
|
+
RestClient.post(@url, set_port_channel_xml, :content_type => 'text/xml').body
|
269
328
|
rescue Exception => e
|
270
329
|
raise "Error #{e}"
|
271
330
|
end
|
272
331
|
|
273
332
|
end
|
274
333
|
|
275
|
-
def
|
276
|
-
|
277
|
-
org = JSON.parse(json)['org']
|
278
|
-
|
279
|
-
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
280
|
-
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true') {
|
281
|
-
xml.inConfigs{
|
282
|
-
xml.pair('key' => "org-root/org-#{org}") {
|
283
|
-
xml.orgOrg('descr' => "#{org} org", 'dn' => "org-root/org-#{org}", 'name' => "#{org}", 'status' => 'created')
|
284
|
-
}
|
285
|
-
}
|
286
|
-
}
|
287
|
-
end
|
288
|
-
|
289
|
-
#Create XML
|
290
|
-
create_org_XML= xml_builder.to_xml.to_s
|
291
|
-
|
292
|
-
#Post
|
293
|
-
|
294
|
-
begin
|
295
|
-
RestClient.post(@url, create_org_XML, :content_type => 'text/xml').body
|
296
|
-
rescue Exception => e
|
297
|
-
raise "Error #{e}"
|
298
|
-
end
|
299
|
-
|
300
|
-
end
|
301
|
-
|
302
|
-
def set_local_disk_policy(json)
|
303
|
-
|
304
|
-
local_disk_policy = JSON.parse(json)['local_disk_policy']
|
305
|
-
org = JSON.parse(json)['org']
|
306
|
-
|
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
|
318
|
-
|
319
|
-
#Create XML
|
320
|
-
set_local_disk_policy_XML = xml_builder.to_xml.to_s
|
321
|
-
|
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
|
328
|
-
|
329
|
-
end
|
330
|
-
|
331
|
-
def create_local_boot_policy(json)
|
334
|
+
def set_local_boot_policy(json)
|
332
335
|
|
333
336
|
name = JSON.parse(json)['name']
|
334
337
|
description = JSON.parse(json)['description']
|
@@ -351,19 +354,19 @@ class UCSProvision
|
|
351
354
|
}
|
352
355
|
end
|
353
356
|
|
354
|
-
#Create
|
355
|
-
|
357
|
+
#Create xml
|
358
|
+
set_local_boot_policy_xml = xml_builder.to_xml.to_s
|
356
359
|
|
357
360
|
#Post
|
358
361
|
begin
|
359
|
-
RestClient.post(@url,
|
362
|
+
RestClient.post(@url, set_local_boot_policy_xml, :content_type => 'text/xml').body
|
360
363
|
rescue Exception => e
|
361
364
|
raise "Error #{e}"
|
362
365
|
end
|
363
366
|
|
364
367
|
end
|
365
368
|
|
366
|
-
def
|
369
|
+
def set_pxe_boot_policy(json)
|
367
370
|
|
368
371
|
name = JSON.parse(json)['name']
|
369
372
|
description = JSON.parse(json)['description']
|
@@ -393,25 +396,25 @@ class UCSProvision
|
|
393
396
|
}
|
394
397
|
end
|
395
398
|
|
396
|
-
#Create
|
397
|
-
|
399
|
+
#Create xml
|
400
|
+
set_pxe_boot_policy_xml = xml_builder.to_xml.to_s
|
398
401
|
|
399
402
|
#Post
|
400
403
|
begin
|
401
|
-
RestClient.post(@url,
|
404
|
+
RestClient.post(@url, set_pxe_boot_policy_xml, :content_type => 'text/xml').body
|
402
405
|
rescue Exception => e
|
403
406
|
raise "Error #{e}"
|
404
407
|
end
|
405
408
|
|
406
409
|
end
|
407
410
|
|
408
|
-
def
|
411
|
+
def set_san_boot_policy(json)
|
409
412
|
|
410
413
|
name = JSON.parse(json)['name']
|
411
414
|
description = JSON.parse(json)['description']
|
412
415
|
org = JSON.parse(json)['org']
|
413
|
-
vnic_a = JSON.parse(json)['
|
414
|
-
vnic_b = JSON.parse(json)['
|
416
|
+
vnic_a = JSON.parse(json)['vhba_a']
|
417
|
+
vnic_b = JSON.parse(json)['vhba_b']
|
415
418
|
target_a_1 = JSON.parse(json)['target_a_1']
|
416
419
|
target_a_2 = JSON.parse(json)['target_a_2']
|
417
420
|
target_b_1 = JSON.parse(json)['target_b_1']
|
@@ -439,12 +442,12 @@ class UCSProvision
|
|
439
442
|
}
|
440
443
|
end
|
441
444
|
|
442
|
-
#Create
|
443
|
-
|
445
|
+
#Create xml
|
446
|
+
set_san_boot_policy_xml = xml_builder.to_xml.to_s
|
444
447
|
|
445
448
|
#Post
|
446
449
|
begin
|
447
|
-
RestClient.post(@url,
|
450
|
+
RestClient.post(@url, set_san_boot_policy_xml, :content_type => 'text/xml').body
|
448
451
|
rescue Exception => e
|
449
452
|
raise "Error #{e}"
|
450
453
|
end
|
@@ -452,21 +455,23 @@ class UCSProvision
|
|
452
455
|
end
|
453
456
|
|
454
457
|
|
455
|
-
def
|
458
|
+
def set_mgmt_firmware_package(json)
|
459
|
+
|
460
|
+
mgmt_firmware_pkg_name = JSON.parse(json)['mgmt_firmware_pkg_name']
|
461
|
+
mgmt_firmware_pkg_description = JSON.parse(json)['mgmt_firmware_pkg_description']
|
462
|
+
hardware_model = JSON.parse(json)['hardware_model'].to_s
|
463
|
+
hardware_type = JSON.parse(json)['hardware_type']
|
464
|
+
hardware_vendor = JSON.parse(json)['hardware_vendor'].to_s
|
465
|
+
firmware_version = JSON.parse(json)['firmware_version'].to_s
|
466
|
+
org = JSON.parse(json)['org']
|
467
|
+
|
456
468
|
|
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
469
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
465
470
|
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
|
466
471
|
xml.inConfigs{
|
467
|
-
xml.pair('key' => "org-root/org-#{org}/fw-
|
468
|
-
xml.
|
469
|
-
'ignoreCompCheck' => 'yes', 'mode' => 'staged', 'name' => "#{
|
472
|
+
xml.pair('key' => "org-root/org-#{org}/fw-mgmt-pack-#{mgmt_firmware_pkg_name}"){
|
473
|
+
xml.firmwareComputeMgmtPack('descr' => "#{mgmt_firmware_pkg_description}", 'dn' => "org-root/org-#{org}/fw-mgmt-pack-#{mgmt_firmware_pkg_name}",
|
474
|
+
'ignoreCompCheck' => 'yes', 'mode' => 'staged', 'name' => "#{mgmt_firmware_pkg_name}", 'stageSize' => '0',
|
470
475
|
'status' => 'created', 'updateTrigger' => 'immediate'){
|
471
476
|
xml.firmwarePackItem('hwModel' => "#{hardware_model}", 'hwVendor' => "#{hardware_vendor}",
|
472
477
|
'rn' => "pack-image-#{hardware_vendor}|#{hardware_model}|#{hardware_type}",
|
@@ -478,22 +483,84 @@ class UCSProvision
|
|
478
483
|
end
|
479
484
|
|
480
485
|
|
486
|
+
#Create xml
|
481
487
|
|
482
|
-
|
488
|
+
set_mgmt_firmware_packagexml = xml_builder.to_xml.to_s
|
483
489
|
|
484
|
-
|
490
|
+
#Post
|
491
|
+
|
492
|
+
begin
|
493
|
+
RestClient.post(@url, set_mgmt_firmware_packagexml, :content_type => 'text/xml').body
|
494
|
+
rescue Exception => e
|
495
|
+
raise "Error #{e}"
|
496
|
+
end
|
497
|
+
|
498
|
+
end
|
499
|
+
|
500
|
+
def set_host_firmware_package(json)
|
501
|
+
|
502
|
+
host_firmware_pkg_name = JSON.parse(json)['host_firmware_pkg_name']
|
503
|
+
host_firmware_pkg_description = JSON.parse(json)['host_firmware_pkg_description']
|
504
|
+
hardware_model = JSON.parse(json)['hardware_model'].to_s
|
505
|
+
hardware_type = JSON.parse(json)['hardware_type']
|
506
|
+
hardware_vendor = JSON.parse(json)['hardware_vendor'].to_s
|
507
|
+
firmware_version = JSON.parse(json)['firmware_version'].to_s
|
508
|
+
org = JSON.parse(json)['org']
|
509
|
+
flag = JSON.parse(json)['flag']
|
510
|
+
|
511
|
+
unless flag == 'update'
|
512
|
+
|
513
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
514
|
+
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
|
515
|
+
xml.inConfigs{
|
516
|
+
xml.pair('key' => "org-root/org-#{org}/fw-host-pack-#{host_firmware_pkg_name}"){
|
517
|
+
xml.firmwareComputeHostPack('descr' => "#{host_firmware_pkg_description}", 'dn' => "org-root/org-#{org}/fw-host-pack-#{host_firmware_pkg_name}",
|
518
|
+
'ignoreCompCheck' => 'yes', 'mode' => 'staged', 'name' => "#{host_firmware_pkg_name}", 'stageSize' => '0',
|
519
|
+
'status' => 'created', 'updateTrigger' => 'immediate'){
|
520
|
+
xml.firmwarePackItem('hwModel' => "#{hardware_model}", 'hwVendor' => "#{hardware_vendor}",
|
521
|
+
'rn' => "pack-image-#{hardware_vendor}|#{hardware_model}|#{hardware_type}",
|
522
|
+
'type' => "#{hardware_type}", 'version' => "#{firmware_version}")
|
523
|
+
}
|
524
|
+
}
|
525
|
+
}
|
526
|
+
}
|
527
|
+
end
|
528
|
+
|
529
|
+
else
|
530
|
+
|
531
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
532
|
+
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
|
533
|
+
xml.inConfigs{
|
534
|
+
xml.pair('key' => "org-root/org-#{org}/fw-host-pack-#{host_firmware_pkg_name}"){
|
535
|
+
xml.firmwareComputeHostPack('descr' => "#{host_firmware_pkg_description}", 'dn' => "org-root/org-#{org}/fw-host-pack-#{host_firmware_pkg_name}",
|
536
|
+
'ignoreCompCheck' => 'yes', 'mode' => 'staged', 'stageSize' => '0', 'updateTrigger' => 'immediate'){
|
537
|
+
xml.firmwarePackItem('hwModel' => "#{hardware_model}", 'hwVendor' => "#{hardware_vendor}",
|
538
|
+
'rn' => "pack-image-#{hardware_vendor}|#{hardware_model}|#{hardware_type}",
|
539
|
+
'type' => "#{hardware_type}", 'version' => "#{firmware_version}")
|
540
|
+
}
|
541
|
+
}
|
542
|
+
}
|
543
|
+
}
|
544
|
+
end
|
545
|
+
|
546
|
+
end
|
547
|
+
|
548
|
+
|
549
|
+
#Create xml
|
550
|
+
|
551
|
+
set_host_firmware_packagexml = xml_builder.to_xml.to_s
|
485
552
|
|
486
553
|
#Post
|
487
554
|
|
488
555
|
begin
|
489
|
-
RestClient.post(@url,
|
556
|
+
RestClient.post(@url, set_host_firmware_packagexml, :content_type => 'text/xml').body
|
490
557
|
rescue Exception => e
|
491
558
|
raise "Error #{e}"
|
492
559
|
end
|
493
560
|
|
494
561
|
end
|
495
562
|
|
496
|
-
def
|
563
|
+
def set_management_ip_pool(json)
|
497
564
|
|
498
565
|
start_ip = JSON.parse(json)['start_ip']
|
499
566
|
end_ip = JSON.parse(json)['end_ip']
|
@@ -511,19 +578,19 @@ class UCSProvision
|
|
511
578
|
}
|
512
579
|
end
|
513
580
|
|
514
|
-
#Create
|
515
|
-
|
581
|
+
#Create xml
|
582
|
+
set_management_ip_pool_xml = xml_builder.to_xml.to_s
|
516
583
|
|
517
584
|
#Post
|
518
585
|
begin
|
519
|
-
RestClient.post(@url,
|
586
|
+
RestClient.post(@url, set_management_ip_pool_xml, :content_type => 'text/xml').body
|
520
587
|
rescue Exception => e
|
521
588
|
raise "Error #{e}"
|
522
589
|
end
|
523
590
|
|
524
591
|
end
|
525
592
|
|
526
|
-
def
|
593
|
+
def set_vlan(json)
|
527
594
|
|
528
595
|
vlan_id = JSON.parse(json)['vlan_id']
|
529
596
|
vlan_name = JSON.parse(json)['vlan_name']
|
@@ -539,19 +606,19 @@ class UCSProvision
|
|
539
606
|
}
|
540
607
|
end
|
541
608
|
|
542
|
-
#Create
|
543
|
-
|
609
|
+
#Create xml
|
610
|
+
set_vlan_xml = xml_builder.to_xml.to_s
|
544
611
|
|
545
612
|
#Post
|
546
613
|
begin
|
547
|
-
RestClient.post(@url,
|
614
|
+
RestClient.post(@url, set_vlan_xml, :content_type => 'text/xml').body
|
548
615
|
rescue Exception => e
|
549
616
|
raise "Error #{e}"
|
550
617
|
end
|
551
618
|
|
552
619
|
end
|
553
620
|
|
554
|
-
def
|
621
|
+
def set_mac_pool(json)
|
555
622
|
|
556
623
|
mac_pool_name = JSON.parse(json)['mac_pool_name']
|
557
624
|
mac_pool_start = JSON.parse(json)['mac_pool_start']
|
@@ -584,19 +651,19 @@ class UCSProvision
|
|
584
651
|
|
585
652
|
end
|
586
653
|
|
587
|
-
#Create
|
588
|
-
|
654
|
+
#Create xml
|
655
|
+
set_mac_pool_xml = xml_builder.to_xml.to_s
|
589
656
|
|
590
657
|
#Post
|
591
658
|
begin
|
592
|
-
RestClient.post(@url,
|
659
|
+
RestClient.post(@url, set_mac_pool_xml, :content_type => 'text/xml').body
|
593
660
|
rescue Exception => e
|
594
661
|
raise "Error #{e}"
|
595
662
|
end
|
596
663
|
|
597
664
|
end
|
598
665
|
|
599
|
-
def
|
666
|
+
def set_vnic_template(json)
|
600
667
|
|
601
668
|
vnic_template_name = JSON.parse(json)['vnic_template_name']
|
602
669
|
vnic_template_mac_pool = JSON.parse(json)['vnic_template_mac_pool']
|
@@ -628,12 +695,12 @@ class UCSProvision
|
|
628
695
|
}
|
629
696
|
end
|
630
697
|
|
631
|
-
#Create
|
632
|
-
|
698
|
+
#Create xml
|
699
|
+
set_vnic_template_xml = xml_builder.to_xml.to_s
|
633
700
|
|
634
701
|
#Post
|
635
702
|
begin
|
636
|
-
RestClient.post(@url,
|
703
|
+
RestClient.post(@url, set_vnic_template_xml, :content_type => 'text/xml').body
|
637
704
|
rescue Exception => e
|
638
705
|
raise "Error #{e}"
|
639
706
|
end
|
@@ -641,7 +708,7 @@ class UCSProvision
|
|
641
708
|
end
|
642
709
|
|
643
710
|
|
644
|
-
def
|
711
|
+
def set_vsan(json)
|
645
712
|
|
646
713
|
vsan_id = JSON.parse(json)['vsan_id']
|
647
714
|
vsan_fcoe_id = JSON.parse(json)['vsan_fcoe_id']
|
@@ -658,19 +725,19 @@ class UCSProvision
|
|
658
725
|
}
|
659
726
|
end
|
660
727
|
|
661
|
-
#Create
|
662
|
-
|
728
|
+
#Create xml
|
729
|
+
set_vsan_xml = xml_builder.to_xml.to_s
|
663
730
|
|
664
731
|
#Post
|
665
732
|
begin
|
666
|
-
RestClient.post(@url,
|
733
|
+
RestClient.post(@url, set_vsan_xml, :content_type => 'text/xml').body
|
667
734
|
rescue Exception => e
|
668
735
|
raise "Error #{e}"
|
669
736
|
end
|
670
737
|
|
671
738
|
end
|
672
739
|
|
673
|
-
def
|
740
|
+
def set_wwnn_pool(json)
|
674
741
|
|
675
742
|
wwnn_name = JSON.parse(json)['wwnn_name']
|
676
743
|
wwnn_from = JSON.parse(json)['wwnn_from']
|
@@ -690,19 +757,19 @@ class UCSProvision
|
|
690
757
|
}
|
691
758
|
}
|
692
759
|
end
|
693
|
-
#Create
|
694
|
-
|
760
|
+
#Create xml
|
761
|
+
set_wwnn_pool_xml = xml_builder.to_xml.to_s
|
695
762
|
|
696
763
|
#Post
|
697
764
|
begin
|
698
|
-
RestClient.post(@url,
|
765
|
+
RestClient.post(@url, set_wwnn_pool_xml, :content_type => 'text/xml').body
|
699
766
|
rescue Exception => e
|
700
767
|
raise "Error #{e}"
|
701
768
|
end
|
702
769
|
|
703
770
|
end
|
704
771
|
|
705
|
-
def
|
772
|
+
def set_wwpn_pool(json)
|
706
773
|
|
707
774
|
wwpn_name = JSON.parse(json)['wwpn_name']
|
708
775
|
wwpn_from = JSON.parse(json)['wwpn_from']
|
@@ -724,32 +791,33 @@ class UCSProvision
|
|
724
791
|
end
|
725
792
|
|
726
793
|
|
727
|
-
#Create
|
728
|
-
|
794
|
+
#Create xml
|
795
|
+
set_wwpn_pool_xml = xml_builder.to_xml.to_s
|
729
796
|
|
730
797
|
#Post
|
731
798
|
begin
|
732
|
-
RestClient.post(@url,
|
799
|
+
RestClient.post(@url, set_wwpn_pool_xml, :content_type => 'text/xml').body
|
733
800
|
rescue Exception => e
|
734
801
|
raise "Error #{e}"
|
735
802
|
end
|
736
803
|
|
737
804
|
end
|
738
805
|
|
739
|
-
def
|
806
|
+
def set_vhba_template(json)
|
740
807
|
|
741
|
-
|
808
|
+
vhba_template_name = JSON.parse(json)['vhba_template_name']
|
742
809
|
wwpn_pool = JSON.parse(json)['wwpn_pool']
|
743
810
|
switch = JSON.parse(json)['switch']
|
744
811
|
vsan_name = JSON.parse(json)['vsan_name']
|
745
812
|
org = JSON.parse(json)['org']
|
813
|
+
description = JSON.parse(json)['description']
|
746
814
|
|
747
815
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
748
816
|
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
|
749
817
|
xml.inConfigs{
|
750
|
-
xml.pair('key' => "org-root/org-#{org}/san-conn-templ-#{
|
751
|
-
xml.vnicSanConnTempl('descr' =>
|
752
|
-
'identPoolName' => "#{wwpn_pool}", 'maxDataFieldSize' => '2048', 'name' => "#{
|
818
|
+
xml.pair('key' => "org-root/org-#{org}/san-conn-templ-#{vhba_template_name}"){
|
819
|
+
xml.vnicSanConnTempl('descr' => "#{description}", 'dn' => "org-root/org-#{org}/san-conn-templ-#{vhba_template_name}",
|
820
|
+
'identPoolName' => "#{wwpn_pool}", 'maxDataFieldSize' => '2048', 'name' => "#{vhba_template_name}",
|
753
821
|
'pinToGroupName' => '', 'qosPolicyName' => '', 'statsPolicyName' => 'default', 'status' => 'created',
|
754
822
|
'switchId' => "#{switch}", 'templType' => 'updating-template'){
|
755
823
|
xml.vnicFcIf('name' => "#{vsan_name}", 'rn' => 'if-default')
|
@@ -758,19 +826,20 @@ class UCSProvision
|
|
758
826
|
}
|
759
827
|
}
|
760
828
|
end
|
761
|
-
|
762
|
-
|
829
|
+
|
830
|
+
#Create xml
|
831
|
+
set_vhba_template_xml = xml_builder.to_xml.to_s
|
763
832
|
|
764
833
|
#Post
|
765
834
|
begin
|
766
|
-
RestClient.post(@url,
|
835
|
+
RestClient.post(@url, set_vhba_template_xml, :content_type => 'text/xml').body
|
767
836
|
rescue Exception => e
|
768
837
|
raise "Error #{e}"
|
769
838
|
end
|
770
839
|
|
771
840
|
end
|
772
841
|
|
773
|
-
def
|
842
|
+
def set_uuid_pool(json)
|
774
843
|
|
775
844
|
uuid_pool_name = JSON.parse(json)['uuid_pool_name']
|
776
845
|
uuid_from = JSON.parse(json)['uuid_from']
|
@@ -791,19 +860,19 @@ class UCSProvision
|
|
791
860
|
}
|
792
861
|
end
|
793
862
|
|
794
|
-
#Create
|
795
|
-
|
863
|
+
#Create xml
|
864
|
+
set_uuid_pool_xml = xml_builder.to_xml.to_s
|
796
865
|
|
797
866
|
#Post
|
798
867
|
begin
|
799
|
-
RestClient.post(@url,
|
868
|
+
RestClient.post(@url, set_uuid_pool_xml, :content_type => 'text/xml').body
|
800
869
|
rescue Exception => e
|
801
870
|
raise "Error #{e}"
|
802
871
|
end
|
803
872
|
|
804
873
|
end
|
805
874
|
|
806
|
-
def
|
875
|
+
def set_service_profile_template(json)
|
807
876
|
|
808
877
|
service_profile_template_name = JSON.parse(json)['service_profile_template_name']
|
809
878
|
service_profile_template_boot_policy = JSON.parse(json)['service_profile_template_boot_policy']
|
@@ -863,19 +932,19 @@ class UCSProvision
|
|
863
932
|
}
|
864
933
|
end
|
865
934
|
|
866
|
-
#Create Template
|
867
|
-
|
935
|
+
#Create Template xml
|
936
|
+
set_service_profile_template_xml = xml_builder.to_xml.to_s
|
868
937
|
|
869
938
|
#Post create Service Profile Template
|
870
939
|
begin
|
871
|
-
RestClient.post(@url,
|
940
|
+
RestClient.post(@url, set_service_profile_template_xml, :content_type => 'text/xml').body
|
872
941
|
rescue Exception => e
|
873
942
|
raise "Error #{e}"
|
874
943
|
end
|
875
944
|
|
876
945
|
end
|
877
946
|
|
878
|
-
def
|
947
|
+
def set_service_profiles_from_template(json)
|
879
948
|
|
880
949
|
service_profile_template_name = JSON.parse(json)['service_profile_template_name'].to_s
|
881
950
|
org = JSON.parse(json)['org'].to_s
|
@@ -891,12 +960,12 @@ class UCSProvision
|
|
891
960
|
end
|
892
961
|
|
893
962
|
|
894
|
-
#Create Template
|
895
|
-
|
963
|
+
#Create Template xml
|
964
|
+
set_service_profiles_from_template_xml = xml_builder.to_xml.to_s
|
896
965
|
|
897
966
|
#Post create Service Profiles from Template
|
898
967
|
begin
|
899
|
-
RestClient.post(@url,
|
968
|
+
RestClient.post(@url, set_service_profiles_from_template_xml, :content_type => 'text/xml').body
|
900
969
|
rescue Exception => e
|
901
970
|
raise "Error #{e}"
|
902
971
|
end
|
@@ -905,7 +974,7 @@ class UCSProvision
|
|
905
974
|
|
906
975
|
|
907
976
|
|
908
|
-
def
|
977
|
+
def set_service_profiles(json)
|
909
978
|
|
910
979
|
service_profile_names = JSON.parse(json)['service_profile_names'].to_s.split(',')
|
911
980
|
service_profile_boot_policy = JSON.parse(json)['service_profile_boot_policy'].to_s
|
@@ -928,7 +997,7 @@ class UCSProvision
|
|
928
997
|
|
929
998
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
930
999
|
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'true'){
|
931
|
-
xml.inConfigs{
|
1000
|
+
xml.inConfigs{service_profile_names.each do |service_profile_name|
|
932
1001
|
xml.pair('key' => "org-root/org-#{org}/ls-#{service_profile_name}"){
|
933
1002
|
xml.lsServer('agentPolicyName' => '', 'biosProfileName' => '', 'bootPolicyName' => "#{service_profile_boot_policy}",
|
934
1003
|
'descr' => '', 'dn' => "org-root/org-#{org}/ls-#{service_profile_name}",
|
@@ -937,14 +1006,14 @@ class UCSProvision
|
|
937
1006
|
'mgmtAccessPolicyName' => '', 'mgmtFwPolicyName' => "#{service_profile_mgmt_fw_policy}", 'name' => "#{service_profile_name}",
|
938
1007
|
'powerPolicyName' => 'default', 'scrubPolicyName' => '', 'solPolicyName' => 'default', 'srcTemplName' => "#{service_profile_template_to_bind}",
|
939
1008
|
'statsPolicyName' => 'default', 'status' => 'created', 'usrLbl' => '', 'uuid' => '0', 'vconProfileName' => ''){
|
940
|
-
|
1009
|
+
service_profile_vnics_a.each do |vnic_a|
|
941
1010
|
xml.vnicEther('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'mtu' => '1500',
|
942
1011
|
'name' => "#{vnic_a}", 'nwCtrlPolicyName' => '', 'nwTemplName' => "#{service_profile_vnic_a_template}",
|
943
1012
|
'order' => '3', 'pinToGroupName' => '', 'qosPolicyName' => '', 'rn' => "ether-#{vnic_a}",
|
944
1013
|
'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'A')
|
945
1014
|
end
|
946
1015
|
|
947
|
-
|
1016
|
+
service_profile_vnics_b.each do |vnic_b|
|
948
1017
|
xml.vnicEther('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'mtu' => '1500',
|
949
1018
|
'name' => "#{vnic_b}", 'nwCtrlPolicyName' => '', 'nwTemplName' => "#{service_profile_vnic_b_template}",
|
950
1019
|
'order' => '4', 'pinToGroupName' => '', 'qosPolicyName' => '', 'rn' => "ether-#{vnic_b}",
|
@@ -954,12 +1023,12 @@ class UCSProvision
|
|
954
1023
|
xml.vnicFcNode('addr' => 'pool-derived', 'identPoolName' => "#{service_profile_wwnn_pool}", 'rn' => 'fc-node')
|
955
1024
|
|
956
1025
|
xml.vnicFc('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'maxDataFieldSize' => '2048',
|
957
|
-
'name' => "#{service_profile_vhba_a}", 'nwTemplName' => "#{
|
1026
|
+
'name' => "#{service_profile_vhba_a}", 'nwTemplName' => "#{service_profile_vhba_a}",
|
958
1027
|
'order' => '1', 'persBind' => 'disabled', 'persBindClear' => 'no', 'pinToGroupName' => '', 'qosPolicyName' => '',
|
959
1028
|
'rn' => "fc-#{service_profile_vhba_a}", 'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'A')
|
960
1029
|
|
961
1030
|
xml.vnicFc('adaptorProfileName' => '', 'addr' => 'derived', 'adminVcon' => 'any', 'identPoolName' => '', 'maxDataFieldSize' => '2048',
|
962
|
-
'name' => "#{service_profile_vhba_b}", 'nwTemplName' => "#{
|
1031
|
+
'name' => "#{service_profile_vhba_b}", 'nwTemplName' => "#{service_profile_vhba_b}",
|
963
1032
|
'order' => '2', 'persBind' => 'disabled', 'persBindClear' => 'no', 'pinToGroupName' => '', 'qosPolicyName' => '',
|
964
1033
|
'rn' => "fc-#{service_profile_vhba_b}", 'statsPolicyName' => 'default', 'status' => 'created', 'switchId' => 'B')
|
965
1034
|
|
@@ -972,18 +1041,72 @@ class UCSProvision
|
|
972
1041
|
end
|
973
1042
|
|
974
1043
|
|
975
|
-
#Create Template
|
976
|
-
|
1044
|
+
#Create Template xml
|
1045
|
+
set_service_profiles_xml = xml_builder.to_xml.to_s
|
977
1046
|
|
978
|
-
#Post create Service
|
1047
|
+
#Post create Service Profiles
|
979
1048
|
begin
|
980
|
-
RestClient.post(@url,
|
1049
|
+
RestClient.post(@url, set_service_profiles_xml, :content_type => 'text/xml').body
|
981
1050
|
rescue Exception => e
|
982
1051
|
raise "Error #{e}"
|
983
1052
|
end
|
984
1053
|
|
985
|
-
|
1054
|
+
end
|
986
1055
|
|
1056
|
+
def set_server_pool(json)
|
1057
|
+
server_pool_name = JSON.parse(json)['server_pool_name'].to_s
|
1058
|
+
server_pool_description = JSON.parse(json)['server_pool_description']
|
1059
|
+
server_pool_chassis_id = JSON.parse(json)['server_pool_chassis_id'].to_i
|
1060
|
+
server_pool_blades = JSON.parse(json)['server_pool_blades'].to_s.split(',')
|
1061
|
+
org = JSON.parse(json)['org'].to_s
|
1062
|
+
|
1063
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
1064
|
+
xml.configConfMos('cookie' => "#{@ucs_cookie}", 'inHierarchical' => 'true'){
|
1065
|
+
xml.inConfigs{
|
1066
|
+
xml.pair('key' => "org-root/org-#{org}/compute-pool-#{server_pool_name}"){
|
1067
|
+
xml.computePool('descr' => "#{server_pool_description}", 'dn' => "org-root/org-#{org}/compute-pool-#{server_pool_name}",
|
1068
|
+
'name' => "#{server_pool_name}", 'status' => 'created'){
|
1069
|
+
server_pool_blades.each do |slot_id|
|
1070
|
+
xml.computePooledSlot('chassisId' => "#{server_pool_chassis_id}",
|
1071
|
+
'rn' => "blade-#{server_pool_chassis_id}-#{slot_id}", 'slotId' => "#{slot_id}")
|
1072
|
+
end
|
1073
|
+
}
|
1074
|
+
}
|
1075
|
+
}
|
1076
|
+
}
|
1077
|
+
end
|
1078
|
+
|
1079
|
+
|
1080
|
+
|
1081
|
+
# xml_builder = Nokogiri::XML::Builder.new do |xml|
|
1082
|
+
# xml.configConfMos('cookie' => "#{@ucs_cookie}", 'inHierarchical' => 'true'){
|
1083
|
+
# xml.inConfigs{
|
1084
|
+
# xml.pair('key' => "org-root/org-#{server_pool_org}/compute-pool-#{server_pool_name}"){
|
1085
|
+
# xml.computePool('descr' => '', 'dn' => "org-root/org-#{server_pool_org}/compute-pool-#{server_pool_name}",
|
1086
|
+
# 'status' => 'created,modified'){
|
1087
|
+
# server_pool_blades.each do |slot_id|
|
1088
|
+
# xml.computePooledSlot('chassisId' => "#{server_pool_chassis_id}",
|
1089
|
+
# 'rn' => "blade-#{server_pool_chassis_id}-#{slot_id}", 'slotId' => "#{slot_id}",
|
1090
|
+
# 'status' => 'created')
|
1091
|
+
# end
|
1092
|
+
# }
|
1093
|
+
# }
|
1094
|
+
# }
|
1095
|
+
# }
|
1096
|
+
# end
|
1097
|
+
|
1098
|
+
|
1099
|
+
#Create XML
|
1100
|
+
|
1101
|
+
set_server_pool_xml = xml_builder.to_xml.to_s
|
1102
|
+
|
1103
|
+
#Post
|
1104
|
+
begin
|
1105
|
+
RestClient.post(@url, set_server_pool_xml, :content_type => 'text/xml').body
|
1106
|
+
rescue Exception => e
|
1107
|
+
raise "Error #{e}"
|
1108
|
+
end
|
987
1109
|
|
1110
|
+
end
|
988
1111
|
|
989
1112
|
end
|
@@ -0,0 +1,67 @@
|
|
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 UCSUpdate
|
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 update_host_firmware_package(json)
|
29
|
+
|
30
|
+
host_firmware_pkg_name = JSON.parse(json)['host_firmware_pkg_name']
|
31
|
+
hardware_model = JSON.parse(json)['hardware_model'].to_s
|
32
|
+
hardware_type = JSON.parse(json)['hardware_type']
|
33
|
+
hardware_vendor = JSON.parse(json)['hardware_vendor'].to_s
|
34
|
+
firmware_version = JSON.parse(json)['firmware_version'].to_s
|
35
|
+
org = JSON.parse(json)['org']
|
36
|
+
|
37
|
+
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
38
|
+
xml.configConfMos('cookie' => "#{@cookie}", 'inHierarchical' => 'false'){
|
39
|
+
xml.inConfigs{
|
40
|
+
xml.pair('key' => "org-root/org-#{org}/fw-host-pack-#{host_firmware_pkg_name}"){
|
41
|
+
xml.firmwareComputeHostPack('descr' => '', 'dn' => "org-root/org-#{org}/fw-host-pack-#{host_firmware_pkg_name}",
|
42
|
+
'ignoreCompCheck' => 'yes', 'mode' => 'staged', 'stageSize' => '0', 'updateTrigger' => 'immediate'){
|
43
|
+
xml.firmwarePackItem('hwModel' => "#{hardware_model}", 'hwVendor' => "#{hardware_vendor}",
|
44
|
+
'rn' => "pack-image-#{hardware_vendor}|#{hardware_model}|#{hardware_type}",
|
45
|
+
'type' => "#{hardware_type}", 'version' => "#{firmware_version}")
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
50
|
+
end
|
51
|
+
|
52
|
+
#Create XML
|
53
|
+
|
54
|
+
update_host_firmware_packageXML = xml_builder.to_xml.to_s
|
55
|
+
|
56
|
+
#Post
|
57
|
+
|
58
|
+
begin
|
59
|
+
RestClient.post(@url, update_host_firmware_packageXML, :content_type => 'text/xml').body
|
60
|
+
rescue Exception => e
|
61
|
+
raise "Error #{e}"
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
end
|
data/lib/ucslib/version.rb
CHANGED
data/lib/ucslib.rb
CHANGED
@@ -18,8 +18,11 @@
|
|
18
18
|
require "ucslib/version"
|
19
19
|
require "ucslib/session"
|
20
20
|
require "ucslib/provision"
|
21
|
+
require "ucslib/parser"
|
22
|
+
require "ucslib/update"
|
21
23
|
require "ucslib/inventory"
|
22
24
|
require 'ucslib/destroy'
|
25
|
+
require 'ucslib/manage'
|
23
26
|
|
24
27
|
require 'nokogiri'
|
25
28
|
require 'rest-client'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ucslib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: nokogiri
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: rest-client
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ! '>='
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: '0'
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: json
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,7 +53,12 @@ dependencies:
|
|
43
53
|
version: '0'
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
47
62
|
description: Ruby Client Library for Cisco UCS Manager that can be used by DevOps
|
48
63
|
toolchains (Chef/Puppet or others) to provide hardware deployment automation
|
49
64
|
email:
|
@@ -97,8 +112,11 @@ files:
|
|
97
112
|
- lib/ucslib.rb
|
98
113
|
- lib/ucslib/destroy.rb
|
99
114
|
- lib/ucslib/inventory.rb
|
115
|
+
- lib/ucslib/manage.rb
|
116
|
+
- lib/ucslib/parser.rb
|
100
117
|
- lib/ucslib/provision.rb
|
101
118
|
- lib/ucslib/session.rb
|
119
|
+
- lib/ucslib/update.rb
|
102
120
|
- lib/ucslib/version.rb
|
103
121
|
- ucslib.gemspec
|
104
122
|
homepage: ''
|
@@ -121,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
139
|
version: '0'
|
122
140
|
requirements: []
|
123
141
|
rubyforge_project: ucslib
|
124
|
-
rubygems_version: 1.8.
|
142
|
+
rubygems_version: 1.8.24
|
125
143
|
signing_key:
|
126
144
|
specification_version: 3
|
127
145
|
summary: Ruby UCS Manager Client Library
|