当前位置: 首页>>代码示例>>Golang>>正文


Golang volume.New函数代码示例

本文整理汇总了Golang中github.com/libopenstorage/openstorage/volume.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了New函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: TestAll

func TestAll(t *testing.T) {

	/*
		cmd := exec.Command("dd", "if=/dev/zero", "of=/tmp/x", "bs=1M", "count=100")
		err := cmd.Run()
		if err != nil {
			t.Fatalf("Failed to create file: %v", err)
		}
		cmd = exec.Command("/sbin/mkfs.btrfs", "/tmp/x")
		err = cmd.Run()
		if err != nil {
			t.Fatalf("Failed to create btrfs:%v", err)
		}
		err = os.MkdirAll("/tmp/btrfs_test", 0755)
		if err != nil {
			t.Fatalf("Failed to create mkdir: %v", err)
		}
		err = syscall.Mount("/tmp/x", "/tmp/btrfs_test", "btrfs", syscall.MS_NODEV, "")
		if err != nil {
			t.Fatalf("Failed to mount btrfs: %v", err)
		}
	*/
	_, err := volume.New(Name, volume.DriverParams{RootParam: "/tmp/btrfs_test"})
	if err != nil {
		t.Fatalf("Failed to initialize Driver: %v", err)
	}
	d, err := volume.Get(Name)
	if err != nil {
		t.Fatalf("Failed to initialize Volume Driver: %v", err)
	}
	ctx := test.NewContext(d)
	ctx.Filesystem = api.FsBtrfs

	test.Run(t, ctx)
}
开发者ID:portworx,项目名称:openstorage,代码行数:35,代码来源:btrfs_test.go

示例2: TestAll

func TestAll(t *testing.T) {
	_, err := volume.New(Name, volume.DriverParams{})
	if err != nil {
		t.Fatalf("Failed to initialize Driver: %v", err)
	}
	d, err := volume.Get(Name)
	if err != nil {
		t.Fatalf("Failed to initialize Volume Driver: %v", err)
	}
	ctx := test.NewContext(d)
	ctx.Filesystem = "ext4"
	test.RunShort(t, ctx)
}
开发者ID:phoenix-io,项目名称:openstorage,代码行数:13,代码来源:aws_test.go

示例3: TestAll

func TestAll(t *testing.T) {
	testPath := "/tmp/openstorage_driver_test"
	_, err := volume.New(Name, volume.DriverParams{RootParam: testPath})
	if err != nil {
		t.Fatalf("Failed to initialize Driver: %v", err)
	}
	d, err := volume.Get(Name)
	if err != nil {
		t.Fatalf("Failed to initialize Volume Driver: %v", err)
	}
	ctx := test.NewContext(d)
	ctx.Filesystem = "btrfs"

	test.Run(t, ctx)
}
开发者ID:phoenix-io,项目名称:openstorage,代码行数:15,代码来源:btrfs_test.go

示例4: TestAll

func TestAll(t *testing.T) {
	if _, err := credentials.NewEnvCredentials().Get(); err != nil {
		t.Skip("No AWS credentials, skipping AWS driver test: ", err)
	}
	_, err := volume.New(Name, volume.DriverParams{})
	if err != nil {
		t.Logf("Failed to initialize Driver: %v", err)
	}
	d, err := volume.Get(Name)
	if err != nil {
		t.Fatalf("Failed to initialize Volume Driver: %v", err)
	}
	ctx := test.NewContext(d)
	ctx.Filesystem = api.FSType_FS_TYPE_EXT4
	test.RunShort(t, ctx)
}
开发者ID:ModelRocket,项目名称:openstorage,代码行数:16,代码来源:aws_test.go

示例5: TestAll

func TestAll(t *testing.T) {

	_, err := volume.New(btrfs.Name, volume.DriverParams{btrfs.RootParam: "/tmp/btrfs_test"})
	if err != nil {
		t.Fatalf("Failed to initialize Driver: %v", err)
	}
	apiserver.StartDriverAPI(btrfs.Name, 9003, config.DriverAPIBase)
	time.Sleep(time.Second * 2)
	c, err := NewDriverClient(btrfs.Name)
	if err != nil {
		t.Fatalf("Failed to initialize Driver: %v", err)
	}
	d := c.VolumeDriver()
	ctx := test.NewContext(d)
	ctx.Filesystem = string(api.FsBtrfs)
	test.Run(t, ctx)
}
开发者ID:portworx,项目名称:openstorage,代码行数:17,代码来源:client_test.go

示例6: TestAll

func TestAll(t *testing.T) {
	err := os.MkdirAll(testPath, 0744)
	if err != nil {
		t.Fatalf("Failed to create test path: %v", err)
	}

	_, err = volume.New(Name, volume.DriverParams{"path": testPath})
	if err != nil {
		t.Fatalf("Failed to initialize Driver: %v", err)
	}
	d, err := volume.Get(Name)
	if err != nil {
		t.Fatalf("Failed to initialize Volume Driver: %v", err)
	}
	ctx := test.NewContext(d)
	ctx.Filesystem = api.FSType_FS_TYPE_NFS

	test.RunShort(t, ctx)
}
开发者ID:ModelRocket,项目名称:openstorage,代码行数:19,代码来源:nfs_test.go

