ucslib 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/.gitignore +4 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +201 -0
  4. data/README.rdoc +106 -0
  5. data/Rakefile +37 -0
  6. data/html/README_rdoc.html +146 -0
  7. data/html/UCSInventory.html +533 -0
  8. data/html/UCSProvision.html +1914 -0
  9. data/html/UCSToken.html +339 -0
  10. data/html/Ucslib.html +173 -0
  11. data/html/created.rid +7 -0
  12. data/html/images/brick.png +0 -0
  13. data/html/images/brick_link.png +0 -0
  14. data/html/images/bug.png +0 -0
  15. data/html/images/bullet_black.png +0 -0
  16. data/html/images/bullet_toggle_minus.png +0 -0
  17. data/html/images/bullet_toggle_plus.png +0 -0
  18. data/html/images/date.png +0 -0
  19. data/html/images/find.png +0 -0
  20. data/html/images/loadingAnimation.gif +0 -0
  21. data/html/images/macFFBgHack.png +0 -0
  22. data/html/images/package.png +0 -0
  23. data/html/images/page_green.png +0 -0
  24. data/html/images/page_white_text.png +0 -0
  25. data/html/images/page_white_width.png +0 -0
  26. data/html/images/plugin.png +0 -0
  27. data/html/images/ruby.png +0 -0
  28. data/html/images/tag_green.png +0 -0
  29. data/html/images/wrench.png +0 -0
  30. data/html/images/wrench_orange.png +0 -0
  31. data/html/images/zoom.png +0 -0
  32. data/html/index.html +193 -0
  33. data/html/js/darkfish.js +116 -0
  34. data/html/js/jquery.js +32 -0
  35. data/html/js/quicksearch.js +114 -0
  36. data/html/js/thickbox-compressed.js +10 -0
  37. data/html/lib/ucslib/inventory_rb.html +75 -0
  38. data/html/lib/ucslib/provision_rb.html +75 -0
  39. data/html/lib/ucslib/session_rb.html +75 -0
  40. data/html/lib/ucslib/version_rb.html +75 -0
  41. data/html/lib/ucslib_rb.html +89 -0
  42. data/html/rdoc.css +763 -0
  43. data/lib/ucslib/inventory.rb +131 -0
  44. data/lib/ucslib/provision.rb +949 -0
  45. data/lib/ucslib/session.rb +108 -0
  46. data/lib/ucslib/version.rb +20 -0
  47. data/lib/ucslib.rb +26 -0
  48. data/ucslib.gemspec +45 -0
  49. metadata +126 -0
