[Yum-devel] Plugin interface to add yumvars? [SOLVED]
Michael E Brown
Michael_E_Brown at dell.com
Tue Mar 27 20:36:15 UTC 2007
On Tue, Mar 20, 2007 at 08:26:20AM +0200, Panu Matilainen wrote:
> On Mon, 19 Mar 2007, Michael E Brown wrote:
>
> >On Mon, Mar 19, 2007 at 05:44:42PM -0400, seth vidal wrote:
> >>On Mon, 2007-03-19 at 09:48 -0500, Michael E Brown wrote:
> >>>I would like to write a plugin to be able to add vars to the 'yumvars'
> >>>hash. I
> >>>would like to have a yum repo like this:
> >>>
> >>> [dell-machinespecific]
> >>> baseurl=http://linux.dell.com/repo/machine_specific/system-$dellsystemid
> >>>
> >>>But the problem I see is that there is no place where the plugins get
> >>>called
> >>>between where yumvars is set (readMainConfig()) and where it is used
> >>>(getReposFromConfig()):
> >>>
> >>> --> yum/__init__.py doConfigSetup():
> >>> ======================================
> >>> self.conf = config.readMainConfig(startupconf)
> >>> self.yumvar = self.conf.yumvar
> >>> self.getReposFromConfig()
> >>>
> >>>The only way I can see to do this is really ugly. Any suggestions?
Ok, after much digging, it looks like I dont actually need the hook I
thought I did. :)
The yumvars are not used early, as I had thought. They are not used
until baseurlSetup() in yumRepo.py. This function is called from
repo.enable() and repo.setup() which are called from doRepoSetup(). This
means I can add the conf.yumvar[] I want, then
repo.yumvar.update(conf.yumvar) and everything works out just fine.
This appears to work (prototype only):
=========================================
def init_hook(conduit):
conf = conduit.getConf()
conf.yumvar["dellsysid"] = "MAGIC"
repos = conduit.getRepos()
for repo in repos.findRepos('*'):
repo.yumvar.update(conf.yumvar)
=========================================
I have code to get the dell system id which I will plug in. Then the
only thing I have left to do is automatically disable the repo if the
repo doesnt exist (ie. no repo for that sys id).
--
Michael
More information about the Yum-devel
mailing list