示例7: TestAll

func TestAll(t *testing.T) {
	err := os.MkdirAll(testPath, 0744)
	if err != nil {
		t.Fatalf("Failed to create test path: %v", err)
	}

	_, err = volume.New(nfs.Name, volume.DriverParams{"path": testPath})
	if err != nil {
		t.Fatalf("Failed to initialize Driver: %v", err)
	}
	apiserver.StartServerAPI(nfs.Name, 9003, config.DriverAPIBase)
	time.Sleep(time.Second * 2)
	c, err := NewDriverClient(nfs.Name)
	if err != nil {
		t.Fatalf("Failed to initialize Driver: %v", err)
	}
	d := c.VolumeDriver()
	ctx := test.NewContext(d)
	ctx.Filesystem = string("btrfs")
	test.Run(t, ctx)
}
开发者ID:kunalkushwaha,项目名称:openstorage,代码行数:21,代码来源:client_test.go

示例8: TestAll

func TestAll(t *testing.T) {
	output, err := exec.Command("umount", btrfsFile).Output()
	if err != nil {
		t.Logf("error on umount %s (not fatal): %s %v", btrfsFile, string(output), err)
	}
	if err := os.Remove(btrfsFile); err != nil {
		t.Logf("error on rm %s (not fatal): %v", btrfsFile, err)
	}
	if err := os.MkdirAll(testPath, 0755); err != nil {
		t.Fatalf("failed on mkdir -p %s: %v", testPath, err)
	}
	file, err := os.Create(btrfsFile)
	if err != nil {
		t.Fatalf("failed to setup btrfs file at %s: %v", btrfsFile, err)
	}
	if err := file.Truncate(GiB); err != nil {
		t.Fatalf("failed to truncate %s 1G  %v", btrfsFile, err)
	}
	output, err = exec.Command("mkfs", "-t", "btrfs", "-f", btrfsFile).Output()
	if err != nil {
		t.Fatalf("failed to format to btrfs: %s %v", string(output), err)
	}
	output, err = exec.Command("mount", btrfsFile, testPath).Output()
	if err != nil {
		t.Fatalf("failed to mount to btrfs: %s %v", string(output), err)
	}
	if _, err := volume.New(Name, volume.DriverParams{RootParam: testPath}); err != nil {
		t.Fatalf("failed to initialize Driver: %v", err)
	}
	volumeDriver, err := volume.Get(Name)
	if err != nil {
		t.Fatalf("failed to initialize VolumeDriver: %v", err)
	}
	ctx := test.NewContext(volumeDriver)
	ctx.Filesystem = "btrfs"
	test.Run(t, ctx)
}
开发者ID:alwang1234,项目名称:openstorage,代码行数:37,代码来源:btrfs_test.go

示例9: start

func start(c *cli.Context) {
	var cm *cluster.ClusterManager

	if !osdcli.DaemonMode(c) {
		cli.ShowAppHelp(c)
		return
	}

	datastores := []string{mem.Name, etcd.Name}

	// We are in daemon mode.
	file := c.String("file")
	if file == "" {
		fmt.Println("OSD configuration file not specified.  Visit openstorage.org for an example.")
		return
	}
	cfg, err := config.Parse(file)
	if err != nil {
		fmt.Println(err)
		return
	}
	kvdbURL := c.String("kvdb")
	u, err := url.Parse(kvdbURL)
	scheme := u.Scheme
	u.Scheme = "http"

	kv, err := kvdb.New(scheme, "openstorage", []string{u.String()}, nil)
	if err != nil {
		fmt.Println("Failed to initialize KVDB: ", u.Scheme, err)
		fmt.Println("Supported datastores: ", datastores)
		return
	}
	err = kvdb.SetInstance(kv)
	if err != nil {
		fmt.Println("Failed to initialize KVDB: ", err)
		return
	}

	// Start the cluster state machine, if enabled.
	if cfg.Osd.ClusterConfig.NodeId != "" && cfg.Osd.ClusterConfig.ClusterId != "" {
		dockerClient, err := docker.NewClientFromEnv()
		if err != nil {
			fmt.Println("Failed to initialize docker client: ", err)
			return
		}
		cm = cluster.New(cfg.Osd.ClusterConfig, kv, dockerClient)
	}

	// Start the volume drivers.
	for d, v := range cfg.Osd.Drivers {
		fmt.Println("Starting volume driver: ", d)
		_, err := volume.New(d, v)
		if err != nil {
			fmt.Println("Unable to start volume driver: ", d, err)
			return
		}

		err = apiserver.StartServerAPI(d, 0, config.DriverAPIBase)
		if err != nil {
			fmt.Println("Unable to start volume driver: ", err)
			return
		}

		err = apiserver.StartPluginAPI(d, config.PluginAPIBase)
		if err != nil {
			fmt.Println("Unable to start volume plugin: ", err)
			return
		}
	}

	if cm != nil {
		err = cm.Start()
		if err != nil {
			fmt.Println("Unable to start cluster manager: ", err)
			return
		}
	}

	// Daemon does not exit.
	select {}
}
开发者ID:kunalkushwaha,项目名称:openstorage,代码行数:81,代码来源:main.go

