示例#1
0
文件: rexray.go 项目: bottkars/rexray
// NewWithConfigReader creates a new REX-Ray instance and configures it with a
// custom configuration stream.
func NewWithConfigReader(in io.Reader) (*core.RexRay, error) {
	c := gofig.New()
	if err := c.ReadConfig(in); err != nil {
		return nil, err
	}
	return core.New(c), nil
}
示例#2
0
文件: rexray.go 项目: bottkars/rexray
// NewWithConfigFile creates a new REX-Ray instance and configures it with a
// custom configuration file.
func NewWithConfigFile(path string) (*core.RexRay, error) {
	c := gofig.New()
	if err := c.ReadConfigFile(path); err != nil {
		return nil, err
	}
	return core.New(c), nil
}
示例#3
0
func TestNewWithBadVolumeDriver(t *testing.T) {
	r := core.New(nil)
	r.Config.OSDrivers = []string{mock.MockOSDriverName}
	r.Config.VolumeDrivers = []string{mock.BadMockVolDriverName}
	r.Config.StorageDrivers = []string{mock.MockStorDriverName}
	if err := r.InitDrivers(); err != errors.ErrNoVolumeDrivers {
		t.Fatal(err)
	}
}
示例#4
0
func newModule(id int32, cfg *module.Config) (module.Module, error) {
	return &mod{
		id:   id,
		r:    core.New(cfg.Config),
		name: modName,
		desc: modDescription,
		addr: cfg.Address,
	}, nil
}
示例#5
0
func getRexRayNoDrivers() (*core.RexRay, error) {
	c := gofig.New()
	c.Set("rexray.osDrivers", []string{""})
	c.Set("rexray.volumeDrivers", []string{""})
	c.Set("rexray.storageDrivers", []string{""})
	r := core.New(c)
	r.InitDrivers()
	return r, nil
}
示例#6
0
func getRexRayNoDrivers() (*core.RexRay, error) {
	c := config.New()
	c.OSDrivers = []string{""}
	c.VolumeDrivers = []string{""}
	c.StorageDrivers = []string{""}
	r := core.New(c)
	r.InitDrivers()
	return r, nil
}
func TestNewWithBadStorageDriver(t *testing.T) {
	r := core.New(nil)
	r.Config.Set("osDrivers", []string{mock.MockOSDriverName})
	r.Config.Set("volumeDrivers", []string{mock.MockVolDriverName})
	r.Config.Set("storageDrivers", []string{mock.BadMockStorDriverName})
	if err := r.InitDrivers(); err != errors.ErrNoStorageDrivers {
		t.Fatal(err)
	}
}
示例#8
0
func TestNewNoVolumeDrivers(t *testing.T) {
	c := gofig.New()
	c.Set("rexray.osDrivers", []string{mock.MockOSDriverName})
	c.Set("rexray.volumeDrivers", []string{})
	c.Set("rexray.storageDrivers", []string{mock.MockStorDriverName})
	r := core.New(c)
	if err := r.InitDrivers(); err != errors.ErrNoVolumeDrivers {
		t.Fatal(err)
	}
}
示例#9
0
func TestNewNoStorageDrivers(t *testing.T) {
	c := config.New()
	c.Set("osDrivers", []string{mock.MockOSDriverName})
	c.Set("volumeDrivers", []string{mock.MockVolDriverName})
	c.Set("storageDrivers", []string{})
	r := core.New(c)
	if err := r.InitDrivers(); err != errors.ErrNoStorageDrivers {
		t.Fatal(err)
	}
}
示例#10
0
func TestNewNoVolumeDrivers(t *testing.T) {
	c := config.New()
	c.OSDrivers = []string{mock.MockOSDriverName}
	c.VolumeDrivers = []string{}
	c.StorageDrivers = []string{mock.MockStorDriverName}
	r := core.New(c)
	if err := r.InitDrivers(); err != errors.ErrNoVolumeDrivers {
		t.Fatal(err)
	}
}
示例#11
0
func TestNewWithNilConfig(t *testing.T) {
	r := core.New(nil)
	r.Config.Set("rexray.osDrivers", []string{mock.MockOSDriverName})
	r.Config.Set("rexray.volumeDrivers", []string{mock.MockVolDriverName})
	r.Config.Set("rexray.storageDrivers", []string{mock.MockStorDriverName})

	if err := r.InitDrivers(); err != nil {
		t.Fatal(err)
	}

	assertDriverNames(t, r)
}
示例#12
0
func TestNewWithNilConfig(t *testing.T) {
	r := core.New(nil)
	r.Config.OSDrivers = []string{mock.MockOSDriverName}
	r.Config.VolumeDrivers = []string{mock.MockVolDriverName}
	r.Config.StorageDrivers = []string{mock.MockStorDriverName}

	if err := r.InitDrivers(); err != nil {
		t.Fatal(err)
	}

	assertDriverNames(t, r)
}
示例#13
0
func getRexRay() (*core.RexRay, error) {
	c := gofig.New()
	c.Set("rexray.osDrivers", []string{mock.MockOSDriverName})
	c.Set("rexray.volumeDrivers", []string{mock.MockVolDriverName})
	c.Set("rexray.storageDrivers", []string{mock.MockStorDriverName})
	r := core.New(c)

	if err := r.InitDrivers(); err != nil {
		return nil, err
	}

	return r, nil
}
示例#14
0
func getRexRay() (*core.RexRay, error) {
	c := config.New()
	c.OSDrivers = []string{mock.MockOSDriverName}
	c.VolumeDrivers = []string{mock.MockVolDriverName}
	c.StorageDrivers = []string{mock.MockStorDriverName}
	r := core.New(c)

	if err := r.InitDrivers(); err != nil {
		return nil, err
	}

	return r, nil
}
示例#15
0
文件: voldriver.go 项目: luk5/rexray
func newModule(c *module.Config) (module.Module, error) {

	host := strings.Trim(c.Address, " ")

	if host == "" {
		if c.Name == "default-docker" {
			host = "unix:///run/docker/plugins/rexray.sock"
		} else {
			fname := cleanName(c.Name)
			host = fmt.Sprintf("unix:///run/docker/plugins/%s.sock", fname)
		}
	}

	c.Address = host

	return &mod{
		r:    core.New(c.Config),
		name: c.Name,
		desc: c.Description,
		addr: host,
	}, nil
}
示例#16
0
文件: cli.go 项目: moypray/rexray
// NewWithArgs returns a new CLI using the specified arguments.
func NewWithArgs(a ...string) *CLI {

	s := "REX-Ray:\n" +
		"  A guest-based storage introspection tool that enables local\n" +
		"  visibility and management from cloud and storage platforms."

	c := &CLI{
		l: log.New(),
		r: core.New(nil),
	}

	c.c = &cobra.Command{
		Use:              "rexray",
		Short:            s,
		PersistentPreRun: c.preRun,
		Run: func(cmd *cobra.Command, args []string) {
			cmd.Usage()
		},
	}

	c.c.SetArgs(a)

	c.initOtherCmdsAndFlags()

	c.initAdapterCmdsAndFlags()
	c.initDeviceCmdsAndFlags()
	c.initVolumeCmdsAndFlags()
	c.initSnapshotCmdsAndFlags()

	c.initServiceCmdsAndFlags()
	c.initModuleCmdsAndFlags()

	c.initUsageTemplates()

	return c
}
示例#17
0
文件: rexray.go 项目: bottkars/rexray
// New creates a new REX-Ray instance and configures using the standard
// configuration workflow: environment variables followed by global and user
// configuration files.
func New() (*core.RexRay, error) {
	return core.New(gofig.New()), nil
}