vagrant-ovirt4 1.1.0 → 1.2.0

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: 06efacb9cd5bc8d26e60779d35eb749df58e67c7
4
- data.tar.gz: f4af437a4d0a5271517ab889a2778a8ef48bce23
3
+ metadata.gz: a27827fdc957c72739e7370205f87421bdc11bb2
4
+ data.tar.gz: 696f0b8fa78127ca5ff3822b3f5ed1308118c9d8
5
5
  SHA512:
6
- metadata.gz: 450e1eaca5c4508127c18951ffe237b52991f4a0b3b85e833294d95ae4c04b3452b616442a13cf9008f1e35ffd0bcfff4f70faa100250e04043883b638fcb8cd
7
- data.tar.gz: 99aff87c777092ca05e9fd4d5dbd31a4b0529dcf833214294c879b467c915c139767b5a2a517c63c1b0754fc046c562ef24d84f7bcc80e18e05256ef2e6f0dd2
6
+ metadata.gz: cec6cf0493c478586ae46a5d4206908763e5ad1689b511afce420216f25e5eaf712f2d94b471bd7bdc5c35806f77da6a296fe4ae4ea9ac71675bd99241c07bb4
7
+ data.tar.gz: 7a03e6879022c4f263c46e42ae2accc102726830d7b5349159e7f30d32ada547c03188ea06757c347efac169cd144f7242f7aabb0b6d66a177fc7a32f416ac86
data/.gitignore CHANGED
@@ -5,3 +5,5 @@
5
5
  .vagrant
6
6
  /.idea
7
7
  *.gem
8
+ /manifests
9
+ hiera.yaml
data/Gemfile CHANGED
@@ -1,9 +1,7 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
1
+ source 'http://rubygems.org'
4
2
 
5
3
  group :development do
6
- #gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git'
4
+ gem 'vagrant', :git => 'git://github.com/mitchellh/vagrant.git'
7
5
  gem 'pry'
8
6
  gem 'byebug'
9
7
  gem 'pry-byebug'
@@ -16,5 +14,5 @@ group :testing do
16
14
  end
17
15
 
18
16
  group :plugins do
19
- #gem 'vagrant-ovirt4', :path => '.'
17
+ gem 'vagrant-ovirt4', :path => '.'
20
18
  end
@@ -1,17 +1,81 @@
1
+ GIT
2
+ remote: git://github.com/mitchellh/vagrant.git
3
+ revision: b223380c86680a0a22caa7c288055411faa4a072
4
+ specs:
5
+ vagrant (1.9.2.dev)
6
+ childprocess (~> 0.5.0)
7
+ erubis (~> 2.7.0)
8
+ hashicorp-checkpoint (~> 0.1.1)
9
+ i18n (>= 0.6.0, <= 0.8.0)
10
+ listen (~> 3.1.5)
11
+ log4r (~> 1.1.9, < 1.1.11)
12
+ net-scp (~> 1.1.0)
13
+ net-sftp (~> 2.1)
14
+ net-ssh (~> 3.0.1)
15
+ nokogiri (= 1.6.7.1)
16
+ rb-kqueue (~> 0.2.0)
17
+ rest-client (>= 1.6.0, < 3.0)
18
+ ruby_dep (<= 1.3.1)
19
+ wdm (~> 0.1.0)
20
+ winrm (~> 2.1)
21
+ winrm-elevated (~> 1.1)
22
+ winrm-fs (~> 1.0)
23
+
1
24
  PATH
2
25
  remote: .
3
26
  specs:
4
- vagrant-ovirt4 (1.0.2)
27
+ vagrant-ovirt4 (1.1.0)
28
+ filesize (~> 0)
5
29
  ovirt-engine-sdk (~> 4.0, >= 4.0.6)
6
30
 
7
31
  GEM
8
- remote: https://rubygems.org/
32
+ remote: http://rubygems.org/
9
33
  specs:
34
+ builder (3.2.3)
10
35
  byebug (9.0.6)
36
+ childprocess (0.5.9)
37
+ ffi (~> 1.0, >= 1.0.11)
11
38
  coderay (1.1.1)
12
39
  diff-lcs (1.3)