示例10: start

func start(c *cli.Context) {
	var cm cluster.Cluster

	if !osdcli.DaemonMode(c) {
		cli.ShowAppHelp(c)
		return
	}

	datastores := []string{mem.Name, etcd.Name, consul.Name}

	// We are in daemon mode.
	file := c.String("file")
	if file == "" {
		logrus.Warn("OSD configuration file not specified.  Visit openstorage.org for an example.")
		return
	}
	cfg, err := config.Parse(file)
	if err != nil {
		logrus.Error(err)
		return
	}
	kvdbURL := c.String("kvdb")
	u, err := url.Parse(kvdbURL)
	scheme := u.Scheme
	u.Scheme = "http"

	kv, err := kvdb.New(scheme, "openstorage", []string{u.String()}, nil)
	if err != nil {
		logrus.Warnf("Failed to initialize KVDB: %v (%v)", scheme, err)
		logrus.Warnf("Supported datastores: %v", datastores)
		return
	}
	err = kvdb.SetInstance(kv)
	if err != nil {
		logrus.Warnf("Failed to initialize KVDB: %v", err)
		return
	}

	// Start the cluster state machine, if enabled.
	if cfg.Osd.ClusterConfig.NodeId != "" && cfg.Osd.ClusterConfig.ClusterId != "" {
		logrus.Infof("OSD enabling cluster mode.")

		dockerClient, err := docker.NewClientFromEnv()
		if err != nil {
			logrus.Warnf("Failed to initialize docker client: %v", err)
			return
		}

		cm = cluster.New(cfg.Osd.ClusterConfig, kv, dockerClient)

		if err := server.StartClusterAPI(config.ClusterAPIBase); err != nil {
			logrus.Warnf("Unable to start cluster API server: %v", err)
			return
		}
	}

	// Start the volume drivers.
	for d, v := range cfg.Osd.Drivers {
		logrus.Infof("Starting volume driver: %v", d)
		if _, err := volume.New(d, v); err != nil {
			logrus.Warnf("Unable to start volume driver: %v, %v", d, err)
			return
		}

		if err := server.StartPluginAPI(d, config.DriverAPIBase, config.PluginAPIBase); err != nil {
			logrus.Warnf("Unable to start volume plugin: %v", err)
			return
		}
	}

	// Start the graph drivers.
	for d, _ := range cfg.Osd.GraphDrivers {
		logrus.Infof("Starting graph driver: %v", d)
		if err := server.StartGraphAPI(d, config.PluginAPIBase); err != nil {
			logrus.Warnf("Unable to start graph plugin: %v", err)
			return
		}
	}

	if cm != nil {
		if err := cm.Start(); err != nil {
			logrus.Warnf("Unable to start cluster manager: %v", err)
			return
		}
	}

	// Daemon does not exit.
	select {}
}
开发者ID:alwang1234,项目名称:openstorage,代码行数:89,代码来源:main.go

示例11: start

func start(c *cli.Context) {
	if !osdcli.DaemonMode(c) {
		cli.ShowAppHelp(c)
		return
	}

	datastores := []string{mem.Name, etcd.Name}

	// We are in daemon mode.
	file := c.String("file")
	if file == "" {
		fmt.Println("OSD configuration file not specified.  Visit openstorage.org for an example.")
		return
	}
	cfg, err := config.Parse(file)
	if err != nil {
		fmt.Println(err)
		return
	}
	kvdb_url := c.String("kvdb")
	u, err := url.Parse(kvdb_url)
	scheme := u.Scheme
	u.Scheme = "http"

	kv, err := kvdb.New(scheme, "openstorage", []string{u.String()}, nil)
	if err != nil {
		fmt.Println("Failed to initialize KVDB: ", u.Scheme, err)
		fmt.Println("Supported datastores: ", datastores)
		return
	}
	err = kvdb.SetInstance(kv)
	if err != nil {
		fmt.Println("Failed to initialize KVDB: ", err)
		return
	}

	// Start the volume drivers.
	for d, v := range cfg.Osd.Drivers {

		fmt.Println("Starting volume driver: ", d)
		_, err := volume.New(d, v)
		if err != nil {
			fmt.Println("Unable to start volume driver: ", d, err)
			return
		}

		err = apiserver.StartDriverAPI(d, 0, config.DriverAPIBase)
		if err != nil {
			fmt.Println("Unable to start volume driver: ", err)
			return
		}

		err = apiserver.StartPluginAPI(d, config.PluginAPIBase)
		if err != nil {
			fmt.Println("Unable to start volume plugin: ", err)
			return
		}
	}

	// Daemon does not exit.
	select {}
}
开发者ID:portworx,项目名称:openstorage,代码行数:62,代码来源:osd.go


注:本文中的github.com/libopenstorage/openstorage/volume.New函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。