]> xenbits.xensource.com Git - people/dariof/osstest.git/commitdiff
ts-xen-install: nodhcp: restructure
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 23 Jan 2014 17:50:02 +0000 (17:50 +0000)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 12 Feb 2014 14:22:47 +0000 (14:22 +0000)
Move target_editfile_root to contain all the meat of the function.
This is useful because we're going to possibly want to read the input
interfaces file twice.

No functional change.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
ts-xen-install

index fc96516bbdb4b7b3a19492967260962389f0b120..09c90ceac69e0383e58a531d3f5dd9f6d21cdfe3 100755 (executable)
@@ -206,33 +206,37 @@ END
 }
 
 sub nodhcp () {
-    my ($iface,$bridgex);
-    my $physif= get_host_property($ho,'interface force','eth0');
-    if ($initscripts_nobridge) {
-        $iface= 'xenbr0';
-        $bridgex= <<END;
+    target_editfile_root($ho, "/etc/network/interfaces",
+                         "etc-network-interfaces", sub {
+        my $physif= get_host_property($ho,'interface force',undef);
+
+       my ($iface,$bridgex);
+
+       if ($initscripts_nobridge) {
+           $iface= 'xenbr0';
+           $bridgex= <<END;
     bridge_ports $physif
     bridge_fd 0
     bridge_stp off
 END
-    } else {
-        $iface= $physif;
-        $bridgex= '';
-    }
+       } else {
+           $iface= $physif;
+           $bridgex= '';
+        }
 
-    my $routes= target_cmd_output_root($ho, "route -n");
+       my $routes= target_cmd_output_root($ho, "route -n");
 
-    $routes =~ m/^ [0-9.]+ \s+ 0\.0\.0\.0 \s+ ([0-9.]+) \s+ \S*U\S* \s /mxi
-        or die "no own local network in route ?  $routes ";
-    my $netmask= $1;
+       $routes =~ m/^ [0-9.]+ \s+ 0\.0\.0\.0 \s+ ([0-9.]+) \s+ \S*U\S* \s /mxi
+           or die "no own local network in route ?  $routes ";
+       my $netmask= $1;
 
-    $routes =~ m/^ 0\.0\.0\.0 \s+ ([0-9.]+) \s+ 0\.0\.0\.0 \s+ \S*UG\S* \s /mxi
-        or die "no default gateway ?  $routes ";
-    my $gateway= $1;
+       $routes =~
+           m/^ 0\.0\.0\.0 \s+ ([0-9.]+) \s+ 0\.0\.0\.0 \s+ \S*UG\S* \s /mxi
+           or die "no default gateway ?  $routes ";
+       my $gateway= $1;
+
+       logm("iface $iface mask=$netmask gw=$gateway");
 
-    logm("iface $iface mask=$netmask gw=$gateway");
-    target_editfile_root($ho, "/etc/network/interfaces",
-                         "etc-network-interfaces", sub {
         my $suppress= 0;
         while (<EI>) {
             $suppress= 0 unless m/^\s+/;