示例#1
0
// Init initializes the driver.
func (d *driver) Init(ctx types.Context, config gofig.Config) error {
	d.config = config

	fields := map[string]interface{}{
		"provider":        vbox.Name,
		"moduleName":      vbox.Name,
		"endpoint":        d.endpoint(),
		"userName":        d.username(),
		"tls":             d.tls(),
		"volumePath":      d.volumePath(),
		"controllerName":  d.controllerName(),
		"machineNameOrId": d.machineNameID(""),
	}

	ctx.Info("initializing driver: ", fields)
	d.vbox = vboxc.New(d.username(), d.password(),
		d.endpoint(), d.tls(), d.controllerName())

	if err := d.vbox.Logon(); err != nil {
		return goof.WithFieldsE(fields,
			"error logging in", err)
	}

	ctx.WithFields(fields).Info("storage driver initialized")
	return nil
}
示例#2
0
func main() {
	url := "http://127.0.0.1:18083"
	if len(os.Args) >= 2 {
		url = os.Args[1]
	}

	client := client.New("", "", url)
	if err := client.Logon(); err != nil {
		log.Fatalf("Unable to log on to vboxwebsrv: %v\n", err)
	}
}
示例#3
0
func (d *driver) Init(r *core.RexRay) error {
	d.r = r

	fields := eff(map[string]interface{}{
		"endpoint":             d.endpoint(),
		"userName":             d.userName(),
		"tls":                  d.tls(),
		"volumePath":           d.volumePath(),
		"localMachineNameOrId": d.localMachineNameOrId(),
	})

	if d.volumePath() == "" {
		return goof.New("missing volumePath")
	}

	if d.endpoint() == "" {
		return goof.New("missing endpoint")
	}

	if d.password() == "" {
		fields["password"] = ""
	} else {
		fields["password"] = "******"
	}

	d.virtualbox = vbox.New(d.userName(), d.password(),
		d.endpoint(), d.tls(), d.controllerName())

	if err := d.login(); err != nil {
		return goof.WithFieldsE(fields,
			"error logging in", err)
	}

	if m, err := d.findLocalMachine(d.localMachineNameOrId()); err != nil {
		goof.WithFieldsE(fields,
			"failed to find local machine", err)
	} else {
		d.machine = m
	}

	log.WithField("provider", providerName).Info("storage driver initialized")

	return nil
}