opennebula 3.9.90.rc → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/lib/opennebula.rb CHANGED
@@ -54,5 +54,5 @@ require 'opennebula/system'
54
54
  module OpenNebula
55
55
 
56
56
  # OpenNebula version
57
- VERSION = '3.9.90'
57
+ VERSION = '4.0.0'
58
58
  end
@@ -69,7 +69,7 @@ module OpenNebula
69
69
 
70
70
  # Constructor
71
71
  #
72
- # @param xml [String] must be an xml built with {#build_xml}
72
+ # @param xml [String] must be an xml built with {.build_xml}
73
73
  # @param client [Client] represents an XML-RPC connection
74
74
  def initialize(xml, client)
75
75
  super(xml,client)
@@ -79,7 +79,6 @@ module OpenNebula
79
79
  # specified.
80
80
  #
81
81
  # @param pe_id [Integer] rule ID
82
- # @param client [Client] represents an XML-RPC connection
83
82
  #
84
83
  # @return [String] an empty XML representation
85
84
  def self.build_xml(pe_id=nil)
@@ -33,7 +33,7 @@ module OpenNebula
33
33
  :monitoring => "host.monitoring"
34
34
  }
35
35
 
36
- HOST_STATES=%w{INIT MONITORING_MONITORED MONITORED ERROR DISABLED MONITORING_ERROR}
36
+ HOST_STATES=%w{INIT MONITORING_MONITORED MONITORED ERROR DISABLED MONITORING_ERROR MONITORING_INIT MONITORING_DISABLED}
37
37
 
38
38
  SHORT_HOST_STATES={
39
39
  "INIT" => "init",
@@ -42,6 +42,8 @@ module OpenNebula
42
42
  "ERROR" => "err",
43
43
  "DISABLED" => "off",
44
44
  "MONITORING_ERROR" => "retry",
45
+ "MONITORING_INIT" => "init",
46
+ "MONITORING_DISABLED" => "off"
45
47
  }
46
48
 
47
49
  # Creates a Host description with just its identifier
@@ -85,7 +87,7 @@ module OpenNebula
85
87
  # @param hostname [String] Name of the new Host.
86
88
  # @param im [String] Name of the im_driver (information/monitoring)
87
89
  # @param vmm [String] Name of the vmm_driver (hypervisor)
88
- # @param tm [String] Name of the vnm_driver (networking)
90
+ # @param vnm [String] Name of the vnm_driver (networking)
89
91
  # @param cluster_id [String] Id of the cluster
90
92
  #
91
93
  # @return [Integer, OpenNebula::Error] the new ID in case of
@@ -29,6 +29,7 @@ class OpenNebula::LdapAuth
29
29
  :base => nil,
30
30
  :auth_method => :simple,
31
31
  :user_field => 'cn',
32
+ :user_group_field => 'dn',
32
33
  :group_field => 'member'
33
34
  }.merge(options)
34
35
 
@@ -56,24 +57,25 @@ class OpenNebula::LdapAuth
56
57
  :filter => "#{@options[:user_field]}=#{name}")
57
58
 
58
59
  if result && result.first
59
- result.first.dn
60
+ [result.first.dn, result.first[@options[:user_group_field]]]
60
61
  else
61
62
  result=@ldap.search(:base => name)
62
63
 
63
64
  if result && result.first
64
- name
65
+ [name, result.first[@options[:user_group_field]]]
65
66
  else
66
- nil
67
+ [nil, nil]
67
68
  end
68
69
  end
69
70
  rescue
70
- nil
71
+ [nil, nil]
71
72
  end
72
73
  end
73
74
 
74
75
  def is_in_group?(user, group)
75
- result=@ldap.search(:base => group,
76
- :filter => "(#{@options[:group_field]}=#{user})")
76
+ result=@ldap.search(
77
+ :base => group,
78
+ :filter => "(#{@options[:group_field]}=#{user.first})")
77
79
 
78
80
  if result && result.first
79
81
  true
@@ -29,17 +29,21 @@ describe LdapAuth do
29
29
  end
30
30
 
