rbovirt 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rbovirt might be problematic. Click here for more details.

data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.12
1
+ 0.0.13
@@ -1,5 +1,10 @@
1
1
  module OVIRT
2
2
  class Client
3
+ def cluster_version(cluster_id)
4
+ c = cluster(cluster_id)
5
+ return c.version.split('.')[0].to_i, c.version.split('.')[1].to_i
6
+ end
7
+
3
8
  def cluster_version?(cluster_id, major)
4
9
  c = cluster(cluster_id)
5
10
  c.version.split('.')[0] == major
data/lib/client/vm_api.rb CHANGED
@@ -14,6 +14,22 @@ module OVIRT
14
14
  end
15
15
 
16
16
  def create_vm(opts)
17
+ cluster_major_ver, cluster_minor_ver = cluster_version(self.cluster_id)
18
+
19
+ if opts[:user_data] and not opts[:user_data].empty?
20
+ if api_version?('3') and cluster_major_ver >= 3
21
+ if cluster_minor_ver >= 1
22
+ opts[:user_data_method] = :payload
23
+ elsif floppy_hook?
24
+ opts[:user_data_method] = :custom_property
25
+ else
26
+ raise "Required VDSM hook 'floppyinject' not supported by RHEV-M"
27
+ end
28
+ else
29
+ raise BackendVersionUnsupportedException.new
30
+ end
31
+ end
32
+
17
33
  opts[:cluster_name] ||= clusters.first.name
18
34
  OVIRT::VM::new(self, http_post("/vms",OVIRT::VM.to_xml(opts)).root)
19
35
  end
@@ -75,4 +91,4 @@ module OVIRT
75
91
  OVIRT::VM::new(self, result_xml.root)
76
92
  end
77
93
  end
78
- end
94
+ end
@@ -1,6 +1,6 @@
1
1
  module OVIRT
2
2
  class Template < BaseObject
3
- attr_reader :description, :status, :cluster
3
+ attr_reader :description, :status, :cluster, :creation_time, :os, :storage, :display, :profile, :memory
4
4
 
5
5
  def initialize(client, xml)
6
6
  super(client, xml[:id], xml[:href], (xml/'name').first.text)
@@ -47,4 +47,4 @@ module OVIRT
47
47
  }
48
48
  end
49
49
  end
50
- end
50
+ end
data/lib/ovirt/vm.rb CHANGED
@@ -49,10 +49,14 @@ module OVIRT
49
49
  cluster_{ name_(opts[:cluster_name])}
50
50
  end
51
51
  type_ opts[:hwp_id] || 'Server'
52
- memory opts[:memory] ? opts[:memory].to_s : (512*1024*1024).to_s
53
- cpu {
54
- topology( :cores => (opts[:cores] || '1'), :sockets => '1' )
55
- }
52
+ if opts[:memory]
53
+ memory opts[:memory]
54
+ end
55
+ if opts[:cores]
56
+ cpu {
57
+ topology( :cores => (opts[:cores] || '1'), :sockets => '1' )
58
+ }
59
+ end
56
60
  os{
57
61
  boot(:dev=> opts[:boot_dev1] || 'network')
58
62
  boot(:dev=> opts[:boot_dev2] || 'hd')
@@ -65,7 +69,12 @@ module OVIRT
65
69
  :name => "floppyinject",
66
70
  :value => "#{opts[:fileinject_path] || OVIRT::FILEINJECT_PATH}:#{opts[:user_data]}",
67
71
  :regexp => "^([^:]+):(.*)$"})
68
- } if(opts[:user_data] && !opts[:user_data].empty?)
72
+ } if(opts[:user_data_method] && opts[:user_data_method] == :custom_property)
73
+ payloads {
74
+ payload(:type => 'floppy') {
75
+ file(:name => "#{opts[:fileinject_path] || OVIRT::FILEINJECT_PATH}") { content(Base64::decode64(opts[:user_data])) }
76
+ }
77
+ } if(opts[:user_data_method] && opts[:user_data_method] == :payload)
69
78
  }
70
79
  end
71
80
  Nokogiri::XML(builder.to_xml).root.to_s
@@ -85,6 +94,7 @@ module OVIRT
85
94
  :type => (xml/'display/type').first.text,
86
95
  :address => ((xml/'display/address').first.text rescue nil),
87
96
  :port => ((xml/'display/port').first.text rescue nil),
97
+ :secure_port => ((xml/'display/secure_port').first.text rescue nil),
88
98
  :monitors => (xml/'display/monitors').first.text
89
99
  }
90
100
  @cores = ((xml/'cpu/topology').first[:cores].to_i * (xml/'cpu/topology').first[:sockets].to_i rescue nil)
data/lib/rbovirt.rb CHANGED
@@ -53,6 +53,11 @@ module OVIRT
53
53
  api_version.split('.')[0] == major
54
54
  end
55
55
 
56
+ def floppy_hook?
57
+ xml = http_get("/capabilities")
58
+ !(xml/"version/custom_properties/custom_property[@name='floppyinject']").empty?
59
+ end
60
+
56
61
  private
57
62
  def current_datacenter
58
63
  @current_datacenter ||= self.datacenter_id ? datacenter(self.datacenter_id) : datacenters.first
@@ -146,4 +151,4 @@ module OVIRT
146
151
  object_class.new(@client, (xml.root))
147
152
  end
148
153
  end
