This file is indexed.

/usr/share/rubygems-integration/all/gems/vagrant-libvirt-0.0.43/lib/vagrant-libvirt/action/handle_storage_pool.rb is in vagrant-libvirt 0.0.43-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
require 'log4r'

module VagrantPlugins
  module ProviderLibvirt
    module Action
      class HandleStoragePool
        include VagrantPlugins::ProviderLibvirt::Util::ErbTemplate

        @@lock = Mutex.new

        def initialize(app, _env)
          @logger = Log4r::Logger.new('vagrant_libvirt::action::handle_storage_pool')
          @app = app
        end

        def call(env)
          # Get config options.
          config = env[:machine].provider_config

          # while inside the synchronize block take care not to call the next
          # action in the chain, as must exit this block first to prevent
          # locking all subsequent actions as well.
          @@lock.synchronize do
            # Check for storage pool, where box image should be created
            break if ProviderLibvirt::Util::Collection.find_matching(
              env[:machine].provider.driver.connection.pools.all, config.storage_pool_name
            )

            @logger.info("No storage pool '#{config.storage_pool_name}' is available.")

            # If user specified other pool than default, don't create default
            # storage pool, just write error message.
            raise Errors::NoStoragePool if config.storage_pool_name != 'default'

            @logger.info("Creating storage pool 'default'")

            # Fog libvirt currently doesn't support creating pools. Use
            # ruby-libvirt client directly.
            begin
              libvirt_pool = env[:machine].provider.driver.connection.client.define_storage_pool_xml(
                to_xml('default_storage_pool')
              )
              libvirt_pool.build
              libvirt_pool.create
            rescue => e
              raise Errors::CreatingStoragePoolError,
                    error_message: e.message
            end
            raise Errors::NoStoragePool unless libvirt_pool
          end

          @app.call(env)
        end
      end
    end
  end
end