diff mbox series

[OSSTEST,v5,1/5] host: introduce modify_host

Message ID 20200311172010.7777-1-roger.pau@citrix.com (mailing list archive)
State New, archived
Headers show
Series [OSSTEST,v5,1/5] host: introduce modify_host | expand

Commit Message

Roger Pau Monné March 11, 2020, 5:20 p.m. UTC
Abstract the set_property checks and DB call into a helper.

No functional change.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Requested on IRC:
17:09:30 Diziet Also if it were me I would put the modify_host refactoring in its own nfc patch,
                but I won't insist on that...
---
changes since v4:
 - New in this version.
---
 Osstest/HostDB/Executive.pm | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

Comments

Ian Jackson March 12, 2020, 10:56 a.m. UTC | #1
Roger Pau Monne writes ("[PATCH OSSTEST v5 1/5] host: introduce modify_host"):
> Abstract the set_property checks and DB call into a helper.
> 
> No functional change.
> 
> Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>

Reviewed-by: Ian Jackson <ian.jackson@eu.citrix.com>
diff mbox series

Patch

diff --git a/Osstest/HostDB/Executive.pm b/Osstest/HostDB/Executive.pm
index 7ffca6c4..d402bcac 100644
--- a/Osstest/HostDB/Executive.pm
+++ b/Osstest/HostDB/Executive.pm
@@ -51,6 +51,16 @@  END
     }
 }
 
+sub modify_host ($$$) {
+    my ($hd, $ho, $query) = @_;
+    my $blessing = intended_blessing();
+
+    die "Attempting to modify host with intended blessing $blessing != real"
+        if $blessing ne "real";
+
+    db_retry($dbh_tests, [qw(resources)], $query);
+}
+
 sub set_property($$$$) {
     my ($hd, $ho, $prop, $val) = @_;
     my $rmq = $dbh_tests->prepare(<<END);
@@ -61,12 +71,8 @@  END
         INSERT INTO resource_properties (restype,resname,name,val)
                VALUES ('host', ?,?,?)
 END
-    my $blessing = intended_blessing();
-
-    die "Attempting to modify host props with intended blessing $blessing != real"
-        if $blessing ne "real";
 
-    db_retry($dbh_tests, [qw(resources)], sub {
+    modify_host($hd, $ho, sub {
         $rmq->execute($ho->{Name}, $prop);
         if (length $val) {
             $addq->execute($ho->{Name}, $prop, $val);