[DRE-commits] [vagrant-libvirt] 52/67: Add network debugging output

Antonio Terceiro terceiro at moszumanska.debian.org
Sun Apr 24 13:56:06 UTC 2016


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

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

commit c4d758b4e74ce6885c4b644cd164e27ead68b312
Author: Brian Pitts <brian at polibyte.com>
Date:   Sun Jan 12 14:05:08 2014 -0600

    Add network debugging output
---
 lib/vagrant-libvirt/action/create_network_interfaces.rb | 13 +++++++++++--
 lib/vagrant-libvirt/action/create_networks.rb           | 12 ++++++++++++
 2 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/lib/vagrant-libvirt/action/create_network_interfaces.rb b/lib/vagrant-libvirt/action/create_network_interfaces.rb
index 3f51b41..adc7588 100644
--- a/lib/vagrant-libvirt/action/create_network_interfaces.rb
+++ b/lib/vagrant-libvirt/action/create_network_interfaces.rb
@@ -37,6 +37,7 @@ module VagrantPlugins
 
           # Assign interfaces to slots.
           env[:machine].config.vm.networks.each do |type, options|
+            @logger.debug "In config found network type #{type} options #{options}"
 
             # Get options for this interface. Options can be specified in
             # Vagrantfile in short format (:ip => ...), or provider format
@@ -51,8 +52,10 @@ module VagrantPlugins
               end
 
               free_slot = options[:adapter].to_i
+              @logger.debug "Using specified adapter slot #{free_slot}"
             else
               free_slot = find_empty(adapters)
+              @logger.debug "Adapter not specified so found slot #{free_slot}"
               raise Errors::InterfaceSlotNotAvailable if free_slot == nil
             end
 
@@ -104,6 +107,7 @@ module VagrantPlugins
             # it has to be available during provisioning - ifdown command is
             # not acceptable here.
             next if slot_number == 0
+            @logger.debug "Configuring interface slot_number #{slot_number} options #{options}"
 
             network = {
               :interface => slot_number,
@@ -139,7 +143,10 @@ module VagrantPlugins
 
         # Return network name according to interface options.
         def interface_network(libvirt_client, options)
-          return options[:network_name] if options[:network_name]
+          if options[:network_name]
+            @logger.debug "Found network by name"
+            return options[:network_name]
+          end
 
           # Get list of all (active and inactive) libvirt networks.
           available_networks = libvirt_networks(libvirt_client)
@@ -147,11 +154,13 @@ module VagrantPlugins
           if options[:ip]
             address = network_address(options[:ip], options[:netmask])
             available_networks.each do |network|
+              @logger.debug "Found network by ip"
               return network[:name] if address == network[:network_address]
             end
           end
 
-          # TODO Network default can be missing or named different.
+          # TODO Network default can be missing
+          @logger.debug "Did not find network so using default #{@default_network}"
           return @default_network;
         end
       end
diff --git a/lib/vagrant-libvirt/action/create_networks.rb b/lib/vagrant-libvirt/action/create_networks.rb
index 5ebaa17..1da3a85 100644
--- a/lib/vagrant-libvirt/action/create_networks.rb
+++ b/lib/vagrant-libvirt/action/create_networks.rb
@@ -28,6 +28,7 @@ module VagrantPlugins
           # Iterate over networks requested from config. If some network is not
           # available, create it if possible. Otherwise raise an error.
           env[:machine].config.vm.networks.each do |type, options|
+            @logger.debug "In config found network type #{type} options #{options}"
 
             # Get a list of all (active and inactive) libvirt networks. This
             # list is used throughout this class and should be easier to
@@ -64,10 +65,13 @@ module VagrantPlugins
             }
 
             if @options[:ip]
+              @logger.debug "handle by ip"
               handle_ip_option(env)
             elsif @options[:network_name]
+              @logger.debug "handle by name"
               handle_network_name_option
             else
+              @logger.debug "neither ip nor name specified so finding default"
               # TODO: Should be smarter than just using fixed 'default' string.
               @interface_network = lookup_network_by_name('default')
               if !@interface_network
@@ -87,6 +91,7 @@ module VagrantPlugins
 
         # Return hash of network for specified name, or nil if not found.
         def lookup_network_by_name(network_name)
+          @logger.debug "looking up network named #{network_name}"
           @available_networks.each do |network|
             return network if network[:name] == network_name
           end
@@ -95,6 +100,7 @@ module VagrantPlugins
 
         # Return hash of network for specified bridge, or nil if not found.
         def lookup_bridge_by_name(bridge_name)
+          @logger.debug "looking up bridge named #{bridge_name}"
           @available_networks.each do |network|
             return network if network[:bridge_name] == bridge_name
           end
@@ -120,11 +126,14 @@ module VagrantPlugins
             if available_network[:network_address] == \
             @interface_network[:network_address]
               @interface_network = available_network
+              @logger.debug "found existing network by ip, values are"
+              @logger.debug @interface_network
               break
             end
           end
 
           if @options[:network_name]
+            @logger.debug "Checking that network name does not clash with ip"
             if @interface_network[:created]
               # Just check for mismatch error here - if name and ip from
               # config match together.
@@ -156,6 +165,7 @@ module VagrantPlugins
             # Is name for new network set? If not, generate a unique one.
             count = 0
             while @interface_network[:name].nil?
+              @logger.debug "generating name for network"
 
               # Generate a network name.
               network_name = env[:root_path].basename.to_s.dup
@@ -171,6 +181,7 @@ module VagrantPlugins
             # Generate a unique name for network bridge.
             count = 0
             while @interface_network[:bridge_name].nil?
+              @logger.debug "generating name for bridge"
               bridge_name = 'virbr'
               bridge_name << count.to_s
               count += 1
@@ -234,6 +245,7 @@ module VagrantPlugins
           begin
             @interface_network[:libvirt_network] = \
               @libvirt_client.define_network_xml(to_xml('private_network'))
+            @logger.debug "created network"
           rescue => e
             raise Errors::CreateNetworkError, error_message: e.message
           end

-- 
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