Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plenary template adjustment to fix the template library support #87

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion etc/aqd.conf.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ gzip_output = false
# only used if gzip_output = true
transparent_gzip = true
template_extension = .tpl
include_pan = True
object_declarations_template = false

[tool_timeout]
# If set to True, timeout will be set to 'default_value' for any tools run via subprocess
Expand Down
4 changes: 4 additions & 0 deletions etc/aqd.conf.noms
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ location_uri_validator = /bin/true
# in raw mode and set the version variable itself.
pan_compiler = /usr/lib/panc.jar

# Include a preface template in the object template if true
object_declarations_template = true


###############################################################################

[site]
Expand Down
11 changes: 8 additions & 3 deletions lib/aquilon/worker/templates/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,16 @@ def get_key(self, exclusive=True):
return CompileKey.merge(keylist)

def body(self, lines):
# This is required to be able to override LOADPATH
if self.config.getboolean("panc", "include_pan"):
pan_include(lines, ["pan/units", "pan/functions"])
# Allow settings such as loadpath to be modified by the archetype before anything else happens
# Included only if object_declarations_template option is true
# It the option is true, the template MUST exist
if self.config.getboolean("panc", "object_declarations_template"):
pan_include(lines, "archetype/declarations")
lines.append("")

pan_include(lines, ["pan/units", "pan/functions"])
lines.append("")

# Okay, here's the real content
path = PlenaryClusterData.template_name(self.dbobj)
pan_assign(lines, "/",
Expand Down
11 changes: 8 additions & 3 deletions lib/aquilon/worker/templates/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,16 @@ def body(self, lines):
services.sort()
provides.sort()

# This is required to be able to override LOADPATH
if self.config.getboolean("panc", "include_pan"):
pan_include(lines, ["pan/units", "pan/functions"])
# Allow settings such as loadpath to be modified by the archetype before anything else happens
# Included only if object_declarations_template option is true
# It the option is true, the template MUST exist
if self.config.getboolean("panc", "object_declarations_template"):
pan_include(lines, "archetype/declarations")
lines.append("")

pan_include(lines, ["pan/units", "pan/functions"])
lines.append("")

# Okay, here's the real content
path = PlenaryHostData.template_name(self.dbobj)
pan_assign(lines, "/",
Expand Down
4 changes: 2 additions & 2 deletions lib/aquilon/worker/templates/machine.py
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": self.dbobj.memory})]
{"size": PanMetric(self.dbobj.memory, "MB")})]
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, 1024),
params = {"capacity": PanMetric(disk.capacity, "GB"),
"interface": disk.controller_type}
if disk.bootable:
params["boot"] = True
Expand Down
11 changes: 8 additions & 3 deletions lib/aquilon/worker/templates/metacluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,11 +117,16 @@ def get_key(self, exclusive=True):
return CompileKey.merge(keylist)

def body(self, lines):
# This is required to be able to override LOADPATH
if self.config.getboolean("panc", "include_pan"):
pan_include(lines, ["pan/units", "pan/functions"])
# Allow settings such as loadpath to be modified by the archetype before anything else happens
# Included only if object_declarations_template option is true
# It the option is true, the template MUST exist
if self.config.getboolean("panc", "object_declarations_template"):
pan_include(lines, "archetype/declarations")
lines.append("")

pan_include(lines, ["pan/units", "pan/functions"])
lines.append("")

