vagrant-libvirt 0.0.36 → 0.0.37

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -0
  3. data/Gemfile +1 -0
  4. data/README.md +171 -13
  5. data/lib/vagrant-libvirt/action/create_domain.rb +44 -19
  6. data/lib/vagrant-libvirt/action/create_domain_volume.rb +12 -12
  7. data/lib/vagrant-libvirt/action/create_network_interfaces.rb +37 -39
  8. data/lib/vagrant-libvirt/action/create_networks.rb +34 -34
  9. data/lib/vagrant-libvirt/action/destroy_domain.rb +7 -8
  10. data/lib/vagrant-libvirt/action/destroy_networks.rb +12 -13
  11. data/lib/vagrant-libvirt/action/forward_ports.rb +21 -23
  12. data/lib/vagrant-libvirt/action/halt_domain.rb +8 -9
  13. data/lib/vagrant-libvirt/action/handle_box_image.rb +28 -27
  14. data/lib/vagrant-libvirt/action/handle_storage_pool.rb +8 -8
  15. data/lib/vagrant-libvirt/action/is_created.rb +1 -1
  16. data/lib/vagrant-libvirt/action/is_running.rb +2 -2
  17. data/lib/vagrant-libvirt/action/is_suspended.rb +4 -4
  18. data/lib/vagrant-libvirt/action/message_already_created.rb +2 -2
  19. data/lib/vagrant-libvirt/action/message_not_created.rb +2 -2
  20. data/lib/vagrant-libvirt/action/message_not_running.rb +2 -2
  21. data/lib/vagrant-libvirt/action/message_not_suspended.rb +2 -2
  22. data/lib/vagrant-libvirt/action/package_domain.rb +6 -5
  23. data/lib/vagrant-libvirt/action/prepare_nfs_settings.rb +7 -6
  24. data/lib/vagrant-libvirt/action/prepare_nfs_valid_ids.rb +2 -2
  25. data/lib/vagrant-libvirt/action/prune_nfs_exports.rb +3 -3
  26. data/lib/vagrant-libvirt/action/read_mac_addresses.rb +8 -10
  27. data/lib/vagrant-libvirt/action/remove_libvirt_image.rb +4 -4
  28. data/lib/vagrant-libvirt/action/remove_stale_volume.rb +8 -7
  29. data/lib/vagrant-libvirt/action/resume_domain.rb +5 -5
  30. data/lib/vagrant-libvirt/action/set_boot_order.rb +70 -27
  31. data/lib/vagrant-libvirt/action/set_name_of_domain.rb +10 -12
  32. data/lib/vagrant-libvirt/action/share_folders.rb +16 -18
  33. data/lib/vagrant-libvirt/action/start_domain.rb +59 -64
  34. data/lib/vagrant-libvirt/action/suspend_domain.rb +5 -5
  35. data/lib/vagrant-libvirt/action/wait_till_up.rb +24 -26
  36. data/lib/vagrant-libvirt/action.rb +18 -23
  37. data/lib/vagrant-libvirt/cap/mount_p9.rb +11 -10
  38. data/lib/vagrant-libvirt/cap/nic_mac_addresses.rb +1 -1
  39. data/lib/vagrant-libvirt/cap/synced_folder.rb +20 -19
  40. data/lib/vagrant-libvirt/config.rb +164 -136
  41. data/lib/vagrant-libvirt/driver.rb +10 -13
  42. data/lib/vagrant-libvirt/errors.rb +4 -3
  43. data/lib/vagrant-libvirt/plugin.rb +4 -6
  44. data/lib/vagrant-libvirt/provider.rb +23 -24
  45. data/lib/vagrant-libvirt/templates/domain.xml.erb +14 -1
  46. data/lib/vagrant-libvirt/templates/private_network.xml.erb +4 -0
  47. data/lib/vagrant-libvirt/util/collection.rb +0 -3
  48. data/lib/vagrant-libvirt/util/erb_template.rb +6 -10
  49. data/lib/vagrant-libvirt/util/error_codes.rb +32 -33
  50. data/lib/vagrant-libvirt/util/network_util.rb +29 -21
  51. data/lib/vagrant-libvirt/util.rb +3 -4
  52. data/lib/vagrant-libvirt/version.rb +1 -1
  53. data/locales/en.yml +3 -0
  54. data/spec/spec_helper.rb +3 -0
  55. data/spec/support/environment_helper.rb +5 -7
  56. data/spec/support/libvirt_context.rb +13 -11
  57. data/spec/support/sharedcontext.rb +9 -10
  58. data/spec/unit/action/destroy_domain_spec.rb +38 -37
  59. data/spec/unit/action/set_name_of_domain_spec.rb +4 -4
  60. data/spec/unit/action/wait_till_up_spec.rb +45 -46
  61. data/spec/unit/config_spec.rb +106 -0
  62. data/spec/unit/templates/domain_all_settings.xml +125 -0
  63. data/spec/unit/templates/domain_defaults.xml +44 -0
  64. data/spec/unit/templates/domain_spec.rb +69 -0
  65. data/tools/create_box.sh +8 -2
  66. metadata +12 -3
