mirror of
https://github.com/vagrant-libvirt/vagrant-libvirt.git
synced 2025-02-25 18:55:27 -06:00
close #72 possibility to give VMs a name
This commit is contained in:
@@ -3,10 +3,10 @@ require 'vagrant-libvirt/plugin'
|
||||
|
||||
module VagrantPlugins
|
||||
module ProviderLibvirt
|
||||
lib_path = Pathname.new(File.expand_path("../vagrant-libvirt", __FILE__))
|
||||
autoload :Action, lib_path.join("action")
|
||||
autoload :Errors, lib_path.join("errors")
|
||||
autoload :Util, lib_path.join("util")
|
||||
lib_path = Pathname.new(File.expand_path('../vagrant-libvirt', __FILE__))
|
||||
autoload :Action, lib_path.join('action')
|
||||
autoload :Errors, lib_path.join('errors')
|
||||
autoload :Util, lib_path.join('util')
|
||||
|
||||
# Hold connection handler so there is no need to connect more times than
|
||||
# one. This can be annoying when there are more machines to create, or when
|
||||
@@ -23,7 +23,7 @@ module VagrantPlugins
|
||||
end
|
||||
|
||||
def self.source_root
|
||||
@source_root ||= Pathname.new(File.expand_path("../../", __FILE__))
|
||||
@source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
require "log4r"
|
||||
require 'log4r'
|
||||
|
||||
module VagrantPlugins
|
||||
module ProviderLibvirt
|
||||
@@ -8,7 +8,7 @@ module VagrantPlugins
|
||||
class ReadState
|
||||
def initialize(app, env)
|
||||
@app = app
|
||||
@logger = Log4r::Logger.new("vagrant_libvirt::action::read_state")
|
||||
@logger = Log4r::Logger.new('vagrant_libvirt::action::read_state')
|
||||
end
|
||||
|
||||
def call(env)
|
||||
@@ -21,9 +21,9 @@ module VagrantPlugins
|
||||
|
||||
# Find the machine
|
||||
server = libvirt.servers.get(machine.id)
|
||||
if server.nil? || [:"shutting-down", :terminated].include?(server.state.to_sym)
|
||||
if server.nil? || [:'shutting-down', :terminated].include?(server.state.to_sym)
|
||||
# The machine can't be found
|
||||
@logger.info("Machine not found or terminated, assuming it got destroyed.")
|
||||
@logger.info('Machine not found or terminated, assuming it got destroyed.')
|
||||
machine.id = nil
|
||||
return :not_created
|
||||
end
|
||||
|
||||
@@ -11,8 +11,9 @@ module VagrantPlugins
|
||||
def call(env)
|
||||
require 'securerandom'
|
||||
env[:domain_name] = env[:root_path].basename.to_s.dup
|
||||
env[:domain_name].gsub!(/[^-a-z0-9_]/i, "")
|
||||
env[:domain_name] << "_#{SecureRandom.hex}"
|
||||
env[:domain_name].gsub!(/[^-a-z0-9_]/i, '')
|
||||
env[:domain_name] << '_'
|
||||
env[:domain_name] << env[:machine].name.to_s
|
||||
|
||||
# Check if the domain name is not already taken
|
||||
domain = ProviderLibvirt::Util::Collection.find_matching(
|
||||
|
||||
Reference in New Issue
Block a user