Changeset 823 for vanHelsing/trunk/src
- Timestamp:
- Feb 12, 2010, 2:50:32 PM (15 years ago)
- Location:
- vanHelsing/trunk/src
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
vanHelsing/trunk/src/bcfg.py
r822 r823 212 212 213 213 def getClients(directorName): 214 return getResources(directorName,"Client") 215 216 def getResources(directorName,resType): 214 217 dirdcfg=getDirectorConfig(directorName) 215 clients=dirdcfg.getRoot().getByType("Client",1)218 resources=dirdcfg.getRoot().getByType(resType,1) 216 219 result=[] 217 for c in clients:218 result.append(( c.id,c.getName()))220 for r in resources: 221 result.append((r.id,r.getName())) 219 222 return result 223 224 def getResourceById(directorName,resId): 225 dirdcfg=getDirectorConfig(directorName) 226 return dirdcfg.getRoot().getById(resId) 227 228 def getResourceByName(directorName,resType,name): 229 dirdcfg=getDirectorConfig(directorName) 230 return dirdcfg.getRoot().getByName(name,resType)[0] 231 220 232 221 233 if __name__ == "__main__": … … 228 240 229 241 print getClients("bacula-dir") 230 242 print getResources("bacula-dir","Client") 243 print getResources("bacula-dir","Job") 244 print getResourceById("bacula-dir",100) 245 print getResourceByName("Bacula-dir","Client","cryptoserver-fd") 231 246 sys.exit(0) -
vanHelsing/trunk/src/resource.py
r816 r823 83 83 return None 84 84 85 def getByName(self,name ):85 def getByName(self,name,type=None): 86 86 result=[] 87 if self.getName()==name :87 if self.getName()==name and (type==None or self.type==type): 88 88 result.append(self) 89 89 for i in self.items: 90 r=i.getByName(name )90 r=i.getByName(name,type) 91 91 if len(r)!=0: 92 92 for a in r:
Note:
See TracChangeset
for help on using the changeset viewer.