Module: VagrantPlugins::ProviderLibvirt

Defined in:
lib/vagrant-libvirt.rb,
lib/vagrant-libvirt/util.rb,
lib/vagrant-libvirt/action.rb,
lib/vagrant-libvirt/config.rb,
lib/vagrant-libvirt/driver.rb,
lib/vagrant-libvirt/errors.rb,
lib/vagrant-libvirt/plugin.rb,
lib/vagrant-libvirt/util/ui.rb,
lib/vagrant-libvirt/version.rb,
lib/vagrant-libvirt/provider.rb,
lib/vagrant-libvirt/util/nfs.rb,
lib/vagrant-libvirt/util/xml.rb,
lib/vagrant-libvirt/util/timer.rb,
lib/vagrant-libvirt/util/compat.rb,
lib/vagrant-libvirt/cap/mount_9p.rb,
lib/vagrant-libvirt/cap/snapshots.rb,
lib/vagrant-libvirt/util/resolvers.rb,
lib/vagrant-libvirt/util/collection.rb,
lib/vagrant-libvirt/util/error_codes.rb,
lib/vagrant-libvirt/action/is_created.rb,
lib/vagrant-libvirt/action/is_running.rb,
lib/vagrant-libvirt/util/domain_flags.rb,
lib/vagrant-libvirt/util/erb_template.rb,
lib/vagrant-libvirt/util/network_util.rb,
lib/vagrant-libvirt/util/storage_util.rb,
lib/vagrant-libvirt/action/halt_domain.rb,
lib/vagrant-libvirt/cap/mount_virtiofs.rb,
lib/vagrant-libvirt/cap/public_address.rb,
lib/vagrant-libvirt/action/is_suspended.rb,
lib/vagrant-libvirt/action/start_domain.rb,
lib/vagrant-libvirt/action/wait_till_up.rb,
lib/vagrant-libvirt/action/create_domain.rb,
lib/vagrant-libvirt/action/forward_ports.rb,
lib/vagrant-libvirt/action/forward_ports.rb,
lib/vagrant-libvirt/action/resume_domain.rb,
lib/vagrant-libvirt/action/share_folders.rb,
lib/vagrant-libvirt/action/snapshot_save.rb,
lib/vagrant-libvirt/action/destroy_domain.rb,
lib/vagrant-libvirt/action/package_domain.rb,
lib/vagrant-libvirt/action/set_boot_order.rb,
lib/vagrant-libvirt/action/suspend_domain.rb,
lib/vagrant-libvirt/cap/nic_mac_addresses.rb,
lib/vagrant-libvirt/action/create_networks.rb,
lib/vagrant-libvirt/action/shutdown_domain.rb,
lib/vagrant-libvirt/action/shutdown_domain.rb,
lib/vagrant-libvirt/action/snapshot_delete.rb,
lib/vagrant-libvirt/action/destroy_networks.rb,
lib/vagrant-libvirt/action/handle_box_image.rb,
lib/vagrant-libvirt/action/snapshot_restore.rb,
lib/vagrant-libvirt/action/prune_nfs_exports.rb,
lib/vagrant-libvirt/action/cleanup_on_failure.rb,
lib/vagrant-libvirt/action/read_mac_addresses.rb,
lib/vagrant-libvirt/action/set_name_of_domain.rb,
lib/vagrant-libvirt/action/handle_storage_pool.rb,
lib/vagrant-libvirt/action/message_not_created.rb,
lib/vagrant-libvirt/action/message_not_running.rb,
lib/vagrant-libvirt/action/remove_stale_volume.rb,
lib/vagrant-libvirt/action/clean_machine_folder.rb,
lib/vagrant-libvirt/action/create_domain_volume.rb,
lib/vagrant-libvirt/action/prepare_nfs_settings.rb,
lib/vagrant-libvirt/action/remove_libvirt_image.rb,
lib/vagrant-libvirt/action/message_not_suspended.rb,
lib/vagrant-libvirt/action/prepare_nfs_valid_ids.rb,
lib/vagrant-libvirt/action/resolve_disk_settings.rb,
lib/vagrant-libvirt/action/message_already_created.rb,
lib/vagrant-libvirt/action/message_will_not_destroy.rb,
lib/vagrant-libvirt/action/create_network_interfaces.rb

Defined Under Namespace

Modules: Action, Cap, Errors, Util Classes: Config, Driver, Plugin, Provider

Constant Summary collapse

VERSION_FILE =
File.dirname(__FILE__) + "/version"
GIT_ARCHIVE_VERSION =
"$Format:%H %D$"
HOMEPAGE =
'https://github.com/vagrant-libvirt/vagrant-libvirt'

Class Method Summary collapse

Class Method Details

.get_versionObject



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
# File 'lib/vagrant-libvirt/version.rb', line 14

def self.get_version
  if File.exist?(VERSION_FILE)
    # built gem
    version = File.read(VERSION_FILE)
  elsif self.inside_git_repository
    # local repo
    git_version = `git describe --tags`
    version = self.version_from_describe(git_version)
  elsif !GIT_ARCHIVE_VERSION.start_with?('$Format')
    # archive - format string replaced during export
    hash, refs = GIT_ARCHIVE_VERSION.split(' ', 2)

    tag = refs.split(',').select { |ref| ref.strip.start_with?("tag:") }.first
    if tag != nil
      # tagged
      version = tag.strip.split(' ').last
    else
      version = ""
      # arbitrary branch/commit
      Dir.mktmpdir do |dir|
        stdout_and_stderr, status = Open3.capture2e("git -C #{dir} clone --bare #{HOMEPAGE}")
        raise "failed to clone original to resolve version: #{stdout_and_stderr}" unless status.success?

        stdout_and_stderr, status = Open3.capture2e("git --git-dir=#{dir}/vagrant-libvirt.git describe --tags #{hash}")
        raise "failed to determine version for #{hash}: #{stdout_and_stderr}" unless status.success?

        version = version_from_describe(stdout_and_stderr)
      end

      # in this case write the version file to avoid cloning a second time
      File.write(VERSION_FILE, version)
    end
  else
    # no idea
    version = "9999"
  end

  return version.freeze
end

.source_rootObject



12
13
14
# File 'lib/vagrant-libvirt.rb', line 12

def self.source_root
  @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
end

.write_versionObject



54
55
56
# File 'lib/vagrant-libvirt/version.rb', line 54

def self.write_version
  File.write(VERSION_FILE, self.get_version)
end