summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNarayan Desai <desai@mcs.anl.gov>2009-07-13 20:08:59 +0000
committerNarayan Desai <desai@mcs.anl.gov>2009-07-13 20:08:59 +0000
commit3248a42b83731ff31b6ee3a449421ae0dd06e601 (patch)
tree0ba983b5b2a42c116d968ae8c3c01d561be0de68 /src
parent3f3257a6a0af296efbfa798bbee053d43648f3c1 (diff)
downloadbcfg2-3248a42b83731ff31b6ee3a449421ae0dd06e601.tar.gz
bcfg2-3248a42b83731ff31b6ee3a449421ae0dd06e601.tar.bz2
bcfg2-3248a42b83731ff31b6ee3a449421ae0dd06e601.zip
bcfg2-admin init: fix traceback (reported by somekool on irc)
Apparently classmethods aren't callable from subclasses if overridden git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5322 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r--src/lib/Server/Plugin.py23
-rw-r--r--src/lib/Server/Plugins/Metadata.py5
2 files changed, 17 insertions, 11 deletions
diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py
index 269508b13..829ab64fd 100644
--- a/src/lib/Server/Plugin.py
+++ b/src/lib/Server/Plugin.py
@@ -4,6 +4,7 @@ __revision__ = '$Revision$'
import copy
import logging
import lxml.etree
+import os
import posixpath
import re
@@ -62,17 +63,21 @@ class Plugin(object):
self.core = core
self.data = "%s/%s" % (datastore, self.name)
self.logger = logging.getLogger('Bcfg2.Plugins.%s' % (self.name))
+
+ @staticmethod
+ def make_path(path):
+ p_comp = path.split('/')
+ for i in range(2, len(p_comp) + 1):
+ ppath = '/' + '/'.join(p_comp[1:i])
+ try:
+ os.stat(ppath)
+ except:
+ os.mkdir(ppath)
@classmethod
- def init_repo(self, repo):
- path = "%s/%s" % (repo, self.name)
- newpath = ''
- for subdir in path.split('/'):
- newpath = newpath + subdir + '/'
- try:
- os.mkdir(newpath)
- except:
- return
+ def init_repo(cls, repo):
+ path = "%s/%s" % (repo, cls.name)
+ cls.make_path(path)
class Generator(object):
'''Generator plugins contribute to literal client configurations'''
diff --git a/src/lib/Server/Plugins/Metadata.py b/src/lib/Server/Plugins/Metadata.py
index ae717eadf..daf1ab16c 100644
--- a/src/lib/Server/Plugins/Metadata.py
+++ b/src/lib/Server/Plugins/Metadata.py
@@ -104,7 +104,8 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
@classmethod
def init_repo(cls, repo, groups, os_selection, clients):
- Bcfg2.Server.Plugin.Plugin.init_repo(repo)
+ path = '%s/%s' % (repo, cls.name)
+ cls.make_path(path)
open("%s/Metadata/groups.xml" %
repo, "w").write(groups % os_selection)
open("%s/Metadata/clients.xml" %
@@ -152,7 +153,7 @@ class Metadata(Bcfg2.Server.Plugin.Plugin,
group_tree.close()
def update_group(self, group_name, attribs):
- '''Update a group's attributes'''
+ '''Update a groups attributes'''
tree = lxml.etree.parse(self.data + "/groups.xml")
root = tree.getroot()
node = self.search_group(group_name, tree)