@@ -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);
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(-)