vagrant-libvirt 0.0.40 → 0.0.41

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. checksums.yaml +4 -4
  2. metadata +13 -103
  3. data/.coveralls.yml +0 -1
  4. data/.github/issue_template.md +0 -37
  5. data/.gitignore +0 -21
  6. data/.travis.yml +0 -28
  7. data/CHANGELOG.md +0 -99
  8. data/Gemfile +0 -27
  9. data/LICENSE +0 -22
  10. data/README.md +0 -1311
  11. data/Rakefile +0 -8
  12. data/example_box/README.md +0 -29
  13. data/example_box/Vagrantfile +0 -60
  14. data/example_box/metadata.json +0 -5
  15. data/lib/vagrant-libvirt.rb +0 -29
  16. data/lib/vagrant-libvirt/action.rb +0 -362
  17. data/lib/vagrant-libvirt/action/create_domain.rb +0 -313
  18. data/lib/vagrant-libvirt/action/create_domain_volume.rb +0 -87
  19. data/lib/vagrant-libvirt/action/create_network_interfaces.rb +0 -294
  20. data/lib/vagrant-libvirt/action/create_networks.rb +0 -353
  21. data/lib/vagrant-libvirt/action/destroy_domain.rb +0 -83
  22. data/lib/vagrant-libvirt/action/destroy_networks.rb +0 -95
  23. data/lib/vagrant-libvirt/action/forward_ports.rb +0 -221
  24. data/lib/vagrant-libvirt/action/halt_domain.rb +0 -35
  25. data/lib/vagrant-libvirt/action/handle_box_image.rb +0 -156
  26. data/lib/vagrant-libvirt/action/handle_storage_pool.rb +0 -57
  27. data/lib/vagrant-libvirt/action/is_created.rb +0 -18
  28. data/lib/vagrant-libvirt/action/is_running.rb +0 -21
  29. data/lib/vagrant-libvirt/action/is_suspended.rb +0 -42
  30. data/lib/vagrant-libvirt/action/message_already_created.rb +0 -16
  31. data/lib/vagrant-libvirt/action/message_not_created.rb +0 -16
  32. data/lib/vagrant-libvirt/action/message_not_running.rb +0 -16
  33. data/lib/vagrant-libvirt/action/message_not_suspended.rb +0 -16
  34. data/lib/vagrant-libvirt/action/package_domain.rb +0 -105
  35. data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +0 -94
  36. data/lib/vagrant-libvirt/action/prepare_nfs_valid_ids.rb +0 -17
  37. data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +0 -27
  38. data/lib/vagrant-libvirt/action/read_mac_addresses.rb +0 -40
  39. data/lib/vagrant-libvirt/action/remove_libvirt_image.rb +0 -20
  40. data/lib/vagrant-libvirt/action/remove_stale_volume.rb +0 -50
  41. data/lib/vagrant-libvirt/action/resume_domain.rb +0 -34
  42. data/lib/vagrant-libvirt/action/set_boot_order.rb +0 -109
  43. data/lib/vagrant-libvirt/action/set_name_of_domain.rb +0 -64
  44. data/lib/vagrant-libvirt/action/share_folders.rb +0 -71
  45. data/lib/vagrant-libvirt/action/start_domain.rb +0 -303
  46. data/lib/vagrant-libvirt/action/suspend_domain.rb +0 -40
  47. data/lib/vagrant-libvirt/action/wait_till_up.rb +0 -102
  48. data/lib/vagrant-libvirt/cap/mount_p9.rb +0 -42
  49. data/lib/vagrant-libvirt/cap/nic_mac_addresses.rb +0 -17
  50. data/lib/vagrant-libvirt/cap/synced_folder.rb +0 -113
  51. data/lib/vagrant-libvirt/config.rb +0 -698
  52. data/lib/vagrant-libvirt/driver.rb +0 -118
  53. data/lib/vagrant-libvirt/errors.rb +0 -149
  54. data/lib/vagrant-libvirt/plugin.rb +0 -92
  55. data/lib/vagrant-libvirt/provider.rb +0 -130
  56. data/lib/vagrant-libvirt/templates/default_storage_pool.xml.erb +0 -13
  57. data/lib/vagrant-libvirt/templates/domain.xml.erb +0 -229
  58. data/lib/vagrant-libvirt/templates/private_network.xml.erb +0 -34
  59. data/lib/vagrant-libvirt/templates/public_interface.xml.erb +0 -23
  60. data/lib/vagrant-libvirt/util.rb +0 -11
  61. data/lib/vagrant-libvirt/util/collection.rb +0 -19
  62. data/lib/vagrant-libvirt/util/erb_template.rb +0 -22
  63. data/lib/vagrant-libvirt/util/error_codes.rb +0 -100
  64. data/lib/vagrant-libvirt/util/network_util.rb +0 -138
  65. data/lib/vagrant-libvirt/util/timer.rb +0 -17
  66. data/lib/vagrant-libvirt/version.rb +0 -5
  67. data/locales/en.yml +0 -159
  68. data/spec/spec_helper.rb +0 -9
  69. data/spec/support/environment_helper.rb +0 -46
  70. data/spec/support/libvirt_context.rb +0 -30
  71. data/spec/support/sharedcontext.rb +0 -34
  72. data/spec/unit/action/destroy_domain_spec.rb +0 -97
  73. data/spec/unit/action/set_name_of_domain_spec.rb +0 -21
  74. data/spec/unit/action/wait_till_up_spec.rb +0 -127
  75. data/spec/unit/config_spec.rb +0 -106
  76. data/spec/unit/templates/domain_all_settings.xml +0 -133
  77. data/spec/unit/templates/domain_defaults.xml +0 -46
  78. data/spec/unit/templates/domain_spec.rb +0 -75
  79. data/tools/create_box.sh +0 -130
  80. data/tools/prepare_redhat_for_box.sh +0 -119
  81. data/vagrant-libvirt.gemspec +0 -28