@@ -4,38 +4,38 @@ module VagrantPlugins
4
4
  module ProviderLibvirt
5
5
  module Action
6
6
  class HandleBoxImage
7
-
8
7
  @@lock = Mutex.new
9
8
 
10
- def initialize(app, env)
9
+ def initialize(app, _env)
11
10
  @logger = Log4r::Logger.new('vagrant_libvirt::action::handle_box_image')
12
11
  @app = app
13
12
  end
14
13
 
15
14
  def call(env)
16
-
17
15
  # Verify box metadata for mandatory values.
18
16
  #
19
17
  # Virtual size has to be set for allocating space in storage pool.
20
18
  box_virtual_size = env[:machine].box.metadata['virtual_size']
21
- if box_virtual_size == nil
22
- raise Errors::NoBoxVirtualSizeSet
23
- end
19
+ raise Errors::NoBoxVirtualSizeSet if box_virtual_size.nil?
24
20
 
25
21
  # Support qcow2 format only for now, but other formats with backing
26
22
  # store capability should be usable.
27
23
  box_format = env[:machine].box.metadata['format']
28
- if box_format == nil
24
+ if box_format.nil?
29
25
  raise Errors::NoBoxFormatSet
30
26
  elsif box_format != 'qcow2'
31
27
  raise Errors::WrongBoxFormatSet
32
28
  end
33
29
 
34
30
  # Get config options
35
- config = env[:machine].provider_config
31
+ config = env[:machine].provider_config
36
32
  box_image_file = env[:machine].box.directory.join('box.img').to_s
37
- env[:box_volume_name] = env[:machine].box.name.to_s.dup.gsub("/", "-VAGRANTSLASH-")
38
- env[:box_volume_name] << "_vagrant_box_image_#{env[:machine].box.version.to_s rescue ''}.img"
33
+ env[:box_volume_name] = env[:machine].box.name.to_s.dup.gsub('/', '-VAGRANTSLASH-')
34
+ env[:box_volume_name] << "_vagrant_box_image_#{begin
35
+ env[:machine].box.version.to_s
36
+ rescue
37
+ ''
38
+ end}.img"
39
39
 
40
40
  # Override box_virtual_size
41
41
  if config.machine_virtual_size
@@ -60,15 +60,16 @@ module VagrantPlugins
60
60
  @@lock.synchronize do
61
61
  # Don't continue if image already exists in storage pool.
62
62
  break if ProviderLibvirt::Util::Collection.find_matching(
63
- env[:machine].provider.driver.connection.volumes.all, env[:box_volume_name])
63
+ env[:machine].provider.driver.connection.volumes.all, env[:box_volume_name]
64
+ )
64
65
 
65
66
  # Box is not available as a storage pool volume. Create and upload
66
67
  # it as a copy of local box image.
67
68
  env[:ui].info(I18n.t('vagrant_libvirt.uploading_volume'))
68
69
 
69
70
  # Create new volume in storage pool
70
- unless File.exists?(box_image_file)
71
- raise Vagrant::Errors::BoxNotFound.new(name: env[:machine].box.name)
71
+ unless File.exist?(box_image_file)
72
+ raise Vagrant::Errors::BoxNotFound, name: env[:machine].box.name
72
73
  end
73
74
  box_image_size = File.size(box_image_file) # B
