ucslib 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -3
- data/lib/ucslib/service/ucs/destroy.rb +2 -2
- data/lib/ucslib/service/ucs/inventory.rb +1 -1
- data/lib/ucslib/service/ucs/manage.rb +1 -1
- data/lib/ucslib/service/ucs/provision.rb +29 -29
- data/lib/ucslib/service/ucs/session.rb +2 -2
- data/lib/ucslib/service/ucs/stats.rb +1 -1
- data/lib/ucslib/service/ucs/ucs.rb +28 -2
- data/lib/ucslib/service/ucs/update.rb +2 -2
- data/lib/ucslib/version.rb +1 -1
- metadata +3 -3
- data/lib/ucslib/Gemfile +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8fd182ff6438d01a5d4fd9885e37266b80be9eb
|
4
|
+
data.tar.gz: 99429adb1a242bf8006e666084915d0e7433d572
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29481c2eb690c5b5ed240d135be00a76e4928aab8619bffe056ee4c1204e5a105e138060d184c06fb26f1a8937198efbf82ef20d48e74d22ea0ab05efda6c44e
|
7
|
+
data.tar.gz: f2c7dd9556f984daa793aa906d1bc23d4a203e947915b00c8f4d599cac935fc999d16557d8bdfe92f731c7f1c2597841be65375309320e6f40d354096f521a2a
|
data/README.md
CHANGED
@@ -6,7 +6,12 @@ To see an example of how ucslib is being used, checkout the ucs and ucs-solo Che
|
|
6
6
|
|
7
7
|
In addition there is a knife plugin that use ucslib as well - https://github.com/velankanisys/knife-ucs
|
8
8
|
|
9
|
-
** Version 0.1.
|
9
|
+
** Version 0.1.9 has been released **
|
10
|
+
|
11
|
+
0.1.9
|
12
|
+
|
13
|
+
Updates to allow SSL to be ignored if desired, still defaults to verify_ssl =True
|
14
|
+
Abstracted out the Rest post call to allow for easier global changes down the road
|
10
15
|
|
11
16
|
0.1.8
|
12
17
|
|
@@ -44,8 +49,8 @@ gem install ucslib
|
|
44
49
|
|
45
50
|
[1] pry(main)> require 'ucslib'
|
46
51
|
=> true
|
47
|
-
[2] pry(main)> authjson = { :username => 'admin', :password => 'admin', :ip => '172.16.192.175' }.to_json
|
48
|
-
=> "{\"username\":\"admin\",\"password\":\"admin\",\"ip\":\"172.16.192.175\"}"
|
52
|
+
[2] pry(main)> authjson = { :username => 'admin', :password => 'admin', :ip => '172.16.192.175', :verify_ssl => "false"}.to_json
|
53
|
+
=> "{\"username\":\"admin\",\"password\":\"admin\",\"ip\":\"172.16.192.175\",\"verify_ssl_\":\"false\"}"
|
49
54
|
[3] pry(main)> ucs = UCS.new(authjson)
|
50
55
|
Your credentials are username: admin password: admin ip: 172.16.192.175 url https://172.16.192.175/nuova
|
51
56
|
=> #<UCS:0x007fd269d1eb18>
|
@@ -36,7 +36,7 @@ module Destroy
|
|
36
36
|
|
37
37
|
#Post
|
38
38
|
begin
|
39
|
-
|
39
|
+
rest_post(delete_org_XML, @url)
|
40
40
|
rescue Exception => e
|
41
41
|
raise "Error #{e}"
|
42
42
|
end
|
@@ -64,7 +64,7 @@ module Destroy
|
|
64
64
|
|
65
65
|
#Post
|
66
66
|
begin
|
67
|
-
|
67
|
+
rest_post(delete_vlan_XML, @url)
|
68
68
|
rescue Exception => e
|
69
69
|
raise "Error #{e}"
|
70
70
|
end
|
@@ -79,7 +79,7 @@ module Inventory
|
|
79
79
|
#End Build Multi-Class XML
|
80
80
|
|
81
81
|
ucs_multi_class_XML = xml_builder.to_xml.to_s
|
82
|
-
ucs_response_multi_class =
|
82
|
+
ucs_response_multi_class = rest_post(ucs_multi_class_XML,@url)
|
83
83
|
|
84
84
|
#Uncomment the following to create a dump to review and debug elements
|
85
85
|
# fh = File.new("ucs_response_multiclass.xml", "w")
|
@@ -81,7 +81,7 @@ module Manage
|
|
81
81
|
|
82
82
|
#Post
|
83
83
|
begin
|
84
|
-
|
84
|
+
rest_post(associate_service_profile_template_to_server_pool_xml,@url)
|
85
85
|
rescue Exception => e
|
86
86
|
raise "Error #{e}"
|
87
87
|
end
|
@@ -39,7 +39,7 @@ module Provision
|
|
39
39
|
#Post
|
40
40
|
|
41
41
|
begin
|
42
|
-
|
42
|
+
rest_post(set_org_xml,@url)
|
43
43
|
rescue Exception => e
|
44
44
|
raise "Error #{e}"
|
45
45
|
end
|
@@ -64,7 +64,7 @@ module Provision
|
|
64
64
|
|
65
65
|
#Post
|
66
66
|
begin
|
67
|
-
|
67
|
+
rest_post(set_power_policy_xml,@url)
|
68
68
|
rescue Exception => e
|
69
69
|
raise "Error #{e}"
|
70
70
|
end
|
@@ -91,7 +91,7 @@ module Provision
|
|
91
91
|
#Post
|
92
92
|
|
93
93
|
begin
|
94
|
-
|
94
|
+
rest_post(set_chassis_discovery_policy_xml,@url)
|
95
95
|
rescue Exception => e
|
96
96
|
raise "Error #{e}"
|
97
97
|
end
|
@@ -119,7 +119,7 @@ module Provision
|
|
119
119
|
#Post
|
120
120
|
|
121
121
|
begin
|
122
|
-
|
122
|
+
rest_post(set_time_zone_xml,@url)
|
123
123
|
rescue Exception => e
|
124
124
|
raise "Error #{e}"
|
125
125
|
end
|
@@ -145,7 +145,7 @@ module Provision
|
|
145
145
|
#Post
|
146
146
|
|
147
147
|
begin
|
148
|
-
|
148
|
+
rest_post(set_ntp_xml,@url)
|
149
149
|
rescue Exception => e
|
150
150
|
raise "Error #{e}"
|
151
151
|
end
|
@@ -175,7 +175,7 @@ module Provision
|
|
175
175
|
|
176
176
|
#Post
|
177
177
|
begin
|
178
|
-
|
178
|
+
rest_post(set_local_disk_policy_xml,@url)
|
179
179
|
rescue Exception => e
|
180
180
|
raise "Error #{e}"
|
181
181
|
end
|
@@ -204,7 +204,7 @@ module Provision
|
|
204
204
|
|
205
205
|
#Post
|
206
206
|
begin
|
207
|
-
|
207
|
+
rest_post(set_syslog_server_xml,@url)
|
208
208
|
rescue Exception => e
|
209
209
|
raise "Error #{e}"
|
210
210
|
end
|
@@ -238,7 +238,7 @@ module Provision
|
|
238
238
|
#Post
|
239
239
|
|
240
240
|
begin
|
241
|
-
|
241
|
+
rest_post(set_server_port_xml,@url)
|
242
242
|
rescue Exception => e
|
243
243
|
raise "Error #{e}"
|
244
244
|
end
|
@@ -272,7 +272,7 @@ module Provision
|
|
272
272
|
#Post
|
273
273
|
|
274
274
|
begin
|
275
|
-
|
275
|
+
rest_post(set_network_uplink_xml,@url)
|
276
276
|
rescue Exception => e
|
277
277
|
raise "Error #{e}"
|
278
278
|
end
|
@@ -302,7 +302,7 @@ module Provision
|
|
302
302
|
|
303
303
|
#Post
|
304
304
|
begin
|
305
|
-
|
305
|
+
rest_post(set_fc_uplink_xml,@url)
|
306
306
|
rescue Exception => e
|
307
307
|
raise "Error #{e}"
|
308
308
|
end
|
@@ -345,7 +345,7 @@ module Provision
|
|
345
345
|
|
346
346
|
#Post
|
347
347
|
begin
|
348
|
-
|
348
|
+
rest_post(set_port_channel_xml,@url)
|
349
349
|
rescue Exception => e
|
350
350
|
raise "Error #{e}"
|
351
351
|
end
|
@@ -380,7 +380,7 @@ module Provision
|
|
380
380
|
|
381
381
|
#Post
|
382
382
|
begin
|
383
|
-
|
383
|
+
rest_post(set_local_boot_policy_xml,@url)
|
384
384
|
rescue Exception => e
|
385
385
|
raise "Error #{e}"
|
386
386
|
end
|
@@ -422,7 +422,7 @@ module Provision
|
|
422
422
|
|
423
423
|
#Post
|
424
424
|
begin
|
425
|
-
|
425
|
+
rest_post(set_pxe_boot_policy_xml,@url)
|
426
426
|
rescue Exception => e
|
427
427
|
raise "Error #{e}"
|
428
428
|
end
|
@@ -468,7 +468,7 @@ module Provision
|
|
468
468
|
|
469
469
|
#Post
|
470
470
|
begin
|
471
|
-
|
471
|
+
rest_post(set_san_boot_policy_xml,@url)
|
472
472
|
rescue Exception => e
|
473
473
|
raise "Error #{e}"
|
474
474
|
end
|
@@ -511,7 +511,7 @@ module Provision
|
|
511
511
|
#Post
|
512
512
|
|
513
513
|
begin
|
514
|
-
|
514
|
+
rest_post(set_mgmt_firmware_packagexml,@url)
|
515
515
|
rescue Exception => e
|
516
516
|
raise "Error #{e}"
|
517
517
|
end
|
@@ -574,7 +574,7 @@ module Provision
|
|
574
574
|
#Post
|
575
575
|
|
576
576
|
begin
|
577
|
-
|
577
|
+
rest_post(set_host_firmware_packagexml,@url)
|
578
578
|
rescue Exception => e
|
579
579
|
raise "Error #{e}"
|
580
580
|
end
|
@@ -604,7 +604,7 @@ module Provision
|
|
604
604
|
|
605
605
|
#Post
|
606
606
|
begin
|
607
|
-
|
607
|
+
rest_post(set_management_ip_pool_xml,@url)
|
608
608
|
rescue Exception => e
|
609
609
|
raise "Error #{e}"
|
610
610
|
end
|
@@ -632,7 +632,7 @@ module Provision
|
|
632
632
|
|
633
633
|
#Post
|
634
634
|
begin
|
635
|
-
|
635
|
+
rest_post(set_vlan_xml,@url)
|
636
636
|
rescue Exception => e
|
637
637
|
raise "Error #{e}"
|
638
638
|
end
|
@@ -677,7 +677,7 @@ module Provision
|
|
677
677
|
|
678
678
|
#Post
|
679
679
|
begin
|
680
|
-
|
680
|
+
rest_post(set_mac_pool_xml,@url)
|
681
681
|
rescue Exception => e
|
682
682
|
raise "Error #{e}"
|
683
683
|
end
|
@@ -721,7 +721,7 @@ module Provision
|
|
721
721
|
|
722
722
|
#Post
|
723
723
|
begin
|
724
|
-
|
724
|
+
rest_post(set_vnic_template_xml,@url)
|
725
725
|
rescue Exception => e
|
726
726
|
raise "Error #{e}"
|
727
727
|
end
|
@@ -751,7 +751,7 @@ module Provision
|
|
751
751
|
|
752
752
|
#Post
|
753
753
|
begin
|
754
|
-
|
754
|
+
rest_post(set_vsan_xml,@url)
|
755
755
|
rescue Exception => e
|
756
756
|
raise "Error #{e}"
|
757
757
|
end
|
@@ -783,7 +783,7 @@ module Provision
|
|
783
783
|
|
784
784
|
#Post
|
785
785
|
begin
|
786
|
-
|
786
|
+
rest_post(set_wwnn_pool_xml,@url)
|
787
787
|
rescue Exception => e
|
788
788
|
raise "Error #{e}"
|
789
789
|
end
|
@@ -817,7 +817,7 @@ module Provision
|
|
817
817
|
|
818
818
|
#Post
|
819
819
|
begin
|
820
|
-
|
820
|
+
rest_post(set_wwpn_pool_xml,@url)
|
821
821
|
rescue Exception => e
|
822
822
|
raise "Error #{e}"
|
823
823
|
end
|
@@ -853,7 +853,7 @@ module Provision
|
|
853
853
|
|
854
854
|
#Post
|
855
855
|
begin
|
856
|
-
|
856
|
+
rest_post(set_vhba_template_xml,@url)
|
857
857
|
rescue Exception => e
|
858
858
|
raise "Error #{e}"
|
859
859
|
end
|
@@ -886,7 +886,7 @@ module Provision
|
|
886
886
|
|
887
887
|
#Post
|
888
888
|
begin
|
889
|
-
|
889
|
+
rest_post(set_uuid_pool_xml,@url)
|
890
890
|
rescue Exception => e
|
891
891
|
raise "Error #{e}"
|
892
892
|
end
|
@@ -958,7 +958,7 @@ module Provision
|
|
958
958
|
|
959
959
|
#Post create Service Profile Template
|
960
960
|
begin
|
961
|
-
|
961
|
+
rest_post(set_service_profile_template_xml,@url)
|
962
962
|
rescue Exception => e
|
963
963
|
raise "Error #{e}"
|
964
964
|
end
|
@@ -986,7 +986,7 @@ module Provision
|
|
986
986
|
|
987
987
|
#Post create Service Profiles from Template
|
988
988
|
begin
|
989
|
-
|
989
|
+
rest_post(set_service_profiles_from_template_xml,@url)
|
990
990
|
rescue Exception => e
|
991
991
|
raise "Error #{e}"
|
992
992
|
end
|
@@ -1067,7 +1067,7 @@ module Provision
|
|
1067
1067
|
|
1068
1068
|
#Post create Service Profiles
|
1069
1069
|
begin
|
1070
|
-
|
1070
|
+
rest_post(set_service_profiles_xml,@url)
|
1071
1071
|
rescue Exception => e
|
1072
1072
|
raise "Error #{e}"
|
1073
1073
|
end
|
@@ -1126,7 +1126,7 @@ module Provision
|
|
1126
1126
|
|
1127
1127
|
#Post
|
1128
1128
|
begin
|
1129
|
-
|
1129
|
+
rest_post(set_server_pool_xml,@url)
|
1130
1130
|
rescue Exception => e
|
1131
1131
|
raise "Error #{e}"
|
1132
1132
|
end
|
@@ -65,7 +65,7 @@ module Session
|
|
65
65
|
end
|
66
66
|
aaa_refresh_xml = xml_builder.to_xml.to_s
|
67
67
|
|
68
|
-
ucs_response =
|
68
|
+
ucs_response = rest_post(aaa_refresh_xml,@url)
|
69
69
|
|
70
70
|
|
71
71
|
ucs_login_doc = Nokogiri::XML(ucs_response)
|
@@ -99,7 +99,7 @@ module Session
|
|
99
99
|
aaaLogoutXML = xml_builder.to_xml.to_s
|
100
100
|
|
101
101
|
begin
|
102
|
-
|
102
|
+
rest_post(aaaLogoutXML,@url)
|
103
103
|
rescue Exception => e
|
104
104
|
raise "Error #{e}"
|
105
105
|
end
|
@@ -73,7 +73,7 @@ module Stats
|
|
73
73
|
#End Build Multi-Class XML
|
74
74
|
|
75
75
|
ucs_multi_class_XML = xml_builder.to_xml.to_s
|
76
|
-
|
76
|
+
rest_post(ucs_multi_class_XML,@url)
|
77
77
|
|
78
78
|
#Uncomment the following to create a dump to review and debug elements
|
79
79
|
# fh = File.new("ucs_response_multiclass.xml", "w")
|
@@ -40,6 +40,8 @@ class UCS
|
|
40
40
|
username = "#{JSON.parse(authjson)['username']}"
|
41
41
|
password = "#{JSON.parse(authjson)['password']}"
|
42
42
|
ip = "#{JSON.parse(authjson)['ip']}"
|
43
|
+
#Required to default to true if verify_ssl is left out, more secure and backwards compatible
|
44
|
+
@verify_ssl = JSON.parse(authjson)['verify_ssl'].nil? ? true : to_boolean(JSON.parse(authjson)['verify_ssl'])
|
43
45
|
@url = "https://#{ip}/nuova"
|
44
46
|
|
45
47
|
xml_builder = Nokogiri::XML::Builder.new do |xml|
|
@@ -47,7 +49,7 @@ class UCS
|
|
47
49
|
end
|
48
50
|
|
49
51
|
aaa_login_xml = xml_builder.to_xml.to_s
|
50
|
-
ucs_response =
|
52
|
+
ucs_response = rest_post(aaa_login_xml,@url)
|
51
53
|
ucs_login_doc = Nokogiri::XML(ucs_response)
|
52
54
|
ucs_login_root = ucs_login_doc.root
|
53
55
|
@cookie = ucs_login_root.attributes['outCookie']
|
@@ -66,5 +68,29 @@ class UCS
|
|
66
68
|
# end
|
67
69
|
|
68
70
|
end
|
71
|
+
|
72
|
+
def rest_post(payload, api_url)
|
73
|
+
RestClient::Request.execute(method: :post,
|
74
|
+
url: api_url,
|
75
|
+
verify_ssl: @verify_ssl,
|
76
|
+
payload: payload,
|
77
|
+
headers: {
|
78
|
+
content_type: 'text/xml',
|
79
|
+
}).body
|
80
|
+
end
|
81
|
+
|
82
|
+
# Generic API get call
|
83
|
+
#
|
84
|
+
# @param api_url [string] the full API URL path
|
85
|
+
# @return [Hash] the object converted into Hash format and can be parsed with object[0] or object['id'] notation
|
86
|
+
def rest_get(api_url)
|
87
|
+
RestClient::Request.execute(method: :get,
|
88
|
+
url: api_url,
|
89
|
+
verify_ssl: @verify_ssl).body
|
90
|
+
end
|
69
91
|
|
70
|
-
|
92
|
+
def to_boolean(str)
|
93
|
+
str.to_s.downcase == "true"
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
@@ -48,7 +48,7 @@ module Update
|
|
48
48
|
#Post
|
49
49
|
|
50
50
|
begin
|
51
|
-
|
51
|
+
rest_post(update_host_firmware_packageXML,@url)
|
52
52
|
rescue Exception => e
|
53
53
|
raise "Error #{e}"
|
54
54
|
end
|
@@ -85,7 +85,7 @@ module Update
|
|
85
85
|
|
86
86
|
#Post Update Boot Policy on Service Profile Template
|
87
87
|
begin
|
88
|
-
|
88
|
+
rest_post(update_boot_policy_on_service_profile_template_xml,@url)
|
89
89
|
rescue Exception => e
|
90
90
|
raise "Error #{e}"
|
91
91
|
end
|
data/lib/ucslib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Murali Raju
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -65,7 +65,6 @@ files:
|
|
65
65
|
- README.rdoc
|
66
66
|
- Rakefile
|
67
67
|
- lib/ucslib.rb
|
68
|
-
- lib/ucslib/Gemfile
|
69
68
|
- lib/ucslib/service/ucs/destroy.rb
|
70
69
|
- lib/ucslib/service/ucs/inventory.rb
|
71
70
|
- lib/ucslib/service/ucs/manage.rb
|
@@ -100,3 +99,4 @@ signing_key:
|
|
100
99
|
specification_version: 4
|
101
100
|
summary: Ruby UCS Manager Client Library
|
102
101
|
test_files: []
|
102
|
+
has_rdoc:
|
data/lib/ucslib/Gemfile
DELETED