149
- end
154
+ end
data/rbovirt.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "rbovirt"
8
- s.version = "0.0.12"
8
+ s.version = "0.0.13"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Amos Benari"]
metadata CHANGED
@@ -1,135 +1,136 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rbovirt
3
- version: !ruby/object:Gem::Version
4
- hash: 7
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.13
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 12
10
- version: 0.0.12
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Amos Benari
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2012-05-03 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
21
- type: :runtime
22
- requirement: &id001 !ruby/object:Gem::Requirement
23
- none: false
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- hash: 3
28
- segments:
29
- - 0
30
- version: "0"
31
- version_requirements: *id001
12
+ date: 2012-05-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
32
15
  name: nokogiri
33
- prerelease: false
34
- - !ruby/object:Gem::Dependency
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
35
22
  type: :runtime
36
- requirement: &id002 !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
37
25
  none: false
38
- requirements:
39
- - - ">="
40
- - !ruby/object:Gem::Version
41
- hash: 3
42
- segments:
43
- - 0
44
- version: "0"
45
- version_requirements: *id002
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
46
31
  name: rest-client
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
47
39
  prerelease: false
48
- - !ruby/object:Gem::Dependency
49
- type: :development
50
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
51
41
  none: false
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- hash: 3
56
- segments:
57
- - 0
58
- version: "0"
59
- version_requirements: *id003
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
60
47
  name: shoulda
61
- prerelease: false
62
- - !ruby/object:Gem::Dependency
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
63
54
  type: :development
64
- requirement: &id004 !ruby/object:Gem::Requirement
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: bundler
64
+ requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
- requirements:
66
+ requirements:
67
67
  - - ~>
68
- - !ruby/object:Gem::Version
69
- hash: 23
70
- segments:
71
- - 1
72
- - 0
73
- - 0
68
+ - !ruby/object:Gem::Version
74
69
  version: 1.0.0
75
- version_requirements: *id004
76
- name: bundler
77
- prerelease: false
78
- - !ruby/object:Gem::Dependency
79
70
  type: :development
80
- requirement: &id005 !ruby/object:Gem::Requirement
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
81
73
  none: false
82
- requirements:
74
+ requirements:
83
75
  - - ~>
84
- - !ruby/object:Gem::Version
85
- hash: 7
86
- segments:
87
- - 1
88
- - 6
89
- - 4
90
- version: 1.6.4
91
- version_requirements: *id005
76
+ - !ruby/object:Gem::Version
77
+ version: 1.0.0
78
+ - !ruby/object:Gem::Dependency
92
79
  name: jeweler
93
- prerelease: false
94
- - !ruby/object:Gem::Dependency
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ~>
84
+ - !ruby/object:Gem::Version
85
+ version: 1.6.4
95
86
  type: :development
96
- requirement: &id006 !ruby/object:Gem::Requirement
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
97
89
  none: false
98
- requirements:
99
- - - ">="
100
- - !ruby/object:Gem::Version
101
- hash: 3
102
- segments:
103
- - 0
104
- version: "0"
105
- version_requirements: *id006
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: 1.6.4
94
+ - !ruby/object:Gem::Dependency
106
95
  name: rcov
107
- prerelease: false
108
- - !ruby/object:Gem::Dependency
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
109
102
  type: :development
110
- requirement: &id007 !ruby/object:Gem::Requirement
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
111
105
  none: false
112
- requirements:
113
- - - ~>
114
- - !ruby/object:Gem::Version
115
- hash: 15
116
- segments:
117
- - 2
118
- - 6
119
- version: "2.6"
120
- version_requirements: *id007
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
121
111
  name: rspec-rails
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ~>
116
+ - !ruby/object:Gem::Version
117
+ version: '2.6'
118
+ type: :development
122
119
  prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ~>
124
+ - !ruby/object:Gem::Version
125
+ version: '2.6'
123
126
  description: A Ruby client for oVirt REST API
124
127
  email: abenari@redhat.com
125
128
  executables: []
126
-
127
129
  extensions: []
128
-
129
- extra_rdoc_files:
130
+ extra_rdoc_files:
130
131
  - LICENSE.txt
131
132
  - README.rdoc
132
- files:
133
+ files:
133
134
  - .document
134
135
  - Gemfile
135
136
  - LICENSE.txt
@@ -159,37 +160,28 @@ files:
159
160
  - spec/spec_helper.rb
160
161
  - spec/unit/vm_spec.rb
161
162
  homepage: http://github.com/abenari/rbovirt
162
- licenses:
163
+ licenses:
163
164
  - MIT
164
165
  post_install_message:
165
166
  rdoc_options: []
166
-
167
- require_paths:
167
+ require_paths:
168
168
  - lib
169
- required_ruby_version: !ruby/object:Gem::Requirement
169
+ required_ruby_version: !ruby/object:Gem::Requirement
170
170
  none: false
171
- requirements:
172
- - - ">="
173
- - !ruby/object:Gem::Version
174
- hash: 3
175
- segments:
176
- - 0
177
- version: "0"
178
- required_rubygems_version: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ required_rubygems_version: !ruby/object:Gem::Requirement
179
176
  none: false
180
- requirements:
181
- - - ">="
182
- - !ruby/object:Gem::Version
183
- hash: 3
184
- segments:
185
- - 0
186
- version: "0"
177
+ requirements:
178
+ - - ! '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
187
181
  requirements: []
188
-
189
182
  rubyforge_project:
190
- rubygems_version: 1.8.24
183
+ rubygems_version: 1.8.23
191
184
  signing_key:
192
185
  specification_version: 3
193
186
  summary: A Ruby client for oVirt REST API
194
187
  test_files: []
195
-