74
75
  message = "Creating volume #{env[:box_volume_name]}"
@@ -77,20 +78,21 @@ module VagrantPlugins
77
78
  begin
78
79
  fog_volume = env[:machine].provider.driver.connection.volumes.create(
79
80
  name: env[:box_volume_name],
80
- allocation: "#{box_image_size/1024/1024}M",
81
+ allocation: "#{box_image_size / 1024 / 1024}M",
81
82
  capacity: "#{box_virtual_size}G",
82
83
  format_type: box_format,
83
- pool_name: config.storage_pool_name)
84
+ pool_name: config.storage_pool_name
85
+ )
84
86
  rescue Fog::Errors::Error => e
85
87
  raise Errors::FogCreateVolumeError,
86
- :error_message => e.message
88
+ error_message: e.message
87
89
  end
88
90
 
89
91
  # Upload box image to storage pool
90
92
  ret = upload_image(box_image_file, config.storage_pool_name,
91
- env[:box_volume_name], env) do |progress|
92
- env[:ui].clear_line
93
- env[:ui].report_progress(progress, box_image_size, false)
93
+ env[:box_volume_name], env) do |progress|
94
+ env[:ui].clear_line
95
+ env[:ui].report_progress(progress, box_image_size, false)
94
96
  end
95
97
 
96
98
  # Clear the line one last time since the progress meter doesn't
@@ -120,10 +122,11 @@ module VagrantPlugins
120
122
 
121
123
  begin
122
124
  pool = env[:machine].provider.driver.connection.client.lookup_storage_pool_by_name(
123
- pool_name)
125
+ pool_name
126
+ )
124
127
  volume = pool.lookup_volume_by_name(volume_name)
125
128
  stream = env[:machine].provider.driver.connection.client.stream
126
- volume.upload(stream, offset=0, length=image_size)
129
+ volume.upload(stream, offset = 0, length = image_size)
127
130
 
128
131
  # Exception ProviderLibvirt::RetrieveError can be raised if buffer is
129
132
  # longer than length accepted by API send function.
@@ -131,10 +134,10 @@ module VagrantPlugins
131
134
  # TODO: How to find out if buffer is too large and what is the
132
135
  # length that send function will accept?
133
136
 
134
- buf_size = 1024*250 # 250K
137
+ buf_size = 1024 * 250 # 250K
135
138
  progress = 0
136
139
  open(image_file, 'rb') do |io|
137
- while (buff = io.read(buf_size)) do
140
+ while (buff = io.read(buf_size))
138
141
  sent = stream.send buff
139
142
  progress += sent
140
143
  yield progress
@@ -142,14 +145,12 @@ module VagrantPlugins
142
145
  end
143
146
  rescue => e
144
147
  raise Errors::ImageUploadError,
145
- :error_message => e.message
148
+ error_message: e.message
146
149
  end
147
150
 
148
- return progress == image_size
151
+ progress == image_size
149
152
  end
150
-
151
153
  end
152
154
  end
153
155
  end
154
156
  end
155
-
@@ -8,8 +8,8 @@ module VagrantPlugins
8
8
 
9
9
  @@lock = Mutex.new
10
10
 
11
- def initialize(app, env)
12
- @logger = Log4r::Logger.new("vagrant_libvirt::action::handle_storage_pool")
11
+ def initialize(app, _env)
12
+ @logger = Log4r::Logger.new('vagrant_libvirt::action::handle_storage_pool')
13
13
  @app = app
14
14
  end
15
15
 
@@ -23,7 +23,8 @@ module VagrantPlugins
23
23
  @@lock.synchronize do
24
24
  # Check for storage pool, where box image should be created
25
25
  break if ProviderLibvirt::Util::Collection.find_matching(
26
- env[:machine].provider.driver.connection.pools.all, config.storage_pool_name)
26
+ env[:machine].provider.driver.connection.pools.all, config.storage_pool_name
27
+ )
27
28
 
28
29
  @logger.info("No storage pool '#{config.storage_pool_name}' is available.")
29
30
 
@@ -37,21 +38,20 @@ module VagrantPlugins
37
38
  # ruby-libvirt client directly.
38
39
  begin
