From f129fdca2b322314e911992c0f037a4cde8edb8a Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Wed, 9 Jun 2004 18:36:20 +0000 Subject: update to new API 2004/06/08 09:50:38-05:00 anl.gov!desai update to use metadata argument for generators (Logical change 1.21) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@87 ce84e21b-d406-0410-9b95-82705330c041 --- generators/sshbase.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'generators') diff --git a/generators/sshbase.py b/generators/sshbase.py index c41ab16ae..006eda31e 100644 --- a/generators/sshbase.py +++ b/generators/sshbase.py @@ -12,24 +12,26 @@ class sshbase(Generator): __name__ = 'sshbase' __version__ = '$Id$' __author__ = 'bcfg-dev@mcs.anl.gov' - __provides__ = {'ConfigFile':{'/etc/ssh/ssh_known_hosts':'build_skn', - '/etc/ssh/ssh_host_dsa_key':'build_hk', - '/etc/ssh/ssh_host_rsa_key':'build_hk', - '/etc/ssh/ssh_host_dsa_key.pub':'build_hk', - '/etc/ssh/ssh_host_rsa_key.pub':'build_hk'}} def __setup__(self): self.repository = DirectoryBacked(self.data, self.core.fam) + self.__provides__ = {'ConfigFile':{'/etc/ssh/ssh_known_hosts':self.build_skn, + '/etc/ssh/ssh_host_dsa_key':self.build_hk, + '/etc/ssh/ssh_host_rsa_key':self.build_hk, + '/etc/ssh/ssh_host_dsa_key.pub':self.build_hk, + '/etc/ssh/ssh_host_rsa_key.pub':self.build_hk}} - def build_skn(self,name,client): + def build_skn(self,name,metadata): + client = metadata.hostname filedata = self.repository.entries['ssh_known_hosts'].data ip=gethostbyname(client) - keylist = map(lambda x:x%client, ["ssh_host_dsa_key.pub.H_%s","ssh_host_rsa_key.pub.H_%s","ssh_host_key.pub.H_%s"]) + keylist = map(lambda x:x%(client), ["ssh_host_dsa_key.pub.H_%s","ssh_host_rsa_key.pub.H_%s","ssh_host_key.pub.H_%s"]) for hostkey in keylist: filedata += "%s,%s,%s %s"%(client,"%s.mcs.anl.gov"%(client),ip,self.repository.entries[hostkey].data) return ConfigFile(name,'root','root','0644',filedata) - def build_hk(self,name,client): + def build_hk(self,name,metadata): + client = metadata.hostname filename = "%s.H_%s"%(name.split('/')[-1],client) if filename not in self.repository.entries.keys(): self.GenerateHostKeys(client) -- cgit v1.2.3-1-g7c22