vagrant-libvirt 0.0.30 → 0.0.31

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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +20 -0
  3. data/Gemfile +6 -1
  4. data/README.md +146 -6
  5. data/example_box/Vagrantfile +1 -1
  6. data/example_box/metadata.json +1 -1
  7. data/lib/vagrant-libvirt.rb +3 -15
  8. data/lib/vagrant-libvirt/action.rb +59 -73
  9. data/lib/vagrant-libvirt/action/create_domain.rb +47 -19
  10. data/lib/vagrant-libvirt/action/create_domain_volume.rb +5 -5
  11. data/lib/vagrant-libvirt/action/create_network_interfaces.rb +82 -36
  12. data/lib/vagrant-libvirt/action/create_networks.rb +99 -54
  13. data/lib/vagrant-libvirt/action/destroy_domain.rb +4 -4
  14. data/lib/vagrant-libvirt/action/destroy_networks.rb +2 -2
  15. data/lib/vagrant-libvirt/action/halt_domain.rb +1 -1
  16. data/lib/vagrant-libvirt/action/handle_box_image.rb +25 -5
  17. data/lib/vagrant-libvirt/action/handle_storage_pool.rb +9 -7
  18. data/lib/vagrant-libvirt/action/is_running.rb +1 -1
  19. data/lib/vagrant-libvirt/action/is_suspended.rb +1 -1
  20. data/lib/vagrant-libvirt/action/package_domain.rb +3 -3
  21. data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +8 -5
  22. data/lib/vagrant-libvirt/action/prepare_nfs_valid_ids.rb +1 -1
  23. data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +1 -1
  24. data/lib/vagrant-libvirt/action/read_mac_addresses.rb +1 -1
  25. data/lib/vagrant-libvirt/action/remove_libvirt_image.rb +1 -1
  26. data/lib/vagrant-libvirt/action/remove_stale_volume.rb +2 -2
  27. data/lib/vagrant-libvirt/action/resume_domain.rb +1 -1
  28. data/lib/vagrant-libvirt/action/set_boot_order.rb +66 -0
  29. data/lib/vagrant-libvirt/action/set_name_of_domain.rb +3 -2
  30. data/lib/vagrant-libvirt/action/start_domain.rb +1 -1
  31. data/lib/vagrant-libvirt/action/suspend_domain.rb +1 -1
  32. data/lib/vagrant-libvirt/action/wait_till_up.rb +1 -1
  33. data/lib/vagrant-libvirt/cap/mount_p9.rb +2 -1
  34. data/lib/vagrant-libvirt/cap/synced_folder.rb +11 -5
  35. data/lib/vagrant-libvirt/config.rb +44 -5
  36. data/lib/vagrant-libvirt/driver.rb +121 -0
  37. data/lib/vagrant-libvirt/errors.rb +4 -0
  38. data/lib/vagrant-libvirt/plugin.rb +7 -5
  39. data/lib/vagrant-libvirt/provider.rb +54 -12
  40. data/lib/vagrant-libvirt/templates/domain.xml.erb +18 -12
  41. data/lib/vagrant-libvirt/templates/filesystem.xml.erb +1 -1
  42. data/lib/vagrant-libvirt/templates/tunnel_interface.xml.erb +11 -0
  43. data/lib/vagrant-libvirt/util/network_util.rb +11 -1
  44. data/lib/vagrant-libvirt/version.rb +1 -1
  45. data/locales/en.yml +24 -15
  46. data/spec/support/environment_helper.rb +1 -1
  47. data/tools/prepare_redhat_for_box.sh +1 -2
  48. metadata +6 -5
  49. data/lib/vagrant-libvirt/action/connect_libvirt.rb +0 -51
  50. data/lib/vagrant-libvirt/action/read_ssh_info.rb +0 -68
  51. data/lib/vagrant-libvirt/action/read_state.rb +0 -60
@@ -1,7 +1,7 @@
1
1
  <filesystem type='mount' accessmode='<%= accessmode %>'>
2
2
  <driver type='path' wrpolicy='immediate'/>
3
3
  <source dir='<%= hostpath %>'/>