39
40
  libvirt_pool = env[:machine].provider.driver.connection.client.define_storage_pool_xml(
40
- to_xml('default_storage_pool'))
41
+ to_xml('default_storage_pool')
42
+ )
41
43
  libvirt_pool.build
42
44
  libvirt_pool.create
43
45
  rescue => e
44
46
  raise Errors::CreatingStoragePoolError,
45
- :error_message => e.message
47
+ error_message: e.message
46
48
  end
47
- raise Errors::NoStoragePool if !libvirt_pool
49
+ raise Errors::NoStoragePool unless libvirt_pool
48
50
  end
49
51
 
50
52
  @app.call(env)
51
53
  end
52
-
53
54
  end
54
55
  end
55
56
  end
56
57
  end
57
-
@@ -4,7 +4,7 @@ module VagrantPlugins
4
4
  # This can be used with "Call" built-in to check if the machine
5
5
  # is created and branch in the middleware.
6
6
  class IsCreated
7
- def initialize(app, env)
7
+ def initialize(app, _env)
8
8
  @app = app
9
9
  end
10
10
 
@@ -4,13 +4,13 @@ module VagrantPlugins
4
4
  # This can be used with "Call" built-in to check if the machine
5
5
  # is running and branch in the middleware.
6
6
  class IsRunning
7
- def initialize(app, env)
7
+ def initialize(app, _env)
8
8
  @app = app
9
9
  end
10
10
 
11
11
  def call(env)
12
12
  domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
13
- raise Errors::NoDomainError if domain == nil
13
+ raise Errors::NoDomainError if domain.nil?
14
14
  env[:result] = domain.state.to_s == 'running'
15
15
 
16
16
  @app.call(env)
@@ -4,16 +4,16 @@ module VagrantPlugins
4
4
  # This can be used with "Call" built-in to check if the machine
5
5
  # is suspended and branch in the middleware.
6
6
  class IsSuspended
7
- def initialize(app, env)
7
+ def initialize(app, _env)
8
8
  @app = app
9
9
  end
10
10
 
11
11
  def call(env)
12
12
  domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
13
- raise Errors::NoDomainError if domain == nil
13
+ raise Errors::NoDomainError if domain.nil?
14
14
 
15
15
  config = env[:machine].provider_config
16
- libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(env[:machine].id)
16
+ libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(env[:machine].id)
17
17
  if config.suspend_mode == 'managedsave'
18
18
  if libvirt_domain.has_managed_save?
19
19
  env[:result] = libvirt_domain.has_managed_save?
@@ -33,7 +33,7 @@ module VagrantPlugins
33
33
  env[:result] = domain.state.to_s == 'paused'
34
34
  end
35
35
  end
36
-
36
+
37
37
  @app.call(env)
38
38
  end
39
39
  end
@@ -2,12 +2,12 @@ module VagrantPlugins
2
2
  module ProviderLibvirt
3
3
  module Action
4
4
  class MessageAlreadyCreated
5
- def initialize(app, env)
5
+ def initialize(app, _env)
6
6
  @app = app
7
7
  end
8
8
 
9
9
  def call(env)
10
- env[:ui].info(I18n.t("vagrant_libvirt.already_created"))
10
+ env[:ui].info(I18n.t('vagrant_libvirt.already_created'))
11
11
  @app.call(env)
12
12
  end
13
13
  end
@@ -2,12 +2,12 @@ module VagrantPlugins
2
2
  module ProviderLibvirt
3
3
  module Action
4
4
  class MessageNotCreated
5
- def initialize(app, env)
5
+ def initialize(app, _env)
6
6
  @app = app
7
7
  end
8
8
 
9
9
  def call(env)
10
- env[:ui].info(I18n.t("vagrant_libvirt.not_created"))
10
+ env[:ui].info(I18n.t('vagrant_libvirt.not_created'))
11
11
  @app.call(env)
12
12
  end
13
13
  end
@@ -2,12 +2,12 @@ module VagrantPlugins
2
2
  module ProviderLibvirt
3
3
  module Action
4
4
  class MessageNotRunning
5
- def initialize(app, env)
5
+ def initialize(app, _env)
6
6
  @app = app
7
7
  end
8
8
 
9
9
  def call(env)
