summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-08-27 15:09:16 -0400
committerMichael DeHaan <mdehaan@mdehaan.rdu.redhat.com>2007-08-27 15:09:16 -0400
commit159c39eef9df2fe4c4797f70a2598edb8a72d15b (patch)
tree641a493e6694584b5e5ca22564e6f71176f18b5b
parent52cd0bfe11da992cc17b55f5de4175482055b1d8 (diff)
downloadcobbler-159c39eef9df2fe4c4797f70a2598edb8a72d15b.tar.gz
cobbler-159c39eef9df2fe4c4797f70a2598edb8a72d15b.tar.xz
cobbler-159c39eef9df2fe4c4797f70a2598edb8a72d15b.zip
Fix bug with upward/downward propogation of array content when using inheritance.
-rw-r--r--cobbler/item_profile.py5
-rw-r--r--cobbler/utils.py2
-rw-r--r--tests/tests.py53
3 files changed, 57 insertions, 3 deletions
diff --git a/cobbler/item_profile.py b/cobbler/item_profile.py
index 3df3113e..f27f3a70 100644
--- a/cobbler/item_profile.py
+++ b/cobbler/item_profile.py
@@ -40,7 +40,7 @@ class Profile(item.Item):
self.ks_meta = ({}, '<<inherit>>')[is_subobject]
self.virt_file_size = (5, '<<inherit>>')[is_subobject]
self.virt_ram = (512, '<<inherit>>')[is_subobject]
- self.repos = ("", '<<inherit>>')[is_subobject]
+ self.repos = ([], '<<inherit>>')[is_subobject]
self.depth = 1
self.virt_type = (self.settings.default_virt_type, '<<inherit>>')[is_subobject]
self.virt_path = ("", '<<inherit>>')[is_subobject]
@@ -74,6 +74,8 @@ class Profile(item.Item):
self.set_kernel_options(self.kernel_options)
if self.ks_meta != "<<inherit>>" and type(self.ks_meta) != dict:
self.set_ksmeta(self.ks_meta)
+ if self.repos != "<<inherit>>" and type(self.ks_meta) != list:
+ self.set_repos(self.repos)
return self
@@ -133,6 +135,7 @@ class Profile(item.Item):
self.repos = repolist
else:
raise CX(_("repository not found"))
+ return True
def set_kickstart(self,kickstart):
"""
diff --git a/cobbler/utils.py b/cobbler/utils.py
index 78459608..23dcca64 100644
--- a/cobbler/utils.py
+++ b/cobbler/utils.py
@@ -309,6 +309,8 @@ def __consolidate(node,results):
if value != "<<inherit>>":
if type(value) == type({}):
node_data_copy[key] = value.copy()
+ elif type(value) == type([]):
+ node_data_copy[key] = value[:]
else:
node_data_copy[key] = value
diff --git a/tests/tests.py b/tests/tests.py
index 71862c20..291ab07b 100644
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -211,16 +211,27 @@ class Additions(BootTest):
def test_inheritance_and_variable_propogation(self):
+
# STEP ONE: verify that non-inherited objects behave
# correctly with ks_meta (we picked this attribute
# because it's a hash and it's a bit harder to handle
# than strings). It should be passed down the render
# tree to all subnodes
+ repo = self.api.new_repo()
+ try:
+ os.path.makedirs("/tmp/test_cobbler_repo")
+ except:
+ pass
+ self.assertTrue(repo.set_name("testrepo"))
+ self.assertTrue(repo.set_mirror("/tmp"))
+ self.assertTrue(self.api.repos().add(repo))
+
profile = self.api.new_profile()
self.assertTrue(profile.set_name("testprofile12b2"))
self.assertTrue(profile.set_distro("testdistro0"))
self.assertTrue(profile.set_kickstart("http://127.0.0.1/foo"))
+ self.assertTrue(profile.set_repos(["testrepo"]))
self.assertTrue(self.api.profiles().add(profile))
self.api.sync()
system = self.api.new_system()
@@ -253,7 +264,42 @@ class Additions(BootTest):
self.assertTrue(self.api.systems().add(system2))
self.api.sync()
- # now see if the profile does NOT have the ksmeta attribute
+ # FIXME: now evaluate the system object and make sure
+ # that it has inherited the repos value from the superprofile
+ # above it's actual profile. This should NOT be present in the
+ # actual object, which we have not modified yet.
+
+ data = utils.blender(False, system2)
+ self.assertTrue(data["repos"] == ["testrepo"])
+ self.assertTrue(self.api.profiles().find(system2.profile).repos == "<<inherit>>")
+
+ # now if we set the repos object of the system to an additional
+ # repo we should verify it now contains two repos.
+ # (FIXME)
+
+ repo2 = self.api.new_repo()
+ self.assertTrue(repo2.set_name("testrepo2"))
+ self.assertTrue(repo2.set_mirror("/tmp"))
+ self.assertTrue(self.api.repos().add(repo2))
+ profile2 = self.api.profiles().find("testprofile12b3")
+ # note: side check to make sure we can also set to string values
+ profile2.set_repos("testrepo2")
+ self.api.profiles().add(profile2) # save it
+
+ data = utils.blender(False, system2)
+ self.assertTrue("testrepo" in data["repos"])
+ self.assertTrue("testrepo2" in data["repos"])
+ self.assertTrue(self.api.profiles().find(system2.profile).repos == ["testrepo2"])
+
+ # now double check that the parent profile still only has one repo in it.
+ # this is part of our test against upward propogation
+
+ profile = self.api.profiles().find("testprofile12b2")
+ print profile.repos
+ self.assertTrue(len(profile.repos) == 1)
+ self.assertTrue(profile.repos == ["testrepo"])
+
+ # now see if the subprofile does NOT have the ksmeta attribute
# this is part of our test against upward propogation
profile2 = self.api.profiles().find("testprofile12b3")
@@ -310,7 +356,10 @@ class Additions(BootTest):
self.assertTrue(data.has_key("ks_meta"))
self.assertTrue(data["ks_meta"].has_key("alsoalsowik"))
- # STEP SIX: see if settings changes also propogate
+
+
+
+ # STEP SEVEN: see if settings changes also propogate
# TBA
def test_system_name_is_a_MAC(self):