4
- <target dir='<%= target %>'/>
4
+ <target dir='<%= mount_tag %>'/>
5
5
  <% unless readonly.nil? %>
6
6
  <readonly />
7
7
  <% end %>
@@ -0,0 +1,11 @@
1
+ <interface type='<%= @type %>'>
2
+ <% if @mac %>
3
+ <mac address='<%= @mac %>'/>
4
+ <% end %>
5
+ <source address='<%=@tunnel_ip%>' port='<%= @tunnel_port %>'>
6
+ <% if @type == 'udp' %>
7
+ <local address='<%=@udp_tunnel_local_ip%>' port='<%=@udp_tunnel_local_port%>' />
8
+ <% end %>
9
+ </source>
10
+ <model type='<%=@model_type%>'/>
11
+ </interface>
@@ -10,7 +10,8 @@ module VagrantPlugins
10
10
  def configured_networks(env, logger)
11
11
  management_network_name = env[:machine].provider_config.management_network_name
12
12
  management_network_address = env[:machine].provider_config.management_network_address
13
- management_network_mode = env[:machine].provider_config.management_network_mode
13
+ management_network_mode = env[:machine].provider_config.management_network_mode
14
+ management_network_mac = env[:machine].provider_config.management_network_mac
14
15
  logger.info "Using #{management_network_name} at #{management_network_address} as the management network #{management_network_mode} is the mode"
15
16
 
16
17
  begin
@@ -37,6 +38,10 @@ module VagrantPlugins
37
38
  forward_mode: management_network_mode,
38
39
  }
39
40
 
41
+ unless management_network_mac.nil?
42
+ management_network_options[:mac] = management_network_mac
43
+ end
44
+
40
45
  # add management network to list of networks to check
41
46
  networks = [ management_network_options ]
42
47
 
@@ -54,6 +59,11 @@ module VagrantPlugins
54
59
  dhcp_enabled: true,
55
60
  forward_mode: 'nat',
56
61
  }.merge(options)
62
+
63
+ if options[:type].to_s == 'dhcp' && options[:ip].nil?
64
+ options[:network_name] = "vagrant-private-dhcp"
65
+ end
66
+
57
67
  # add to list of networks to check
58
68
  networks.push(options)
59
69
  end
@@ -1,5 +1,5 @@
1
1
  module VagrantPlugins
2
2
  module ProviderLibvirt
3
- VERSION = '0.0.30'
3
+ VERSION = '0.0.31'
4
4
  end
5
5
  end
@@ -12,6 +12,9 @@ en:
12
12
  Checking if volume is available.
13
13
  creating_domain: |-
14
14
  Creating domain with the following settings...
15
+ manual_resize_required: |-
16
+ Created volume larger than box defaults, will require manual resizing of
17
+ filesystems to utilize.
15
18
  uploading_volume: |-
16
19
  Uploading base box image as volume into libvirt storage...
17
20
  creating_domain_volume: |-
@@ -47,8 +50,13 @@ en:
47
50
  remove_stale_volume: |-
48
51
  Remove stale volume...
49
52
 
53
+ warnings:
54
+ ignoring_virtual_size_too_small: |-
55
+ Ignoring requested virtual disk size of '%{requested}' as it is below
56
+ the minimum box image size of '%{box_virtual_size}'.
57
+
50
58
  errors:
51
- package_not_supported: Not support package for libvirt. Create box manualy.
59
+ package_not_supported: No support for package with libvirt. Create box manually.
52
60
  fog_error: |-
53
61
  There was an error talking to Libvirt. The error message is shown
54
62
  below:
@@ -71,7 +79,7 @@ en:
71
79
  Interface adapter number is already in use. Please specify other adapter
72
80
  number.
73
81
  rsync_error: |-
74
- There was an error when attemping to rsync a share folder.
82
+ There was an error when attempting to rsync a share folder.
75
83
  Please inspect the error message below for more info.
76
84
 
77
85
  Host path: %{hostpath}
@@ -115,7 +123,7 @@ en:
115
123
  Network %{network_name} exists but does not have dhcp %{requested}.
116
124
  Please fix your configuration and run vagrant again.