10
- env[:ui].info(I18n.t("vagrant_libvirt.not_running"))
10
+ env[:ui].info(I18n.t('vagrant_libvirt.not_running'))
11
11
  @app.call(env)
12
12
  end
13
13
  end
@@ -2,12 +2,12 @@ module VagrantPlugins
2
2
  module ProviderLibvirt
3
3
  module Action
4
4
  class MessageNotSuspended
5
- def initialize(app, env)
5
+ def initialize(app, _env)
6
6
  @app = app
7
7
  end
8
8
 
9
9
  def call(env)
10
- env[:ui].info(I18n.t("vagrant_libvirt.not_suspended"))
10
+ env[:ui].info(I18n.t('vagrant_libvirt.not_suspended'))
11
11
  @app.call(env)
12
12
  end
13
13
  end
@@ -14,14 +14,15 @@ module VagrantPlugins
14
14
 
15
15
  def call(env)
16
16
  env[:ui].info(I18n.t('vagrant_libvirt.package_domain'))
17
- libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(
18
- env[:machine].id)
17
+ libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(
18
+ env[:machine].id
19
+ )
19
20
  domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
20
21
  root_disk = domain.volumes.select do |x|
21
22
  x.name == libvirt_domain.name + '.img'
22
23
  end.first
23
24
  boxname = env['package.output']
24
- raise "#{boxname}: Already exists" if File.exists?(boxname)
25
+ raise "#{boxname}: Already exists" if File.exist?(boxname)
25
26
  @tmp_dir = Dir.pwd + '/_tmp_package'
26
27
  @tmp_img = @tmp_dir + '/box.img'
27
28
  Dir.mkdir(@tmp_dir)
@@ -37,11 +38,11 @@ module VagrantPlugins
37
38
  `qemu-img rebase -p -b "" #{@tmp_img}`
38
39
  # remove hw association with interface
39
40
  # working for centos with lvs default disks
40
- `virt-sysprep --no-logfile --operations defaults,-ssh-userdir -a #{@tmp_img} `
41
+ `virt-sysprep --no-logfile --operations defaults,-ssh-userdir -a #{@tmp_img}`
41
42
  Dir.chdir(@tmp_dir)
42
43
  img_size = `qemu-img info #{@tmp_img} | grep 'virtual size' | awk '{print $3;}' | tr -d 'G'`.chomp
43
44
  File.write(@tmp_dir + '/metadata.json', metadata_content(img_size))
44
- File.write(@tmp_dir + '/Vagrantfile',vagrantfile_content)
45
+ File.write(@tmp_dir + '/Vagrantfile', vagrantfile_content)
45
46
  assebmle_box(boxname)
46
47
  FileUtils.mv(@tmp_dir + '/' + boxname, '../' + boxname)
47
48
  FileUtils.rm_rf(@tmp_dir)
@@ -8,9 +8,9 @@ module VagrantPlugins
8
8
  class PrepareNFSSettings
9
9
  include Vagrant::Action::Builtin::MixinSyncedFolders
10
10
 
11
- def initialize(app,env)
11
+ def initialize(app, _env)
12
12
  @app = app
13
- @logger = Log4r::Logger.new("vagrant::action::vm::nfs")
13
+ @logger = Log4r::Logger.new('vagrant::action::vm::nfs')
14
14
  end
15
15
 
16
16
  def call(env)
@@ -18,7 +18,7 @@ module VagrantPlugins
18
18
  @app.call(env)
19
19
 
20
20
  if using_nfs?
21
- @logger.info("Using NFS, preparing NFS settings by reading host IP and machine IP")
21
+ @logger.info('Using NFS, preparing NFS settings by reading host IP and machine IP')
22
22
  env[:nfs_machine_ip] = read_machine_ip(env[:machine])
23
23
  env[:nfs_host_ip] = read_host_ip(env[:nfs_machine_ip])
24
24
 
@@ -41,7 +41,7 @@ module VagrantPlugins
41
41
  # @return [String]
42
42
  def read_host_ip(ip)
43
43
  UDPSocket.open do |s|
44
- if(ip.kind_of?(Array))
44
+ if ip.is_a?(Array)
45
45
  s.connect(ip.last, 1)
46
46
  else
