ilorb 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4dda8bc7feb3994e4cfbd360716f380af125b2e0
4
- data.tar.gz: 9c2b8b3d6f61d440df5039feaf2f94769b9c2ec9
3
+ metadata.gz: 62653f5b9895874fed33c3809ef3ee0ab36be009
4
+ data.tar.gz: cac900742ac25d1bfbff654e0aba7094d1419bb2
5
5
  SHA512:
6
- metadata.gz: 423966543881ffd1e3720fdc0d44bd2858dd4f4cbd2681c72d2ed7d7b9b64b92b4b796d733df0e0d2120c4f8adf1e2e698350e1a24e0377e6a6c3c90e81a76f2
7
- data.tar.gz: d43910027cb1dc97efe24c9f81c743d49fc56731d744a73f7f508b9b3755998949b64a2ae9361599b61af2cbf4348e636d83e61f632a3305e7623b08e78b3a57
6
+ metadata.gz: d7cb339ba4da6be19d191aac561538b76324efd1cf205c8cd32b8a3724a12c91000cd2719b8ee47611a98d2ebd88a201c29fb9b58a4fe988e69f988f205e659f
7
+ data.tar.gz: 6801e037528efada5421ff2a088e7cd80749c4bf3db80974c6f803c16a93fc2dea9f1cc9bcdba288d555663f1019de2366c017fbde5fe1a48b1adaa7ca83dc36
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ ilorb
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ilorb (0.0.2)
4
+ ilorb (0.0.3)
5
5
  nokogiri