# Okay, here's the real content
pan_assign(lines, "/",
StructureTemplate("clusterdata/%s" % self.dbobj.name,
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 @@ -102,14 +102,14 @@ def test_300_cat_ut3c5n10(self):
r'"harddisks/{sda}" = '
r'create\("hardware/harddisk/generic/scsi",\s*'
r'"boot", true,\s*'
r'"capacity", 68\*1024,\s*'
r'"capacity", 68\*GB,\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\*1024,\s*'
r'"capacity", 34\*GB,\s*'
r'"interface", "scsi"\s*\);',
command)

Expand All @@ -130,15 +130,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\*1024,\s*'
r'"capacity", 34\*GB,\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\*1024,\s*'
r'"capacity", 68\*GB,\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 @@ -84,7 +84,7 @@ def test_105_cat_ut3c5n10(self):
self.searchoutput(out,
r'"ram" = list\(\s*'
r'create\("hardware/ram/generic",\s*'
r'"size", 8192\s*\)\s*\);',
r'"size", 8192\*MB\s*\)\s*\);',
command)
self.searchoutput(out,
r'"cpu" = list\(\s*'
Expand Down Expand Up @@ -259,7 +259,7 @@ def test_145_cat_ut3c1n3(self):
self.searchoutput(out,
r'"ram" = list\(\s*'
r'create\("hardware/ram/generic",\s*'
r'"size", 8192\s*\)\s*\);',
r'"size", 8192\*MB\s*\)\s*\);',
command)
self.searchoutput(out,
r'"cpu" = list\(\s*'
Expand Down Expand Up @@ -297,7 +297,7 @@ def test_155_cat_ut3c1n4(self):
self.searchoutput(out,
r'"ram" = list\(\s*'
r'create\("hardware/ram/generic",\s*'
r'"size", 8192\s*\)\s*\);',
r'"size", 8192\*MB\s*\)\s*\);',
command)
self.searchoutput(out,
r'"cpu" = list\(\s*'
Expand Down Expand Up @@ -332,7 +332,7 @@ def test_165_cat_cciss_machine(self):
'create("hardware/harddisk/generic/cciss",',
command)
self.matchoutput(out,
'"capacity", 466*1024',
'"capacity", 466*GB',
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 @@ -177,7 +177,7 @@ def test_130_cat_utecl1_tmachines(self):
self.searchoutput(out,
r'"ram" = list\(\s*'
r'create\("hardware/ram/generic",\s*'
r'"size", 8192\s*\)\s*\);',
r'"size", 8192\*MB\s*\)\s*\);',
command)
self.searchoutput(out,
r'"cpu" = list\(\s*'
Expand All @@ -194,7 +194,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\*1024,\s*'
r'"capacity", 15\*GB,\s*'
r'"interface", "sata",\s*'
r'"mountpoint", "/vol/lnn30f1v1/test_share_%d",\s*'
r'"path", "evm%d/sda.vmdk",\s*'
Expand Down Expand Up @@ -467,7 +467,7 @@ def test_260_verifycatmachines(self):
self.searchoutput(out,
r'"ram" = list\(\s*'
r'create\("hardware/ram/generic",\s*'
r'"size", 8192\s*\)\s*\);',
r'"size", 8192\*MB\s*\)\s*\);',
command)
self.searchoutput(out,
r'"cpu" = list\(\s*'
Expand All @@ -485,7 +485,7 @@ def test_260_verifycatmachines(self):
r'"harddisks/\{sda\}" = nlist\(\s*'
r'"address", "0:0",\s*'
r'"boot", true,\s*'
r'"capacity", 15\*1024,\s*'
r'"capacity", 15\*GB,\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 @@ -57,7 +57,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\*1024,\s*'
r'"capacity", 34\*GB,\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 @@ -104,7 +104,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\*1024,\s*'
r'"capacity", 34\*GB,\s*'
r'"interface", "cciss",\s*'
r'"wwn", "600508b112233445566778899aabbccd"\s*\);',
command)
Expand All @@ -113,7 +113,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\*1024,\s*'
r'"capacity", 50\*GB,\s*'
r'"interface", "sata"\s*\);',
command)
self.matchclean(out, "c0d0", command)
Expand Down Expand Up @@ -167,7 +167,7 @@ def test_112_cat_evm10(self):
r'"harddisks/{sda}" = nlist\(\s*'
r'"address", "0:1",\s*'
r'"boot", true,\s*'
r'"capacity", 45\*1024,\s*'
r'"capacity", 45\*GB,\s*'
r'"filesystemname", "disk_update_test",\s*'
r'"interface", "scsi",\s*'
r'"iopslimit", 30,\s*'
Expand Down Expand Up @@ -211,7 +211,7 @@ def test_114_cat_evm10(self):
r'"harddisks/{sda}" = nlist\(\s*'
r'"address", "0:0",\s*'
r'"boot", true,\s*'
r'"capacity", 45\*1024,\s*'
r'"capacity", 45\*GB,\s*'
r'"interface", "scsi",\s*'
r'"iopslimit", 30,\s*'
r'"mountpoint", "/vol/lnn30f1v1/utecl5_share",\s*'
Expand Down Expand Up @@ -261,7 +261,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\*1024,\s*'
r'"capacity", 34\*GB,\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 @@ -58,7 +58,7 @@ def test_1005_cat_ut3c1n3(self):
self.searchoutput(out,
r'"ram" = list\(\s*'
r'create\("hardware/ram/generic",\s*'
r'"size", 8192\s*\)\s*\);',
r'"size", 8192\*MB\s*\)\s*\);',
command)
self.searchoutput(out,
r'"cpu" = list\(\s*'
Expand Down Expand Up @@ -126,7 +126,7 @@ def test_1015_cat_ut3c5n10(self):
self.searchoutput(out,
r'"ram" = list\(\s*'
r'create\("hardware/ram/generic",\s*'
r'"size", 8192\s*\)\s*\);',
r'"size", 8192\*MB\s*\)\s*\);',
command)
self.searchoutput(out,
r'"cpu" = list\(\s*'
Expand Down Expand Up @@ -180,7 +180,7 @@ def test_1025_cat_ut3c1n4(self):
self.searchoutput(out,
r'"ram" = list\(\s*'
r'create\("hardware/ram/generic",\s*'
r'"size", 8192\s*\)\s*\);',
r'"size", 8192\*MB\s*\)\s*\);',
command)
self.searchoutput(out,
r'"cpu" = list\(\s*'
Expand Down Expand Up @@ -476,7 +476,7 @@ def test_1132_cat_evm1(self):
self.searchoutput(out,
r'"ram" = list\(\s*'
r'create\("hardware/ram/generic",\s*'
r'"size", 12288\s*\)\s*\);',
r'"size", 12288\*MB\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\s*\)\s*\);',
r'"size", 8192\*MB\s*\)\s*\);',
command)
self.searchoutput(out,
r'"cpu" = list\(\s*'
r'create\("hardware/cpu/intel/l5520"\)\s*\);',
command)
self.matchoutput(out, '"capacity", 15*1024,', command)
self.matchoutput(out, '"capacity", 15*GB,', 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\s*\)\s*\);',
r'"size", 4096\*MB\s*\)\s*\);',
command)
self.searchoutput(out,
r'"cpu" = list\(\s*'
r'create\("hardware/cpu/intel/utcpu"\)\s*\);',
command)
self.matchoutput(out, '"capacity", 45*1024,', command)
self.matchoutput(out, '"capacity", 45*GB,', 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\s*\)\s*\);',
r'"size", 4096\*MB\s*\)\s*\);',
command)
self.searchoutput(out,
r'"cpu" = list\(\s*'
r'create\("hardware/cpu/intel/utcpu"\)\s*\);',
command)
self.matchoutput(out, '"capacity", 45*1024,', command)
self.matchoutput(out, '"capacity", 45*GB,', command)
self.matchoutput(out, '"interface", "scsi",', command)

def test_300_updatetype(self):
Expand Down
1 change: 0 additions & 1 deletion tests/unittest.conf
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ default_domain = ut-prod

[panc]
pan_compiler = %(basedir)s/panc-links/panc-%(version)s.jar
include_pan = True

[site]
# Site specific settings
Expand Down