47
47
  s.connect(ip, 1)
@@ -49,6 +49,7 @@ module VagrantPlugins
49
49
  s.addr.last
50
50
  end
51
51
  end
52
+
52
53
  # Returns the IP address of the guest
53
54
  #
54
55
  # @param [Machine] machine
@@ -59,8 +60,8 @@ module VagrantPlugins
59
60
  return ssh_host if ping(ssh_host)
60
61
 
61
62
  # check other ips
62
- command = "ip addr show | grep -i 'inet ' | grep -v '127.0.0.1' | tr -s ' ' | cut -d' ' -f3 | cut -d'/' -f 1"
63
- result = ""
63
+ command = "ip=$(which ip); ${ip:-/sbin/ip} addr show | grep -i 'inet ' | grep -v '127.0.0.1' | tr -s ' ' | cut -d' ' -f3 | cut -d'/' -f 1"
64
+ result = ''
64
65
  machine.communicate.execute(command) do |type, data|
65
66
  result << data if type == :stdout
66
67
  end
@@ -2,9 +2,9 @@ module VagrantPlugins
2
2
  module ProviderLibvirt
3
3
  module Action
4
4
  class PrepareNFSValidIds
5
- def initialize(app, env)
5
+ def initialize(app, _env)
6
6
  @app = app
7
- @logger = Log4r::Logger.new("vagrant::action::vm::nfs")
7
+ @logger = Log4r::Logger.new('vagrant::action::vm::nfs')
8
8
  end
9
9
 
10
10
  def call(env)
@@ -3,8 +3,7 @@ module VagrantPlugins
3
3
  module ProviderLibvirt
4
4
  module Action
5
5
  class PruneNFSExports
6
-
7
- def initialize(app, env)
6
+ def initialize(app, _env)
8
7
  @app = app
9
8
  end
10
9
 
@@ -16,7 +15,8 @@ module VagrantPlugins
16
15
  # not exiisted in array will removed from nfs
17
16
  uuids.delete(uuid)
18
17
  env[:host].capability(
19
- :nfs_prune, env[:machine].ui, uuids)
18
+ :nfs_prune, env[:machine].ui, uuids
19
+ )
20
20
  end
21
21
 
22
22
  @app.call(env)
@@ -1,12 +1,12 @@
1
- require "log4r"
1
+ require 'log4r'
2
2
 
3
3
  module VagrantPlugins
4
4
  module ProviderLibvirt
5
5
  module Action
6
6
  class ReadMacAddresses
7
- def initialize(app, env)
7
+ def initialize(app, _env)
8
8
  @app = app
9
- @logger = Log4r::Logger.new("vagrant_libvirt::action::read_mac_addresses")
9
+ @logger = Log4r::Logger.new('vagrant_libvirt::action::read_mac_addresses')
10
10
  end
11
11
 
12
12
  def call(env)
@@ -19,21 +19,19 @@ module VagrantPlugins
19
19
  domain = libvirt.client.lookup_domain_by_uuid(machine.id)
20
20
 
21
21
  if domain.nil?
22
- @logger.info("Machine could not be found, assuming it got destroyed")
22
+ @logger.info('Machine could not be found, assuming it got destroyed')
23
23
  machine.id = nil
24
24
  return nil
25
25
  end
26
26
 
27
27
  xml = Nokogiri::XML(domain.xml_desc)
28
- mac = xml.xpath("/domain/devices/interface/mac/@address")
28
+ mac = xml.xpath('/domain/devices/interface/mac/@address')
29
29
 
30
- if mac.length == 0
31
- return {}
32
- end
30
+ return {} if mac.empty?
33
31
 
