[DRE-commits] [vagrant-libvirt] 101/104: close #72 possibility to give VMs a name

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Apr 24 13:55:52 UTC 2016


This is an automated email from the git hooks/post-receive script.

terceiro pushed a commit to annotated tag 0.0.11
in repository vagrant-libvirt.

commit be44fc10b8a6a527b33f3020ad36654536e41862
Author: dima <pronix.service at gmail.com>
Date:   Sat Oct 19 23:10:31 2013 +0200

    close #72 possibility to give VMs a name
---
 lib/vagrant-libvirt.rb                           | 10 +++++-----
 lib/vagrant-libvirt/action/read_state.rb         |  8 ++++----
 lib/vagrant-libvirt/action/set_name_of_domain.rb |  5 +++--
 3 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/lib/vagrant-libvirt.rb b/lib/vagrant-libvirt.rb
index 6d1f899..c7204d9 100644
--- a/lib/vagrant-libvirt.rb
+++ b/lib/vagrant-libvirt.rb
@@ -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
diff --git a/lib/vagrant-libvirt/action/read_state.rb b/lib/vagrant-libvirt/action/read_state.rb
index 696c42b..4b06d3b 100644
--- a/lib/vagrant-libvirt/action/read_state.rb
+++ b/lib/vagrant-libvirt/action/read_state.rb
@@ -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
diff --git a/lib/vagrant-libvirt/action/set_name_of_domain.rb b/lib/vagrant-libvirt/action/set_name_of_domain.rb
index 7ff0e49..30fc5b4 100644
--- a/lib/vagrant-libvirt/action/set_name_of_domain.rb
+++ b/lib/vagrant-libvirt/action/set_name_of_domain.rb
@@ -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(

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/vagrant-libvirt.git



More information about the Pkg-ruby-extras-commits mailing list