117
125
  create_network_error: |-
118
- Error occured while creating new network: %{error_message}.
126
+ Error occurred while creating new network: %{error_message}.
119
127
  network_not_available_error: |-
120
128
  Network %{network_name} is not available. Specify available network
121
129
  name, or an ip address if you want to create a new network.
@@ -127,21 +135,22 @@ en:
127
135
  Error while removing network %{network_name}. %{error_message}.
128
136
  delete_snapshot_error: |-
129
137
  Error while deleting snapshot: %{error_message}.
138
+ tunnel_port_not_defined: |-
139
+ tunnel UDP or TCP port not defined.
130
140
 
131
141
  states:
132
- short_paused: |-
133
- pause
134
- short_shutoff: |-
135
- shutoff
136
- long_shutoff: |-
142
+ paused: |-
143
+ The Libvirt domain is suspended. Run `vagrant resume` to resume it.
144
+ shutting_down: |-
145
+ The Libvirt domain is shutting down. Wait for it to complete and
146
+ then run `vagrant up` to start it or `vagrant destroy` to remove.
147
+ shutoff: |-
137
148
  The Libvirt domain is not running. Run `vagrant up` to start it.
138
- short_not_created: |-
139
- not created
140
- long_not_created: |-
149
+ not_created: |-
141
150
  The Libvirt domain is not created. Run `vagrant up` to create it.
142
-
143
- short_running: |-
144
- running
145
- long_running: |-
151
+ running: |-
146
152
  The Libvirt domain is running. To stop this machine, you can run
