lang: Initial implementation of the mgmt language
This is an initial implementation of the mgmt language. It is a declarative (immutable) functional, reactive, domain specific programming language. It is intended to be a language that is: * safe * powerful * easy to reason about With these properties, we hope this language, and the mgmt engine will allow you to model the real-time systems that you'd like to automate. This also includes a number of other associated changes. Sorry for the large size of this patch.
This commit is contained in:
31
examples/lang/hysteresis1.mcl
Normal file
31
examples/lang/hysteresis1.mcl
Normal file
@@ -0,0 +1,31 @@
|
||||
file "/tmp/mgmt/systemload" {
|
||||
content => template("load average: {{ .load }} threshold: {{ .threshold }}\n", $tmplvalues),
|
||||
}
|
||||
|
||||
$tmplvalues = struct{load => $theload, threshold => $threshold,}
|
||||
|
||||
$theload = structlookup(load(), "x1")
|
||||
$threshold = 1.5 # change me if you like
|
||||
|
||||
# simple hysteresis implementation
|
||||
$h1 = $theload > $threshold
|
||||
$h2 = $theload{1} > $threshold
|
||||
$h3 = $theload{2} > $threshold
|
||||
$unload = $h1 || $h2 || $h3
|
||||
|
||||
virt "mgmt1" {
|
||||
uri => "qemu:///session",
|
||||
cpus => 1,
|
||||
memory => 524288,
|
||||
state => "running",
|
||||
transient => true,
|
||||
}
|
||||
|
||||
# this vm shuts down under load...
|
||||
virt "mgmt2" {
|
||||
uri => "qemu:///session",
|
||||
cpus => 1,
|
||||
memory => 524288,
|
||||
state => if $unload { "shutoff" } else { "running" },
|
||||
transient => true,
|
||||
}
|
||||
Reference in New Issue
Block a user