[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [OSSTEST PATCH 12/62] ts-guests-nbd-mirror: make it work with stretch



From: Wei Liu <wei.liu2@xxxxxxxxxx>

On the server side, only add oldstyle= and port= on wheezy and jessie.
stretch doesn't support or need those anymore.

On the client side, generate new style configuration file.

Reorder nbd-client setup a bit. Install it first, then write our own
configuration file, then start it.  This stops dpkg asking what to
do regarding configuration files.

Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx>
Acked-by: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
---
v3: invert some tests, rearrange client setup code.
v4: Fix commit message grammar.
---
 ts-guests-nbd-mirror | 47 +++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 43 insertions(+), 4 deletions(-)

diff --git a/ts-guests-nbd-mirror b/ts-guests-nbd-mirror
index ca8300db..7ea31f7c 100755
--- a/ts-guests-nbd-mirror
+++ b/ts-guests-nbd-mirror
@@ -60,15 +60,19 @@ sub configserver () {
 [generic]
     user = root
 END
-    $scfg .= <<END unless $sho->{Suite} =~ m/sarge|lenny|squeeze/;
+
+    $scfg .= <<END if $sho->{Suite} =~ m/wheezy|jessie/;
     oldstyle = true
 END
+
     foreach my $v (@vols) {
        $v->{Port}= unique_incrementing_runvar("${srvhost}_nextport",4000);
        $v->{Path}= "/dev/$v->{Gho}{Vg}/$v->{Lv}";
        $scfg.=<<END;
 [export$v->{Ix}]
     exportname = $v->{Path}
+END
+       $scfg.=<<END if $sho->{Suite} =~ m/wheezy|jessie/;
     port = $v->{Port}
 END
     }
@@ -79,9 +83,7 @@ END
     target_install_packages($sho, qw(nbd-server));
 }
 
-sub configclient () {
-    target_cmd_root($cho, "dpkg --purge nbd-client ||:");
-
+sub configclient_pre_stretch () {
     my $mydaemon= '/root/nbd-client-async';
     target_putfilecontents_root_stash($cho,10,<<'END',$mydaemon);
 #!/bin/sh
@@ -107,7 +109,44 @@ NBD_PORT[$v->{Ix}]=$v->{Port}
 END
     }
     target_putfilecontents_root_stash($cho,10,$ccfg,"/etc/nbd-client");
+}
+
+sub configclient_stretch_and_later () {
+    my $ccfg = <<END;
+# generated by $0
+END
+
+    foreach my $v (@vols) {
+       my $nbddev = "nbd$v->{Ix}";
+       $ccfg .= <<END;
+$nbddev $sho->{Name} export$v->{Ix}
+END
+    }
+
+    target_putfilecontents_root_stash($cho,10,$ccfg,"/etc/nbdtab");
+}
+
+sub configclient () {
+    target_cmd_root($cho, "dpkg --purge nbd-client ||:");
+
     target_install_packages($cho, qw(nbd-client));
+
+    target_cmd_root($cho, "/etc/init.d/nbd-client stop ||:");
+
+    if ($cho->{Suite} =~ m/wheezy|jessie/) {
+        configclient_pre_stretch();
+    } else {
+        configclient_stretch_and_later();
+       foreach my $v (@vols) {
+           my $nbddev = "nbd$v->{Ix}";
+           target_cmd_root($cho, <<END);
+mkdir -p /dev/$v->{Gho}{Vg}
+if ! test -L $v->{Path}; then ln -s /dev/$nbddev $v->{Path}; fi
+END
+       }
+    }
+
+    target_cmd_root($cho, "/etc/init.d/nbd-client start");
 }
 
 sub shuffleconfigs () {
-- 
2.11.0


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.