40
+ domain_name (0.5.20161129)
41
+ unf (>= 0.0.5, < 1.0.0)
42
+ erubis (2.7.0)
43
+ ffi (1.9.17)
44
+ filesize (0.1.1)
45
+ gssapi (1.2.0)
46
+ ffi (>= 1.0.1)
47
+ gyoku (1.3.1)
48
+ builder (>= 2.1.2)
49
+ hashicorp-checkpoint (0.1.4)
50
+ http-cookie (1.0.3)
51
+ domain_name (~> 0.5)
52
+ httpclient (2.8.3)
53
+ i18n (0.8.0)
13
54
  json (2.0.3)
55
+ listen (3.1.5)
56
+ rb-fsevent (~> 0.9, >= 0.9.4)
57
+ rb-inotify (~> 0.9, >= 0.9.7)
58
+ ruby_dep (~> 1.2)
59
+ little-plugger (1.1.4)
60
+ log4r (1.1.10)
61
+ logging (2.1.0)
62
+ little-plugger (~> 1.1)
63
+ multi_json (~> 1.10)
14
64
  method_source (0.8.2)
65
+ mime-types (3.1)
66
+ mime-types-data (~> 3.2015)
67
+ mime-types-data (3.2016.0521)
68
+ mini_portile2 (2.0.0)
69
+ multi_json (1.12.1)
70
+ net-scp (1.1.2)
71
+ net-ssh (>= 2.6.5)
72
+ net-sftp (2.1.2)
73
+ net-ssh (>= 2.6.5)
74
+ net-ssh (3.0.2)
75
+ netrc (0.11.0)
76
+ nokogiri (1.6.7.1)
77
+ mini_portile2 (~> 2.0.0.rc2)
78
+ nori (2.6.0)
15
79
  ovirt-engine-sdk (4.1.2)
16
80
  json
17
81
  pry (0.10.4)
@@ -22,6 +86,15 @@ GEM
22
86
  byebug (~> 9.0)
23
87
  pry (~> 0.10)
24
88
  rake (0.9.6)
89
+ rb-fsevent (0.9.8)
90
+ rb-inotify (0.9.8)
91
+ ffi (>= 0.5.0)
92
+ rb-kqueue (0.2.4)
93
+ ffi (>= 0.5.0)
94
+ rest-client (2.0.0)
95
+ http-cookie (>= 1.0.2, < 2.0)
96
+ mime-types (>= 1.16, < 4.0)
97
+ netrc (~> 0.8)
25
98
  rspec (3.5.0)
26
99
  rspec-core (~> 3.5.0)
27
100
  rspec-expectations (~> 3.5.0)
@@ -38,7 +111,31 @@ GEM
38
111
  diff-lcs (>= 1.2.0, < 2.0)
39
112
  rspec-support (~> 3.5.0)
40
113
  rspec-support (3.5.0)
114
+ ruby_dep (1.3.1)
115
+ rubyntlm (0.6.1)
116
+ rubyzip (1.2.1)
41
117
  slop (3.6.0)
118
+ unf (0.1.4)
119
+ unf_ext
120
+ unf_ext (0.0.7.2)
121
+ wdm (0.1.1)
122
+ winrm (2.1.2)
123
+ builder (>= 2.1.2)
124
+ erubis (~> 2.7)
125
+ gssapi (~> 1.2)
126
+ gyoku (~> 1.0)
127
+ httpclient (~> 2.2, >= 2.2.0.2)
128
+ logging (>= 1.6.1, < 3.0)
129
+ nori (~> 2.0)
130
+ rubyntlm (~> 0.6.0, >= 0.6.1)
131
+ winrm-elevated (1.1.0)
132
+ winrm (~> 2.0)
133
+ winrm-fs (~> 1.0)
134
+ winrm-fs (1.0.1)
135
+ erubis (~> 2.7)
136
+ logging (>= 1.6.1, < 3.0)
137
+ rubyzip (~> 1.1)
138
+ winrm (~> 2.0)
42
139
 
43
140
  PLATFORMS
44
141
  ruby
@@ -50,6 +147,7 @@ DEPENDENCIES
50
147
  rake
51
148
  rspec
52
149
  rspec-its
150
+ vagrant!
53
151
  vagrant-ovirt4!
54
152
 
55
153
  BUNDLED WITH
data/README.md CHANGED
@@ -60,8 +60,9 @@ Vagrant.configure("2") do |config|
60
60
  config.vm.box_url = 'https://github.com/myoung34/vagrant-ovirt4/blob/master/example_box/dummy.box?raw=true'
61
61
 
62
62
  config.vm.network :private_network,
