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

[Xen-devel] [PATCH OSSTEST v5 2/5] host: introduce a helper to modify hostflags


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Wed, 11 Mar 2020 18:20:06 +0100
  • Authentication-results: esa2.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=roger.pau@xxxxxxxxxx; spf=Pass smtp.mailfrom=roger.pau@xxxxxxxxxx; spf=None smtp.helo=postmaster@xxxxxxxxxxxxxxx
  • Cc: ian.jackson@xxxxxxxxxxxxx, Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Delivery-date: Wed, 11 Mar 2020 17:20:54 +0000
  • Ironport-sdr: nWdRPX177Z7ZMLeLMMpzQXzCeV9M3IJinb9+/bqG+yaJthKbJWVXx0DsTLZ9N8tyegww08p04v p3DxfxDD9wAueWsApw3czzGgDuqI8IQZdg28Plsmtdwv91sHR2jpblyD6H1wj1w/kW498+2czm ezfoNViGpPW+GX0pxxWNdX1PjgAwVuIVkXeZlbjZrEFlkdEumZRB8ZDTahFXlbGgyFxP5cdxUy Y1bems4tXjMowgfOB0gObHJWiHpEsauBA6sOEhzLAsQlrnG7voYouVzmzzB/o2E9NInPtx3el0 9NQ=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Add a generic function to perform database changes related to a host
flag and add a wrapper to TestSupport.

Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Changes since v4:
 - Move addition of hostflag_putative_record to a different patch.
 - Introduce a single helper in TestSupport: modify_host_flag.

Changes since v3:
 - Introduce modify_flag instead of {set/remove}_flag.
 - Introduce a generic modify_host helper.
 - Split from patch 1.
---
Requested on IRC:
17:08:58 Diziet royger: I think your ts-examine-hostprops-save hunk in 2/ 
belongs in 1/ ?  (Or in
                a separate 1.5/ along with hostflag_putative_record.)
---
 Osstest/HostDB/Executive.pm | 17 +++++++++++++++++
 Osstest/HostDB/Static.pm    |  7 +++++++
 Osstest/TestSupport.pm      |  8 +++++++-
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/Osstest/HostDB/Executive.pm b/Osstest/HostDB/Executive.pm
index d402bcac..a6dc4462 100644
--- a/Osstest/HostDB/Executive.pm
+++ b/Osstest/HostDB/Executive.pm
@@ -96,6 +96,23 @@ END
     return $flags;
 }
 
+sub modify_flag ($$$$) {
+    my ($hd, $ho, $flag, $set) = @_;
+    my $rmq = $dbh_tests->prepare(<<END);
+        DELETE FROM hostflags WHERE hostname=? AND hostflag=?
+END
+    my $addq = $dbh_tests->prepare(<<END);
+        INSERT INTO hostflags (hostname,hostflag) VALUES (?,?)
+END
+
+    modify_host($hd, $ho, sub {
+        $rmq->execute($ho->{Name}, $flag);
+        if ($set) {
+            $addq->execute($ho->{Name}, $flag);
+        }
+    });
+}
+
 sub get_arch_platforms ($$$) {
     my ($hd, $blessing, $arch, $suite) = @_;
 
diff --git a/Osstest/HostDB/Static.pm b/Osstest/HostDB/Static.pm
index 0c6be3ee..d0669fb2 100644
--- a/Osstest/HostDB/Static.pm
+++ b/Osstest/HostDB/Static.pm
@@ -72,6 +72,13 @@ sub get_flags ($$) { #method
     return $flags;
 }
 
+sub modify_flag ($$$$) {
+    my ($hd, $ho, $flag, $set) = @_;
+
+    die
+    "Cannot modify flags in standalone mode for $ho->{Name} $flag set: $set\n";
+}
+
 sub get_arch_platforms ($$$) {
     my ($hd, $blessing, $arch, $suite) = @_;
 
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index f49ed529..ceb6bb7b 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -84,7 +84,7 @@ BEGIN {
                       get_target_property get_host_native_linux_console
                       hostnamepath hostnamepath_list set_runtime_hostflag
                       power_state power_cycle power_reboot_attempts
-                      serial_fetch_logs set_host_property
+                      serial_fetch_logs set_host_property modify_host_flag
                       propname_massage propname_check
                       hostprop_putative_record
          
@@ -1411,6 +1411,12 @@ sub hostprop_putative_record ($$$) {
     store_runvar("hostprop/$ho->{Ident}/$prop", $val);
 }
 
+sub modify_host_flag ($$$) {
+    my ($ho, $flag, $set) = @_;
+
+    $mhostdb->modify_flag($ho, $flag, $set);
+}
+
 sub get_target_property ($$;$);
 sub get_target_property ($$;$) {
     my ($ho, $prop, $defval) = @_;
-- 
2.25.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®.