34
- Hash[mac.each_with_index.map do |x,i|
32
+ Hash[mac.each_with_index.map do |x, i|
35
33
  @logger.debug("interface[#{i}] = #{x.value}")
36
- [i,x.value]
34
+ [i, x.value]
37
35
  end]
38
36
  end
39
37
  end
@@ -4,14 +4,14 @@ module VagrantPlugins
4
4
  module ProviderLibvirt
5
5
  module Action
6
6
  class RemoveLibvirtImage
7
- def initialize(app, env)
8
- @logger = Log4r::Logger.new("vagrant_libvirt::action::remove_libvirt_image")
7
+ def initialize(app, _env)
8
+ @logger = Log4r::Logger.new('vagrant_libvirt::action::remove_libvirt_image')
9
9
  @app = app
10
10
  end
11
11
 
12
12
  def call(env)
13
- env[:ui].info("Vagrant-libvirt plugin removed box only from you LOCAL ~/.vagrant/boxes directory")
14
- env[:ui].info("From libvirt storage pool you have to delete image manually(virsh, virt-manager or by any other tool)")
13
+ env[:ui].info('Vagrant-libvirt plugin removed box only from you LOCAL ~/.vagrant/boxes directory')
14
+ env[:ui].info('From libvirt storage pool you have to delete image manually(virsh, virt-manager or by any other tool)')
15
15
  @app.call(env)
16
16
  end
17
17
  end
@@ -1,15 +1,14 @@
1
1
  require 'log4r'
2
- #require 'log4r/yamlconfigurator'
2
+ # require 'log4r/yamlconfigurator'
3
3
 
4
4
  module VagrantPlugins
5
5
  module ProviderLibvirt
6
6
  module Action
7
7
  class RemoveStaleVolume
8
8
  def initialize(app, _env)
9
-
10
- # log4r_config= YAML.load_file(File.join(File.dirname(__FILE__),"log4r.yaml"))
11
- # log_cfg = Log4r::YamlConfigurator
12
- # log_cfg.decode_yaml( log4r_config['log4r_config'] )
9
+ # log4r_config= YAML.load_file(File.join(File.dirname(__FILE__),"log4r.yaml"))
10
+ # log_cfg = Log4r::YamlConfigurator
11
+ # log_cfg.decode_yaml( log4r_config['log4r_config'] )
13
12
 
14
13
  @logger = Log4r::Logger.new('vagrant_libvirt::action::remove_stale_volume')
15
14
  @app = app
@@ -22,7 +21,8 @@ module VagrantPlugins
22
21
  config = env[:machine].provider_config
23
22
  # Check for storage pool, where box image should be created
24
23
  fog_pool = ProviderLibvirt::Util::Collection.find_matching(
25
- env[:machine].provider.driver.connection.pools.all, config.storage_pool_name)
24
+ env[:machine].provider.driver.connection.pools.all, config.storage_pool_name
25
+ )
26
26
  @logger.debug("**** Pool #{fog_pool.name}")
27
27
 
28
28
  # This is name of newly created image for vm.
@@ -31,7 +31,8 @@ module VagrantPlugins
31
31
 
32
32
  # remove root storage
33
33
  box_volume = ProviderLibvirt::Util::Collection.find_matching(
34
- env[:machine].provider.driver.connection.volumes.all, name)
34
+ env[:machine].provider.driver.connection.volumes.all, name
35
+ )
35
36
  if box_volume && box_volume.pool_name == fog_pool.name
36
37
  @logger.info("Deleting volume #{box_volume.key}")
37
38
  box_volume.destroy
@@ -5,18 +5,18 @@ module VagrantPlugins
5
5
  module Action
6
6
  # Resume suspended domain.
7
7
  class ResumeDomain
8
- def initialize(app, env)
9
- @logger = Log4r::Logger.new("vagrant_libvirt::action::resume_domain")
8
+ def initialize(app, _env)
9
+ @logger = Log4r::Logger.new('vagrant_libvirt::action::resume_domain')
10
10
  @app = app
11
11
  end
12
12
 
13
13
  def call(env)
14
- env[:ui].info(I18n.t("vagrant_libvirt.resuming_domain"))
14
+ env[:ui].info(I18n.t('vagrant_libvirt.resuming_domain'))
15
15
 
16
16
  domain = env[:machine].provider.driver.connection.servers.get(env[:machine].id.to_s)
17
- raise Errors::NoDomainError if domain == nil
17
+ raise Errors::NoDomainError if domain.nil?
18
18
 
19
- libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(env[:machine].id)
19
+ libvirt_domain = env[:machine].provider.driver.connection.client.lookup_domain_by_uuid(env[:machine].id)
20
20
  config = env[:machine].provider_config
21
21
  if config.suspend_mode == 'managedsave'
22
22
  domain.start