63
- :ip => '192.168.56.100', :nictype => 'virtio', :netmask => '255.255.255.0', #normal network configuration
64
- :ovirt__ip => '192.168.2.198', :ovirt__network_name => 'ovirtmgmt', :ovirt__gateway => '192.168.2.125' # oVirt specific information, overwrites previous on oVirt provider
63
+ :ovirt__network_name => 'ovirtmgmt' #DHCP
64
+ # Static configuration
65
+ #:ovirt__ip => '192.168.2.198', :ovirt__network_name => 'ovirtmgmt', :ovirt__gateway => '192.168.2.125', :ovirt__netmask => '255.255.0.0', :ovirt__dns_servers => '192.168.2.1', :ovirt__dns_search => 'test.local'
65
66
 
66
67
  config.vm.provider :ovirt4 do |ovirt|
67
68
  ovirt.url = 'https://server/ovirt-engine/api'
@@ -72,8 +73,8 @@ Vagrant.configure("2") do |config|
72
73
  ovirt.cluster = 'Default'
73
74
  ovirt.template = 'Vagrant-Centos7-test'
74
75
  ovirt.console = 'vnc'
75
- ovirt.memory_size = 512 #MB
76
- ovirt.memory_guaranteed = 256 #MB
76
+ ovirt.memory_size = '1 GiB' #see https://github.com/dominikh/filesize for usage
77
+ ovirt.memory_guaranteed = '256 MB' #see https://github.com/dominikh/filesize for usage
77
78
  ovirt.cpu_cores = 2
78
79
  ovirt.cpu_sockets = 2
79
80
  ovirt.cpu_threads = 2
@@ -107,17 +108,17 @@ end
107
108
  1. `insecure` => Allow connecting to SSL sites without certificates. Optional. Bool. Default is `false`
108
109
  1. `debug` => Turn on additional log statements. Optional. Bool. Default is `false`.
109
110
  1. `datacenter` => The name of the ovirt datacenter to create within. Required. String. No Default value.
