Example #1
0
// check if it was added previously, if not create a new vagrantUtil
// instance
func (h *Handlers) vagrantutil(path string, debug bool) (*vagrantutil.Vagrant, error) {
	path = h.absolute(path)

	h.pathsMu.Lock()
	defer h.pathsMu.Unlock()

	v, ok := h.paths[path]
	if !ok {
		var err error
		v, err = vagrantutil.NewVagrant(path)
		if err != nil {
			return nil, err
		}

		if debug || h.opts.Debug {
			v.Log = logging.NewCustom("vagrantutil", true)
		}

		// Set explicitely to virtualbox to overwrite any default
		// provider that may be set system-wide.
		v.ProviderName = "virtualbox"

		h.paths[path] = v
	}

	return v, nil
}
Example #2
0
func (h *Handlers) init() {
	v, err := vagrantutil.NewVagrant(".") // "vagrant box" commands does not require working dir
	if err != nil {
		h.log().Error("failed to init Vagrant handlers: %s", err)
		return
	}

	h.boxAdd(v, "ubuntu/trusty64", "")

	if err := os.MkdirAll(filepath.Join(h.opts.Home, "logs"), 0755); err != nil {
		h.log().Error("failed to init Vagrant handlers: %s", err)
	}
}
Example #3
0
func TestMain(m *testing.M) {
	vagrantKite = kite.New("vagrant", "0.0.1")
	vagrantKite.Config.DisableAuthentication = true
	vagrantKite.Config.Port = 3640
	vagrantKite.SetLogLevel(kite.DEBUG)

	var err error
	localVagrant, err = vagrantutil.NewVagrant(vagrantName)
	if err != nil {
		log.Fatalln(err)
	}

	handlers = NewHandlers(&Options{Home: home, Log: vagrantKite.Log})

	vagrantKite.HandleFunc("list", handlers.List)
	vagrantKite.HandleFunc("create", handlers.Create)
	vagrantKite.HandleFunc("destroy", handlers.Destroy)
	vagrantKite.HandleFunc("halt", handlers.Halt)
	vagrantKite.HandleFunc("status", handlers.Status)
	vagrantKite.HandleFunc("up", handlers.Up)
	vagrantKite.HandleFunc("version", handlers.Version)

	go vagrantKite.Run()
	<-vagrantKite.ServerReadyNotify()

	remoteKite := kite.New("remote", "0.0.1")
	remoteKite.Config.Username = "******"
	remote = remoteKite.NewClient("http://127.0.0.1:3640/kite")
	err = remote.Dial()
	if err != nil {
		log.Fatalf("err")
	}

	// run our tests...
	exitStatus := m.Run()

	os.Exit(exitStatus)
}