diff options
author | Michael DeHaan <mdehaan@mdehaan.rdu.redhat.com> | 2007-04-20 17:57:02 -0400 |
---|---|---|
committer | Michael DeHaan <mdehaan@mdehaan.rdu.redhat.com> | 2007-04-20 17:57:02 -0400 |
commit | bb1e5b50e930b7c9618387cc43634e6050eb3481 (patch) | |
tree | ac7feb459190458ed21a57ae1bf7d5dc5b664666 /cobbler/item_distro.py | |
parent | 8205bf0691bb48080c3bc4d0fd7c444238187801 (diff) | |
download | third_party-cobbler-bb1e5b50e930b7c9618387cc43634e6050eb3481.tar.gz third_party-cobbler-bb1e5b50e930b7c9618387cc43634e6050eb3481.tar.xz third_party-cobbler-bb1e5b50e930b7c9618387cc43634e6050eb3481.zip |
This commit overhauls the main cobbler CLI module and adds support for
object renaming, copying, and editing -- previously only addition and
removal were supported. This frees uses (hopefully) from the need
to hack YAML and risk damaging their configurations by rendering the
config unparseable. It also makes "cobbler list" print out a simple
tree representation that shows the association between objects.
This also relaxes the requirements for what constitutes a kernel and initrd
filename, just in case they are named something different. They still have
to exist.
Diffstat (limited to 'cobbler/item_distro.py')
-rw-r--r-- | cobbler/item_distro.py | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/cobbler/item_distro.py b/cobbler/item_distro.py index c4c115f..3f5dcce 100644 --- a/cobbler/item_distro.py +++ b/cobbler/item_distro.py @@ -22,12 +22,12 @@ import cexceptions class Distro(item.Item): - def __init__(self,config): - """ - Constructor. Requires a back reference to the Config management object. - """ - self.config = config - self.clear() + #def __init__(self,config): + # """ + # Constructor. Requires a back reference to the Config management object. + # """ + # self.config = config + # self.clear() def clear(self): """ @@ -42,6 +42,12 @@ class Distro(item.Item): self.breed = "redhat" self.source_repos = [] + def make_clone(self): + ds = self.to_datastruct() + cloned = Distro(self.config) + cloned.from_datastruct(ds) + return cloned + def from_datastruct(self,seed_data): """ Modify this object to take on values in seed_data @@ -151,14 +157,15 @@ class Distro(item.Item): """ kstr = utils.find_kernel(self.kernel) istr = utils.find_initrd(self.initrd) - if kstr is None: - kstr = "%s (NOT FOUND)" % self.kernel - elif os.path.isdir(self.kernel): - kstr = "%s (FOUND BY SEARCH)" % kstr - if istr is None: - istr = "%s (NOT FOUND)" % self.initrd - elif os.path.isdir(self.initrd): - istr = "%s (FOUND BY SEARCH)" % istr + # old code, as we've relaxed filename requirements: + #if kstr is None: + # kstr = "%s (NOT FOUND)" % self.kernel + #elif os.path.isdir(self.kernel): + # kstr = "%s (FOUND BY SEARCH)" % kstr + #if istr is None: + # istr = "%s (NOT FOUND)" % self.initrd + #elif os.path.isdir(self.initrd): + # istr = "%s (FOUND BY SEARCH)" % istr buf = "distro : %s\n" % self.name buf = buf + "kernel : %s\n" % kstr buf = buf + "initrd : %s\n" % istr |