@@ -0,0 +1,108 @@
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
+ #UCSM API Session management
19
+
20
+
21
+ class UCSToken
22
+ #Accept a JSON object that contains the UCSM username, password, and IP
23
+ def get_token(authjson)
24
+
25
+ username = "#{JSON.parse(authjson)['username']}"
26
+ password = "#{JSON.parse(authjson)['password']}"
27
+ ip = "#{JSON.parse(authjson)['ip']}"
28
+ url = "https://#{ip}/nuova"
29
+
30
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
31
+ xml.aaaLogin('inName' => username, 'inPassword' => password)
32
+ end
33
+ aaa_login_xml = xml_builder.to_xml.to_s
34
+ ucs_response = RestClient.post(url, aaa_login_xml, :content_type => 'text/xml').body
35
+ ucs_login_doc = Nokogiri::XML(ucs_response)
36
+ ucs_login_root = ucs_login_doc.root
37
+ cookie = ucs_login_root.attributes['outCookie']
38
+
39
+ begin
40
+ return session = { :cookie => "#{cookie}",
41
+ :username => "#{username}",
42
+ :password => "#{password}",
43
+ :ip => "#{ip}" }.to_json
44
+ rescue Exception => e
45
+ 'An Error Occured. Please check authentication credentials'
46
+ else
47
+ Process.exit
48
+ end
49
+
50
+ end
51
+
52
+
53
+ def refresh_token(tokenjson)
54
+
55
+ cookie = "#{JSON.parse(tokenjson)['cookie']}"
56
+ username = "#{JSON.parse(tokenjson)['username']}"
57
+ password = "#{JSON.parse(tokenjson)['password']}"
58
+ ip = "#{JSON.parse(tokenjson)['ip']}"
59
+ url = "https://#{ip}/nuova"
60
+
61
+
62
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
63
+ xml.aaaRefresh('inName' => username, 'inPassword' => password, 'inCookie' => cookie)
64
+ end
65
+ aaa_refresh_xml = xml_builder.to_xml.to_s
66
+
67
+ ucs_response = RestClient.post(url, aaa_refresh_xml, :content_type => 'text/xml').body
68
+
69
+
70
+ ucs_login_doc = Nokogiri::XML(ucs_response)
71
+ ucs_login_root = ucs_login_doc.root
72
+ new_cookie = ucs_login_root.attributes['outCookie']
73
+
74
+ begin
75
+ #return ucs_session json containing new cookie, url, ip
76
+ return session = { :cookie => "#{new_cookie}",
77
+ :username => "#{username}",
78
+ :password => "#{password}",
79
+ :ip => "#{ip}" }.to_json
80
+ rescue Exception => e
81
+ 'An Error Occured. Please check authentication credentials'
82
+ else
83
+ Process.exit
84
+ end
85
+
86
+ end
87
+
88
+ def logout(tokenjson)
89
+
90
+ cookie = "#{JSON.parse(tokenjson)['cookie']}"
91
+ ip = "#{JSON.parse(tokenjson)['ip']}"
92
+ url = "https://#{ip}/nuova"
93
+
94
+ xml_builder = Nokogiri::XML::Builder.new do |xml|
95
+ xml.aaaLogout('inCookie' => cookie)
96
+ end
97
+
98
+ aaaLogoutXML = xml_builder.to_xml.to_s
99
+
100
+ begin
101
+ RestClient.post(url, aaaLogoutXML, :content_type => 'text/xml').body
102
+ rescue Exception => e
103
+ raise "Error #{e}"
104
+ end
105
+
106
+ end
107
+
108
+ end
@@ -0,0 +1,20 @@
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
+ module Ucslib
19
+ VERSION = "0.0.2"
20
+ end
data/lib/ucslib.rb ADDED
@@ -0,0 +1,26 @@
1
+ # Author:: Murali Raju (<murali.raju@appliv.com>)
2
+ # Copyright:: Copyright (c) 2011 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 "ucslib/version"
19
+ require "ucslib/session"
20
+ require "ucslib/provision"
21
+ require "ucslib/inventory"
22
+
23
+ require 'nokogiri'
24
+ require 'rest-client'
25
+ require 'json'
26
+
data/ucslib.gemspec ADDED
@@ -0,0 +1,45 @@
1
+ # Author:: Murali Raju (<murali.raju@appliv.com>)
2
+ # Copyright:: Copyright (c) 2011 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
+ # -*- encoding: utf-8 -*-
19
+ $:.push File.expand_path("../lib", __FILE__)
20
+ require "ucslib/version"
21
+
22
+ Gem::Specification.new do |s|
23
+ s.name = "ucslib"
24
+ s.version = Ucslib::VERSION
25
+ s.authors = ["Murali Raju"]
26
+ s.email = ["murali.raju@appliv.com"]
27
+ s.homepage = ""
28
+ s.summary = %q{Ruby UCS Manager Client Library}
29
+ s.description = %q{RUby UCS Manager API abstraction to build automation tools}
30
+
31
+ s.rubyforge_project = "ucslib"
32
+
33
+ s.files = `git ls-files`.split("\n")
34
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
35
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
36
+ s.require_paths = ["lib"]
37
+
38
+ # specify any dependencies here; for example:
39
+ # s.add_development_dependency "rspec"
40
+ # s.add_runtime_dependency "rest-client"
41
+
42
+ s.add_dependency("nokogiri")
43
+ s.add_dependency("rest-client")
44
+ s.add_dependency("json")
45
+ end
metadata ADDED
@@ -0,0 +1,126 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ucslib
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Murali Raju
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-05-13 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: nokogiri
16
+ requirement: &70183491062120 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70183491062120
25
+ - !ruby/object:Gem::Dependency
26
+ name: rest-client
27
+ requirement: &70183491061540 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70183491061540
36
+ - !ruby/object:Gem::Dependency
37
+ name: json
38
+ requirement: &70183491061100 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70183491061100
47
+ description: RUby UCS Manager API abstraction to build automation tools
48
+ email:
49
+ - murali.raju@appliv.com
50
+ executables: []
51
+ extensions: []
52
+ extra_rdoc_files: []
53
+ files:
54
+ - .gitignore
55
+ - Gemfile
56
+ - LICENSE.txt
57
+ - README.rdoc
58
+ - Rakefile
59
+ - html/README_rdoc.html
60
+ - html/UCSInventory.html
61
+ - html/UCSProvision.html
62
+ - html/UCSToken.html
63
+ - html/Ucslib.html
64
+ - html/created.rid
65
+ - html/images/brick.png
66
+ - html/images/brick_link.png
67
+ - html/images/bug.png
68
+ - html/images/bullet_black.png
69
+ - html/images/bullet_toggle_minus.png
70
+ - html/images/bullet_toggle_plus.png
71
+ - html/images/date.png
72
+ - html/images/find.png
73
+ - html/images/loadingAnimation.gif
74
+ - html/images/macFFBgHack.png
75
+ - html/images/package.png
76
+ - html/images/page_green.png
77
+ - html/images/page_white_text.png
78
+ - html/images/page_white_width.png
79
+ - html/images/plugin.png
80
+ - html/images/ruby.png
81
+ - html/images/tag_green.png
82
+ - html/images/wrench.png
83
+ - html/images/wrench_orange.png
84
+ - html/images/zoom.png
85
+ - html/index.html
86
+ - html/js/darkfish.js
87
+ - html/js/jquery.js
88
+ - html/js/quicksearch.js
89
+ - html/js/thickbox-compressed.js
90
+ - html/lib/ucslib/inventory_rb.html
91
+ - html/lib/ucslib/provision_rb.html
92
+ - html/lib/ucslib/session_rb.html
93
+ - html/lib/ucslib/version_rb.html
94
+ - html/lib/ucslib_rb.html
95
+ - html/rdoc.css
96
+ - lib/ucslib.rb
97
+ - lib/ucslib/inventory.rb
98
+ - lib/ucslib/provision.rb
99
+ - lib/ucslib/session.rb
100
+ - lib/ucslib/version.rb
101
+ - ucslib.gemspec
102
+ homepage: ''
103
+ licenses: []
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project: ucslib
122
+ rubygems_version: 1.8.10
123
+ signing_key:
124
+ specification_version: 3
125
+ summary: Ruby UCS Manager Client Library
126
+ test_files: []