147
153
  `vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
154
+ preparing: |-
155
+ The vagrant machine is being prepared for creation, please wait for
156
+ it to reach a steady state before issuing commands on it.
@@ -19,7 +19,7 @@ class EnvironmentHelper
19
19
  1024
20
20
  end
21
21
 
22
- %w(cpus cpu_mode boot_order machine_type disk_bus nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms driver).each do |name|
22
+ %w(cpus cpu_mode loader boot_order machine_type disk_bus nested volume_cache kernel cmd_line initrd graphics_type graphics_autoport graphics_port graphics_ip graphics_passwd video_type video_vram keymap storage_pool_name disks cdroms driver).each do |name|
23
23
  define_method(name.to_sym) do
24
24
  nil
25
25
  end
@@ -54,8 +54,6 @@ rm -f ~root/${EPEL_PKG}
54
54
  yum -y install openssh-server openssh-clients sudo \
55
55
  ruby ruby-devel make gcc rubygems rsync
56
56
  chkconfig sshd on
57
- gem install puppet
58
- gem install chef
59
57
 
60
58
 
61
59
  # Users, groups, passwords and sudoers.
@@ -118,3 +116,4 @@ rm -f ~root/.bash_history
118
116
  rm -r "$(gem env gemdir)"/doc/*
119
117
  yum clean all
120
118
 
119
+ halt
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vagrant-libvirt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.30
4
+ version: 0.0.31
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lukas Stanek
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-06-04 00:00:00.000000000 Z
13
+ date: 2015-09-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec-core
@@ -106,6 +106,7 @@ extensions: []
106
106
  extra_rdoc_files: []
107
107
  files:
108
108
  - ".gitignore"
109
+ - ".travis.yml"
109
110
  - CHANGELOG.md
110
111
  - Gemfile
111
112
  - LICENSE
@@ -116,7 +117,6 @@ files:
116
117
  - example_box/metadata.json
117
118
  - lib/vagrant-libvirt.rb
118
119
  - lib/vagrant-libvirt/action.rb
119
- - lib/vagrant-libvirt/action/connect_libvirt.rb
120
120
  - lib/vagrant-libvirt/action/create_domain.rb
121
121
  - lib/vagrant-libvirt/action/create_domain_volume.rb
122
122
  - lib/vagrant-libvirt/action/create_network_interfaces.rb
@@ -139,11 +139,10 @@ files:
139
139
  - lib/vagrant-libvirt/action/prepare_nfs_valid_ids.rb
140
140
  - lib/vagrant-libvirt/action/prune_nfs_exports.rb
141
141
  - lib/vagrant-libvirt/action/read_mac_addresses.rb
142
- - lib/vagrant-libvirt/action/read_ssh_info.rb
143
- - lib/vagrant-libvirt/action/read_state.rb
144
142
  - lib/vagrant-libvirt/action/remove_libvirt_image.rb
145
143
  - lib/vagrant-libvirt/action/remove_stale_volume.rb
146
144
  - lib/vagrant-libvirt/action/resume_domain.rb
145
+ - lib/vagrant-libvirt/action/set_boot_order.rb
147
146
  - lib/vagrant-libvirt/action/set_name_of_domain.rb
148
147
  - lib/vagrant-libvirt/action/share_folders.rb
149
148
  - lib/vagrant-libvirt/action/start_domain.rb
@@ -153,6 +152,7 @@ files:
153
152
  - lib/vagrant-libvirt/cap/nic_mac_addresses.rb
154
153
  - lib/vagrant-libvirt/cap/synced_folder.rb
155
154
  - lib/vagrant-libvirt/config.rb
155
+ - lib/vagrant-libvirt/driver.rb
156
156
  - lib/vagrant-libvirt/errors.rb
157
157
  - lib/vagrant-libvirt/plugin.rb
158
158
  - lib/vagrant-libvirt/provider.rb
@@ -162,6 +162,7 @@ files:
162
162
  - lib/vagrant-libvirt/templates/interface.xml.erb
163
163
  - lib/vagrant-libvirt/templates/private_network.xml.erb
164
164
  - lib/vagrant-libvirt/templates/public_interface.xml.erb
165
+ - lib/vagrant-libvirt/templates/tunnel_interface.xml.erb
165
166
  - lib/vagrant-libvirt/templates/volume_snapshot.xml.erb
166
167
  - lib/vagrant-libvirt/util.rb
167
168
  - lib/vagrant-libvirt/util/collection.rb
@@ -1,51 +0,0 @@
1
- require 'fog/libvirt'
2
- require 'log4r'
3
-
4
- module VagrantPlugins
5
- module ProviderLibvirt
6
- module Action
7
- class ConnectLibvirt
8
- def initialize(app, env)
9
- @logger = Log4r::Logger.new('vagrant_libvirt::action::connect_libvirt')
10
- @app = app
11
- end
12
-
13
- def call(env)
14
- # If already connected to libvirt, just use it and don't connect
15
- # again.
16
- if ProviderLibvirt.libvirt_connection
17
- env[:libvirt_compute] = ProviderLibvirt.libvirt_connection
18
- return @app.call(env)
19
- end
20
-
21
- # Get config options for libvirt provider.
22
- config = env[:machine].provider_config
23
- uri = config.uri
24
-
25
- conn_attr = {}
26
- conn_attr[:provider] = 'libvirt'
27
- conn_attr[:libvirt_uri] = uri
28
- conn_attr[:libvirt_username] = config.username if config.username
29
- conn_attr[:libvirt_password] = config.password if config.password
30
-
31
- # Setup command for retrieving IP address for newly created machine
32
- # with some MAC address. Get it from dnsmasq leases table
33
- ip_command = %q[ awk "/$mac/ {print \$1}" /proc/net/arp ]
34
- conn_attr[:libvirt_ip_command] = ip_command
35
-
36
- @logger.info("Connecting to Libvirt (#{uri}) ...")
37
- begin
38
- env[:libvirt_compute] = Fog::Compute.new(conn_attr)
39
- rescue Fog::Errors::Error => e
40
- raise Errors::FogLibvirtConnectionError,
41
- :error_message => e.message
42
- end
43
- ProviderLibvirt.libvirt_connection = env[:libvirt_compute]
44
-
45
- @app.call(env)
46
- end
47
- end
48
- end
49
- end
50
- end
51
-
@@ -1,68 +0,0 @@
1
- require "log4r"
2
-
3
- module VagrantPlugins
4
- module ProviderLibvirt
5
- module Action
6
- # This action reads the SSH info for the machine and puts it into the
7
- # `:machine_ssh_info` key in the environment.
8
- class ReadSSHInfo
9
- def initialize(app, env)
10
- @app = app
11
- @logger = Log4r::Logger.new("vagrant_libvirt::action::read_ssh_info")
12
- end
13
-
14
- def call(env)
15
- env[:machine_ssh_info] = read_ssh_info(env[:libvirt_compute],
16
- env[:machine])
17
-
18
- @app.call(env)
19
- end
20
-
21
- def read_ssh_info(libvirt, machine)
22
- return nil if machine.id.nil?
23
- return nil if machine.state.id != :running
24
-
25
- # Find the machine
26
- domain = libvirt.servers.get(machine.id)
27
- if domain.nil?
28
- # The machine can't be found
29
- @logger.info("Machine couldn't be found, assuming it got destroyed.")
30
- machine.id = nil
31
- return nil
32
- end
33
-
34
- # Get IP address from dnsmasq lease file.
35
- ip_address = nil
36
- begin
37
- domain.wait_for(2) do
38
- addresses.each_pair do |type, ip|
39
- # Multiple leases are separated with a newline, return only
40
- # the most recent address
41
- ip_address = ip[0].split("\n").first if ip[0] != nil
42
- end
43
- ip_address != nil
44
- end
45
- rescue Fog::Errors::TimeoutError
46
- @logger.info("Timeout at waiting for an ip address for machine %s" % machine.name)
47
- end
48
-
49
- if not ip_address
50
- @logger.info("No lease found for machine %s" % machine.name)
51
- return nil
52
- end
53
-
54
- ssh_info = {
55
- :host => ip_address,
56
- :port => machine.config.ssh.guest_port,
57
- :forward_agent => machine.config.ssh.forward_agent,
58
- :forward_x11 => machine.config.ssh.forward_x11,
59
- }
60
-
61
- ssh_info[:proxy_command] = "ssh '#{machine.provider_config.host}' -l '#{machine.provider_config.username}' -i '#{machine.provider_config.id_ssh_key_file}' nc %h %p" if machine.provider_config.connect_via_ssh
62
-
63
- ssh_info
64
- end
65
- end
66
- end
67
- end
68
- end
@@ -1,60 +0,0 @@
1
- require 'log4r'
2
-
3
- module VagrantPlugins
4
- module ProviderLibvirt
5
- module Action
6
- # This action reads the state of the machine and puts it in the
7
- # `:machine_state_id` key in the environment.
8
- class ReadState
9
- def initialize(app, env)
10
- @app = app
11
- @logger = Log4r::Logger.new('vagrant_libvirt::action::read_state')
12
- end
13
-
14
- def call(env)
15
- env[:machine_state_id] = read_state(env[:libvirt_compute], env[:machine])
16
- @app.call(env)
17
- end
18
-
19
- def read_state(libvirt, machine)
20
- return :not_created if machine.id.nil?
21
-
22
- begin
23
- server = libvirt.servers.get(machine.id)
24
- rescue Libvirt::RetrieveError => e
25
- server = nil
26
- @logger.debug('Machine not found #{e}.')
27
- end
28
- # Find the machine
29
- begin
30
- # Wait for libvirt to shutdown the domain
31
- while libvirt.servers.get(machine.id).state.to_sym == :'shutting-down' do
32
- @logger.info('Waiting on the machine to shut down...')
33
- sleep 1
34
- end
35
-
36
- server = libvirt.servers.get(machine.id)
37
-
38
- if server.nil? || server.state.to_sym == :terminated
39
- # The machine can't be found
40
- @logger.info('Machine terminated, assuming it got destroyed.')
41
- machine.id = nil
42
- return :not_created
43
- end
44
- rescue Libvirt::RetrieveError => e
45
- if e.libvirt_code == ProviderLibvirt::Util::ErrorCodes::VIR_ERR_NO_DOMAIN
46
- @logger.info("Machine #{machine.id} not found.")
47
- machine.id = nil
48
- return :not_created
49
- else
50
- raise e
51
- end
52
- end
53
-
54
- # Return the state
55
- return server.state.to_sym
56
- end
57
- end
58
- end
59
- end
60
- end