From 78936c5ce84bd47400ba1c881a7b29aa3c01abe3 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Fri, 1 Feb 2019 03:47:18 -0500 Subject: [PATCH] examples: lang: Update examples to fix imports and port from yaml Some small fixes that are useful for demos! --- examples/lang/autoedges1.mcl | 30 ++++++++++++++++++++++++++++++ examples/lang/autogroup1.mcl | 17 +++++++++++++++++ examples/lang/datetime3.mcl | 3 ++- examples/lang/hysteresis1.mcl | 4 +++- 4 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 examples/lang/autoedges1.mcl create mode 100644 examples/lang/autogroup1.mcl diff --git a/examples/lang/autoedges1.mcl b/examples/lang/autoedges1.mcl new file mode 100644 index 00000000..17b00402 --- /dev/null +++ b/examples/lang/autoedges1.mcl @@ -0,0 +1,30 @@ +pkg "drbd-utils" { + state => "installed", + + Meta:autoedge => true, + Meta:noop => true, +} + +file "/etc/drbd.conf" { + content => "this is an mgmt test", + state => "exists", + + Meta:autoedge => true, + Meta:noop => true, +} + +file "/etc/drbd.d/" { + source => "/dev/null", + state => "exists", + + Meta:autoedge => true, + Meta:noop => true, +} + +# note that the autoedges between the files and the svc don't exist yet :( +svc "drbd" { + state => "stopped", + + Meta:autoedge => true, + Meta:noop => true, +} diff --git a/examples/lang/autogroup1.mcl b/examples/lang/autogroup1.mcl new file mode 100644 index 00000000..57939621 --- /dev/null +++ b/examples/lang/autogroup1.mcl @@ -0,0 +1,17 @@ +pkg "powertop" { + state => "installed", + + Meta:autogroup => true, +} + +pkg "sl" { + state => "installed", + + Meta:autogroup => true, +} + +pkg "cowsay" { + state => "installed", + + Meta:autogroup => true, +} diff --git a/examples/lang/datetime3.mcl b/examples/lang/datetime3.mcl index 5667ad52..ff5acfe5 100644 --- a/examples/lang/datetime3.mcl +++ b/examples/lang/datetime3.mcl @@ -1,5 +1,6 @@ import "datetime" import "sys" +import "example" $secplusone = datetime.now() + $ayear @@ -10,7 +11,7 @@ $tmplvalues = struct{year => $secplusone, load => $theload, vumeter => $vumeter, $theload = structlookup(sys.load(), "x1") -$vumeter = vumeter("====", 10, 0.9) +$vumeter = example.vumeter("====", 10, 0.9) file "/tmp/mgmt/datetime" { content => template("Now + 1 year is: {{ .year }} seconds, aka: {{ datetime_print .year }}\n\nload average: {{ .load }}\n\nvu: {{ .vumeter }}\n", $tmplvalues), diff --git a/examples/lang/hysteresis1.mcl b/examples/lang/hysteresis1.mcl index 54792f67..90e40da3 100644 --- a/examples/lang/hysteresis1.mcl +++ b/examples/lang/hysteresis1.mcl @@ -1,10 +1,12 @@ +import "sys" + file "/tmp/mgmt/systemload" { content => template("load average: {{ .load }} threshold: {{ .threshold }}\n", $tmplvalues), } $tmplvalues = struct{load => $theload, threshold => $threshold,} -$theload = structlookup(load(), "x1") +$theload = structlookup(sys.load(), "x1") $threshold = 1.5 # change me if you like # simple hysteresis implementation