110
- a. Note: (TODO) [Unknown usage](https://github.com/myoung34/vagrant-ovirt4/issues/26)
111
111
  1. `template` => The name of the template to use for creation. Required. String. No Default value.
112
112
  1. `cluster` => The name of the ovirt cluster to create within. Required. String. No Default value.
113
113
  1. `console` => The type of remote viewing protocol to use. Required. String. No Default value.
114
- a. Note: (TODO) Enforce this to be Spice, VNC, and RDP
115
114
  1. `memory_size` => The physical size of the memory for the VM (in MB). Defaults to `256`
116
115
  1. `memory_guaranteed` => The guaranteed size of the memory for the VM (in MB). Note: cannot be larger than `memory_size`. Defaults to `memory_size`
117
116
  1. `cpu_cores` => The number of CPU cores. Defaults to `1`
118
117
  1. `cpu_sockets` => The number of CPU cores. Defaults to `1`
119
118
  1. `cpu_threads` => The number of CPU threads. Defaults to `1`
120
119
  1. `cloud_init` => The cloud-init data to pass. Must be properly formatted as yaml. [Docs here](http://cloudinit.readthedocs.io/en/latest/topics/examples.html)
120
+ 1. `affinity` => The affinity to use. [See this for possible uses](http://www.rubydoc.info/gems/ovirt-engine-sdk/OvirtSDK4/VmAffinity). Optional. Invalid will cause a `RuntimeError`
121
+ 1. `placement_host` => The host to start the VM on. Optional.
121
122
 
122
123
 
123
124
  ## Contributing
@@ -127,7 +128,3 @@ end
127
128
  3. Commit your changes (`git commit -am 'Add some feature'`)
128
129
  4. Push to the branch (`git push origin my-new-feature`)
129
130
  5. Create new Pull Request
130
-
131
- ## Contributing Notes
132
-
133
- 1. You must comment out `gemspec` in the [Gemfile](Gemfile), uncomment `vagrant` and `plugins/vagrant-ovirt4` in order for `bundle install` to work and use live code. Not sure why. Too lazy to figure it out.
@@ -16,35 +16,57 @@ module VagrantPlugins
16
16
 
17
17
  def call(env)
18
18
 
19
- iface = "nic1"
20
19
  iface_options = nil
20
+ config = env[:machine].provider_config
21
21
  env[:machine].config.vm.networks.each do |config|
22
22
  type, options = config
23
- # We support private and public networks only. They mean both the
24
- # same right now.
23
+ # We support private networks only. They mean both the same right now.
25
24
  next unless [:private_network].include? type
26
25
 
27
26
  iface_options = scoped_hash_override(options, :ovirt)
28
27
  end
29
28
 
30
- profiles_service = env[:connection].system_service.vnic_profiles_service
31
- network_profile_id = profiles_service.list.map { |p| p.id if p.name == iface_options[:network_name] }.first
32
- raise Errors::NoNetworkError, :network_name => iface_options[:network_name] if network_profile_id.nil?
33
-
34
- @logger.info("Creating network interface #{iface}")
35
29
  begin
36
30
  nics_service = env[:vms_service].vm_service(env[:machine].id).nics_service
37
- nics_service.add(
38
- OvirtSDK4::Nic.new(
39
- name: iface,
40
- vnic_profile: {
41
- id: network_profile_id
42
- }
31
+ if iface_options.nil?
32
+ # throw an error if they didn't provide any sort of information on interfaces _and_ the VM has none
33
+ raise Errors::NoNetworkError if nics_service.list.count == 0
34
+ else
35
+ # provided a network block of some sort. Search oVirt for the corresponding network_profile_ids
36
+ @logger.info("Finding network #{iface_options[:network_name]} for given cluster #{config.cluster}")
37
+ clusters_service = env[:connection].system_service.clusters_service
38
+ cluster = clusters_service.list(search: "name=#{config.cluster}").first
39
+ profiles_service = env[:connection].system_service.vnic_profiles_service
40
+ network_profile_ids = profiles_service.list.map do |profile|
41
+ if env[:connection].follow_link(profile.network).data_center.id == cluster.data_center.id and
42
+ profile.name == iface_options[:network_name]
43
+ profile.id
44
+ end
45
+ end
46
+ network_profile_id = network_profile_ids.compact.first
47
+ # error if they provided a 'network name' but it could not be located in the previous search
48
+ raise Errors::NetworkNotFoundError, :network_name => iface_options[:network_name] if network_profile_id.nil? and !iface_options[:network_name].nil?
49
+
50
+ # quick and dirty way to look for a 'nic#' that is not already attached to the machine
51
+ iface = (("nic1".."nic8").flat_map { |x| x } - env[:vms_service].vm_service(env[:machine].id).nics_service.list.map(&:name)).first rescue "vagrant_nic1"
52
+ @logger.info("Creating network interface #{iface}")
53
+ nics_service.add(
54
+ OvirtSDK4::Nic.new(
55
+ name: iface,
56
+ vnic_profile: {
57
+ id: network_profile_id
58
+ }
59
+ )
43
60
  )
44
- )
61
+ end
45
62
  rescue => e
46
- raise Errors::AddInterfaceError,
47
- :error_message => e.message
63
+ if config.debug
64
+ raise e
65
+ else
66
+ fault_message = /Fault detail is \"\[?(.+?)\]?\".*/.match(e.message)[1] rescue e.message
67
+ raise Errors::AddInterfaceError,
68
+ :error_message => fault_message
69
+ end
48
70
  end
49
71
 
50
72
  # Continue the middleware chain.
@@ -20,16 +20,15 @@ module VagrantPlugins
20
20
  hostname = 'vagrant' if hostname.nil?
21
21
 
22
22
  # Output the settings we're going to use to the user
23
- memory_size = config.memory_size*1024*1024
24
- memory_guaranteed = config.memory_guaranteed*1024*1024
25
23
  env[:ui].info(I18n.t("vagrant_ovirt4.creating_vm"))
26
24
  env[:ui].info(" -- Name: #{hostname}")
27
25
  env[:ui].info(" -- Cluster: #{config.cluster}")
28
26
  env[:ui].info(" -- Template: #{config.template}")
29
27
  env[:ui].info(" -- Console Type: #{config.console}")
30
28
  env[:ui].info(" -- Memory: ")
31
- env[:ui].info(" ---- Memory: #{config.memory_size}")
32
- env[:ui].info(" ---- Guaranteed: #{config.memory_guaranteed}")
29
+ env[:ui].info(" ---- Memory: #{Filesize.from("#{config.memory_size} B").to_f('MB').to_i} MB")
30
+ env[:ui].info(" ---- Maximum: #{Filesize.from("#{config.memory_maximum} B").to_f('MB').to_i} MB")
31
+ env[:ui].info(" ---- Guaranteed: #{Filesize.from("#{config.memory_guaranteed} B").to_f('MB').to_i} MB")
33
32
  env[:ui].info(" -- Cpu: ")
34
33
  env[:ui].info(" ---- Cores: #{config.cpu_cores}")
35
34
  env[:ui].info(" ---- Sockets: #{config.cpu_sockets}")
@@ -47,11 +46,12 @@ module VagrantPlugins
47
46
  :threads => config.cpu_threads,
48
47
  },
49
48
  },
50
- :memory => memory_size,
51
- :memory_policy => {
52
- :ballooning => true,
53
- :guaranteed => memory_guaranteed,
54
- },
49
+ :memory_policy => OvirtSDK4::MemoryPolicy.new(
50
+ ballooning: true,
51
+ guaranteed: config.memory_guaranteed,
52
+ max: config.memory_maximum,
53
+ ),
54
+ :memory => config.memory_size,
55
55
  :cluster => {
56
56
  :name => config.cluster,
57
57
  },
@@ -66,9 +66,13 @@ module VagrantPlugins
66
66
  begin
67
67
  server = env[:vms_service].add(attr)
68
68
  rescue OvirtSDK4::Error => e
69
- fault_message = /Fault detail is \"\[?(.+?)\]?\".*/.match(e.message)[1] rescue e.message
70
- raise Errors::CreateVMError,
71
- :error_message => fault_message
69
+ if config.debug
70
+ raise e
71
+ else
72
+ fault_message = /Fault detail is \"\[?(.+?)\]?\".*/.match(e.message)[1] rescue e.message
73
+ raise Errors::CreateVMError,
74
+ :error_message => fault_message
75
+ end
72
76
  end
73
77
 
74
78
  # Immediately save the ID since it is created at this point.
@@ -15,6 +15,8 @@ module VagrantPlugins
15
15
  end
16
16
 
17
17
  def call(env)
18
+ config = env[:machine].provider_config
19
+
18
20
  env[:ui].info(I18n.t("vagrant_ovirt4.starting_vm"))
19
21
 
20
22
  machine = env[:vms_service].vm_service(env[:machine].id)
@@ -35,37 +37,63 @@ module VagrantPlugins
35
37
  hostname = 'vagrant' if hostname.nil?
36
38
 
37
39
  nic_configuration = nil
38
- if iface_options[:ip] then
39
- nic_configuration = {
40
- name: 'eth0',
41
- on_boot: true,
42
- boot_protocol: OvirtSDK4::BootProtocol::STATIC,
43
- ip: {
44
- version: OvirtSDK4::IpVersion::V4,
45
- address: iface_options[:ip],
46
- gateway: iface_options[:gateway],
40
+ unless iface_options.nil?
41
+ if iface_options[:ip] then
42
+ nic_configuration = {
43
+ name: 'eth0',
44
+ on_boot: true,
45
+ boot_protocol: OvirtSDK4::BootProtocol::STATIC,
46
+ ip: {
47
+ version: OvirtSDK4::IpVersion::V4,
48
+ address: iface_options[:ip],
49
+ gateway: iface_options[:gateway],
50
+ netmask: iface_options[:netmask],
51
+ }
47
52
  }
48
- }
49
- else
50
- nic_configuration = {
51
- name: 'eth0',
52
- on_boot: true,
53
- boot_protocol: OvirtSDK4::BootProtocol::DYNAMIC,
54
- }
55
- end
53
+ else
54
+ nic_configuration = {
55
+ name: 'eth0',
56
+ on_boot: true,
57
+ boot_protocol: OvirtSDK4::BootProtocol::DHCP,
58
+ }
59
+ end
56
60
 
57
- vm_configuration = {
58
- initialization: {
61
+ initialization = {
59
62
  host_name: hostname,
60
63
  nic_configurations: [nic_configuration],
61
- custom_script: env[:machine].provider_config.cloud_init,
64
+ custom_script: config.cloud_init,
62
65
  }
66
+
67
+ initialization[:dns_servers] = iface_options[:dns_servers] unless iface_options[:dns_servers].nil?
68
+ initialization[:dns_search] = iface_options[:dns_search] unless iface_options[:dns_search].nil?
69
+ end
70
+
71
+ vm_configuration = {
72
+ initialization: initialization,
73
+ placement_policy: {},
63
74
  }
64
-
65
- machine.start(
66
- use_cloud_init: true,
67
- vm: vm_configuration
68
- )
75
+
76
+ vm_configuration[:placement_policy][:hosts] = [{ :name => config.placement_host }] unless config.placement_host.nil?
77
+ vm_configuration[:placement_policy][:affinity] = config.affinity unless config.affinity.nil?
78
+
79
+ vm_configuration.delete(:placement_policy) if vm_configuration[:placement_policy].empty?
80
+ vm_configuration.delete(:nic_configurations) if vm_configuration[:nic_configurations].nil? or vm_configuration[:nic_configurations].empty?
81
+
82
+ begin
83
+ machine.start(
84
+ use_cloud_init: true,
85
+ vm: vm_configuration
86
+ )
87
+ rescue OvirtSDK4::Error => e
88
+ if config.debug
89
+ raise e
90
+ else
91
+ fault_message = /Fault detail is \"\[?(.+?)\]?\".*/.match(e.message)[1] rescue e.message
92
+ raise Errors::StartVMError,
93
+ :error_message => fault_message
94
+ end
95
+
96
+ end
69
97
 
70
98
  @app.call(env)
71
99
  end
@@ -1,4 +1,6 @@
1
1
  require 'vagrant'
2
+ require 'filesize'
3
+ require 'ovirtsdk4'
2
4
 
3
5
  module VagrantPlugins
4
6
  module OVirtProvider
@@ -14,10 +16,13 @@ module VagrantPlugins
14
16
  attr_accessor :cpu_threads
15
17
  attr_accessor :template
16
18
  attr_accessor :memory_size
19
+ attr_accessor :memory_maximum
17
20
  attr_accessor :memory_guaranteed
18
21
  attr_accessor :cluster
19
22
  attr_accessor :console
20
23
  attr_accessor :cloud_init
24
+ attr_accessor :affinity
25
+ attr_accessor :placement_host
21
26
 
22
27
  def initialize
23
28
  @url = UNSET_VALUE
@@ -30,10 +35,13 @@ module VagrantPlugins
30
35
  @cpu_threads = UNSET_VALUE
31
36
  @template = UNSET_VALUE
32
37
  @memory_size = UNSET_VALUE
38
+ @memory_maximum = UNSET_VALUE
33
39
  @memory_guaranteed = UNSET_VALUE
34
40
  @cluster = UNSET_VALUE
35
41
  @console = UNSET_VALUE
36
42
  @cloud_init = UNSET_VALUE
43
+ @affinity = UNSET_VALUE
44
+ @placement_host = UNSET_VALUE
37
45
 
38
46
  end
39
47
 
@@ -48,11 +56,25 @@ module VagrantPlugins
48
56
  @cpu_threads = 1 if @cpu_threads == UNSET_VALUE
49
57
  @cluster = nil if @cluster == UNSET_VALUE
50
58
  @console = nil if @console == UNSET_VALUE
51
- @memory_size = 256 if @memory_size == UNSET_VALUE
59
+ @memory_size = '256 MB' if @memory_size == UNSET_VALUE
60
+ @memory_maximum = @memory_size if @memory_maximum == UNSET_VALUE
52
61
  @memory_guaranteed = @memory_size if @memory_guaranteed == UNSET_VALUE
53
62
  @template = nil if @template == UNSET_VALUE
54
63
  @cloud_init = nil if @cloud_init == UNSET_VALUE
64
+ @affinity = nil if @affinity == UNSET_VALUE
65
+ @placement_host = nil if @placement_host == UNSET_VALUE
55
66
 
67
+ unless affinity.nil?
68
+ raise "Invalid affinity. Must be one of #{OvirtSDK4::VmAffinity.constants.map { |s| "'#{s.downcase}'" }.join(' ')}" unless OvirtSDK4::VmAffinity.constants.include? affinity.upcase.to_sym
69
+ end
70
+
71
+ begin
72
+ @memory_size = Filesize.from(@memory_size).to_f('B').to_i
73
+ @memory_maximum = Filesize.from(@memory_maximum).to_f('B').to_i
74
+ @memory_guaranteed = Filesize.from(@memory_guaranteed).to_f('B').to_i
75
+ rescue ArgumentError
76
+ raise "Not able to parse either `memory_size` or `memory_guaranteed`. Please verify and check again."
77
+ end
56
78
  end
57
79
 
58
80
  end
@@ -31,6 +31,10 @@ module VagrantPlugins
31
31
  error_key(:no_network_error)
32
32
  end
33
33
 
34
+ class NetworkNotFoundError < VagrantOVirtError
35
+ error_key(:network_not_found_error)
36
+ end
37
+
34
38
  class NoIPError < VagrantOVirtError
35
39
  error_key(:no_ip_error)
36
40
  end
@@ -1,6 +1,6 @@
1
1
  module VagrantPlugins
2
2
  module OVirtProvider
3
- VERSION = '1.1.0'
3
+ VERSION = '1.2.0'
4
4
  end
5
5
  end
6
6
 
@@ -61,6 +61,8 @@ en:
61
61
  start_vm_error: |-
62
62
  Unable to start VM: %{error_message}
63
63
  no_network_error: |-
64
+ No network provided and none were imported from the template. There would be no way to communicate with this machine.
65
+ network_not_found_error: |-
64
66
  No network %{network_name} found.
65
67
  wait_for_ready_vm_timeout: |-
66
68
  Timeout occurred while waiting for VM to become ready to start
@@ -39,14 +39,17 @@ describe VagrantPlugins::OVirtProvider::Config do
39
39
  its("cluster") { should be_nil }
40
40
  its("console") { should be_nil }
41
41
  its("template") { should be_nil }
42
- its("memory_size") { should == 256 }
43
- its("memory_guaranteed") { should == 256 }
42
+ its("memory_size") { should == 256000000 }
43
+ its("memory_maximum") { should == 256000000 }
44
+ its("memory_guaranteed") { should == 256000000 }
44
45
  its("cloud_init") { should be_nil }
46
+ its("affinity") { should be_nil }
47
+ its("placement_host") { should be_nil }
45
48
 
46
49
  end
47
50
 
48
51
  describe "overriding defaults" do
49
- [:url, :username, :password, :insecure, :debug, :cpu_cores, :cpu_sockets, :cpu_threads, :cluster, :console, :template, :memory_size, :memory_guaranteed, :cloud_init].each do |attribute|
52
+ [:url, :username, :password, :insecure, :debug, :cpu_cores, :cpu_sockets, :cpu_threads, :cluster, :console, :template, :cloud_init, :placement_host].each do |attribute|
50
53
 
51
54
  it "should not default #{attribute} if overridden" do
52
55
  instance.send("#{attribute}=".to_sym, "foo")
@@ -56,4 +59,46 @@ describe VagrantPlugins::OVirtProvider::Config do
56
59
  end
57
60
  end
58
61
 
62
+ describe "overriding memory defaults" do
63
+ [:memory_size, :memory_maximum, :memory_guaranteed].each do |attribute|
64
+
65
+ it "should not default #{attribute} if overridden" do
66
+ instance.send("#{attribute}=".to_sym, "512 MB")
67
+ instance.finalize!
68
+ instance.send(attribute).should == 512000000
69
+ end
70
+
71
+ it "should convert the value" do
72
+ instance.send("#{attribute}=".to_sym, "1 GB")
73
+ instance.finalize!
74
+ instance.send(attribute).should == 1000000000
75
+ end
76
+
77
+ end
78
+ end
79
+
80
+ describe "overriding affinity defaults" do
81
+ [:affinity].each do |attribute|
82
+
83
+ context 'valid value' do
84
+ it "should not default #{attribute} if overridden" do
85
+ instance.send("#{attribute}=".to_sym, "pinned")
86
+ instance.finalize!
87
+ instance.send(attribute).should == "pinned"
88
+ end
89
+ end
90
+
91
+ context 'invalid value' do
92
+ it "should error" do
93
+ expect {
94
+ instance.send("#{attribute}=".to_sym, "foo")
95
+ instance.finalize!
96
+ }.to raise_error(RuntimeError)
97
+
98
+ end
99
+
100
+ end
101
+
102
+ end
103
+ end
59
104
  end
@@ -42,7 +42,6 @@ fi
42
42
  if [[ $ATOMIC != "true" ]]; then
43
43
  yum install -y epel-release
44
44
  yum install -y ovirt-guest-agent-common
45
- for i in cloud-init ovirt-guest-agent; do chkconfig $i on; done
46
45
  if [[ $RHEL_MAJOR_VERSION -eq 5 ]]; then
47
46
  yum install -y \
48
47
  http://ftp.astral.ro/mirrors/fedora/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm \
@@ -59,12 +58,18 @@ if [[ $ATOMIC != "true" ]]; then
59
58
  echo "Is this a valid major release?"
60
59
  exit 1
61
60
  fi
61
+ else
62
+ ostree remote add --set=gpg-verify=false centos-atomic-continuous https://ci.centos.org/artifacts/sig-atomic/rdgo/centos-continuous/ostree/repo/
63
+ rpm-ostree rebase centos-atomic-continuous:centos-atomic-host/${RHEL_MAJOR_VERSION}/x86_64/devel/alpha
64
+ rpm-ostree pkg-add epel-release
65
+ rpm-ostree install ovirt-guest-agent-common
66
+ systemctl reboot
62
67
  fi
63
68
 
64
69
  # Install some required software.
65
70
  if [[ $ATOMIC != "true" ]]; then
66
71
  yum -y install openssh-server openssh-clients sudo curl \
67
- ruby ruby-devel make gcc rubygems rsync puppet ovirt-guest-agent cloud-init \
72
+ ruby ruby-devel make gcc rubygems rsync puppet ovirt-guest-agent ovirt-guest-agent-common cloud-init \
68
73
  iptables-services net-tools
69
74
  fi
70
75
 
@@ -98,7 +103,9 @@ chown -R vagrant:vagrant $vagrant_home/.ssh
98
103
 
99
104
  # Disable firewall and switch SELinux to permissive mode.
100
105
  chkconfig iptables off
106
+ chkconfig firewalld off
101
107
  chkconfig ip6tables off
108
+ for i in cloud-init ovirt-guest-agent; do chkconfig $i on; done
102
109
  sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/sysconfig/selinux
103
110
  [ -f /etc/selinux/config ] && sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
104
111
 
@@ -111,7 +118,11 @@ rm -fr /var/lib/dhclient/*
111
118
  # Interface eth0 should always get IP address via dhcp.
112
119
  echo $'' > /etc/sysconfig/network-scripts/ifcfg-eth0
113
120
 
121
+ CLOUD_CONFIG=/etc/cloud/cloud.cfg
122
+ grep -q ' - resolv-conf' $CLOUD_CONFIG || sed -i -e 's/ - timezone/&\n - resolv-conf/' $CLOUD_CONFIG
123
+
114
124
  # Do some cleanup..
115
125
  rm -f /root/.bash_history
116
126
  rm -f /root/authorized_keys
117
127
  [[ $ATOMIC != "true" ]] && yum clean all
128
+
@@ -17,5 +17,6 @@ Gem::Specification.new do |gem|
17
17
  gem.version = VagrantPlugins::OVirtProvider::VERSION
18
18
 
19
19
  gem.add_runtime_dependency 'ovirt-engine-sdk', '~> 4.0', '>= 4.0.6'
20
+ gem.add_runtime_dependency 'filesize', '~> 0'
20
21
 
21
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-ovirt4
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcus Young
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-15 00:00:00.000000000 Z
11
+ date: 2017-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ovirt-engine-sdk
@@ -30,6 +30,20 @@ dependencies:
30
30
  - - ">="
31
31
  - !ruby/object:Gem::Version
32
32
  version: 4.0.6
33
+ - !ruby/object:Gem::Dependency
34
+ name: filesize
35
+ requirement: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - "~>"
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
33
47
  description: Vagrant provider for oVirt and RHEV v4
34
48
  email:
35
49
  - myoung34@my.apsu.edu
@@ -44,7 +58,6 @@ files:
44
58
  - LICENSE
45
59
  - README.md
46
60
  - Rakefile
47
- - docker-compose.yml
48
61
  - example_box/README.md
49
62
  - example_box/Vagrantfile
50
63
  - example_box/dummy.box
@@ -125,7 +138,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
138
  version: '0'
126
139
  requirements: []
127
140
  rubyforge_project:
128
- rubygems_version: 2.6.10
141
+ rubygems_version: 2.4.8
129
142
  signing_key:
130
143
  specification_version: 4
131
144
  summary: This vagrant plugin provides the ability to create, control, and destroy
@@ -1,9 +0,0 @@
1
- version: '2'
2
-
3
- services:
4
- ruby:
5
- image: ruby-2.2.0
6
- container_name: ruby
7
- build: .
8
- volumes:
9
- - .:/srv