6
- nori
6
+ nori (~> 2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -14,10 +14,10 @@ GEM
14
14
  safe_yaml (~> 0.9.0)
15
15
  diff-lcs (1.2.4)
16
16
  method_source (0.8.1)
17
- mini_portile (0.5.3)
18
- nokogiri (1.6.1)
19
- mini_portile (~> 0.5.0)
20
- nori (2.4.0)
17
+ mini_portile (0.6.2)
18
+ nokogiri (1.6.6.2)
19
+ mini_portile (~> 0.6.0)
20
+ nori (2.5.0)
21
21
  pry (0.9.12.2)
22
22
  coderay (~> 1.0.5)
23
23
  method_source (~> 0.8)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
data/ilorb.gemspec CHANGED
@@ -24,5 +24,5 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "webmock", "~> 1.13"
25
25
  spec.add_development_dependency "pry"
26
26
  spec.add_dependency "nokogiri"
27
- spec.add_dependency "nori"
27
+ spec.add_dependency "nori", "~> 2"
28
28
  end
@@ -27,7 +27,9 @@ context :rib_info do
27
27
 
28
28
  write_cmd :ahs_clear_data
29
29
  write_cmd :brownout_recovery # > mod_global_settings
30
- write_cmd :certificate_signing_request
30
+ write_cmd :certificate_signing_request do
31
+ elements :csr_state, :csr_country, :csr_locality, :csr_organization, :csr_organizational_unit, :csr_common_name
32
+ end
31
33
  write_cmd :clear_eventlog
32
34
  write_cmd :computer_lock do
33
35
  not_implemented
@@ -41,8 +43,7 @@ context :rib_info do
41
43
  write_cmd :hotkey_config do
42
44
  not_implemented
43
45
  end
44
- write_cmd :import_certificate do #TODO
45
- not_implemented
46
+ write_cmd :import_certificate do
46
47
  text :certificate
47
48
  end
48
49
  write_cmd :insert_virtual_media do
@@ -51,11 +52,18 @@ context :rib_info do
51
52
  write_cmd :license do
52
53
  elements :activate => :key
53
54
  end
54
- write_cmd :mod_global_settings do #TODO
55
- not_implemented
56
- end
57
- write_cmd :mod_network_settings do #TODO
58
- not_implemented
55
+ write_cmd :mod_global_settings do
56
+ elements :session_timeout, :f8_prompt_enabled, :http_port, :https_port, :remote_console_port, :min_password, :ilo_funct_enabled, :virtual_media_port, :f8_login_required, :enforce_aes, :authentication_failure_logging, :ssh_status, :ssh_port, :serial_cli_status, :serial_cli_speed, :rbsu_post_ip, :snmp_access_enabled, :snmp_port, :snmp_trap_port, :remote_syslog_enable, :remote_syslog_port, :remote_syslog_server_address, :alertmail_enable, :alertmail_email_address, :alertmail_sender_domain, :alertmail_smtp_server, :ipmi_dcmi_over_lan_enabled, :vsp_log_enable
57
+ end
58
+ write_cmd :mod_network_settings do
59
+ elements :enable_nic, :nic_speed, :full_duplex, :speed_autoselect, :ping_gateway,
60
+ :shared_network_port, :vlan_enabled, :vlan_id,
61
+ :dhcp_enable, :dhcp_domain_name, :dhcp_gateway, :dhcp_dns_server, :dhcp_wins_server, :dhcp_static_route, :dhcp_sntp_settings,
62
+ :ip_address, :subnet_mask, :gateway_ip_address, :dns_name, :domain_name,
63
+ :prim_dns_server, :sec_dns_server, :ter_dns_server, :reg_ddns_server,
64
+ :prim_wins_server, :sec_wins_server, :reg_wins_server,
65
+ :sntp_server1, :sntp_server2, :timezone,
66
+ :enclosure_ip_enable, :web_agent_ip_address
59
67
  end
60
68
  write_cmd :mod_snmp_im_settings do #TODO
61
69
  not_implemented
@@ -1,51 +1,95 @@
1
1
  context :server_info do
2
- read_cmd :get_embedded_health
3
- read_cmd :get_host_power_saver_status
4
- read_cmd :get_host_power_status
5
- read_cmd :get_host_pwr_micro_ver
6
- read_cmd :get_one_time_boot
7
- read_cmd :get_persistent_boot
8
- read_cmd :get_power_cap
9
- read_cmd :get_power_readings
10
- read_cmd :get_pwreg
11
- read_cmd :get_server_auto_pwr
12
- read_cmd :get_server_name
13
- read_cmd :get_server_power_on_time
14
- read_cmd :get_uid_status
2
+ read_cmd :get_tpm_status
15
3
 
16
- write_cmd :clear_server_power_on_time
17
- write_cmd :cold_boot_server
18
- write_cmd :hold_pwr_btn do
19
- attributes :toggle
4
+ read_cmd :get_current_boot_mode
5
+
6
+ read_cmd :get_pending_boot_mode
7
+ write_cmd :set_pending_boot_mode do
8
+ attributes :value
20
9
  end
21
- write_cmd :press_power_btn
22
- write_cmd :reset_server
23
- write_cmd :server_auto_pwr do
10
+
11
+ read_cmd :get_persistent_boot
12
+ write_cmd :set_persistent_boot do
13
+ elements :device => [ :value ]
14
+ end
15
+
16
+ read_cmd :get_one_time_boot
17
+ write_cmd :set_one_time_boot do
24
18
  attributes :value
25
19
  end
20
+
21
+ read_cmd :get_supported_boot_mode
22
+
23
+ read_cmd :get_server_name
26
24
  write_cmd :server_name do
27
25
  attributes :value
28
26
  end
29
- write_cmd :set_host_power do
30
- attributes :host_power
31
- end
32
- write_cmd :set_host_power_saver do
33
- attributes :host_power_saver
27
+
28
+ read_cmd :get_server_fqdn
29
+ write_cmd :server_fqdn do
30
+ attributes :value
34
31
  end
35
- write_cmd :set_one_time_boot do
32
+
33
+ read_cmd :get_smh_fqdn
34
+ write_cmd :smh_fqdn do
36
35
  attributes :value
37
36
  end
38
- write_cmd :set_persistent_boot do
39
- elements :device => [ :value ]
37
+
38
+ read_cmd :get_product_name
39
+
40
+ read_cmd :get_embedded_health
41
+
42
+ read_cmd :get_power_readings
43
+
44
+ read_cmd :get_pwreg
45
+ write_cmd :set_pwreg do
46
+ elements :pwralert => :type, :pwralert_settings => [:threshold, :duration]
40
47
  end
48
+
49
+ read_cmd :get_power_cap
41
50
  write_cmd :set_power_cap do
42
51
  attributes :power_cap
43
52
  end
44
- write_cmd :set_pwreg do
45
- elements :pwralert => :type, :pwralert_settings => [:threshold, :duration]
53
+
54
+ read_cmd :get_host_power_saver_status
55
+ write_cmd :set_host_power_saver do
56
+ attributes :host_power_saver
57
+ end
58
+
59
+ read_cmd :get_host_power_status
60
+ write_cmd :set_host_power do
61
+ attributes :host_power
62
+ end
63
+
64
+ read_cmd :get_host_pwr_micro_ver
65
+
66
+ write_cmd :reset_server
67
+
68
+ write_cmd :press_pwr_btn
69
+
70
+ write_cmd :hold_pwr_btn do
71
+ attributes :toggle
46
72
  end
73
+
74
+ write_cmd :cold_boot_server
75
+
76
+ write_cmd :warm_boot_server
77
+
78
+ read_cmd :get_server_auto_pwr
79
+ write_cmd :server_auto_pwr do
80
+ attributes :value
81
+ end
82
+
83
+ read_cmd :get_uid_status
47
84
  write_cmd :uid_control do
48
85
  attributes :uid
49
86
  end
50
- write_cmd :warm_boot_server
87
+
88
+ read_cmd :get_pers_mouse_keyboard_enabled
89
+ write_cmd :set_pers_mouse_keyboard_enabled do
90
+ attributes :value
91
+ end
92
+
93
+ read_cmd :get_server_power_on_time
94
+ write_cmd :clear_server_power_on_time
51
95
  end
@@ -1,19 +1,23 @@
1
1
  context :user_info do
2
- read_cmd :get_user do
3
- attributes :user_login
4
- end
5
- read_cmd :get_all_users
6
- read_cmd :get_all_user_info
7
-
8
2
  write_cmd :add_user do
9
3
  attributes :user_name, :user_login, :password
10
4
  elements :admin_priv, :remote_cons_priv, :reset_server_priv, :virtual_media_priv, :config_ilo_priv
11
5
  end
6
+
12
7
  write_cmd :delete_user do
13
8
  attributes :user_login
14
9
  end
10
+
11
+ read_cmd :get_user do
12
+ attributes :user_login
13
+ end
14
+
15
15
  write_cmd :mod_user do
16
16
  attributes :user_login
17
17
  elements :user_name, :user_login, :password, :admin_priv, :remote_cons_priv, :reset_server_priv, :virtual_media_priv, :config_ilo_priv, :del_users_ssh_key
18
18
  end
19
+
20
+ read_cmd :get_all_users
21
+
22
+ read_cmd :get_all_user_info
19
23
  end
data/lib/ilorb/ribcl.rb CHANGED
@@ -1,5 +1,9 @@
1
1
  class ILORb
2
2
  class RIBCL < Hash
3
+
4
+ class NotImplementedError < StandardError; end
5
+ class InvalidDefinitionError < StandardError; end
6
+
3
7
  def initialize
4
8
  super
5
9
  end
@@ -92,14 +96,6 @@ class ILORb
92
96
  map
93
97
  end
94
98
 
95
- def get_params
96
- params = []
97
- params += @attributes
98
- params << @text if @text
99
- params += map_elements.keys
100
- params
101
- end
102
-
103
99
  private
104
100
  # private methods are used by DSL
105
101
 
@@ -118,12 +114,16 @@ class ILORb
118
114
  end
119
115
  end
120
116
  @elements.merge!(hash)
117
+ else
118
+ raise InvalidDefinitionError, "no elements and text"
121
119
  end
122
120
  end
123
121
 
124
122
  def text(param)
125
123
  if @elements.empty?
126
124
  @text = param
125
+ else
126
+ raise InvalidDefinitionError, "no text and elements"
127
127
  end
128
128
  end
129
129
 
data/lib/ilorb/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class ILORb
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/ilorb.rb CHANGED
@@ -8,8 +8,6 @@ require 'ilorb/ribcl'
8
8
 
9
9
  class ILORb
10
10
 
11
- class NotImplemented < StandardError; end
12
-
13
11
  def initialize(config = {})
14
12
  @hostname = config[:hostname]
15
13
  @login = config[:login] || "Administrator"
@@ -32,48 +30,47 @@ class ILORb
32
30
  if @ribcl.has_command?(name)
33
31
  command = @ribcl.command(name)
34
32
 
35
- raise NotImplemented, "#{name} is not supported" unless command.supported?
33
+ raise RIBCL::NotImplementedError, "#{name} is not supported" unless command.supported?
34
+ @log.info("Calling method #{name}")
36
35
 
37
36
  params = args.first || {}
38
37
  attributes = {}
39
38
  element_map = nil
40
39
 
41
- #TODO check for text
42
-
43
40
  command.get_attributes.each do |attr|
44
41
  # Attributes are mandatory
45
42
  error("Attribute #{attr} missing in #{name} call") unless params.has_key?(attr)
46
43
  attributes.store(attr, @ribcl.encode(params.delete(attr)))
47
44
  end
48
45
 
49
- element_map = command.map_elements
46
+ if !command.get_elements.empty?
47
+ element_map = command.map_elements
50
48
 
51
- elements_array = []
52
-
53
- [ params ].flatten.each do |params_hash|
54
- elements = {}
55
- params_hash.each do |key, value|
56
- # Elements are not mandatory for now
57
- elements.store(key, @ribcl.encode(params_hash.delete(key))) if element_map.has_key?(key)
49
+ elements_array = [params].flatten.map do |params_hash|
50
+ Hash[params_hash.map{ |k,v| [ k, @ribcl.encode(params_hash.delete(k)) ] if element_map.has_key?(k) }.compact]
58
51
  end
59
- elements_array << elements
60
- end
61
52
 
62
- #TODO check for CDATA
63
-
64
- @log.info("Calling method #{name}")
65
- request = ribcl_request(command, attributes) do |xml|
66
- elements_array.each do |elements_hash|
67
- elements_hash.each do |key, value|
68
- elt = command.get_elements[element_map[key].first]
69
- if elt.is_a?(Array)
70
- attrs = Hash[elt.map{|x| [x, elements_hash.delete(element_map.invert[[element_map[key].first, x]])]}]
71
- else
72
- attrs = {element_map[key].last => value}
53
+ #TODO check for CDATA
54
+
55
+ request = ribcl_request(command, attributes) do |xml|
56
+ elements_array.each do |elements_hash|
57
+ elements_hash.each do |key, value|
58
+ elt = command.get_elements[element_map[key].first]
59
+ if elt.is_a?(Array)
60
+ attrs = Hash[elt.map{|x| [x, elements_hash.delete(element_map.invert[[element_map[key].first, x]])]}]
61
+ else
62
+ attrs = {element_map[key].last => value}
63
+ end
64
+ xml.send(element_map[key].first, attrs)
73
65
  end
74
- xml.send(element_map[key].first, attrs)
75
66
  end
76
67
  end
68
+ elsif !command.get_text.nil?
69
+ if text = params[command.get_text]
70
+ request = ribcl_request(command, text, attributes)
71
+ end
72
+ else
73
+ request = ribcl_request(command, attributes)
77
74
  end
78
75
 
79
76
  response = send_request(request)
@@ -93,6 +90,22 @@ class ILORb
93
90
 
94
91
  private
95
92
 
93
+ def ribcl_request(command, *args, &block)
94
+ builder = Nokogiri::XML::Builder.new do |xml|
95
+ xml.ribcl(:version => "2.0") {
96
+ xml.login(:password => @password, :user_login => @login) {
97
+ xml.send(command.context, :mode => command.mode) {
98
+ xml.send(command.name, *args) {
99
+ yield xml if block_given?
100
+ }
101
+ }
102
+ }
103
+ }
104
+ end
105
+
106
+ builder.to_xml
107
+ end
108
+
96
109
  def send_request(xml)
97
110
  case @protocol
98
111
  when :http
@@ -127,7 +140,7 @@ class ILORb
127
140
  sock = TCPSocket.new(@hostname, @port)
128
141
 
129
142
  ctx = OpenSSL::SSL::SSLContext.new(:TLSv1)
130
- ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE
143
+ ctx.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @verify_ssl
131
144
  ssl_sock = OpenSSL::SSL::SSLSocket.new(sock, ctx)
132
145
  ssl_sock.sync_close = true
133
146
 
@@ -178,22 +191,6 @@ class ILORb
178
191
  output
179
192
  end
180
193
 
181
- def ribcl_request(command, args = {}, &block)
182
- builder = Nokogiri::XML::Builder.new do |xml|
183
- xml.ribcl(:version => "2.0") {
184
- xml.login(:password => @password, :user_login => @login) {
185
- xml.send(command.context, :mode => command.mode) {
186
- xml.send(command.name, args) {
187
- yield xml if block_given?
188
- }
189
- }
190
- }
191
- }
192
- end
193
-
194
- builder.to_xml
195
- end
196
-
197
194
  def setup_commands
198
195
  @ribcl = ILORb::RIBCL.load(File.join(File.dirname(__FILE__), "ilorb/definitions", "*.rb"))
199
196
  nil
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ilorb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Amiez
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-02 00:00:00.000000000 Z
11
+ date: 2015-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: nori
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ">="
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '2'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ">="
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '2'
97
97
  description: HP ILO Ruby interface
98
98
  email:
99
99
  - jonathan.amiez@gmail.com
@@ -101,9 +101,12 @@ executables: []
101
101
  extensions: []
102
102
  extra_rdoc_files: []
103
103
  files:
104
+ - ".gitignore"
105
+ - ".ruby-gemset"
104
106
  - Gemfile
105
107
  - Gemfile.lock
106
108
  - README.md
109
+ - Rakefile
107
110
  - ilorb.gemspec
108
111
  - lib/ilorb.rb
109
112
  - lib/ilorb/definitions/rib.rb
@@ -135,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
138
  version: '0'
136
139
  requirements: []
137
140
  rubyforge_project:
138
- rubygems_version: 2.2.0
141
+ rubygems_version: 2.4.5
139
142
  signing_key:
140
143
  specification_version: 4
141
144
  summary: Configure and retrieve data from server's ILO management card