From 1ada34baa258498b6e2e81808ae9501cc44e3c5c Mon Sep 17 00:00:00 2001 From: Gintare Urbone Date: Wed, 2 Aug 2017 18:03:28 +0100 Subject: [PATCH] Add support for changing template LOADPATH Add support for changing template LOADPATH by ensuring archetype/base template is really the first one being loaded. Adding option in config which allows to include or not include pan/units and pan/functions. Change-Id: Ib367f24ba0082e781707f5419128182db51a9c59 Addresses-Issue: Jira/AQUILON-4086 Reviewed-By: Gabor Gombas --- etc/aqd.conf.defaults | 1 + lib/aquilon/aqdb/model/building.py | 2 +- lib/aquilon/worker/templates/cluster.py | 7 ++++++- lib/aquilon/worker/templates/host.py | 8 +++++--- lib/aquilon/worker/templates/machine.py | 4 ++-- lib/aquilon/worker/templates/metacluster.py | 7 ++++++- tests/broker/test_add_disk.py | 8 ++++---- tests/broker/test_add_machine.py | 8 ++++---- tests/broker/test_add_virtual_hardware.py | 8 ++++---- tests/broker/test_del_disk.py | 2 +- tests/broker/test_update_disk.py | 10 +++++----- tests/broker/test_update_machine.py | 8 ++++---- tests/broker/test_update_model.py | 12 ++++++------ tests/unittest.conf | 1 + 14 files changed, 50 insertions(+), 36 deletions(-) mode change 100644 => 100755 etc/aqd.conf.defaults mode change 100644 => 100755 lib/aquilon/worker/templates/cluster.py mode change 100644 => 100755 lib/aquilon/worker/templates/host.py mode change 100644 => 100755 lib/aquilon/worker/templates/machine.py mode change 100644 => 100755 lib/aquilon/worker/templates/metacluster.py mode change 100644 => 100755 tests/unittest.conf diff --git a/etc/aqd.conf.defaults b/etc/aqd.conf.defaults old mode 100644 new mode 100755 index ac48f3327..36e8ddd9d --- a/etc/aqd.conf.defaults +++ b/etc/aqd.conf.defaults @@ -331,6 +331,7 @@ transparent_gzip = true template_extension = .tpl # Max. time a compilation is allowed to take. The value is passed to the "timeout" command verbatim. timeout = 30m +include_pan = True [site] # Site specific settings diff --git a/lib/aquilon/aqdb/model/building.py b/lib/aquilon/aqdb/model/building.py index 5e541a108..754caacfc 100644 --- a/lib/aquilon/aqdb/model/building.py +++ b/lib/aquilon/aqdb/model/building.py @@ -34,4 +34,4 @@ class Building(Location): address = Column(String(255), nullable=False) - __table_args__ = ({'info': {'unique_fields': ['name']}},) + __table_args__ = ({'info': {'unique_fields': ['name']}},) \ No newline at end of file diff --git a/lib/aquilon/worker/templates/cluster.py b/lib/aquilon/worker/templates/cluster.py old mode 100644 new mode 100755 index ae54c944f..1f796a1aa --- a/lib/aquilon/worker/templates/cluster.py +++ b/lib/aquilon/worker/templates/cluster.py @@ -188,7 +188,12 @@ def get_key(self, exclusive=True): return CompileKey.merge(keylist) def body(self, lines): - pan_include(lines, ["pan/units", "pan/functions"]) + # This is required to be able to override LOADPATH + if not self.config.has_option("panc", "include_pan") or self.config.getboolean("panc", "include_pan"): + pan_include(lines, ["pan/units", "pan/functions"]) + lines.append("") + + # Okay, here's the real content path = PlenaryClusterData.template_name(self.dbobj) pan_assign(lines, "/", StructureTemplate(path, diff --git a/lib/aquilon/worker/templates/host.py b/lib/aquilon/worker/templates/host.py old mode 100644 new mode 100755 index 57e40a968..2331930db --- a/lib/aquilon/worker/templates/host.py +++ b/lib/aquilon/worker/templates/host.py @@ -374,10 +374,12 @@ def body(self, lines): services.sort() provides.sort() - # Okay, here's the real content - pan_include(lines, ["pan/units", "pan/functions"]) - lines.append("") + # This is required to be able to override LOADPATH + if not self.config.has_option("panc", "include_pan") or self.config.getboolean("panc", "include_pan"): + pan_include(lines, ["pan/units", "pan/functions"]) + lines.append("") + # Okay, here's the real content path = PlenaryHostData.template_name(self.dbobj) pan_assign(lines, "/", StructureTemplate(path, diff --git a/lib/aquilon/worker/templates/machine.py b/lib/aquilon/worker/templates/machine.py old mode 100644 new mode 100755 index a16ccd9fb..1990640d9 --- a/lib/aquilon/worker/templates/machine.py +++ b/lib/aquilon/worker/templates/machine.py @@ -72,7 +72,7 @@ def get_key(self, exclusive=True): def body(self, lines): ram = [StructureTemplate("hardware/ram/generic", - {"size": PanMetric(self.dbobj.memory, "MB")})] + {"size": self.dbobj.memory})] cpu = StructureTemplate("hardware/cpu/%s/%s" % (self.dbobj.cpu_model.vendor.name, self.dbobj.cpu_model.name)) @@ -81,7 +81,7 @@ def body(self, lines): disks = {} for disk in self.dbobj.disks: devname = disk.device_name - params = {"capacity": PanMetric(disk.capacity, "GB"), + params = {"capacity": PanMetric(disk.capacity, 1024), "interface": disk.controller_type} if disk.bootable: params["boot"] = True diff --git a/lib/aquilon/worker/templates/metacluster.py b/lib/aquilon/worker/templates/metacluster.py old mode 100644 new mode 100755 index 0d256c5b8..a1d54340d --- a/lib/aquilon/worker/templates/metacluster.py +++ b/lib/aquilon/worker/templates/metacluster.py @@ -117,7 +117,12 @@ def get_key(self, exclusive=True): return CompileKey.merge(keylist) def body(self, lines): - pan_include(lines, ["pan/units", "pan/functions"]) + # This is required to be able to override LOADPATH + if not self.config.has_option("panc", "include_pan") or self.config.getboolean("panc", "include_pan"): + pan_include(lines, ["pan/units", "pan/functions"]) + lines.append("") + + # Okay, here's the real content pan_assign(lines, "/", StructureTemplate("clusterdata/%s" % self.dbobj.name, {"metadata": PanValue("/metadata")})) diff --git a/tests/broker/test_add_disk.py b/tests/broker/test_add_disk.py index fa8a48359..15557535b 100755 --- a/tests/broker/test_add_disk.py +++ b/tests/broker/test_add_disk.py @@ -106,14 +106,14 @@ def test_300_cat_ut3c5n10(self): r'"harddisks/{sda}" = ' r'create\("hardware/harddisk/generic/scsi",\s*' r'"boot", true,\s*' - r'"capacity", 68\*GB,\s*' + r'"capacity", 68\*1024,\s*' r'"interface", "scsi"\s*\);', command) self.searchoutput(out, r'"harddisks/{sdb}" = ' r'create\("hardware/harddisk/generic/scsi",\s*' r'"address", "0:0:1:0",\s*' - r'"capacity", 34\*GB,\s*' + r'"capacity", 34\*1024,\s*' r'"interface", "scsi"\s*\);', command) @@ -134,7 +134,7 @@ def test_300_cat_ut3c1n3(self): r'"harddisks/{cciss/c0d0}" = ' r'create\("hardware/harddisk/generic/cciss",\s*' r'"bus", "pci:0000:01:00.0",\s*' - r'"capacity", 34\*GB,\s*' + r'"capacity", 34\*1024,\s*' r'"interface", "cciss",\s*' r'"wwn", "600508b112233445566778899aabbccd"\s*\);', command) @@ -142,7 +142,7 @@ def test_300_cat_ut3c1n3(self): r'"harddisks/{sda}" = ' r'create\("hardware/harddisk/generic/scsi",\s*' r'"boot", true,\s*' - r'"capacity", 68\*GB,\s*' + r'"capacity", 68\*1024,\s*' r'"interface", "scsi"\s*\);', command) diff --git a/tests/broker/test_add_machine.py b/tests/broker/test_add_machine.py index 8f9b21db0..f08cc7d06 100755 --- a/tests/broker/test_add_machine.py +++ b/tests/broker/test_add_machine.py @@ -85,7 +85,7 @@ def test_105_cat_ut3c5n10(self): self.searchoutput(out, r'"ram" = list\(\s*' r'create\("hardware/ram/generic",\s*' - r'"size", 8192\*MB\s*\)\s*\);', + r'"size", 8192\s*\)\s*\);', command) self.searchoutput(out, r'"cpu" = list\(\s*' @@ -263,7 +263,7 @@ def test_145_cat_ut3c1n3(self): self.searchoutput(out, r'"ram" = list\(\s*' r'create\("hardware/ram/generic",\s*' - r'"size", 8192\*MB\s*\)\s*\);', + r'"size", 8192\s*\)\s*\);', command) self.searchoutput(out, r'"cpu" = list\(\s*' @@ -303,7 +303,7 @@ def test_155_cat_ut3c1n4(self): self.searchoutput(out, r'"ram" = list\(\s*' r'create\("hardware/ram/generic",\s*' - r'"size", 8192\*MB\s*\)\s*\);', + r'"size", 8192\s*\)\s*\);', command) self.searchoutput(out, r'"cpu" = list\(\s*' @@ -338,7 +338,7 @@ def test_165_cat_cciss_machine(self): 'create("hardware/harddisk/generic/cciss",', command) self.matchoutput(out, - '"capacity", 466*GB', + '"capacity", 466*1024', command) def test_170_add_ut3c1n9(self): diff --git a/tests/broker/test_add_virtual_hardware.py b/tests/broker/test_add_virtual_hardware.py index 71abbb8d7..c4e615dbd 100755 --- a/tests/broker/test_add_virtual_hardware.py +++ b/tests/broker/test_add_virtual_hardware.py @@ -187,7 +187,7 @@ def test_130_cat_utecl1_tmachines(self): self.searchoutput(out, r'"ram" = list\(\s*' r'create\("hardware/ram/generic",\s*' - r'"size", 8192\*MB\s*\)\s*\);', + r'"size", 8192\s*\)\s*\);', command) self.searchoutput(out, r'"cpu" = list\(\s*' @@ -204,7 +204,7 @@ def test_130_cat_utecl1_tmachines(self): r'"harddisks/\{sda\}" = nlist\(\s*' r'"address", "0:0",\s*' r'"boot", true,\s*' - r'"capacity", 15\*GB,\s*' + r'"capacity", 15\*1024,\s*' r'"interface", "sata",\s*' r'"mountpoint", "/vol/lnn30f1v1/test_share_%d",\s*' r'"path", "evm%d/sda.vmdk",\s*' @@ -492,7 +492,7 @@ def test_260_verifycatmachines(self): self.searchoutput(out, r'"ram" = list\(\s*' r'create\("hardware/ram/generic",\s*' - r'"size", 8192\*MB\s*\)\s*\);', + r'"size", 8192\s*\)\s*\);', command) self.searchoutput(out, r'"cpu" = list\(\s*' @@ -510,7 +510,7 @@ def test_260_verifycatmachines(self): r'"harddisks/\{sda\}" = nlist\(\s*' r'"address", "0:0",\s*' r'"boot", true,\s*' - r'"capacity", 15\*GB,\s*' + r'"capacity", 15\*1024,\s*' r'"interface", "sata",\s*' r'"mountpoint", "/vol/lnn30f1v1/%s",\s*' r'"path", "%s/sda.vmdk",\s*' diff --git a/tests/broker/test_del_disk.py b/tests/broker/test_del_disk.py index c2c192b09..022205624 100755 --- a/tests/broker/test_del_disk.py +++ b/tests/broker/test_del_disk.py @@ -59,7 +59,7 @@ def test_105_cat_ut3c1n3(self): r'create\("hardware/harddisk/generic/cciss",\s*' r'"boot", true,\s*' r'"bus", "pci:0000:01:00.0",\s*' - r'"capacity", 34\*GB,\s*' + r'"capacity", 34\*1024,\s*' r'"interface", "cciss"\s*\)', command) diff --git a/tests/broker/test_update_disk.py b/tests/broker/test_update_disk.py index 5b3270342..37836b53d 100755 --- a/tests/broker/test_update_disk.py +++ b/tests/broker/test_update_disk.py @@ -112,7 +112,7 @@ def test_105_cat_ut3c1n3(self): r'create\("hardware/harddisk/generic/cciss",\s*' r'"boot", true,\s*' r'"bus", "pci:0000:01:00.0",\s*' - r'"capacity", 34\*GB,\s*' + r'"capacity", 34\*1024,\s*' r'"interface", "cciss",\s*' r'"wwn", "600508b112233445566778899aabbccd"\s*\);', command) @@ -121,7 +121,7 @@ def test_105_cat_ut3c1n3(self): r'create\("hardware/harddisk/generic/sata",\s*' r'"address", "0:0:0:0",\s*' r'"bus", "pci:0000:02:00.0",\s*' - r'"capacity", 50\*GB,\s*' + r'"capacity", 50\*1024,\s*' r'"interface", "sata"\s*\);', command) self.matchclean(out, "c0d0", command) @@ -177,7 +177,7 @@ def test_112_cat_evm10(self): r'"harddisks/{sda}" = nlist\(\s*' r'"address", "0:1",\s*' r'"boot", true,\s*' - r'"capacity", 45\*GB,\s*' + r'"capacity", 45\*1024,\s*' r'"filesystemname", "disk_update_test",\s*' r'"interface", "scsi",\s*' r'"iopslimit", 30,\s*' @@ -223,7 +223,7 @@ def test_114_cat_evm10(self): r'"harddisks/{sda}" = nlist\(\s*' r'"address", "0:0",\s*' r'"boot", true,\s*' - r'"capacity", 45\*GB,\s*' + r'"capacity", 45\*1024,\s*' r'"interface", "scsi",\s*' r'"iopslimit", 30,\s*' r'"mountpoint", "/vol/lnn30f1v1/utecl5_share",\s*' @@ -275,7 +275,7 @@ def test_124_verify_wwn_update(self): r'"harddisks/{sdb}" = ' r'create\("hardware/harddisk/generic/scsi",\s*' r'"address", "0:0:1:0",\s*' - r'"capacity", 34\*GB,\s*' + r'"capacity", 34\*1024,\s*' r'"interface", "scsi",\s*' r'"wwn", "600508b112233445566778899aabbccd"\s*\);', command) diff --git a/tests/broker/test_update_machine.py b/tests/broker/test_update_machine.py index cfe1e602c..6729b9dd2 100755 --- a/tests/broker/test_update_machine.py +++ b/tests/broker/test_update_machine.py @@ -60,7 +60,7 @@ def test_1005_cat_ut3c1n3(self): self.searchoutput(out, r'"ram" = list\(\s*' r'create\("hardware/ram/generic",\s*' - r'"size", 8192\*MB\s*\)\s*\);', + r'"size", 8192\s*\)\s*\);', command) self.searchoutput(out, r'"cpu" = list\(\s*' @@ -132,7 +132,7 @@ def test_1015_cat_ut3c5n10(self): self.searchoutput(out, r'"ram" = list\(\s*' r'create\("hardware/ram/generic",\s*' - r'"size", 8192\*MB\s*\)\s*\);', + r'"size", 8192\s*\)\s*\);', command) self.searchoutput(out, r'"cpu" = list\(\s*' @@ -194,7 +194,7 @@ def test_1025_cat_ut3c1n4(self): self.searchoutput(out, r'"ram" = list\(\s*' r'create\("hardware/ram/generic",\s*' - r'"size", 8192\*MB\s*\)\s*\);', + r'"size", 8192\s*\)\s*\);', command) self.searchoutput(out, r'"cpu" = list\(\s*' @@ -534,7 +534,7 @@ def test_1132_cat_evm1(self): self.searchoutput(out, r'"ram" = list\(\s*' r'create\("hardware/ram/generic",\s*' - r'"size", 12288\*MB\s*\)\s*\);', + r'"size", 12288\s*\)\s*\);', command) self.searchoutput(out, r'"cpu" = list\(\s*' diff --git a/tests/broker/test_update_model.py b/tests/broker/test_update_model.py index 6fca5f6b9..346ba0a23 100755 --- a/tests/broker/test_update_model.py +++ b/tests/broker/test_update_model.py @@ -34,13 +34,13 @@ def test_000_sanitycheck(self): self.searchoutput(out, r'"ram" = list\(\s*' r'create\("hardware/ram/generic",\s*' - r'"size", 8192\*MB\s*\)\s*\);', + r'"size", 8192\s*\)\s*\);', command) self.searchoutput(out, r'"cpu" = list\(\s*' r'create\("hardware/cpu/intel/l5520"\)\s*\);', command) - self.matchoutput(out, '"capacity", 15*GB,', command) + self.matchoutput(out, '"capacity", 15*1024,', command) self.matchoutput(out, '"interface", "sata",', command) def test_100_updateexisting(self): @@ -74,13 +74,13 @@ def test_120_verifymachine(self): self.searchoutput(out, r'"ram" = list\(\s*' r'create\("hardware/ram/generic",\s*' - r'"size", 4096\*MB\s*\)\s*\);', + r'"size", 4096\s*\)\s*\);', command) self.searchoutput(out, r'"cpu" = list\(\s*' r'create\("hardware/cpu/intel/utcpu"\)\s*\);', command) - self.matchoutput(out, '"capacity", 45*GB,', command) + self.matchoutput(out, '"capacity", 45*1024,', command) self.matchoutput(out, '"interface", "scsi",', command) def test_130_clear_comments(self): @@ -122,13 +122,13 @@ def test_230_verifymachine(self): self.searchoutput(out, r'"ram" = list\(\s*' r'create\("hardware/ram/generic",\s*' - r'"size", 4096\*MB\s*\)\s*\);', + r'"size", 4096\s*\)\s*\);', command) self.searchoutput(out, r'"cpu" = list\(\s*' r'create\("hardware/cpu/intel/utcpu"\)\s*\);', command) - self.matchoutput(out, '"capacity", 45*GB,', command) + self.matchoutput(out, '"capacity", 45*1024,', command) self.matchoutput(out, '"interface", "scsi",', command) def test_300_updatetype(self): diff --git a/tests/unittest.conf b/tests/unittest.conf old mode 100644 new mode 100755 index 7d108c08e..66e7d61d9 --- a/tests/unittest.conf +++ b/tests/unittest.conf @@ -128,6 +128,7 @@ default_domain = ut-prod [panc] pan_compiler = %(basedir)s/panc-links/panc-%(version)s.jar +include_pan = True [site] # Site specific settings