summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@redhat.com>2007-10-23 12:39:41 -0400
committerMichael DeHaan <mdehaan@redhat.com>2007-10-23 12:39:41 -0400
commit695c92d9ffb75d113f07d84b3851e64d6b9b7a97 (patch)
treeaad7496b0f06bfc05d6c5dba1be7ab2bb0575d26
parent430c87c924e773ae4e5368a86a32ef3e16e1ba4d (diff)
downloadthird_party-cobbler-695c92d9ffb75d113f07d84b3851e64d6b9b7a97.tar.gz
third_party-cobbler-695c92d9ffb75d113f07d84b3851e64d6b9b7a97.tar.xz
third_party-cobbler-695c92d9ffb75d113f07d84b3851e64d6b9b7a97.zip
Remove a circular import between the serializer and the API that was confusing Virt-Factory.
-rw-r--r--cobbler/action_sync.py25
-rw-r--r--cobbler/remote.py8
-rw-r--r--cobbler/utils.py10
3 files changed, 22 insertions, 21 deletions
diff --git a/cobbler/action_sync.py b/cobbler/action_sync.py
index 49c01ea..9da375f 100644
--- a/cobbler/action_sync.py
+++ b/cobbler/action_sync.py
@@ -47,6 +47,7 @@ class BootSync:
"""
self.verbose = verbose
self.config = config
+ self.api = config.api
self.distros = config.distros()
self.profiles = config.profiles()
self.systems = config.systems()
@@ -327,7 +328,7 @@ class BootSync:
def validate_kickstart_for_specific_profile(self,g):
distro = g.get_conceptual_parent()
- meta = utils.blender(False, g)
+ meta = utils.blender(self.api, False, g)
if distro is None:
raise CX(_("profile %(profile)s references missing distro %(distro)s") % { "profile" : g.name, "distro" : g.distro })
kickstart_path = utils.find_kickstart(meta["kickstart"])
@@ -341,7 +342,7 @@ class BootSync:
self.mkdir(copy_path)
dest = os.path.join(copy_path, "ks.cfg")
try:
- meta = utils.blender(False, g)
+ meta = utils.blender(self.api, False, g)
ksmeta = meta["ks_meta"]
del meta["ks_meta"]
meta.update(ksmeta) # make available at top level
@@ -375,7 +376,7 @@ class BootSync:
if system:
blend_this = system
- blended = utils.blender(False, blend_this)
+ blended = utils.blender(self.api, False, blend_this)
kickstart = blended.get("kickstart",None)
buf = ""
@@ -398,7 +399,7 @@ class BootSync:
# the list of repos to things that Anaconda can install from. This corresponds
# will replace "TEMPLATE::yum_repo_stanza" in a cobbler kickstart file.
buf = ""
- repos = utils.blender(False, profile)["repos"]
+ repos = utils.blender(self.api, False, profile)["repos"]
for r in repos:
repo = self.repos.find(name=r)
if repo is None:
@@ -419,7 +420,7 @@ class BootSync:
def generate_config_stanza(self, profile):
# returns the line in post that would configure yum to use repos added with "cobbler repo add"
- repos = utils.blender(False,profile)["repos"]
+ repos = utils.blender(self.api, False,profile)["repos"]
buf = ""
for r in repos:
repo = self.repos.find(name=r)
@@ -463,7 +464,7 @@ class BootSync:
if profile is None:
raise CX(_("system %(system)s references missing profile %(profile)s") % { "system" : s.name, "profile" : s.profile })
distro = profile.get_conceptual_parent()
- meta = utils.blender(False, s)
+ meta = utils.blender(self.api, False, s)
kickstart_path = utils.find_kickstart(meta["kickstart"])
if kickstart_path and os.path.exists(kickstart_path):
copy_path = os.path.join(self.settings.webdir,
@@ -707,7 +708,7 @@ class BootSync:
initrd_path = os.path.join("/images",distro.name,os.path.basename(distro.initrd))
# Find the kickstart if we inherit from another profile
- kickstart_path = utils.blender(True, profile)["kickstart"]
+ kickstart_path = utils.blender(self.api, True, profile)["kickstart"]
# ---
# choose a template
@@ -720,9 +721,9 @@ class BootSync:
# now build the kernel command line
if system is not None:
- kopts = utils.blender(True,system)["kernel_options"]
+ kopts = utils.blender(self.api, True,system)["kernel_options"]
else:
- kopts = utils.blender(True,profile)["kernel_options"]
+ kopts = utils.blender(self.api, True,profile)["kernel_options"]
# ---
# generate the append line
@@ -795,7 +796,7 @@ class BootSync:
"""
Create distro information for koan install
"""
- blended = utils.blender(True, distro)
+ blended = utils.blender(self.api, True, distro)
filename = os.path.join(self.settings.webdir,"distros",distro.name)
fd = open(filename, "w+")
fd.write(yaml.dump(blended))
@@ -808,7 +809,7 @@ class BootSync:
NOTE: relevant to http only
"""
- blended = utils.blender(True, profile)
+ blended = utils.blender(self.api, True, profile)
filename = os.path.join(self.settings.webdir,"profiles",profile.name)
fd = open(filename, "w+")
if blended.has_key("kickstart") and blended["kickstart"].startswith("/"):
@@ -824,7 +825,7 @@ class BootSync:
NOTE: relevant to http only
"""
- blended = utils.blender(True, system)
+ blended = utils.blender(self.api, True, system)
filename = os.path.join(self.settings.webdir,"systems",system.name)
fd = open(filename, "w+")
fd.write(yaml.dump(blended))
diff --git a/cobbler/remote.py b/cobbler/remote.py
index 0cdc426..9cbff5c 100644
--- a/cobbler/remote.py
+++ b/cobbler/remote.py
@@ -202,7 +202,7 @@ class CobblerXMLRPCInterface:
self._refresh()
obj = self.api.distros().find(name=name)
if obj is not None:
- return self._fix_none(utils.blender(True, obj))
+ return self._fix_none(utils.blender(self.api, True, obj))
return self._fix_none({})
def get_profile_as_rendered(self,name,token=None):
@@ -220,7 +220,7 @@ class CobblerXMLRPCInterface:
self._refresh()
obj = self.api.profiles().find(name=name)
if obj is not None:
- return self._fix_none(utils.blender(True, obj))
+ return self._fix_none(utils.blender(self.api, True, obj))
return self._fix_none({})
def get_system_as_rendered(self,name,token=None):
@@ -238,7 +238,7 @@ class CobblerXMLRPCInterface:
self._refresh()
obj = self.api.systems().find(name=name)
if obj is not None:
- return self._fix_none(utils.blender(True, obj))
+ return self._fix_none(utils.blender(self.api, True, obj))
return self._fix_none({})
def get_repo_as_rendered(self,name,token=None):
@@ -256,7 +256,7 @@ class CobblerXMLRPCInterface:
self._refresh()
obj = self.api.repos().find(name=name)
if obj is not None:
- return self._fix_none(utils.blender(True, obj))
+ return self._fix_none(utils.blender(self.api, True, obj))
return self._fix_none({})
def get_random_mac(self):
diff --git a/cobbler/utils.py b/cobbler/utils.py
index a2cee35..157974e 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -25,7 +25,7 @@ import logging
from cexceptions import *
from rhpl.translate import _, N_, textdomain, utf8
-import api # factor out
+# import api # factor out
_re_kernel = re.compile(r'vmlinuz(.*)')
_re_initrd = re.compile(r'initrd(.*).img')
@@ -258,11 +258,11 @@ def input_string_or_hash(options,delim=","):
else:
raise CX(_("Foreign options type"))
-def grab_tree(obj):
+def grab_tree(api_handle, obj):
"""
Climb the tree and get every node.
"""
- settings = api.BootAPI().settings()
+ settings = api_handle.BootAPI().settings()
results = [ obj ]
parent = obj.get_parent()
while parent is not None:
@@ -271,13 +271,13 @@ def grab_tree(obj):
results.append(settings)
return results
-def blender(remove_hashes, root_obj):
+def blender(api_handle,remove_hashes, root_obj):
"""
Combine all of the data in an object tree from the perspective
of that point on the tree, and produce a merged hash containing
consolidated data.
"""
- settings = api.BootAPI().settings()
+ settings = api_handle.BootAPI().settings()
tree = grab_tree(root_obj)
tree.reverse() # start with top of tree, override going down
results = {}