Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

Commit

Permalink
Implement start -i, update ps comments
Browse files Browse the repository at this point in the history
  • Loading branch information
twelho committed May 28, 2019
1 parent b5eea00 commit 26adcee
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
3 changes: 1 addition & 2 deletions cmd/ignite/cmd/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ func NewCmdPs(out io.Writer) *cobra.Command {
func RunPs(out io.Writer, cmd *cobra.Command) error {
var mds []*vmmd.VMMetadata

// Match all VMs using the VMFilter
// TODO: VMFilter support for running/stopped VMs
// Match all VMs using the VMFilter with state checking
if matches, err := filter.NewFilterer(vmmd.NewVMFilterAll("", all), metadata.VM.Path(), vmmd.LoadVMMetadata); err == nil {
if all, err := matches.All(); err == nil {
if mds, err = vmmd.ToVMMetadataAll(all); err != nil {
Expand Down
16 changes: 13 additions & 3 deletions cmd/ignite/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ import (
"github.com/spf13/cobra"
)

var interactive bool

// NewCmdStart starts a Firecracker VM
func NewCmdStart(out io.Writer) *cobra.Command {
cmd := &cobra.Command{
Expand All @@ -26,7 +28,8 @@ func NewCmdStart(out io.Writer) *cobra.Command {
errutils.Check(err)
},
}
//cmd.Flags().StringP("output", "o", "", "Output format; available options are 'yaml', 'json' and 'short'")

cmd.Flags().BoolVarP(&interactive, "interactive", "i", false, "Immediately attach to started VM")
return cmd
}

Expand Down Expand Up @@ -73,8 +76,15 @@ func RunStart(out io.Writer, cmd *cobra.Command, args []string) error {
return fmt.Errorf("failed to start container for VM %q: %v", md.ID, err)
}

// Print the ID of the started VM
fmt.Println(md.ID)
// If starting interactively, attach after starting
if interactive {
if err := RunAttach(out, cmd, args, false); err != nil {
return err
}
} else {
// Print the ID of the started VM
fmt.Println(md.ID)
}

return nil
}

0 comments on commit 26adcee

Please sign in to comment.