Exemplo n.º 1
0
func Init(params volume.DriverParams) (volume.VolumeDriver, error) {
	server, ok := params["server"]
	if !ok {
		return nil, errors.New("No NFS server provided")
	}

	path, ok := params["path"]
	if !ok {
		return nil, errors.New("No NFS path provided")
	}

	log.Printf("NFS driver initializing with %s:%s ", server, path)

	inst := &nfsDriver{
		db:        kvdb.Instance(),
		nfsServer: server,
		nfsPath:   path}

	err := os.MkdirAll(nfsMountPath, 0744)
	if err != nil {
		return nil, err
	}

	// Mount the nfs server locally on a unique path.
	syscall.Unmount(nfsMountPath, 0)
	err = syscall.Mount(":"+inst.nfsPath, nfsMountPath, "nfs", 0, "nolock,addr="+inst.nfsServer)
	if err != nil {
		log.Printf("Unable to mount %s at %s.\n", inst.nfsServer, nfsMountPath)
		return nil, err
	}

	log.Println("NFS initialized and driver mounted at: ", nfsMountPath)
	return inst, nil
}
Exemplo n.º 2
0
func Init(params volume.DriverParams) (volume.VolumeDriver, error) {
	root, ok := params[RootParam]
	if !ok {
		return nil, fmt.Errorf("Root directory should be specified with key %q", RootParam)
	}
	home := path.Join(root, Volumes)
	d, err := btrfs.Init(home, nil)
	if err != nil {
		return nil, err
	}
	s := volume.NewDefaultEnumerator(Name, kvdb.Instance())
	return &btrfsDriver{btrfs: d, root: root, DefaultEnumerator: s}, nil
}
Exemplo n.º 3
0
func Init(params volume.DriverParams) (volume.VolumeDriver, error) {
	// Initialize the EC2 interface.
	creds := credentials.NewEnvCredentials()
	inst := &awsDriver{
		ec2: ec2.New(&aws.Config{
			Region:      "us-west-1",
			Credentials: creds,
		}),
	}

	inst.db = kvdb.Instance()

	return inst, nil
}