From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Ian Jackson <ian.jackson@eu.citrix.com>,
Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH v12 26/33] HostDB: introduce set_property
Date: Fri, 20 Oct 2017 14:46:59 +0100 [thread overview]
Message-ID: <20171020134702.41255-2-roger.pau@citrix.com> (raw)
In-Reply-To: <20171020134702.41255-1-roger.pau@citrix.com>
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).
Note that the setting of host properties is limited to flights with
intended blessing real, and it will fail for any other blessing.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
---
Changes since v2:
- Die if attempting to modify a host prop with intended blessing !=
real.
---
Osstest/HostDB/Executive.pm | 23 +++++++++++++++++++++++
Osstest/HostDB/Static.pm | 7 +++++++
Osstest/TestSupport.pm | 8 +++++++-
3 files changed, 37 insertions(+), 1 deletion(-)
diff --git a/Osstest/HostDB/Executive.pm b/Osstest/HostDB/Executive.pm
index 300178bb..2a961b6d 100644
--- a/Osstest/HostDB/Executive.pm
+++ b/Osstest/HostDB/Executive.pm
@@ -51,6 +51,29 @@ 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
+ my $blessing = intended_blessing();
+
+ die "Attempting to modify host props with blessing $blessing != real"
+ if $blessing ne "real";
+
+ 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 585e2286..ec834da7 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.13.5 (Apple Git-94)
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-10-20 13:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-20 13:46 [PATCH v12 00/33] osstest: FreeBSD host support Roger Pau Monne
2017-10-20 13:46 ` Roger Pau Monne [this message]
2017-10-20 14:35 ` [PATCH v12 26/33] HostDB: introduce set_property Ian Jackson
2017-10-20 13:47 ` [PATCH v12 29/33] ts-freebsd-host-install: add arguments to test memdisk append options Roger Pau Monne
2017-10-20 14:44 ` Ian Jackson
2017-10-20 13:47 ` [PATCH v12 31/33] ts-examine-hostprops-save: introduce a script to save properties Roger Pau Monne
2017-10-20 15:04 ` Ian Jackson
2017-10-20 13:47 ` [PATCH v12 33/33] sg-run-job: hook the memdisk test into examine Roger Pau Monne
2017-10-20 15:00 ` Ian Jackson
2017-10-20 15:32 ` [PATCH v12 00/33] osstest: FreeBSD host support Ian Jackson
2017-10-23 14:50 ` Roger Pau Monné
2017-10-24 11:05 ` Ian Jackson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171020134702.41255-2-roger.pau@citrix.com \
--to=roger.pau@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).