summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2021-09-20 13:47:43 -0400
committerGitHub <noreply@github.com>2021-09-20 13:47:43 -0400
commitb700fe22fdb3b25d6eef2f9ccff8fe39eadd3979 (patch)
treee6b9eee071bdb6333386bb5139b5b14b223dbad5
parent4cdffd07142c4362e9c2efdb841b286d6cd4f2b8 (diff)
parent74ad05396b7c988856c3c2d3af88f3725ef29775 (diff)
downloadpodman-b700fe22fdb3b25d6eef2f9ccff8fe39eadd3979.tar.gz
podman-b700fe22fdb3b25d6eef2f9ccff8fe39eadd3979.tar.bz2
podman-b700fe22fdb3b25d6eef2f9ccff8fe39eadd3979.zip
Merge pull request #11644 from rhatdan/now
Add podman machine init --now option
-rw-r--r--cmd/podman/machine/init.go21
-rw-r--r--docs/source/markdown/podman-machine-init.1.md4
2 files changed, 24 insertions, 1 deletions
diff --git a/cmd/podman/machine/init.go b/cmd/podman/machine/init.go
index ec44a707d..19f31d1a6 100644
--- a/cmd/podman/machine/init.go
+++ b/cmd/podman/machine/init.go
@@ -3,6 +3,8 @@
package machine
import (
+ "fmt"
+
"github.com/containers/common/pkg/completion"
"github.com/containers/podman/v3/cmd/podman/registry"
"github.com/containers/podman/v3/pkg/machine"
@@ -26,6 +28,7 @@ var (
var (
initOpts = machine.InitOptions{}
defaultMachineName = "podman-machine-default"
+ now bool
)
func init() {
@@ -61,6 +64,12 @@ func init() {
)
_ = initCmd.RegisterFlagCompletionFunc(memoryFlagName, completion.AutocompleteNone)
+ flags.BoolVar(
+ &now,
+ "now", false,
+ "Start machine now",
+ )
+
ImagePathFlagName := "image-path"
flags.StringVar(&initOpts.ImagePath, ImagePathFlagName, cfg.Engine.MachineImage, "Path to qcow image")
_ = initCmd.RegisterFlagCompletionFunc(ImagePathFlagName, completion.AutocompleteDefault)
@@ -91,5 +100,15 @@ func initMachine(cmd *cobra.Command, args []string) error {
if err != nil {
return err
}
- return vm.Init(initOpts)
+ err = vm.Init(initOpts)
+ if err != nil {
+ return err
+ }
+ if now {
+ err = vm.Start(initOpts.Name, machine.StartOptions{})
+ if err == nil {
+ fmt.Printf("Machine %q started successfully\n", initOpts.Name)
+ }
+ }
+ return err
}
diff --git a/docs/source/markdown/podman-machine-init.1.md b/docs/source/markdown/podman-machine-init.1.md
index c864a87ef..1236db602 100644
--- a/docs/source/markdown/podman-machine-init.1.md
+++ b/docs/source/markdown/podman-machine-init.1.md
@@ -47,6 +47,10 @@ Defaults to `testing`.
Memory (in MB).
+#### **--now**
+
+Start the virtual machine immediately after it has been initialized.
+
#### **--help**
Print usage statement.