Merge pull request #1503 from sergiobuj/add_status_command
Add status command
This commit is contained in:
@@ -384,6 +384,12 @@ var Commands = []cli.Command{
|
|||||||
Description: "Argument(s) are one or more machine names.",
|
Description: "Argument(s) are one or more machine names.",
|
||||||
Action: cmdStart,
|
Action: cmdStart,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
Name: "status",
|
||||||
|
Usage: "Get the status of a machine",
|
||||||
|
Description: "Argument is a machine name.",
|
||||||
|
Action: cmdStatus,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
Name: "stop",
|
Name: "stop",
|
||||||
Usage: "Stop a machine",
|
Usage: "Stop a machine",
|
||||||
|
|||||||
16
commands/status.go
Normal file
16
commands/status.go
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package commands
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/docker/machine/log"
|
||||||
|
|
||||||
|
"github.com/codegangsta/cli"
|
||||||
|
)
|
||||||
|
|
||||||
|
func cmdStatus(c *cli.Context) {
|
||||||
|
host := getHost(c)
|
||||||
|
currentState, err := host.Driver.GetState()
|
||||||
|
if err != nil {
|
||||||
|
log.Errorf("error getting state for host %s: %s", host.Name, err)
|
||||||
|
}
|
||||||
|
log.Info(currentState)
|
||||||
|
}
|
||||||
1
commands/status_test.go
Normal file
1
commands/status_test.go
Normal file
@@ -0,0 +1 @@
|
|||||||
|
package commands
|
||||||
@@ -27,6 +27,7 @@ parent="smn_machine_ref"
|
|||||||
* [scp](scp.md)
|
* [scp](scp.md)
|
||||||
* [ssh](ssh.md)
|
* [ssh](ssh.md)
|
||||||
* [start](start.md)
|
* [start](start.md)
|
||||||
|
* [status](status.md)
|
||||||
* [stop](stop.md)
|
* [stop](stop.md)
|
||||||
* [upgrade](upgrade.md)
|
* [upgrade](upgrade.md)
|
||||||
* [url](url.md)
|
* [url](url.md)
|
||||||
|
|||||||
18
docs/reference/status.md
Normal file
18
docs/reference/status.md
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
<!--[metadata]>
|
||||||
|
+++
|
||||||
|
title = "status"
|
||||||
|
description = "Get the status of a machine"
|
||||||
|
keywords = ["machine, status, subcommand"]
|
||||||
|
[menu.main]
|
||||||
|
parent="smn_machine_subcmds"
|
||||||
|
+++
|
||||||
|
<![end-metadata]-->
|
||||||
|
|
||||||
|
# status
|
||||||
|
|
||||||
|
Get the status of a machine.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ docker-machine status dev
|
||||||
|
Running
|
||||||
|
```
|
||||||
@@ -104,3 +104,9 @@ load ${BASE_TEST_DIR}/helpers.bash
|
|||||||
[ "$status" -eq 0 ]
|
[ "$status" -eq 0 ]
|
||||||
[[ ${lines[1]} == *"Running"* ]]
|
[[ ${lines[1]} == *"Running"* ]]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "$DRIVER: status" {
|
||||||
|
run machine status $NAME
|
||||||
|
[ "$status" -eq 0 ]
|
||||||
|
[[ ${output} == *"Running"* ]]
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user