|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH OSSTEST v2 04/11] HostDB: introduce set_property
And provide a helper in TestSupport to use it. This allows osstest to
set host properties from test script themselves (instead of using
the mg-hosts clu).
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Osstest/HostDB/Executive.pm | 19 +++++++++++++++++++
Osstest/HostDB/Static.pm | 7 +++++++
Osstest/TestSupport.pm | 8 +++++++-
3 files changed, 33 insertions(+), 1 deletion(-)
diff --git a/Osstest/HostDB/Executive.pm b/Osstest/HostDB/Executive.pm
index 300178bb..403c2f02 100644
--- a/Osstest/HostDB/Executive.pm
+++ b/Osstest/HostDB/Executive.pm
@@ -51,6 +51,25 @@ END
}
}
+sub set_property($$$$) {
+ my ($hd, $ho, $prop, $val) = @_;
+ my $rmq = $dbh_tests->prepare(<<END);
+ DELETE FROM resource_properties
+ WHERE restype='host' and resname=? AND name=?
+END
+ my $addq = $dbh_tests->prepare(<<END);
+ INSERT INTO resource_properties (restype,resname,name,val)
+ VALUES ('host', ?,?,?)
+END
+
+ db_retry($dbh_tests, [qw(resources)], sub {
+ $rmq->execute($ho->{Name}, $prop);
+ if (length $val) {
+ $addq->execute($ho->{Name}, $prop, $val);
+ }
+ });
+}
+
sub get_flags ($$) {
my ($hd, $ho) = @_;
diff --git a/Osstest/HostDB/Static.pm b/Osstest/HostDB/Static.pm
index 60f5d3c2..3191c565 100644
--- a/Osstest/HostDB/Static.pm
+++ b/Osstest/HostDB/Static.pm
@@ -40,6 +40,13 @@ sub get_properties ($$$) { #method
my ($hd, $name, $hp) = @_;
}
+sub set_property($$$$) {
+ my ($hd, $ho, $prop, $val) = @_;
+
+ die
+ "Cannot set property in standalone mode for $ho->{Name} $prop = $val\n";
+}
+
sub get_flags ($$) { #method
my ($hd, $ho) = @_;
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 0af55555..27b2342c 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -80,7 +80,7 @@ BEGIN {
get_target_property get_host_native_linux_console
hostnamepath hostnamepath_list set_runtime_hostflag
power_state power_cycle power_cycle_sleep
- serial_fetch_logs
+ serial_fetch_logs set_host_property
propname_massage propname_check
get_stashed open_unique_stashfile compress_stashed
@@ -1183,6 +1183,12 @@ sub get_host_property ($$;$) {
return defined($val) ? $val : $defval;
}
+sub set_host_property ($$$) {
+ my ($ho,$prop,$val) = @_;
+
+ $mhostdb->set_property($ho, $prop, $val);
+}
+
sub get_target_property ($$;$);
sub get_target_property ($$;$) {
my ($ho, $prop, $defval) = @_;
--
2.11.0 (Apple Git-81)
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |