Exemple #1
0
func (c *VMCommand) Execute(args []string) error {
	client, err := rpc.NewClient(true)
	if err != nil {
		return err
	}

	cfg, err := config.New(os.ExpandEnv("$SUDO_USER"))
	if err != nil {
		return err
	}

	err = cfg.Load()
	if err != nil {
		return err
	}

	vm := vm.New(cfg)
	done, err := vm.Start()
	if err != nil {
		return err
	}

	shutdown := make(chan os.Signal, 1)
	signal.Notify(shutdown, syscall.SIGINT, syscall.SIGTERM, syscall.SIGKILL)
	go func() {
		<-shutdown
		var i int
		client.Call("VM.Stop", "", &i)
	}()

	err = <-done
	return err
}
Exemple #2
0
func (c *IPCommand) Execute(args []string) error {
	cfg, err := config.New(os.ExpandEnv("$USER"))
	if err != nil {
		return err
	}

	err = cfg.Load()
	if err != nil {
		return err
	}

	v := vm.New(cfg)
	ip, err := v.IP()
	if err != nil {
		return err
	}

	fmt.Println(ip)
	return nil
}
Exemple #3
0
func (s *Server) IP() (string, error) {
	vm := vm.New(s.config)
	return vm.IP()
}