31
31
  it 'should find user dn' do
32
- name=@ldap.find_user('user01')
32
+ name,group_name=@ldap.find_user('user01')
33
33
  name.should=='cn=user01,dc=localdomain'
34
+ group_name.should=='cn=user01,dc=localdomain'
34
35
 
35
- name=@ldap.find_user('user02')
36
+ name,group_name=@ldap.find_user('user02')
36
37
  name.should=='cn=user02,dc=localdomain'
38
+ group_name.should=='cn=user02,dc=localdomain'
37
39
 
38
- name=@ldap.find_user('user03')
40
+ name,group_name=@ldap.find_user('user03')
39
41
  name.should==nil
42
+ group_name.should==nil
40
43
 
41
44
  name=@ldap.find_user('cn=user01,dc=localdomain')
42
45
  name.should=='cn=user01,dc=localdomain'
46
+ group_name.should=='cn=user01,dc=localdomain'
43
47
  end
44
48
 
45
49
  it 'should tell if a user is in a group' do
@@ -62,7 +62,6 @@ module OpenNebula
62
62
  #
63
63
  # @param [String] xml_method the name of the XML-RPC method
64
64
  # @param [String] root_element Base XML element name
65
- # @param [Array] args additional arguments
66
65
  #
67
66
  # @return [nil, OpenNebula::Error] nil in case of success, Error
68
67
  # otherwise
@@ -243,9 +242,8 @@ module OpenNebula
243
242
  # @param [String] root_elem Root for each individual PoolElement
244
243
  # @param [String] timestamp_elem Name of the XML element with the last
245
244
  # monitorization timestamp
246
- # @param [Integer] Id of the object to process
245
+ # @param [Integer] oid Id of the object to process
247
246
  # @param [Array<String>] xpath_expressions Elements to retrieve.
248
- # @param args arguemnts for the xml_method call
249
247
  #
250
248
  # @return [Hash<String, Array<Array<int>>, OpenNebula::Error] Hash with
251
249
  # the requested xpath expressions, and an Array of [timestamp, value].
@@ -37,29 +37,33 @@ class OpenNebula::SshAuth
37
37
  @private_key = nil
38
38
  @public_key = nil
39
39
 
40
+ # Initialize the private key
40
41
  if options[:private_key]
41
42
  begin
42
43
  @private_key = File.read(options[:private_key])
43
44
  rescue Exception => e
44
45
  raise "Cannot read #{options[:private_key]}"
45
46
  end
47
+
48
+ @private_key_rsa = OpenSSL::PKey::RSA.new(@private_key)
46
49
  end
47
50
 
51
+ # Initialize the public key
48
52
  if options[:public_key]
49
53
  @public_key = options[:public_key]
50
54
  elsif @private_key != nil
51
55
  # Init ssh keys using private key. public key is extracted in a
52
56
  # format compatible with openssl. The public key does not contain
53
- # "---- BEGIN/END RSA PUBLIC KEY ----" and is in a single line
54
- key = OpenSSL::PKey::RSA.new(@private_key)
55
-
56
- @public_key = key.public_key.to_pem.split("\n")
57
- @public_key = @public_key.reject {|l| l.match(/RSA PUBLIC KEY/) }.join('')
57
+ # "---- BEGIN/END PUBLIC KEY ----" and is in a single line
58
+ @public_key = @private_key_rsa.public_key.to_pem.split("\n")
59
+ @public_key = @public_key.reject {|l| l.match(/PUBLIC KEY/) }.join('')
58
60
  end
59
61
 
60
62
  if @private_key.nil? && @public_key.nil?
61
63
  raise "You have to define at least one of the keys"
62
64
  end
65
+
66
+ @public_key_rsa = OpenSSL::PKey::RSA.new(Base64::decode64(@public_key))
63
67
  end
64
68
 
65
69
  # Creates the login file for ssh authentication at ~/.one/one_ssh.
@@ -89,7 +93,7 @@ class OpenNebula::SshAuth
89
93
  file.close
90
94
 
91
95
  File.chmod(0600,LOGIN_PATH)
