all: Switch the --lang syntax to use argv instead
It was a bit awkward using `mgmt run lang --lang <input>` so instead, we now drop the --lang, and read the positional argv for the input. This also does the same for the --yaml frontend.
This commit is contained in:
@@ -298,10 +298,6 @@ recommended that you use this, since it's preferable to write code in the
|
|||||||
The main interface to the `mgmt` tool is the command line. For the most recent
|
The main interface to the `mgmt` tool is the command line. For the most recent
|
||||||
documentation, please run `mgmt --help`.
|
documentation, please run `mgmt --help`.
|
||||||
|
|
||||||
#### `--yaml <graph.yaml>`
|
|
||||||
|
|
||||||
Point to a graph file to run.
|
|
||||||
|
|
||||||
#### `--converged-timeout <seconds>`
|
#### `--converged-timeout <seconds>`
|
||||||
|
|
||||||
Exit if the machine has converged for approximately this many seconds.
|
Exit if the machine has converged for approximately this many seconds.
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ requires a number of seconds as an argument.
|
|||||||
#### Example:
|
#### Example:
|
||||||
|
|
||||||
```
|
```
|
||||||
./mgmt run lang --lang examples/lang/hello0.mcl --converged-timeout=5
|
./mgmt run lang examples/lang/hello0.mcl --converged-timeout=5
|
||||||
```
|
```
|
||||||
|
|
||||||
### On startup `mgmt` hangs after: `etcd: server: starting...`.
|
### On startup `mgmt` hangs after: `etcd: server: starting...`.
|
||||||
|
|||||||
@@ -173,7 +173,7 @@ useful when you are in the process of replacing Puppet with mgmt. You
|
|||||||
can translate your custom modules into mgmt's language one by one,
|
can translate your custom modules into mgmt's language one by one,
|
||||||
and let mgmt run the current mix.
|
and let mgmt run the current mix.
|
||||||
|
|
||||||
Instead of the usual `--puppet`, `--puppet-conf`, and `--lang` for mcl,
|
Instead of the usual `--puppet-conf` flag and argv for `puppet` and `mcl` input,
|
||||||
you need to use alternative flags to make this work:
|
you need to use alternative flags to make this work:
|
||||||
|
|
||||||
* `--lp-lang` to specify the mcl input
|
* `--lp-lang` to specify the mcl input
|
||||||
|
|||||||
@@ -57,8 +57,8 @@ export PATH=$PATH:$GOPATH/bin
|
|||||||
|
|
||||||
### Running mgmt
|
### Running mgmt
|
||||||
|
|
||||||
* Run `time ./mgmt run --tmp-prefix lang --lang examples/lang/hello0.mcl` to try
|
* Run `time ./mgmt run --tmp-prefix lang examples/lang/hello0.mcl` to try out a
|
||||||
out a very simple example!
|
very simple example!
|
||||||
* Look in that example file that you ran to see if you can figure out what it
|
* Look in that example file that you ran to see if you can figure out what it
|
||||||
did!
|
did!
|
||||||
* Have fun hacking on our future technology and get involved to shape the
|
* Have fun hacking on our future technology and get involved to shape the
|
||||||
@@ -181,5 +181,5 @@ Other examples:
|
|||||||
|
|
||||||
```
|
```
|
||||||
docker/scripts/exec-development make build
|
docker/scripts/exec-development make build
|
||||||
docker/scripts/exec-development ./mgmt run --tmp-prefix lang --lang examples/lang/load0.mcl
|
docker/scripts/exec-development ./mgmt run --tmp-prefix lang examples/lang/load0.mcl
|
||||||
```
|
```
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# read and print environment variable
|
# read and print environment variable
|
||||||
# env TEST=123 EMPTY= ./mgmt run --tmp-prefix --converged-timeout=5 lang --lang=examples/lang/env0.mcl
|
# env TEST=123 EMPTY= ./mgmt run --tmp-prefix --converged-timeout=5 lang examples/lang/env0.mcl
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
import "sys"
|
import "sys"
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# time ./mgmt run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp empty
|
# time ./mgmt run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp empty
|
||||||
# time ./mgmt run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp empty
|
# time ./mgmt run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp empty
|
||||||
# time ./mgmt run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp empty
|
# time ./mgmt run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp empty
|
||||||
# time ./mgmt deploy --no-git --seeds http://127.0.0.1:2379 lang --lang examples/lang/exchange0.mcl
|
# time ./mgmt deploy --no-git --seeds http://127.0.0.1:2379 lang examples/lang/exchange0.mcl
|
||||||
|
|
||||||
import "sys"
|
import "sys"
|
||||||
import "world"
|
import "world"
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import "fmt"
|
|||||||
import "regexp"
|
import "regexp"
|
||||||
|
|
||||||
# test with:
|
# test with:
|
||||||
# ./mgmt run --hostname foo.example.com --tmp-prefix lang --lang examples/lang/regexp0.mcl
|
# ./mgmt run --hostname foo.example.com --tmp-prefix lang examples/lang/regexp0.mcl
|
||||||
# ./mgmt run --hostname db1.example.com --tmp-prefix lang --lang examples/lang/regexp0.mcl
|
# ./mgmt run --hostname db1.example.com --tmp-prefix lang examples/lang/regexp0.mcl
|
||||||
print "regexp" {
|
print "regexp" {
|
||||||
# TODO: add a heredoc string to avoid needing to escape the \ chars
|
# TODO: add a heredoc string to avoid needing to escape the \ chars
|
||||||
msg => fmt.printf("match: %t", regexp.match("^db\\d+\\.example\\.com$", $hostname)),
|
msg => fmt.printf("match: %t", regexp.match("^db\\d+\\.example\\.com$", $hostname)),
|
||||||
|
|||||||
@@ -373,7 +373,7 @@ func (obj *Instance) DeployLang(code string) error {
|
|||||||
"deploy", // mode
|
"deploy", // mode
|
||||||
"--no-git",
|
"--no-git",
|
||||||
"--seeds", obj.clientURL,
|
"--seeds", obj.clientURL,
|
||||||
"lang", "--lang", filename,
|
"lang", filename,
|
||||||
}
|
}
|
||||||
obj.Logf("run: %s %s", cmdName, strings.Join(cmdArgs, " "))
|
obj.Logf("run: %s %s", cmdName, strings.Join(cmdArgs, " "))
|
||||||
cmd := exec.Command(cmdName, cmdArgs...)
|
cmd := exec.Command(cmdName, cmdArgs...)
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
// test with:
|
// test with:
|
||||||
// time ./mgmt run --hostname h1 --tmp-prefix --no-pgp lang --lang examples/lang/schedule0.mcl
|
// time ./mgmt run --hostname h1 --tmp-prefix --no-pgp lang examples/lang/schedule0.mcl
|
||||||
// time ./mgmt run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp lang --lang examples/lang/schedule0.mcl
|
// time ./mgmt run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp lang examples/lang/schedule0.mcl
|
||||||
// time ./mgmt run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp lang --lang examples/lang/schedule0.mcl
|
// time ./mgmt run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp lang examples/lang/schedule0.mcl
|
||||||
// kill h2 (should see h1 and h3 pick [h1, h3] instead)
|
// kill h2 (should see h1 and h3 pick [h1, h3] instead)
|
||||||
// restart h2 (should see [h1, h3] as before)
|
// restart h2 (should see [h1, h3] as before)
|
||||||
// kill h3 (should see h1 and h2 pick [h1, h2] instead)
|
// kill h3 (should see h1 and h2 pick [h1, h2] instead)
|
||||||
|
|||||||
27
lang/gapi.go
27
lang/gapi.go
@@ -110,11 +110,6 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag {
|
|||||||
fallthrough
|
fallthrough
|
||||||
case gapi.CommandDeploy:
|
case gapi.CommandDeploy:
|
||||||
flags := []cli.Flag{
|
flags := []cli.Flag{
|
||||||
cli.StringFlag{
|
|
||||||
Name: fmt.Sprintf("%s, %s", Name, Name[0:1]),
|
|
||||||
Value: "",
|
|
||||||
Usage: "code to deploy",
|
|
||||||
},
|
|
||||||
// TODO: removed (temporarily?)
|
// TODO: removed (temporarily?)
|
||||||
//cli.BoolFlag{
|
//cli.BoolFlag{
|
||||||
// Name: "stdin",
|
// Name: "stdin",
|
||||||
@@ -157,9 +152,13 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {
|
|||||||
cliInfo.Logf(Name+": "+format, v...)
|
cliInfo.Logf(Name+": "+format, v...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.IsSet(Name) {
|
if l := c.NArg(); l != 1 {
|
||||||
return nil, nil // we weren't activated!
|
if l > 1 {
|
||||||
|
return nil, fmt.Errorf("input program must be a single arg")
|
||||||
}
|
}
|
||||||
|
return nil, fmt.Errorf("must specify input program")
|
||||||
|
}
|
||||||
|
input := c.Args().Get(0)
|
||||||
|
|
||||||
// empty by default (don't set for deploy, only download)
|
// empty by default (don't set for deploy, only download)
|
||||||
modules := c.String(flagModulePath)
|
modules := c.String(flagModulePath)
|
||||||
@@ -180,7 +179,7 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {
|
|||||||
|
|
||||||
// the fs input here is the local fs we're reading to get the files from
|
// the fs input here is the local fs we're reading to get the files from
|
||||||
// this is different from the fs variable which is our output dest!!!
|
// this is different from the fs variable which is our output dest!!!
|
||||||
output, err := parseInput(c.String(Name), localFs)
|
output, err := parseInput(input, localFs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errwrap.Wrapf(err, "could not activate an input parser")
|
return nil, errwrap.Wrapf(err, "could not activate an input parser")
|
||||||
}
|
}
|
||||||
@@ -356,7 +355,7 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {
|
|||||||
|
|
||||||
// display the deploy fs tree
|
// display the deploy fs tree
|
||||||
if debug || true { // TODO: should this only be shown on debug?
|
if debug || true { // TODO: should this only be shown on debug?
|
||||||
logf("input: %s", c.String(Name))
|
logf("input: %s", input)
|
||||||
tree, err := util.FsTree(fs, "/")
|
tree, err := util.FsTree(fs, "/")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -587,6 +586,14 @@ func (obj *GAPI) Get(getInfo *gapi.GetInfo) error {
|
|||||||
debug := getInfo.Debug
|
debug := getInfo.Debug
|
||||||
logf := getInfo.Logf
|
logf := getInfo.Logf
|
||||||
|
|
||||||
|
if l := c.NArg(); l != 1 {
|
||||||
|
if l > 1 {
|
||||||
|
return fmt.Errorf("input program must be a single arg")
|
||||||
|
}
|
||||||
|
return fmt.Errorf("must specify input program")
|
||||||
|
}
|
||||||
|
input := c.Args().Get(0)
|
||||||
|
|
||||||
// empty by default (don't set for deploy, only download)
|
// empty by default (don't set for deploy, only download)
|
||||||
modules := c.String(flagModulePath)
|
modules := c.String(flagModulePath)
|
||||||
if modules != "" && (!strings.HasPrefix(modules, "/") || !strings.HasSuffix(modules, "/")) {
|
if modules != "" && (!strings.HasPrefix(modules, "/") || !strings.HasSuffix(modules, "/")) {
|
||||||
@@ -603,7 +610,7 @@ func (obj *GAPI) Get(getInfo *gapi.GetInfo) error {
|
|||||||
|
|
||||||
// the fs input here is the local fs we're reading to get the files from
|
// the fs input here is the local fs we're reading to get the files from
|
||||||
// this is different from the fs variable which is our output dest!!!
|
// this is different from the fs variable which is our output dest!!!
|
||||||
output, err := parseInput(c.String(Name), localFs)
|
output, err := parseInput(input, localFs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errwrap.Wrapf(err, "could not activate an input parser")
|
return errwrap.Wrapf(err, "could not activate an input parser")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -73,6 +73,19 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag {
|
|||||||
langFlags := (&lang.GAPI{}).CliFlags(command)
|
langFlags := (&lang.GAPI{}).CliFlags(command)
|
||||||
puppetFlags := (&puppet.GAPI{}).CliFlags(command)
|
puppetFlags := (&puppet.GAPI{}).CliFlags(command)
|
||||||
|
|
||||||
|
l := cli.StringFlag{
|
||||||
|
Name: fmt.Sprintf("%s, %s", lang.Name, lang.Name[0:1]),
|
||||||
|
Value: "",
|
||||||
|
Usage: "code to deploy",
|
||||||
|
}
|
||||||
|
langFlags = append(langFlags, l)
|
||||||
|
p := cli.StringFlag{
|
||||||
|
Name: fmt.Sprintf("%s, %s", puppet.Name, puppet.Name[0:1]),
|
||||||
|
Value: "",
|
||||||
|
Usage: "load graph from puppet, optionally takes a manifest or path to manifest file",
|
||||||
|
}
|
||||||
|
puppetFlags = append(puppetFlags, p)
|
||||||
|
|
||||||
var childFlags []cli.Flag
|
var childFlags []cli.Flag
|
||||||
for _, flag := range append(langFlags, puppetFlags...) {
|
for _, flag := range append(langFlags, puppetFlags...) {
|
||||||
childFlags = append(childFlags, &cli.StringFlag{
|
childFlags = append(childFlags, &cli.StringFlag{
|
||||||
@@ -121,12 +134,14 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {
|
|||||||
|
|
||||||
var langDeploy *gapi.Deploy
|
var langDeploy *gapi.Deploy
|
||||||
var puppetDeploy *gapi.Deploy
|
var puppetDeploy *gapi.Deploy
|
||||||
|
// XXX: put the c.String(FlagPrefix+lang.Name) into the argv here!
|
||||||
langCliInfo := &gapi.CliInfo{
|
langCliInfo := &gapi.CliInfo{
|
||||||
CliContext: cli.NewContext(c.App, flagSet, c.Parent()),
|
CliContext: cli.NewContext(c.App, flagSet, c.Parent()),
|
||||||
Fs: fs,
|
Fs: fs,
|
||||||
Debug: debug,
|
Debug: debug,
|
||||||
Logf: logf, // TODO: wrap logf?
|
Logf: logf, // TODO: wrap logf?
|
||||||
}
|
}
|
||||||
|
// XXX: put the c.String(FlagPrefix+puppet.Name) into the argv here!
|
||||||
puppetCliInfo := &gapi.CliInfo{
|
puppetCliInfo := &gapi.CliInfo{
|
||||||
CliContext: cli.NewContext(c.App, flagSet, c.Parent()),
|
CliContext: cli.NewContext(c.App, flagSet, c.Parent()),
|
||||||
Fs: fs,
|
Fs: fs,
|
||||||
|
|||||||
@@ -70,11 +70,6 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag {
|
|||||||
fallthrough
|
fallthrough
|
||||||
case gapi.CommandDeploy:
|
case gapi.CommandDeploy:
|
||||||
return []cli.Flag{
|
return []cli.Flag{
|
||||||
cli.StringFlag{
|
|
||||||
Name: "puppet, p",
|
|
||||||
Value: "",
|
|
||||||
Usage: "load graph from puppet, optionally takes a manifest or path to manifest file",
|
|
||||||
},
|
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "puppet-conf",
|
Name: "puppet-conf",
|
||||||
Value: "",
|
Value: "",
|
||||||
@@ -99,10 +94,13 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {
|
|||||||
// cliInfo.Logf(Name + ": "+format, v...)
|
// cliInfo.Logf(Name + ": "+format, v...)
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if !c.IsSet(Name) {
|
if l := c.NArg(); l != 1 {
|
||||||
return nil, nil // we weren't activated!
|
if l > 1 {
|
||||||
|
return nil, fmt.Errorf("input program must be a single arg")
|
||||||
}
|
}
|
||||||
s := c.String(Name)
|
return nil, fmt.Errorf("must specify input program")
|
||||||
|
}
|
||||||
|
s := c.Args().Get(0)
|
||||||
if s == "" {
|
if s == "" {
|
||||||
return nil, fmt.Errorf("%s input is empty", Name)
|
return nil, fmt.Errorf("%s input is empty", Name)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,7 +32,7 @@
|
|||||||
- iptables -F
|
- iptables -F
|
||||||
- cd /vagrant/mgmt/ && make path
|
- cd /vagrant/mgmt/ && make path
|
||||||
- cd /vagrant/mgmt/ && make deps && make build && cp mgmt ~/bin/
|
- cd /vagrant/mgmt/ && make deps && make build && cp mgmt ~/bin/
|
||||||
- cd && mgmt run --converged-timeout=5 yaml --yaml /vagrant/mgmt/examples/pkg1.yaml
|
- cd && mgmt run --converged-timeout=5 yaml /vagrant/mgmt/examples/pkg1.yaml
|
||||||
:namespace: omv
|
:namespace: omv
|
||||||
:count: 0
|
:count: 0
|
||||||
:username: ''
|
:username: ''
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
- iptables -F
|
- iptables -F
|
||||||
- cd /vagrant/mgmt/ && make path
|
- cd /vagrant/mgmt/ && make path
|
||||||
- cd /vagrant/mgmt/ && make deps && make build && cp mgmt ~/bin/
|
- cd /vagrant/mgmt/ && make deps && make build && cp mgmt ~/bin/
|
||||||
- cd && mgmt run --converged-timeout=5 yaml --yaml /vagrant/mgmt/examples/pkg1.yaml
|
- cd && mgmt run --converged-timeout=5 yaml /vagrant/mgmt/examples/pkg1.yaml
|
||||||
:namespace: omv
|
:namespace: omv
|
||||||
:count: 0
|
:count: 0
|
||||||
:username: ''
|
:username: ''
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
mkdir -p "${MGMT_TMPDIR}"
|
mkdir -p "${MGMT_TMPDIR}"
|
||||||
echo > "${MGMT_TMPDIR}"sshd_config
|
echo > "${MGMT_TMPDIR}"sshd_config
|
||||||
|
|
||||||
$TIMEOUT "$MGMT" run --tmp-prefix yaml --yaml=augeas-1.yaml &
|
$TIMEOUT "$MGMT" run --tmp-prefix yaml augeas-1.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
|
|
||||||
# kill server on error
|
# kill server on error
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ if [[ ! "$tmpdir" =~ "/tmp" ]]; then
|
|||||||
exit 99
|
exit 99
|
||||||
fi
|
fi
|
||||||
|
|
||||||
env TMPDIR="${tmpdir}" TEST=123 EMPTY="" $TIMEOUT "$MGMT" run --tmp-prefix --converged-timeout=5 lang --lang env0.mcl
|
env TMPDIR="${tmpdir}" TEST=123 EMPTY="" $TIMEOUT "$MGMT" run --tmp-prefix --converged-timeout=5 lang env0.mcl
|
||||||
e=$?
|
e=$?
|
||||||
|
|
||||||
egrep "$regex" "$tmpdir/environ" || fail_test "Could not match '$(cat "$tmpdir/environ")' in '$tmpdir/environ' to '$regex'."
|
egrep "$regex" "$tmpdir/environ" || fail_test "Could not match '$(cat "$tmpdir/environ")' in '$tmpdir/environ' to '$regex'."
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ sleep 10s
|
|||||||
$TIMEOUT "$MGMT" run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp empty &
|
$TIMEOUT "$MGMT" run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp empty &
|
||||||
pid4=$!
|
pid4=$!
|
||||||
sleep 10s
|
sleep 10s
|
||||||
$TIMEOUT "$MGMT" deploy --no-git --seeds http://127.0.0.1:2379 lang --lang exchange0.mcl
|
$TIMEOUT "$MGMT" deploy --no-git --seeds http://127.0.0.1:2379 lang exchange0.mcl
|
||||||
|
|
||||||
# kill servers on error/exit
|
# kill servers on error/exit
|
||||||
#trap 'pkill -9 mgmt' EXIT
|
#trap 'pkill -9 mgmt' EXIT
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
# time ./mgmt run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp empty
|
# time ./mgmt run --hostname h2 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2381 --server-urls http://127.0.0.1:2382 --tmp-prefix --no-pgp empty
|
||||||
# time ./mgmt run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp empty
|
# time ./mgmt run --hostname h3 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2383 --server-urls http://127.0.0.1:2384 --tmp-prefix --no-pgp empty
|
||||||
# time ./mgmt run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp empty
|
# time ./mgmt run --hostname h4 --seeds http://127.0.0.1:2379 --client-urls http://127.0.0.1:2385 --server-urls http://127.0.0.1:2386 --tmp-prefix --no-pgp empty
|
||||||
# time ./mgmt deploy --no-git --seeds http://127.0.0.1:2379 lang --lang examples/lang/exchange0.mcl
|
# time ./mgmt deploy --no-git --seeds http://127.0.0.1:2379 lang examples/lang/exchange0.mcl
|
||||||
|
|
||||||
import "sys"
|
import "sys"
|
||||||
import "world"
|
import "world"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
# should take a few seconds plus converged timeout, and test we don't hang!
|
# should take a few seconds plus converged timeout, and test we don't hang!
|
||||||
# TODO: should we return a different exit code if the resources fail?
|
# TODO: should we return a different exit code if the resources fail?
|
||||||
# TODO: should we be converged if one of the resources has permanently failed?
|
# TODO: should we be converged if one of the resources has permanently failed?
|
||||||
$TIMEOUT "$MGMT" run --converged-timeout=15 --no-watch --no-pgp --tmp-prefix yaml --yaml exec-fail.yaml &
|
$TIMEOUT "$MGMT" run --converged-timeout=15 --no-watch --no-pgp --tmp-prefix yaml exec-fail.yaml &
|
||||||
# there's no ^C sent... it should shutdown on its own
|
# there's no ^C sent... it should shutdown on its own
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ function run_usergroup_test() {
|
|||||||
setup
|
setup
|
||||||
|
|
||||||
# run till completion
|
# run till completion
|
||||||
sudo -A $TIMEOUT "$MGMT" run --converged-timeout=15 --no-watch --tmp-prefix yaml --yaml ./exec-usergroup/${graph} &
|
sudo -A $TIMEOUT "$MGMT" run --converged-timeout=15 --no-watch --tmp-prefix yaml ./exec-usergroup/${graph} &
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
e=$?
|
e=$?
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
set -x
|
set -x
|
||||||
|
|
||||||
# run till completion
|
# run till completion
|
||||||
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml file-mode.yaml &
|
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml file-mode.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
e=$?
|
e=$?
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ exit 0
|
|||||||
mkdir -p /tmp/mgmt/a/b/c/
|
mkdir -p /tmp/mgmt/a/b/c/
|
||||||
|
|
||||||
# run empty graph, with prometheus support
|
# run empty graph, with prometheus support
|
||||||
$TIMEOUT "$MGMT" run --tmp-prefix yaml --yaml=examples/deep-dirs.yaml &
|
$TIMEOUT "$MGMT" run --tmp-prefix yaml examples/deep-dirs.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 10s # let it converge
|
sleep 10s # let it converge
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ mkdir -p /tmp/mgmt/
|
|||||||
rm /tmp/mgmt/f1 &>/dev/null || true
|
rm /tmp/mgmt/f1 &>/dev/null || true
|
||||||
|
|
||||||
# run empty graph, with prometheus support
|
# run empty graph, with prometheus support
|
||||||
$TIMEOUT "$MGMT" run --tmp-prefix yaml --yaml=file-move.yaml 2>&1 | tee /tmp/mgmt/file-move.log &
|
$TIMEOUT "$MGMT" run --tmp-prefix yaml file-move.yaml 2>&1 | tee /tmp/mgmt/file-move.log &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 5s # let it converge
|
sleep 5s # let it converge
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ if ! timeout 1s sudo -A true; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# run till completion
|
# run till completion
|
||||||
$TIMEOUT sudo -A "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml file-owner.yaml &
|
$TIMEOUT sudo -A "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml file-owner.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
e=$?
|
e=$?
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ if ! timeout 1s sudo -A true; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# run till completion
|
# run till completion
|
||||||
$TIMEOUT sudo -A "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix lang --lang file-source.mcl &
|
$TIMEOUT sudo -A "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix lang file-source.mcl &
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
e=$?
|
e=$?
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
# should take 15 seconds for longest resources plus startup time to shutdown
|
# should take 15 seconds for longest resources plus startup time to shutdown
|
||||||
# we don't want the ^C to allow the rest of the graph to continue executing!
|
# we don't want the ^C to allow the rest of the graph to continue executing!
|
||||||
# this is a test of mgmt exiting quickly via a fast pause after it sees a ^C
|
# this is a test of mgmt exiting quickly via a fast pause after it sees a ^C
|
||||||
$TIMEOUT "$MGMT" run --no-watch --no-pgp --tmp-prefix lang --lang graph-exit1.mcl &
|
$TIMEOUT "$MGMT" run --no-watch --no-pgp --tmp-prefix lang graph-exit1.mcl &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 5s # let the initial resources start to run...
|
sleep 5s # let the initial resources start to run...
|
||||||
killall -SIGINT mgmt # send ^C to exit mgmt
|
killall -SIGINT mgmt # send ^C to exit mgmt
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
# should take 15 seconds for longest resources plus startup time to shutdown
|
# should take 15 seconds for longest resources plus startup time to shutdown
|
||||||
# we don't want the ^C to allow the rest of the graph to continue executing!
|
# we don't want the ^C to allow the rest of the graph to continue executing!
|
||||||
$TIMEOUT "$MGMT" run --no-watch --no-pgp --tmp-prefix yaml --yaml graph-exit2.yaml &
|
$TIMEOUT "$MGMT" run --no-watch --no-pgp --tmp-prefix yaml graph-exit2.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 10s # let the initial resources start to run...
|
sleep 10s # let the initial resources start to run...
|
||||||
killall -SIGINT mgmt # send ^C to exit mgmt
|
killall -SIGINT mgmt # send ^C to exit mgmt
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
. "$(dirname "$0")/../util.sh"
|
. "$(dirname "$0")/../util.sh"
|
||||||
|
|
||||||
# should take more than 25s plus overhead
|
# should take more than 25s plus overhead
|
||||||
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix --no-pgp yaml --yaml graph-fanin-1.yaml &
|
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix --no-pgp yaml graph-fanin-1.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ file "${tmpdir}/loadavg" {
|
|||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
$TIMEOUT "$MGMT" run --tmp-prefix --converged-timeout=15 lang --lang "$tmpdir/load0.mcl" &
|
$TIMEOUT "$MGMT" run --tmp-prefix --converged-timeout=15 lang "$tmpdir/load0.mcl" &
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
e=$?
|
e=$?
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ sudo mkdir -p /etc/systemd/network
|
|||||||
sudo ip link add $IFACE type dummy || true
|
sudo ip link add $IFACE type dummy || true
|
||||||
|
|
||||||
# run mgmt net res with $IFACE and $ADDR set as above
|
# run mgmt net res with $IFACE and $ADDR set as above
|
||||||
sudo -A $TIMEOUT "$MGMT" run --converged-timeout=5 --tmp-prefix lang --lang ./net0.mcl &
|
sudo -A $TIMEOUT "$MGMT" run --converged-timeout=5 --tmp-prefix lang ./net0.mcl &
|
||||||
pid1=$!
|
pid1=$!
|
||||||
|
|
||||||
# give the engine time to start up
|
# give the engine time to start up
|
||||||
@@ -93,7 +93,7 @@ wait $pid1
|
|||||||
e1=$?
|
e1=$?
|
||||||
|
|
||||||
# run mgmt net res with $IFACE state => "down"
|
# run mgmt net res with $IFACE state => "down"
|
||||||
sudo -A $TIMEOUT "$MGMT" run --converged-timeout=5 --tmp-prefix lang --lang ./net1.mcl &
|
sudo -A $TIMEOUT "$MGMT" run --converged-timeout=5 --tmp-prefix lang ./net1.mcl &
|
||||||
|
|
||||||
# give the engine time to start up
|
# give the engine time to start up
|
||||||
sleep 5
|
sleep 5
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
exit 0 # XXX: temporarily disabled until prometheus is added back post refactor
|
exit 0 # XXX: temporarily disabled until prometheus is added back post refactor
|
||||||
|
|
||||||
# run a graph, with prometheus support
|
# run a graph, with prometheus support
|
||||||
$TIMEOUT "$MGMT" run --tmp-prefix --no-pgp --prometheus yaml --yaml prometheus-3.yaml &
|
$TIMEOUT "$MGMT" run --tmp-prefix --no-pgp --prometheus yaml prometheus-3.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 10s # let it converge
|
sleep 10s # let it converge
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
exit 0 # XXX: temporarily disabled until prometheus is added back post refactor
|
exit 0 # XXX: temporarily disabled until prometheus is added back post refactor
|
||||||
|
|
||||||
# run a graph, with prometheus support
|
# run a graph, with prometheus support
|
||||||
$TIMEOUT "$MGMT" run --tmp-prefix --no-pgp --prometheus yaml --yaml prometheus-4.yaml &
|
$TIMEOUT "$MGMT" run --tmp-prefix --no-pgp --prometheus yaml prometheus-4.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 15s # let it converge
|
sleep 15s # let it converge
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
# should take at least 55s, but fail if we block this
|
# should take at least 55s, but fail if we block this
|
||||||
# TODO: it would be nice to make sure this test doesn't exit too early!
|
# TODO: it would be nice to make sure this test doesn't exit too early!
|
||||||
$TIMEOUT "$MGMT" run --sema 2 --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml --yaml sema-1.yaml &
|
$TIMEOUT "$MGMT" run --sema 2 --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml sema-1.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
# should take at least 55s, but fail if we block this
|
# should take at least 55s, but fail if we block this
|
||||||
# TODO: it would be nice to make sure this test doesn't exit too early!
|
# TODO: it would be nice to make sure this test doesn't exit too early!
|
||||||
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix lang --lang sema-2.mcl &
|
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix lang sema-2.mcl &
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
. "$(dirname "$0")/../util.sh"
|
. "$(dirname "$0")/../util.sh"
|
||||||
|
|
||||||
# run till completion
|
# run till completion
|
||||||
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t2.yaml &
|
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml t2.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
e=$?
|
e=$?
|
||||||
|
|||||||
@@ -12,11 +12,11 @@ fi
|
|||||||
mkdir -p "${MGMT_TMPDIR}"mgmt{A..C}
|
mkdir -p "${MGMT_TMPDIR}"mgmt{A..C}
|
||||||
|
|
||||||
# run till completion
|
# run till completion
|
||||||
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t3-a.yaml &
|
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml t3-a.yaml &
|
||||||
pid1=$!
|
pid1=$!
|
||||||
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t3-b.yaml &
|
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml t3-b.yaml &
|
||||||
pid2=$!
|
pid2=$!
|
||||||
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml --yaml t3-c.yaml &
|
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --tmp-prefix yaml t3-c.yaml &
|
||||||
pid3=$!
|
pid3=$!
|
||||||
|
|
||||||
wait $pid1 # get exit status
|
wait $pid1 # get exit status
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
. "$(dirname "$0")/../util.sh"
|
. "$(dirname "$0")/../util.sh"
|
||||||
|
|
||||||
# should take slightly more than 35s, but fail if we take much longer)
|
# should take slightly more than 35s, but fail if we take much longer)
|
||||||
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml --yaml t5.yaml &
|
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml t5.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
. "$(dirname "$0")/../util.sh"
|
. "$(dirname "$0")/../util.sh"
|
||||||
|
|
||||||
# should take slightly more than 35s, but fail if we take much longer)
|
# should take slightly more than 35s, but fail if we take much longer)
|
||||||
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml --yaml t5b.yaml &
|
$TIMEOUT "$MGMT" run --converged-timeout=5 --no-watch --no-pgp --tmp-prefix yaml t5b.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
wait $pid # get exit status
|
wait $pid # get exit status
|
||||||
exit $?
|
exit $?
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
. "$(dirname "$0")/../util.sh"
|
. "$(dirname "$0")/../util.sh"
|
||||||
|
|
||||||
# run till completion
|
# run till completion
|
||||||
$TIMEOUT "$MGMT" run --no-watch --tmp-prefix yaml --yaml t6.yaml &
|
$TIMEOUT "$MGMT" run --no-watch --tmp-prefix yaml t6.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 10s # let it converge
|
sleep 10s # let it converge
|
||||||
test -e /tmp/mgmt/f1
|
test -e /tmp/mgmt/f1
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ fi
|
|||||||
|
|
||||||
# set the config file
|
# set the config file
|
||||||
cp -a yaml-change1a.yaml /tmp/mgmt/yaml-change.yaml
|
cp -a yaml-change1a.yaml /tmp/mgmt/yaml-change.yaml
|
||||||
$TIMEOUT "$MGMT" run --tmp-prefix yaml --yaml /tmp/mgmt/yaml-change.yaml &
|
$TIMEOUT "$MGMT" run --tmp-prefix yaml /tmp/mgmt/yaml-change.yaml &
|
||||||
pid=$!
|
pid=$!
|
||||||
sleep 5s # let it converge
|
sleep 5s # let it converge
|
||||||
grep -q 'hello world' /tmp/mgmt/change1 # check contents are correct
|
grep -q 'hello world' /tmp/mgmt/change1 # check contents are correct
|
||||||
|
|||||||
@@ -9,6 +9,6 @@ To get started, try:
|
|||||||
|
|
||||||
$ cdmgmt
|
$ cdmgmt
|
||||||
$ make clean build
|
$ make clean build
|
||||||
$ ./mgmt run --tmp-prefix lang --lang examples/lang/hello0.mcl`
|
$ ./mgmt run --tmp-prefix lang examples/lang/hello0.mcl`
|
||||||
|
|
||||||
Enjoy!
|
Enjoy!
|
||||||
|
|||||||
@@ -56,13 +56,7 @@ func (obj *GAPI) CliFlags(command string) []cli.Flag {
|
|||||||
case gapi.CommandRun:
|
case gapi.CommandRun:
|
||||||
fallthrough
|
fallthrough
|
||||||
case gapi.CommandDeploy:
|
case gapi.CommandDeploy:
|
||||||
return []cli.Flag{
|
return []cli.Flag{}
|
||||||
cli.StringFlag{
|
|
||||||
Name: Name,
|
|
||||||
Value: "",
|
|
||||||
Usage: "yaml graph definition to run",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
//case gapi.CommandGet:
|
//case gapi.CommandGet:
|
||||||
default:
|
default:
|
||||||
return []cli.Flag{}
|
return []cli.Flag{}
|
||||||
@@ -80,11 +74,14 @@ func (obj *GAPI) Cli(cliInfo *gapi.CliInfo) (*gapi.Deploy, error) {
|
|||||||
//logf := func(format string, v ...interface{}) {
|
//logf := func(format string, v ...interface{}) {
|
||||||
// cliInfo.Logf(Name + ": "+format, v...)
|
// cliInfo.Logf(Name + ": "+format, v...)
|
||||||
//}
|
//}
|
||||||
if !c.IsSet(Name) {
|
|
||||||
return nil, nil // we weren't activated!
|
|
||||||
}
|
|
||||||
|
|
||||||
s := c.String(Name)
|
if l := c.NArg(); l != 1 {
|
||||||
|
if l > 1 {
|
||||||
|
return nil, fmt.Errorf("input program must be a single arg")
|
||||||
|
}
|
||||||
|
return nil, fmt.Errorf("must specify input program")
|
||||||
|
}
|
||||||
|
s := c.Args().Get(0)
|
||||||
if s == "" {
|
if s == "" {
|
||||||
return nil, fmt.Errorf("input yaml is empty")
|
return nil, fmt.Errorf("input yaml is empty")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user