@@ -1,138 +0,0 @@
1
- require 'nokogiri'
2
- require 'vagrant/util/network_ip'
3
-
4
- module VagrantPlugins
5
- module ProviderLibvirt
6
- module Util
7
- module NetworkUtil
8
- include Vagrant::Util::NetworkIP
9
-
10
- def configured_networks(env, logger)
11
- management_network_name = env[:machine].provider_config.management_network_name
12
- management_network_address = env[:machine].provider_config.management_network_address
13
- management_network_mode = env[:machine].provider_config.management_network_mode
14
- management_network_mac = env[:machine].provider_config.management_network_mac
15
- management_network_guest_ipv6 = env[:machine].provider_config.management_network_guest_ipv6
16
- management_network_autostart = env[:machine].provider_config.management_network_autostart
17
- logger.info "Using #{management_network_name} at #{management_network_address} as the management network #{management_network_mode} is the mode"
18
-
19
- begin
20
- management_network_ip = IPAddr.new(management_network_address)
21
- rescue ArgumentError
22
- raise Errors::ManagementNetworkError,
23
- error_message: "#{management_network_address} is not a valid IP address"
24
- end
25
-
26
- # capture address into $1 and mask into $2
27
- management_network_ip.inspect =~ /IPv4:(.*)\/(.*)>/
28
-
29
- if Regexp.last_match(2) == '255.255.255.255'
30
- raise Errors::ManagementNetworkError,
31
- error_message: "#{management_network_address} does not include both an address and subnet mask"
32
- end
33
-
34
- management_network_options = {
35
- iface_type: :private_network,
36
- network_name: management_network_name,
37
- ip: Regexp.last_match(1),
38
- netmask: Regexp.last_match(2),
39
- dhcp_enabled: true,
40
- forward_mode: management_network_mode,
41
- guest_ipv6: management_network_guest_ipv6,
42
- autostart: management_network_autostart
43
- }
44
-
45
- unless management_network_mac.nil?
46
- management_network_options[:mac] = management_network_mac
47
- end
48
-
49
- if (env[:machine].config.vm.box &&
50
- !env[:machine].provider_config.mgmt_attach)
51
- raise Errors::ManagementNetworkRequired
52
- end
53
-
54
- # add management network to list of networks to check
55
- # unless mgmt_attach set to false
56
- networks = if env[:machine].provider_config.mgmt_attach
57
- [management_network_options]
58
- else
59
- []
60
- end
61
-
62
- env[:machine].config.vm.networks.each do |type, original_options|
63
- logger.debug "In config found network type #{type} options #{original_options}"
64
- # Options can be specified in Vagrantfile in short format (:ip => ...),
65
- # or provider format # (:libvirt__network_name => ...).
66
- # https://github.com/mitchellh/vagrant/blob/master/lib/vagrant/util/scoped_hash_override.rb
67
- options = scoped_hash_override(original_options, :libvirt)
68
- # store type in options
69
- # use default values if not already set
70
- options = {
71
- iface_type: type,
72
- netmask: '255.255.255.0',
73
- dhcp_enabled: true,
74
- forward_mode: 'nat'
75
- }.merge(options)
76
-
77
- if options[:type].to_s == 'dhcp' && options[:ip].nil?
78
- options[:network_name] = 'vagrant-private-dhcp'
79
- end
80
-
81
- # add to list of networks to check
82
- networks.push(options)
83
- end
84
-
85
- networks
86
- end
87
-
88
- # Return a list of all (active and inactive) libvirt networks as a list
89
- # of hashes with their name, network address and status (active or not)
90
- def libvirt_networks(libvirt_client)
91
- libvirt_networks = []
92
-
93
- active = libvirt_client.list_networks
94
- inactive = libvirt_client.list_defined_networks
95
-
96
- # Iterate over all (active and inactive) networks.
97
- active.concat(inactive).each do |network_name|
98
- libvirt_network = libvirt_client.lookup_network_by_name(
99
- network_name
100
- )
101
-
102
- # Parse ip address and netmask from the network xml description.
103
- xml = Nokogiri::XML(libvirt_network.xml_desc)
104
- ip = xml.xpath('/network/ip/@address').first
105
- ip = ip.value if ip
106
- netmask = xml.xpath('/network/ip/@netmask').first
107
- netmask = netmask.value if netmask
108
-
109
- dhcp_enabled = if xml.at_xpath('//network/ip/dhcp')
110
- true
111
- else
112
- false
113
- end
114
-
115
- # Calculate network address of network from ip address and
116
- # netmask.
117
- network_address = (network_address(ip, netmask) if ip && netmask)
118
-
119
- libvirt_networks << {
120
- name: network_name,
121
- ip_address: ip,
122
- netmask: netmask,
123
- network_address: network_address,
124
- dhcp_enabled: dhcp_enabled,
125
- bridge_name: libvirt_network.bridge_name,
126
- created: true,
127
- active: libvirt_network.active?,
128
- autostart: libvirt_network.autostart?,
129
- libvirt_network: libvirt_network
130
- }
131
- end
132
-
133
- libvirt_networks
134
- end
135
- end
136
- end
137
- end
138
- end
@@ -1,17 +0,0 @@
1
- module VagrantPlugins
2
- module ProviderLibvirt
3
- module Util
4
- class Timer
5
- # A basic utility method that times the execution of the given
6
- # block and returns it.
7
- def self.time
8
- start_time = Time.now.to_f
9
- yield
10
- end_time = Time.now.to_f
11
-
12
- end_time - start_time
13
- end
14
- end
15
- end
16
- end
17
- end
@@ -1,5 +0,0 @@
1
- module VagrantPlugins
2
- module ProviderLibvirt
3
- VERSION = '0.0.40'.freeze
4
- end
5
- end
@@ -1,159 +0,0 @@
1
- en:
2
- vagrant_libvirt:
3
- already_created: |-
4
- The domain is already created.
5
- not_created: |-
6
- Domain is not created. Please run `vagrant up` first.
7
- not_running: |-
8
- Domain is not running. Please run `vagrant up` or `vagrant resume` first.
9
- not_suspended: |-
10
- Domain is not suspended.
11
- finding_volume: |-
12
- Checking if volume is available.
13
- creating_domain: |-
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.
18
- uploading_volume: |-
19
- Uploading base box image as volume into libvirt storage...
20
- creating_domain_volume: |-
21
- Creating image (snapshot of base box volume).
22
- removing_domain_volume: |-
23
- Removing image (snapshot of base box volume).
24
- starting_domain: |-
25
- Starting domain.
26
- terminating: |-
27
- Removing domain...
28
- poweroff_domain: |-
29
- Poweroff domain.
30
- destroy_domain: |-
31
- Removing domain...
32
- halt_domain: |-
33
- Halting domain...
34
- resuming_domain: |-
35
- Resuming domain...
36
- suspending_domain: |-
37
- Suspending domain...
38
- waiting_for_ready: |-
39
- Waiting for domain to become "ready"...
40
- waiting_for_ip: |-
41
- Waiting for domain to get an IP address...
42
- waiting_for_ssh: |-
43
- Waiting for SSH to become available...
44
- booted: |-
45
- Machine is booted.
46
- rsync_folder: |-
47
- Rsyncing folder: %{hostpath} => %{guestpath}
48
- ready: |-
49
- Machine is booted and ready for use!
50
- remove_stale_volume: |-
51
- Remove stale volume...
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 '%{minimum}'.
57
-
58
- errors:
59
- package_not_supported: No support for package with libvirt. Create box manually.
60
- fog_error: |-
61
- There was an error talking to Libvirt. The error message is shown
62
- below:
63
-
64
- %{message}
65
- no_matching_volume: |-
66
- No matching volume was found! Please check your volume setting
67
- to make sure you have a valid volume chosen.
68
- no_storage_pool: |-
69
- No usable storage pool found! Please check if storage pool is
70
- created and available.
71
- no_box_volume: |-
72
- Volume for box image is missing in storage pools. Try to run vagrant
73
- again, or check if storage volume is accessible.
74
- domain_volume_exists: |-
75
- Volume for domain is already created. Please run 'vagrant destroy' first.
76
- no_domain_volume: |-
77
- Volume for domain is missing. Try to run 'vagrant up' again.
78
- interface_slot_not_available: |-
79
- Interface adapter number is already in use. Please specify other adapter
80
- number.
81
- rsync_error: |-
82
- There was an error when attempting to rsync a share folder.
83
- Please inspect the error message below for more info.
84
-
85
- Host path: %{hostpath}
86
- Guest path: %{guestpath}
87
- Error: %{stderr}
88
- no_box_virtual_size: |-
89
- No image virtual size specified for box.
90
- no_box_format: |-
91
- No image format specified for box.
92
- wrong_box_format: |-
93
- Wrong image format specified for box.
94
- fog_libvirt_connection_error: |-
95
- Error while connecting to libvirt: %{error_message}
96
- fog_create_volume_error: |-
97
- Error while creating a storage pool volume: %{error_message}
98
- fog_create_domain_volume_error: |-
99
- Error while creating volume for domain: %{error_message}
100
- fog_create_server_error: |-
101
- Error while creating domain: %{error_message}
102
- domain_name_exists: |-
103
- Name `%{domain_name}` of domain about to create is already taken. Please try to run
104
- `vagrant up` command again.
105
- creating_storage_pool_error: |-
106
- There was error while creating libvirt storage pool: %{error_message}
107
- image_upload_error: |-
108
- Error while uploading image to storage pool: %{error_message}
109
- no_domain_error: |-
110
- No domain found. %{error_message}
111
- attach_device_error: |-
112
- Error while attaching new device to domain. %{error_message}
113
- detach_device_error: |-
114
- Error while detaching device from domain. %{error_message}
115
- no_ip_address_error: |-
116
- No IP address found.
117
- management_network_error: |-
118
- Error in specification of management network: %{error_message}.
119
- network_name_and_address_mismatch: |-
120
- Address %{ip_address} does not match with network name %{network_name}.
121
- Please fix your configuration and run vagrant again.
122
- dhcp_mismatch: |-
123
- Network %{network_name} exists but does not have dhcp %{requested}.
124
- Please fix your configuration and run vagrant again.
125
- create_network_error: |-
126
- Error occurred while creating new network: %{error_message}.
127
- network_not_available_error: |-
128
- Network %{network_name} is not available. Specify available network
129
- name, or an ip address if you want to create a new network.
130
- activate_network_error: |-
131
- Error while activating network: %{error_message}.
132
- autostart_network_error: |-
133
- Error while setting up autostart on network: %{error_message}.
134
- destroy_network_error: |-
135
- Error while removing network %{network_name}. %{error_message}.
136
- delete_snapshot_error: |-
137
- Error while deleting snapshot: %{error_message}.
138
- tunnel_port_not_defined: |-
139
- tunnel UDP or TCP port not defined.
140
- management_network_required: |-
141
- Management network can't be disabled when VM use box.
142
- Please fix your configuration and run vagrant again.
143
-
144
- states:
145
- paused: |-
146
- The Libvirt domain is suspended. Run `vagrant resume` to resume it.
147
- shutting_down: |-
148
- The Libvirt domain is shutting down. Wait for it to complete and
149
- then run `vagrant up` to start it or `vagrant destroy` to remove.
150
- shutoff: |-
151
- The Libvirt domain is not running. Run `vagrant up` to start it.
152
- not_created: |-
153
- The Libvirt domain is not created. Run `vagrant up` to create it.
154
- running: |-
155
- The Libvirt domain is running. To stop this machine, you can run
156
- `vagrant halt`. To destroy the machine, you can run `vagrant destroy`.
157
- preparing: |-
158
- The vagrant machine is being prepared for creation, please wait for
159
- it to reach a steady state before issuing commands on it.
@@ -1,9 +0,0 @@
1
- require 'coveralls'
2
- Coveralls.wear!
3
-
4
- require 'vagrant-libvirt'
5
- require 'support/environment_helper'
6
- require 'vagrant-spec/unit'
7
-
8
- RSpec.configure do |spec|
9
- end
@@ -1,46 +0,0 @@
1
- require 'ostruct'
2
- require 'pathname'
3
-
4
- class EnvironmentHelper
5
- attr_writer :domain_name
6
-
7
- attr_accessor :random_hostname, :name, :default_prefix
8
-
9
- def [](value)
10
- send(value.to_sym)
11
- end
12
-
13
- def cpus
14
- 4
15
- end
16
-
17
- def memory
18
- 1024
19
- end
20
-
21
- %w(cpus cpu_mode loader boot_order machine_type disk_bus disk_device 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
- define_method(name.to_sym) do
23
- nil
24
- end
25
- end
26
-
27
- def machine
28
- self
29
- end
30
-
31
- def provider_config
32
- self
33
- end
34
-
35
- def root_path
36
- Pathname.new('./spec/support/foo')
37
- end
38
-
39
- def domain_name
40
- # noop
41
- end
42
-
43
- def libvirt_compute
44
- OpenStruct.new(servers: [])
45
- end
46
- end
@@ -1,30 +0,0 @@
1
- require 'fog/libvirt'
2
-
3
- shared_context 'libvirt' do
4
- include_context 'unit'
5
-
6
- let(:libvirt_context) { true }
7
- let(:id) { 'dummy-vagrant_dummy' }
8
- let(:connection) { double('connection') }
9
- let(:domain) { double('domain') }
10
-
11
- def connection_result(options = {})
12
- result = options.fetch(:result, nil)
13
- double('connection_result' => result)
14
- end
15
-
16
- before (:each) do
17
- # we don't want unit tests to ever run commands on the system; so we wire
18
- # in a double to ensure any unexpected messages raise exceptions
19
- stub_const('::Fog::Compute', connection)
20
-
21
- # drivers also call vm_exists? during init;
22
- allow(connection).to receive(:servers).with(kind_of(String))
23
- .and_return(connection_result(result: nil))
24
-
25
- # return some information for domain when needed
26
- allow(domain).to receive(:mac).and_return('9C:D5:53:F1:5A:E7')
27
-
28
- machine.stub(id: id)
29
- end
30
- end
@@ -1,34 +0,0 @@
1
- require 'spec_helper'
2
-
3
- shared_context 'unit' do
4
- include_context 'vagrant-unit'
5
-
6
- let(:vagrantfile) do
7
- <<-EOF
8
- Vagrant.configure('2') do |config|
9
- config.vm.define :test
10
- end
11
- EOF
12
- end
13
- let(:test_env) do
14
- test_env = isolated_environment
15
- test_env.vagrantfile vagrantfile
16
- test_env
17
- end
18
- let(:env) { { env: iso_env, machine: machine, ui: ui, root_path: '/rootpath' } }
19
- let(:conf) { Vagrant::Config::V2::DummyConfig.new }
20
- let(:ui) { Vagrant::UI::Basic.new }
21
- let(:iso_env) { test_env.create_vagrant_env ui_class: Vagrant::UI::Basic }
22
- let(:machine) { iso_env.machine(:test, :libvirt) }
23
- # Mock the communicator to prevent SSH commands for being executed.
24
- let(:communicator) { double('communicator') }
25
- # Mock the guest operating system.
26
- let(:guest) { double('guest') }
27
- let(:app) { ->(env) {} }
28
- let(:plugin) { register_plugin }
29
-
30
- before (:each) do
31
- machine.stub(guest: guest)
32
- machine.stub(communicator: communicator)
33
- end
34
- end