92
-
96
+
93
97
  secret_crypted
94
98
  end
95
99
 
@@ -127,13 +131,11 @@ class OpenNebula::SshAuth
127
131
  # Encrypts data with the private key of the user and returns
128
132
  # base 64 encoded output in a single line
129
133
  def encrypt(data)
130
- rsa=OpenSSL::PKey::RSA.new(@private_key)
131
- Base64::encode64(rsa.private_encrypt(data)).gsub!(/\n/, '').strip
134
+ Base64::encode64(@private_key_rsa.private_encrypt(data)).gsub!(/\n/, '').strip
132
135
  end
133
136
 
134
137
  # Decrypts base 64 encoded data with pub_key (public key)
135
138
  def decrypt(data)
136
- rsa=OpenSSL::PKey::RSA.new(Base64::decode64(@public_key))
137
- rsa.public_decrypt(Base64::decode64(data))
139
+ @public_key_rsa.public_decrypt(Base64::decode64(data))
138
140
  end
139
141
  end
@@ -306,7 +306,7 @@ module OpenNebula
306
306
 
307
307
  # Detaches a NIC from a running VM
308
308
  #
309
- # @param disk_id [Integer] Id of the NIC to be detached
309
+ # @param nic_id [Integer] Id of the NIC to be detached
310
310
  # @return [nil, OpenNebula::Error] nil in case of success, Error
311
311
  # otherwise
312
312
  def nic_detach(nic_id)
metadata CHANGED
@@ -1,54 +1,59 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: opennebula
3
- version: !ruby/object:Gem::Version
4
- version: 3.9.90.rc
5
- prerelease: 7
3
+ version: !ruby/object:Gem::Version
4
+ hash: 63
5
+ prerelease:
6
+ segments:
7
+ - 4
8
+ - 0
9
+ - 0
10
+ version: 4.0.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - OpenNebula
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2013-04-19 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2013-05-07 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: nokogiri
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: json
32
- requirement: !ruby/object:Gem::Requirement
23
+ requirement: &id001 !ruby/object:Gem::Requirement
33
24
  none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
38
32
  type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: json
39
36
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
37
+ requirement: &id002 !ruby/object:Gem::Requirement
41
38
  none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
46
+ type: :runtime
47
+ version_requirements: *id002
46
48
  description: Libraries needed to talk to OpenNebula
47
49
  email: contact@opennebula.org
48
50
  executables: []
51
+
49
52
  extensions: []
53
+
50
54
  extra_rdoc_files: []
51
- files:
55
+
56
+ files:
52
57
  - lib/opennebula.rb
53
58
  - lib/opennebula/acl.rb
54
59
  - lib/opennebula/acl_pool.rb
@@ -92,27 +97,36 @@ files:
92
97
  - LICENSE
93
98
  homepage: http://opennebula.org
94
99
  licenses: []
100
+
95
101
  post_install_message:
96
102
  rdoc_options: []
97
- require_paths:
103
+
104
+ require_paths:
98
105
  - lib
99
- required_ruby_version: !ruby/object:Gem::Requirement
106
+ required_ruby_version: !ruby/object:Gem::Requirement
100
107
  none: false
101
- requirements:
102
- - - ! '>='
103
- - !ruby/object:Gem::Version
104
- version: '0'
105
- required_rubygems_version: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - ">="
110
+ - !ruby/object:Gem::Version
111
+ hash: 3
112
+ segments:
113
+ - 0
114
+ version: "0"
115
+ required_rubygems_version: !ruby/object:Gem::Requirement
106
116
  none: false
107
- requirements:
108
- - - ! '>'
109
- - !ruby/object:Gem::Version
110
- version: 1.3.1
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ hash: 3
121
+ segments:
122
+ - 0
123
+ version: "0"
111
124
  requirements: []
125
+
112
126
  rubyforge_project:
113
127
  rubygems_version: 1.8.25
114
128
  signing_key:
115
129
  specification_version: 3
116
130
  summary: OpenNebula Client API
117
131
  test_files: []
118
- has_rdoc:
132
+