summaryrefslogtreecommitdiffstats
path: root/tools/upgrade/1.2
diff options
context:
space:
mode:
Diffstat (limited to 'tools/upgrade/1.2')
-rwxr-xr-xtools/upgrade/1.2/nagiosgen-convert.py15
-rwxr-xr-xtools/upgrade/1.2/packages-convert.py15
2 files changed, 18 insertions, 12 deletions
diff --git a/tools/upgrade/1.2/nagiosgen-convert.py b/tools/upgrade/1.2/nagiosgen-convert.py
index 2c2142735..eb10cd4ea 100755
--- a/tools/upgrade/1.2/nagiosgen-convert.py
+++ b/tools/upgrade/1.2/nagiosgen-convert.py
@@ -7,10 +7,13 @@ import lxml.etree
import Bcfg2.Options
def main():
- opts = {'repo': Bcfg2.Options.SERVER_REPOSITORY}
- setup = Bcfg2.Options.OptionParser(opts)
- setup.parse(sys.argv[1:])
- repo = setup['repo']
+ parser = Bcfg2.Options.get_parser(
+ description="Migrate from Bcfg2 1.1-style Properties-based NagiosGen "
+ "configuration to standalone 1.2-style")
+ parser.add_options([Bcfg2.Options.Common.repository])
+ parser.parse()
+
+ repo = Bcfg2.Options.setup.repository
oldconfigfile = os.path.join(repo, 'Properties', 'NagiosGen.xml')
newconfigpath = os.path.join(repo, 'NagiosGen')
newconfigfile = os.path.join(newconfigpath, 'config.xml')
@@ -32,11 +35,11 @@ def main():
if host.tag == lxml.etree.Comment:
# skip comments
continue
-
+
if host.tag == 'default':
print("default tag will not be converted; use a suitable Group tag instead")
continue
-
+
newhost = lxml.etree.Element("Client", name=host.tag)
for opt in host:
newopt = lxml.etree.Element("Option", name=opt.tag)
diff --git a/tools/upgrade/1.2/packages-convert.py b/tools/upgrade/1.2/packages-convert.py
index d65ce90a2..eb1f2f7de 100755
--- a/tools/upgrade/1.2/packages-convert.py
+++ b/tools/upgrade/1.2/packages-convert.py
@@ -30,10 +30,13 @@ def place_source(xdata, source, groups):
return xdata
def main():
- opts = {'repo': Bcfg2.Options.SERVER_REPOSITORY}
- setup = Bcfg2.Options.OptionParser(opts)
- setup.parse(sys.argv[1:])
- repo = setup['repo']
+ parser = Bcfg2.Options.get_parser(
+ description="Migrate from Bcfg2 1.1-style Packages configuration to "
+ "1.2-style")
+ parser.add_options([Bcfg2.Options.Common.repository])
+ parser.parse()
+
+ repo = Bcfg2.Options.setup.repository
configpath = os.path.join(repo, 'Packages')
oldconfigfile = os.path.join(configpath, 'config.xml')
newconfigfile = os.path.join(configpath, 'packages.conf')
@@ -78,7 +81,7 @@ def main():
if el.tag == lxml.etree.Comment or el.tag == 'Config':
# skip comments and Config
continue
-
+
if el.tag == XI + 'include':
oldsources.append(os.path.join(configpath, el.get('href')))
newsource.append(el)
@@ -98,7 +101,7 @@ def main():
newel.set(tag.lower(), el.find(tag).text)
except AttributeError:
pass
-
+
for child in el.getchildren():
if child.tag in ['Component', 'Blacklist', 'Whitelist', 'Arch']:
newel.append(child)