Message ID | 1412942554-752-11-git-send-email-ian.campbell@citrix.com |
---|---|
State | New |
Headers | show |
Ian Campbell writes ("[PATCH RFC OSSTEST 11/19] standalone: Introduce "HostGroups" for use in OSSTEST_CONFIG"): > This saves repeating identical HostProp and HostFlags for sets of identical > machines. e.g. The existing code is rather weird in that host properties from the configuration are dealt with in TestSupport (so apply to both standalone and executive), but host flags in the config are dealt with in HostDB/Static.pm (so apply only to standalone). > I was unsure whether HostGroupProp's ought to be processed before or > after the HostDB properties, but since the latter is a NOP I've > arbitrarily put them before. The HostDB properties are not a NOP if the HostDB isn't Static! In general the configuration should override the database. So I think this is the wrong way round. > diff --git a/README b/README > index 9a85549..b4f9cfb 100644 > --- a/README > +++ b/README > @@ -333,6 +333,26 @@ HostProp_<testbox>_TftpScope > Defines the Tftp scope (i.e. subnet) where this host resides. See > "TftpFoo_<scope> and TftpFoo" below. > > +HostFlags_<testbox> > + Defines a set of flags for the host. Flags is a list separated by > + whitespace, comma or semi-colon. A flag can be unset by prepending > + a !. Only used in standalone mode. > + > +HostGroup_<testbox> <group> > + Defines a group of similar hosts of which <testbox> is a > + member. This can then be used with HostGroupProp and HostGroupFlags Thanks for documenting this. > +HostGroupProps_<group>_<prop> > + Equivalent to writing HostProp_<testbox>_<prop> for every testbox > + which declares HostGroup_<testbox>_<group>. Allows setting a set of > + common properties for a group of similar machines. You should specify that this overrides the hostdb but is overridden by host-specific properties. > +HostGroupFlags_<group> > + Equivalent to writing HostFlags_<testbox> for every testbox which > + declares HostGroup_<testbox>_<group>. Allows setting a set of > + common flags for a group of similar machines. Only used in > + standalone mode. You should say that this is merged with the host-specific properties and applies only to standlone mode. Ian.
On Fri, 2014-10-10 at 15:44 +0100, Ian Jackson wrote: > Ian Campbell writes ("[PATCH RFC OSSTEST 11/19] standalone: Introduce "HostGroups" for use in OSSTEST_CONFIG"): > > This saves repeating identical HostProp and HostFlags for sets of identical > > machines. e.g. > > The existing code is rather weird in that host properties from the > configuration are dealt with in TestSupport (so apply to both > standalone and executive), but host flags in the config are dealt with > in HostDB/Static.pm (so apply only to standalone). Yes, I noticed that... No reason for it, just hysterical raisins? > > I was unsure whether HostGroupProp's ought to be processed before or > > after the HostDB properties, but since the latter is a NOP I've > > arbitrarily put them before. > > The HostDB properties are not a NOP if the HostDB isn't Static! Sorry, I meant for the Static HostDB, on the basis that I don't think you would use the config file with the proper DB, would you? (which might argue for moving a bunch of code from TestSupport to HostDB/Static.pm?) > In general the configuration should override the database. So I think > this is the wrong way round. Ack. Ian.
Ian Campbell writes ("Re: [PATCH RFC OSSTEST 11/19] standalone: Introduce "HostGroups" for use in OSSTEST_CONFIG"): > On Fri, 2014-10-10 at 15:44 +0100, Ian Jackson wrote: > > The HostDB properties are not a NOP if the HostDB isn't Static! > > Sorry, I meant for the Static HostDB, on the basis that I don't think > you would use the config file with the proper DB, would you? You might set some properties from the config and some from the DB. I agree that this would be unusual but I wouldn't want to rule it out and I think the precedence ought to be in favour of the config file. > (which might argue for moving a bunch of code from TestSupport to > HostDB/Static.pm?) Let's not tackle that now :-). Ian.
diff --git a/Osstest/HostDB/Static.pm b/Osstest/HostDB/Static.pm index d0c13a1..ad18395 100644 --- a/Osstest/HostDB/Static.pm +++ b/Osstest/HostDB/Static.pm @@ -58,6 +58,8 @@ sub get_flags ($$) { #method }; $process->('HostFlags'); + $process->("HostGroupFlags_$ho->{Properties}{HostGroup}") + if $ho->{Properties}{HostGroup}; $process->("HostFlags_$ho->{Name}"); return $flags; diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm index d66708e..6901563 100644 --- a/Osstest/TestSupport.pm +++ b/Osstest/TestSupport.pm @@ -766,12 +766,29 @@ sub selecthost ($) { $ho->{Properties}{$pn} = $val; }; - # First, we use the config file's general properites as defaults + # First, set the prop group if any. + foreach my $k (keys %c) { + next unless $k =~ m/^HostGroup_([-a-z0-9]+)$/; + next unless $1 eq $name; + $setprop->("HostGroup", $c{$k}); + logm("Host $name is in HostGroup $ho->{Properties}{HostGroup}"); + } + + # Next, we use the config file's general properites as defaults foreach my $k (keys %c) { next unless $k =~ m/^HostProp_([A-Z].*)$/; $setprop->($1, $c{$k}); } + # Next, we set any HostGroup based properties + if ( $ho->{Properties}{HostGroup} ) { + foreach my $k (keys %c) { + next unless $k =~ m/^HostGroupProp_([-a-z0-9]+)_(.*)$/; + next unless $1 eq $ho->{Properties}{HostGroup}; + $setprop->($2, $c{$k}); + } + } + # Then we read in the HostDB's properties $mhostdb->get_properties($name, $ho->{Properties}); diff --git a/README b/README index 9a85549..b4f9cfb 100644 --- a/README +++ b/README @@ -333,6 +333,26 @@ HostProp_<testbox>_TftpScope Defines the Tftp scope (i.e. subnet) where this host resides. See "TftpFoo_<scope> and TftpFoo" below. +HostFlags_<testbox> + Defines a set of flags for the host. Flags is a list separated by + whitespace, comma or semi-colon. A flag can be unset by prepending + a !. Only used in standalone mode. + +HostGroup_<testbox> <group> + Defines a group of similar hosts of which <testbox> is a + member. This can then be used with HostGroupProp and HostGroupFlags + +HostGroupProps_<group>_<prop> + Equivalent to writing HostProp_<testbox>_<prop> for every testbox + which declares HostGroup_<testbox>_<group>. Allows setting a set of + common properties for a group of similar machines. + +HostGroupFlags_<group> + Equivalent to writing HostFlags_<testbox> for every testbox which + declares HostGroup_<testbox>_<group>. Allows setting a set of + common flags for a group of similar machines. Only used in + standalone mode. + DebianPreseed Text to add to the debian-installer preseed file. Optional but you will need to set some NTP servers here if your firewall
This saves repeating identical HostProp and HostFlags for sets of identical machines. e.g. HostGroupProp_cubietruck_LinuxSerialConsole ttyS0 HostGroupProp_cubietruck_Build_Make_Flags -j12 HostGroupProp_cubietruck_XenSerialConsole dtuart HostGroupProp_cubietruck_XenDTUARTPath /soc@01c00000/serial@01c28000 HostGroupFlags_cubietruck suite-wheezy,equiv-cubietruck,need-kernel-deb-armmp,no-di-kernel,need-uboot-bootscr HostGroup_braque cubietruck HostProp_braque_Fqdn braque.uk.xensource.com HostGroup_picaso cubietruck HostProp_picaso_Fqdn picaso.uk.xensource.com HostGroup_metzinger cubietruck HostProp_metzinger metzinger.uk.xensource.com HostGroup_gleizes cubietruck HostProp_gleizes_Fqdn gleizes.uk.xensource.com I was unsure whether HostGroupProp's ought to be processed before or after the HostDB properties, but since the latter is a NOP I've arbitrarily put them before. Signed-off-by: Ian Campbell <ian.campbell@citrix.com> --- Osstest/HostDB/Static.pm | 2 ++ Osstest/TestSupport.pm | 19 ++++++++++++++++++- README | 20 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-)