Skip to content

Commit

Permalink
Add support for changing template LOADPATH
Browse files Browse the repository at this point in the history
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 <Gabor.Gombas@morganstanley.com>
  • Loading branch information
Gintare Urbone committed Aug 25, 2017
1 parent d4f6ac7 commit 1ada34b
Show file tree
Hide file tree
Showing 14 changed files with 50 additions and 36 deletions.
1 change: 1 addition & 0 deletions etc/aqd.conf.defaults
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/aquilon/aqdb/model/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']}},)
7 changes: 6 additions & 1 deletion lib/aquilon/worker/templates/cluster.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 5 additions & 3 deletions lib/aquilon/worker/templates/host.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lib/aquilon/worker/templates/machine.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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
Expand Down
7 changes: 6 additions & 1 deletion lib/aquilon/worker/templates/metacluster.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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")}))
Expand Down
8 changes: 4 additions & 4 deletions tests/broker/test_add_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -134,15 +134,15 @@ 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)
self.searchoutput(out,
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)

Expand Down
8 changes: 4 additions & 4 deletions tests/broker/test_add_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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*'
Expand Down Expand Up @@ -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*'
Expand Down Expand Up @@ -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*'
Expand Down Expand Up @@ -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):
Expand Down
8 changes: 4 additions & 4 deletions tests/broker/test_add_virtual_hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -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*'
Expand All @@ -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*'
Expand Down Expand Up @@ -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*'
Expand All @@ -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*'
Expand Down
2 changes: 1 addition & 1 deletion tests/broker/test_del_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
10 changes: 5 additions & 5 deletions tests/broker/test_update_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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*'
Expand Down Expand Up @@ -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*'
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions tests/broker/test_update_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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*'
Expand Down Expand Up @@ -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*'
Expand Down Expand Up @@ -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*'
Expand Down Expand Up @@ -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*'
Expand Down
12 changes: 6 additions & 6 deletions tests/broker/test_update_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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):
Expand Down
1 change: 1 addition & 0 deletions tests/unittest.conf
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 1ada34b

Please sign in to comment.