Esempio n. 1
0
func configureVolumes(config *Config, rootUID, rootGID int) (*store.VolumeStore, error) {
	volumesDriver, err := local.New(config.Root, rootUID, rootGID)
	if err != nil {
		return nil, err
	}

	volumedrivers.Register(volumesDriver, volumesDriver.Name())
	return store.New(config.Root)
}
Esempio n. 2
0
func (daemon *Daemon) configureVolumes(rootUID, rootGID int) (*store.VolumeStore, error) {
	volumesDriver, err := local.New(daemon.configStore.Root, rootUID, rootGID)
	if err != nil {
		return nil, err
	}

	if !volumedrivers.Register(volumesDriver, volumesDriver.Name()) {
		return nil, fmt.Errorf("local volume driver could not be registered")
	}
	return store.New(daemon.configStore.Root)
}
Esempio n. 3
0
func configureVolumes(config *Config) (*store.VolumeStore, error) {
	volumesDriver, err := local.New(config.Root)
	if err != nil {
		return nil, err
	}

	volumedrivers.Register(volumesDriver, volumesDriver.Name())
	s := store.New()
	s.AddAll(volumesDriver.List())

	return s, nil
}
Esempio n. 4
0
func initDaemonWithVolumeStore(tmp string) (*Daemon, error) {
	daemon := &Daemon{
		repository: tmp,
		root:       tmp,
		volumes:    store.New(),
	}

	volumesDriver, err := local.New(tmp, 0, 0)
	if err != nil {
		return nil, err
	}
	volumedrivers.Register(volumesDriver, volumesDriver.Name())

	return daemon, nil
}
Esempio n. 5
0
func TestMigratePre17Volumes(t *testing.T) {
	rootDir, err := ioutil.TempDir("", "test-daemon-volumes")
	if err != nil {
		t.Fatal(err)
	}
	defer os.RemoveAll(rootDir)

	volumeRoot := filepath.Join(rootDir, "volumes")
	err = os.MkdirAll(volumeRoot, 0755)
	if err != nil {
		t.Fatal(err)
	}

	containerRoot := filepath.Join(rootDir, "containers")
	cid := "1234"
	err = os.MkdirAll(filepath.Join(containerRoot, cid), 0755)

	vid := "5678"
	vfsPath := filepath.Join(rootDir, "vfs", "dir", vid)
	err = os.MkdirAll(vfsPath, 0755)
	if err != nil {
		t.Fatal(err)
	}

	config := []byte(`
		{
			"ID": "` + cid + `",
			"Volumes": {
				"/foo": "` + vfsPath + `",
				"/bar": "/foo",
				"/quux": "/quux"
			},
			"VolumesRW": {
				"/foo": true,
				"/bar": true,
				"/quux": false
			}
		}
	`)

	volStore, err := store.New(volumeRoot)
	if err != nil {
		t.Fatal(err)
	}
	drv, err := local.New(volumeRoot, 0, 0)
	if err != nil {
		t.Fatal(err)
	}
	volumedrivers.Register(drv, volume.DefaultDriverName)

	daemon := &Daemon{root: rootDir, repository: containerRoot, volumes: volStore}
	err = ioutil.WriteFile(filepath.Join(containerRoot, cid, "config.v2.json"), config, 600)
	if err != nil {
		t.Fatal(err)
	}
	c, err := daemon.load(cid)
	if err != nil {
		t.Fatal(err)
	}
	if err := daemon.verifyVolumesInfo(c); err != nil {
		t.Fatal(err)
	}

	expected := map[string]volume.MountPoint{
		"/foo":  {Destination: "/foo", RW: true, Name: vid},
		"/bar":  {Source: "/foo", Destination: "/bar", RW: true},
		"/quux": {Source: "/quux", Destination: "/quux", RW: false},
	}
	for id, mp := range c.MountPoints {
		x, exists := expected[id]
		if !exists {
			t.Fatal("volume not migrated")
		}
		if mp.Source != x.Source || mp.Destination != x.Destination || mp.RW != x.RW || mp.Name != x.Name {
			t.Fatalf("got unexpected mountpoint, expected: %+v, got: %+v", x, mp)
		}
	}
}