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,46 +0,0 @@
1
- <domain type='' xmlns:qemu='http://libvirt.org/schemas/domain/qemu/1.0'>
2
- <name></name>
3
- <uuid></uuid>
4
- <memory></memory>
5
- <vcpu>1</vcpu>
6
-
7
-
8
- <cpu mode='host-model'>
9
- <model fallback='allow'></model>
10
- </cpu>
11
-
12
-
13
- <os>
14
- <type>hvm</type>
15
- <kernel></kernel>
16
- <initrd></initrd>
17
- <cmdline></cmdline>
18
- </os>
19
- <features>
20
- <acpi/>
21
- <apic/>
22
- <pae/>
23
- </features>
24
- <clock offset='utc'/>
25
- <devices>
26
-
27
-
28
- <serial type='pty'>
29
- <target port='0'/>
30
- </serial>
31
- <console type='pty'>
32
- <target port='0'/>
33
- </console>
34
-
35
-
36
- <input type='mouse' bus='ps2'/>
37
-
38
- <graphics type='vnc' port='5900' autoport='yes' listen='127.0.0.1' keymap='en-us' />
39
- <video>
40
- <model type='cirrus' vram='9216' heads='1'/>
41
- </video>
42
-
43
-
44
- </devices>
45
-
46
- </domain>
@@ -1,75 +0,0 @@
1
- require 'support/sharedcontext'
2
-
3
- require 'vagrant-libvirt/config'
4
- require 'vagrant-libvirt/util/erb_template'
5
-
6
- describe 'templates/domain' do
7
- include_context 'unit'
8
-
9
- class DomainTemplateHelper < VagrantPlugins::ProviderLibvirt::Config
10
- include VagrantPlugins::ProviderLibvirt::Util::ErbTemplate
11
- end
12
-
13
- let(:domain) { DomainTemplateHelper.new }
14
- let(:xml_expected) { File.read(File.join(File.dirname(__FILE__), test_file)) }
15
-
16
- context 'when only defaults used' do
17
- let(:test_file) { 'domain_defaults.xml' }
18
- it 'renders template' do
19
- domain.finalize!
20
- expect(domain.to_xml('domain')).to eq xml_expected
21
- end
22
- end
23
-
24
- context 'when all settings enabled' do
25
- before do
26
- domain.instance_variable_set('@domain_type', 'kvm')
27
- domain.cpu_mode = 'custom'
28
- domain.cpu_feature(name: 'AAA', policy: 'required')
29
- domain.machine_type = 'pc-compatible'
30
- domain.machine_arch = 'x86_64'
31
- domain.loader = '/efi/loader'
32
- domain.boot('network')
33
- domain.boot('cdrom')
34
- domain.boot('hd')
35
- domain.emulator_path = '/usr/bin/kvm-spice'
36
- domain.instance_variable_set('@domain_volume_path', '/var/lib/libvirt/images/test.qcow2')
37
- domain.instance_variable_set('@domain_volume_cache', 'unsafe')
38
- domain.disk_bus = 'ide'
39
- domain.disk_device = 'vda'
40
- domain.storage(:file, path: 'test-disk1.qcow2')
41
- domain.storage(:file, path: 'test-disk2.qcow2')
42
- domain.disks.each do |disk|
43
- disk[:absolute_path] = '/var/lib/libvirt/images/' + disk[:path]
44
- end
45
- domain.storage(:file, device: :cdrom)
46
- domain.storage(:file, device: :cdrom)
47
- domain.channel(type: 'unix',
48
- target_name: 'org.qemu.guest_agent.0',
49
- target_type: 'virtio')
50
- domain.channel(type: 'unix',
51
- target_type: 'guestfwd',
52
- target_address: '192.0.2.42',
53
- target_port: '4242',
54
- source_path: '/tmp/foo')
55
- domain.random(model: 'random')
56
- domain.pci(bus: '0x06', slot: '0x12', function: '0x5')
57
- domain.pci(bus: '0x03', slot: '0x00', function: '0x0')
58
- domain.usb(bus: '1', device: '2', vendor: '0x1234', product: '0xabcd')
59
- domain.redirdev(type: 'tcp', host: 'localhost', port: '4000')
60
- domain.redirfilter(class: '0x0b', vendor: '0x08e6',
61
- product: '0x3437', version: '2.00', allow: 'yes')
62
- domain.watchdog(model: 'i6300esb', action: 'reset')
63
- domain.smartcard(mode: 'passthrough')
64
- domain.tpm_path = '/dev/tpm0'
65
-
66
- domain.qemuargs(value: '-device')
67
- domain.qemuargs(value: 'dummy-device')
68
- end
69
- let(:test_file) { 'domain_all_settings.xml' }
70
- it 'renders template' do
71
- domain.finalize!
72
- expect(domain.to_xml('domain')).to eq xml_expected
73
- end
74
- end
75
- end
@@ -1,130 +0,0 @@
1
- #!/usr/bin/env bash
2
- #set -xu
3
-
4
- error() {
5
- local msg="${1}"
6
- echo "==> ERROR: ${msg}"
7
- exit 1
8
- }
9
-
10
- usage() {
11
- echo "Usage: ${0} IMAGE [BOX] [Vagrantfile.add]"
12
- echo
13
- echo "Package a qcow2 image into a vagrant-libvirt reusable box"
14
- }
15
-
16
- # Print the image's backing file
17
- backing(){
18
- local img=${1}
19
- qemu-img info "$img" | grep 'backing file:' | cut -d ':' -f2
20
- }
21
-
22
- # Rebase the image
23
- rebase(){
24
- local img=${1}
25
- qemu-img rebase -p -b "" "$img"
26
- [[ "$?" -ne 0 ]] && error "Error during rebase"
27
- }
28
-
29
- # Is absolute path
30
- isabspath(){
31
- local path=${1}
32
- [[ "$path" =~ ^/.* ]]
33
- }
34
-
35
- if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
36
- usage
37
- exit 1
38
- fi
39
-
40
- IMG=$(readlink -e "$1")
41
- [[ "$?" -ne 0 ]] && error "'$1': No such image"
42
-
43
- IMG_DIR=$(dirname "$IMG")
44
- IMG_BASENAME=$(basename "$IMG")
45
-
46
- BOX=${2:-}
47
- # If no box name is supplied infer one from image name
48
- if [[ -z "$BOX" ]]; then
49
- BOX_NAME=${IMG_BASENAME%.*}
50
- BOX=$BOX_NAME.box
51
- else
52
- BOX_NAME=$(basename "${BOX%.*}")
53
- fi
54
-
55
- [[ -f "$BOX" ]] && error "'$BOX': Already exists"
56
-
57
- CWD=$(pwd)
58
- TMP_DIR="$CWD/_tmp_package"
59
- TMP_IMG="$TMP_DIR/box.img"
60
-
61
- mkdir -p "$TMP_DIR"
62
-
63
- [[ ! -r "$IMG" ]] && error "'$IMG': Permission denied"
64
-
65
- if [ -n "$3" ] && [ -r "$3" ]; then
66
- VAGRANTFILE_ADD="$(cat $3)"
67
- fi
68
-
69
- # We move / copy (when the image has master) the image to the tempdir
70
- # ensure that it's moved back / removed again
71
- if [[ -n $(backing "$IMG") ]]; then
72
- echo "==> Image has backing image, copying image and rebasing ..."
73
- trap "rm -rf $TMP_DIR" EXIT
74
- cp "$IMG" "$TMP_IMG"
75
- rebase "$TMP_IMG"
76
- else
77
- if fuser -s "$IMG"; then
78
- error "Image '$IMG_BASENAME' is used by another process"
79
- fi
80
-
81
- # move the image to get a speed-up and use less space on disk
82
- trap 'mv "$TMP_IMG" "$IMG"; rm -rf "$TMP_DIR"' EXIT
83
- mv "$IMG" "$TMP_IMG"
84
- fi
85
-
86
- cd "$TMP_DIR"
87
-
88
- #Using the awk int function here to truncate the virtual image size to an
89
- #integer since the fog-libvirt library does not seem to properly handle
90
- #floating point.
91
- IMG_SIZE=$(qemu-img info --output=json "$TMP_IMG" | awk '/virtual-size/{s=int($2)/(1024^3); print (s == int(s)) ? s : int(s)+1 }')
92
-
93
- echo "{$IMG_SIZE}"
94
-
95
- cat > metadata.json <<EOF
96
- {
97
- "provider": "libvirt",
98
- "format": "qcow2",
99
- "virtual_size": ${IMG_SIZE}
100
- }
101
- EOF
102
-
103
- cat > Vagrantfile <<EOF
104
- Vagrant.configure("2") do |config|
105
-
106
- config.vm.provider :libvirt do |libvirt|
107
-
108
- libvirt.driver = "kvm"
109
- libvirt.host = ""
110
- libvirt.connect_via_ssh = false
111
- libvirt.storage_pool_name = "default"
112
-
113
- end
114
-
115
- ${VAGRANTFILE_ADD:-}
116
- end
117
- EOF
118
-
119
- echo "==> Creating box, tarring and gzipping"
120
-
121
- tar cvzf "$BOX" -S --totals ./metadata.json ./Vagrantfile ./box.img
122
-
123
- # if box is in tmpdir move it to CWD before removing tmpdir
124
- if ! isabspath "$BOX"; then
125
- mv "$BOX" "$CWD"
126
- fi
127
-
128
- echo "==> ${BOX} created"
129
- echo "==> You can now add the box:"
130
- echo "==> 'vagrant box add ${BOX} --name ${BOX_NAME}'"
@@ -1,119 +0,0 @@
1
- #!/bin/bash +x
2
-
3
- # This script should help to prepare RedHat and RedHat like OS (CentOS,
4
- # Scientific Linux, ...) for Vagrant box usage.
5
-
6
- # To create new box image, just install minimal base system in VM on top of not
7
- # fully allocated qcow2 image. Then upload this script to the VM and run it.
8
- # After script has finished, nothing else than halting machine should be done.
9
-
10
- # For more info about creating custom box refer to
11
- # https://github.com/vagrant-libvirt/vagrant-libvirt/tree/master/example_box
12
-
13
- # We need to set a hostname.
14
- if [ $# -ne 1 ]; then
15
- echo "Usage: $0 <hostname>"
16
- echo "Hostname should be in format vagrant-[os-name], e.g. vagrant-redhat63."
17
- exit 1
18
- fi
19
-
20
-
21
- # On which version of RedHet are we running?
22
- RHEL_MAJOR_VERSION=$(sed 's/.*release \([0-9]\)\..*/\1/' /etc/redhat-release)
23
- if [ $? -ne 0 ]; then
24
- echo "Is this a RedHat distro?"
25
- exit 1
26
- fi
27
- echo "* Found RedHat ${RHEL_MAJOR_VERSION} version."
28
-
29
-
30
- # Setup hostname vagrant-something.
31
- FQDN="$1.vagrantup.com"
32
- if grep '^HOSTNAME=' /etc/sysconfig/network > /dev/null; then
33
- sed -i 's/HOSTNAME=\(.*\)/HOSTNAME='${FQDN}'/' /etc/sysconfig/network
34
- else
35
- echo "HOSTNAME=${FQDN}" >> /etc/sysconfig/network
36
- fi
37
-
38
-
39
- # Enable EPEL repository.
40
- yum -y install wget
41
- cd ~root
42
- if [ $RHEL_MAJOR_VERSION -eq 5 ]; then
43
- wget http://ftp.astral.ro/mirrors/fedora/pub/epel/5/i386/epel-release-5-4.noarch.rpm
44
- EPEL_PKG="epel-release-5-4.noarch.rpm"
45
- else
46
- wget http://ftp.astral.ro/mirrors/fedora/pub/epel/6/i386/epel-release-6-8.noarch.rpm
47
- EPEL_PKG="epel-release-6-8.noarch.rpm"
48
- fi
49
- rpm -i ~root/${EPEL_PKG}
50
- rm -f ~root/${EPEL_PKG}
51
-
52
-
53
- # Install some required software.
54
- yum -y install openssh-server openssh-clients sudo \
55
- ruby ruby-devel make gcc rubygems rsync
56
- chkconfig sshd on
57
-
58
-
59
- # Users, groups, passwords and sudoers.
60
- echo 'vagrant' | passwd --stdin root
61
- grep 'vagrant' /etc/passwd > /dev/null
62
- if [ $? -ne 0 ]; then
63
- echo '* Creating user vagrant.'
64
- useradd vagrant
65
- echo 'vagrant' | passwd --stdin vagrant
66
- fi
67
- grep '^admin:' /etc/group > /dev/null || groupadd admin
68
- usermod -G admin vagrant
69
-
70
- echo 'Defaults env_keep += "SSH_AUTH_SOCK"' >> /etc/sudoers
71
- echo '%admin ALL=NOPASSWD: ALL' >> /etc/sudoers
72
- sed -i 's/Defaults\s*requiretty/Defaults !requiretty/' /etc/sudoers
73
-
74
-
75
- # SSH setup
76
- # Add Vagrant ssh key for root and vagrant accouts.
77
- sed -i 's/.*UseDNS.*/UseDNS no/' /etc/ssh/sshd_config
78
-
79
- [ -d ~root/.ssh ] || mkdir ~root/.ssh
80
- chmod 700 ~root/.ssh
81
- cat > ~root/.ssh/authorized_keys << EOF
82
- ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key
83
- EOF
84
- chmod 600 ~root/.ssh/authorized_keys
85
-
86
- [ -d ~vagrant/.ssh ] || mkdir ~vagrant/.ssh
87
- chmod 700 ~vagrant/.ssh
88
- cat > ~vagrant/.ssh/authorized_keys << EOF
89
- ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NF8iallvQVp22WDkTkyrtvp9eWW6A8YVr+kz4TjGYe7gHzIw+niNltGEFHzD8+v1I2YJ6oXevct1YeS0o9HZyN1Q9qgCgzUFtdOKLv6IedplqoPkcmF0aYet2PkEDo3MlTBckFXPITAMzF8dJSIFo9D8HfdOV0IAdx4O7PtixWKn5y2hMNG0zQPyUecp4pzC6kivAIhyfHilFR61RGL+GPXQ2MWZWFYbAGjyiYJnAmCP3NOTd0jMZEnDkbUvxhMmBYSdETk1rRgm+R4LOzFUGaHqHDLKLX+FIPKcF96hrucXzcWyLbIbEgE98OHlnVYCzRdK8jlqm8tehUc9c9WhQ== vagrant insecure public key
90
- EOF
91
- chmod 600 ~vagrant/.ssh/authorized_keys
92
-
93
-
94
- # Disable firewall and switch SELinux to permissive mode.
95
- chkconfig iptables off
96
- chkconfig ip6tables off
97
-
98
-
99
- # Networking setup..
100
- # Don't fix ethX names to hw address.
101
- rm -f /etc/udev/rules.d/*persistent-net.rules
102
- rm -f /etc/udev/rules.d/*-net.rules
103
- rm -fr /var/lib/dhclient/*
104
-
105
- # Interface eth0 should get IP address via dhcp.
106
- cat > /etc/sysconfig/network-scripts/ifcfg-eth0 << EOF
107
- DEVICE="eth0"
108
- BOOTPROTO="dhcp"
109
- ONBOOT="yes"
110
- NM_CONTROLLED="no"
111
- EOF
112
-
113
-
114
- # Do some cleanup..
115
- rm -f ~root/.bash_history
116
- rm -r "$(gem env gemdir)"/doc/*
117
- yum clean all
118
-
119
- halt
@@ -1,28 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- require File.expand_path('../lib/vagrant-libvirt/version', __FILE__)
3
-
4
- Gem::Specification.new do |gem|
5
- gem.authors = ['Lukas Stanek','Dima Vasilets','Brian Pitts']
6
- gem.email = ['ls@elostech.cz','pronix.service@gmail.com','brian@polibyte.com']
7
- gem.license = 'MIT'
8
- gem.description = %q{libvirt provider for Vagrant.}
9
- gem.summary = %q{libvirt provider for Vagrant.}
10
- gem.homepage = 'https://github.com/vagrant-libvirt/vagrant-libvirt'
11
-
12
- gem.files = `git ls-files`.split($\)
13
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
14
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
- gem.name = 'vagrant-libvirt'
16
- gem.require_paths = ['lib']
17
- gem.version = VagrantPlugins::ProviderLibvirt::VERSION
18
-
19
- gem.add_development_dependency "rspec-core", "~> 2.14.0"
20
- gem.add_development_dependency "rspec-expectations", "~> 2.14.0"
21
- gem.add_development_dependency "rspec-mocks", "~> 2.14.0"
22
-
23
- gem.add_runtime_dependency 'fog-libvirt', '>= 0.3.0'
24
- gem.add_runtime_dependency 'nokogiri', '~> 1.6.0'
25
- gem.add_runtime_dependency 'fog-core', '~> 1.43.0'
26
-
27
- gem.add_development_dependency 'rake'
28
- end