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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 0172126a4b6154c64708a1484a9b2893d11344e6
4
- data.tar.gz: 36511401b59e7332222d10a8fb92559438e49ad5
3
+ metadata.gz: f8fd182ff6438d01a5d4fd9885e37266b80be9eb
4
+ data.tar.gz: 99429adb1a242bf8006e666084915d0e7433d572
5
5
  SHA512:
6
- metadata.gz: b9d31b08263cbb3e164445c7cf11b624f92d7ac11b799779ad848e765af88837768aaadf55611a46742a72b3e683457a8aba11b54014da97f4729c6b633e1cc0
7
- data.tar.gz: e1ec6b08d119ac16266d80a67959af5308e28e23f433c8831e9480520cac479a17a2b0cf3564dcb84829c88dbeb977d3c294ed588aec81da96fcf1f26cad81b1
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.8 has been released **
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
- RestClient.post(@url, delete_org_XML, :content_type => 'text/xml').body
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
- RestClient.post(@url, delete_vlan_XML, :content_type => 'text/xml').body
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 = RestClient.post(@url, ucs_multi_class_XML, :content_type => 'text/xml').body
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
- RestClient.post(@url, associate_service_profile_template_to_server_pool_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_org_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_power_policy_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_chassis_discovery_policy_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_time_zone_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_ntp_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_local_disk_policy_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_syslog_server_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_server_port_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_network_uplink_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_fc_uplink_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_port_channel_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_local_boot_policy_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_pxe_boot_policy_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_san_boot_policy_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_mgmt_firmware_packagexml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_host_firmware_packagexml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_management_ip_pool_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_vlan_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_mac_pool_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_vnic_template_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_vsan_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_wwnn_pool_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_wwpn_pool_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_vhba_template_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_uuid_pool_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_service_profile_template_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_service_profiles_from_template_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_service_profiles_xml, :content_type => 'text/xml').body
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
- RestClient.post(@url, set_server_pool_xml, :content_type => 'text/xml').body
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 = RestClient.post(url, aaa_refresh_xml, :content_type => 'text/xml').body
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
- RestClient.post(url, aaaLogoutXML, :content_type => 'text/xml').body
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
- ucs_response_multi_class = RestClient.post(url, ucs_multi_class_XML, :content_type => 'text/xml').body
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 = RestClient.post(@url, aaa_login_xml, :content_type => 'text/xml').body
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
- end
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
- RestClient.post(@url, update_host_firmware_packageXML, :content_type => 'text/xml').body
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
- RestClient.post(@url, update_boot_policy_on_service_profile_template_xml, :content_type => 'text/xml').body
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
@@ -17,5 +17,5 @@
17
17
 
18
18
 
19
19
  module Ucslib
20
- VERSION = "0.1.8"
20
+ VERSION = "0.1.9"
21
21
  end
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.8
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: 2014-04-23 00:00:00.000000000 Z
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
@@ -1,4 +0,0 @@
1
- # A sample Gemfile
2
- source "https://rubygems.org"
3
-
4
- # gem "rails"