本文整理汇总了Golang中github.com/libopenstorage/openstorage/volume.NewDefaultEnumerator函数的典型用法代码示例。如果您正苦于以下问题:Golang NewDefaultEnumerator函数的具体用法?Golang NewDefaultEnumerator怎么用?Golang NewDefaultEnumerator使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NewDefaultEnumerator函数的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Init
func Init(params volume.DriverParams) (volume.VolumeDriver, error) {
inst := &driver{
IoNotSupported: &volume.IoNotSupported{},
DefaultEnumerator: volume.NewDefaultEnumerator(Name, kvdb.Instance()),
}
inst.buseDevices = make(map[string]*buseDev)
if err := os.MkdirAll(BuseMountPath, 0744); err != nil {
return nil, err
}
volumeInfo, err := inst.DefaultEnumerator.Enumerate(
&api.VolumeLocator{},
nil,
)
if err == nil {
for _, info := range volumeInfo {
if info.Status == api.VolumeStatus_VOLUME_STATUS_NONE {
info.Status = api.VolumeStatus_VOLUME_STATUS_UP
inst.UpdateVol(info)
}
}
} else {
dlog.Println("Could not enumerate Volumes, ", err)
}
c, err := cluster.Inst()
if err != nil {
dlog.Println("BUSE initializing in single node mode")
} else {
dlog.Println("BUSE initializing in clustered mode")
c.AddEventListener(inst)
}
dlog.Println("BUSE initialized and driver mounted at: ", BuseMountPath)
return inst, nil
}
开发者ID:ModelRocket,项目名称:openstorage,代码行数:35,代码来源:buse.go
示例2: Init
func Init(params volume.DriverParams) (volume.VolumeDriver, error) {
restUrl, ok := params["restUrl"]
if !ok {
return nil, fmt.Errorf("rest api 'url' configuration parameter must be set")
}
user, ok := params["user"]
if !ok {
return nil, fmt.Errorf("rest auth 'user' must be set")
}
pass, ok := params["password"]
if !ok {
return nil, fmt.Errorf("rest auth 'password' must be set")
}
consistency_group, ok := params["consistency_group"]
if !ok {
return nil, fmt.Errorf("'consistency_group' configuration parameter must be set")
}
project, ok := params["project"]
if !ok {
return nil, fmt.Errorf("'project' configuration parameter must be set")
}
varray, ok := params["varray"]
if !ok {
return nil, fmt.Errorf("'varray' configuration parameter must be set")
}
vpool, ok := params["vpool"]
if !ok {
return nil, fmt.Errorf("'vpool' configuration parameter must be set")
}
d := &driver{
DefaultEnumerator: volume.NewDefaultEnumerator(Name, kvdb.Instance()),
consistency_group: consistency_group,
project: project,
varray: varray,
vpool: vpool,
url: restUrl,
creds: url.UserPassword(user, pass),
httpClient: &http.Client{
Transport: &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
},
},
}
return d, nil
}
开发者ID:alwang1234,项目名称:openstorage,代码行数:53,代码来源:coprhd.go
示例3: Init
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 &driver{btrfs: d, root: root, DefaultEnumerator: s}, nil
}
开发者ID:phoenix-io,项目名称:openstorage,代码行数:13,代码来源:btrfs.go
示例4: Init
// Init aws volume driver metadata.
func Init(params volume.DriverParams) (volume.VolumeDriver, error) {
zone, err := metadata("placement/availability-zone")
if err != nil {
return nil, err
}
instance, err := metadata("instance-id")
if err != nil {
return nil, err
}
logrus.Infof("AWS instance %v zone %v", instance, zone)
accessKey, ok := params["AWS_ACCESS_KEY_ID"]
if !ok {
if accessKey = os.Getenv("AWS_ACCESS_KEY_ID"); accessKey == "" {
return nil, fmt.Errorf("AWS_ACCESS_KEY_ID environment variable must be set")
}
}
secretKey, ok := params["AWS_SECRET_ACCESS_KEY"]
if !ok {
if secretKey = os.Getenv("AWS_SECRET_ACCESS_KEY"); secretKey == "" {
return nil, fmt.Errorf("AWS_SECRET_ACCESS_KEY environment variable must be set")
}
}
creds := credentials.NewStaticCredentials(accessKey, secretKey, "")
region := zone[:len(zone)-1]
d := &Driver{
ec2: ec2.New(
session.New(
&aws.Config{
Region: ®ion,
Credentials: creds,
},
),
),
md: &Metadata{
zone: zone,
instance: instance,
},
IoNotSupported: &volume.IoNotSupported{},
DefaultEnumerator: volume.NewDefaultEnumerator(Name, kvdb.Instance()),
}
devPrefix, letters, err := d.freeDevices()
if err != nil {
return nil, err
}
d.SingleLetter, err = device.NewSingleLetter(devPrefix, letters)
if err != nil {
return nil, err
}
return d, nil
}
开发者ID:pombredanne,项目名称:openstorage,代码行数:51,代码来源:aws.go
示例5: newVolumeDriver
func newVolumeDriver(
name string,
baseDirPath string,
provider Provider,
) *volumeDriver {
return &volumeDriver{
name,
baseDirPath,
provider,
&volume.DefaultBlockDriver{},
volume.NewDefaultEnumerator(
name,
kvdb.Instance(),
),
&volume.SnapshotNotSupported{},
}
}
开发者ID:kunalkushwaha,项目名称:openstorage,代码行数:17,代码来源:volume_driver.go
示例6: Init
// Init aws volume driver metadata.
func Init(params volume.DriverParams) (volume.VolumeDriver, error) {
zone, err := metadata("placement/availability-zone")
if err != nil {
return nil, err
}
instance, err := metadata("instance-id")
if err != nil {
return nil, err
}
log.Infof("AWS instance %v zone %v", instance, zone)
if accessKey, ok := params["AWS_ACCESS_KEY_ID"]; ok {
os.Setenv("AWS_ACCESS_KEY_ID", accessKey)
}
if secretKey, ok := params["AWS_SECRET_ACCESS_KEY"]; ok {
os.Setenv("AWS_SECRET_ACCESS_KEY", secretKey)
}
if accessKey := os.Getenv("AWS_ACCESS_KEY_ID"); accessKey == "" {
return nil, fmt.Errorf("AWS_ACCESS_KEY_ID environment variable must be set")
}
if secretKey := os.Getenv("AWS_SECRET_ACCESS_KEY"); secretKey == "" {
return nil, fmt.Errorf("AWS_SECRET_ACCESS_KEY environment variable must be set")
}
creds := credentials.NewEnvCredentials()
region := zone[:len(zone)-1]
inst := &Driver{
ec2: ec2.New(&aws.Config{
Region: ®ion,
Credentials: creds,
}),
md: &Metadata{
zone: zone,
instance: instance,
},
devices: "abcdefghijklmnopqrstuvwxyz",
DefaultEnumerator: volume.NewDefaultEnumerator(Name, kvdb.Instance()),
}
return inst, nil
}
开发者ID:gourao,项目名称:openstorage,代码行数:40,代码来源:aws.go
示例7: Init
func Init(params volume.DriverParams) (volume.VolumeDriver, error) {
path, ok := params["path"]
if !ok {
return nil, errors.New("No NFS path provided")
}
server, ok := params["server"]
if !ok {
log.Printf("No NFS server provided, will attempt to bind mount %s", path)
} else {
log.Printf("NFS driver initializing with %s:%s ", server, path)
}
inst := &driver{
DefaultEnumerator: volume.NewDefaultEnumerator(Name, 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)
if server != "" {
err = syscall.Mount(":"+inst.nfsPath, nfsMountPath, "nfs", 0, "nolock,addr="+inst.nfsServer)
} else {
err = syscall.Mount(inst.nfsPath, nfsMountPath, "", syscall.MS_BIND, "")
}
if err != nil {
log.Printf("Unable to mount %s:%s at %s (%+v)", inst.nfsServer, inst.nfsPath, nfsMountPath, err)
return nil, err
}
log.Println("NFS initialized and driver mounted at: ", nfsMountPath)
return inst, nil
}
开发者ID:pault84,项目名称:openstorage,代码行数:38,代码来源:nfs.go
示例8: Init
func Init(params volume.DriverParams) (volume.VolumeDriver, error) {
path, ok := params["path"]
if !ok {
return nil, errors.New("No NFS path provided")
}
server, ok := params["server"]
if !ok {
dlog.Printf("No NFS server provided, will attempt to bind mount %s", path)
} else {
dlog.Printf("NFS driver initializing with %s:%s ", server, path)
}
// Create a mount manager for this NFS server. Blank sever is OK.
mounter, err := mount.New(mount.NFSMount, server)
if err != nil {
dlog.Warnf("Failed to create mount manager for server: %v (%v)", server, err)
return nil, err
}
inst := &driver{
IoNotSupported: &volume.IoNotSupported{},
DefaultEnumerator: volume.NewDefaultEnumerator(Name, kvdb.Instance()),
nfsServer: server,
nfsPath: path,
mounter: mounter,
}
if err := os.MkdirAll(nfsMountPath, 0744); err != nil {
return nil, err
}
src := inst.nfsPath
if server != "" {
src = ":" + inst.nfsPath
}
// If src is already mounted at dest, leave it be.
mountExists, err := mounter.Exists(src, nfsMountPath)
if !mountExists {
// Mount the nfs server locally on a unique path.
syscall.Unmount(nfsMountPath, 0)
if server != "" {
err = syscall.Mount(src, nfsMountPath, "nfs", 0, "nolock,addr="+inst.nfsServer)
} else {
err = syscall.Mount(src, nfsMountPath, "", syscall.MS_BIND, "")
}
if err != nil {
dlog.Printf("Unable to mount %s:%s at %s (%+v)", inst.nfsServer, inst.nfsPath, nfsMountPath, err)
return nil, err
}
}
volumeInfo, err := inst.DefaultEnumerator.Enumerate(&api.VolumeLocator{}, nil)
if err == nil {
for _, info := range volumeInfo {
if info.Status == api.VolumeStatus_VOLUME_STATUS_NONE {
info.Status = api.VolumeStatus_VOLUME_STATUS_UP
inst.UpdateVol(info)
}
}
} else {
dlog.Println("Could not enumerate Volumes, ", err)
}
dlog.Println("NFS initialized and driver mounted at: ", nfsMountPath)
return inst, nil
}
开发者ID:ModelRocket,项目名称:openstorage,代码行数:61,代码来源:nfs.go
示例9: Init
// Init Driver intialization.
func Init(params volume.DriverParams) (volume.VolumeDriver, error) {
return &driver{
IoNotSupported: &volume.IoNotSupported{},
DefaultEnumerator: volume.NewDefaultEnumerator(Name, kvdb.Instance()),
}, nil
}
开发者ID:pombredanne,项目名称:openstorage,代码行数:7,代码来源:vfs.go
示例10: Init
func Init(params map[string]string) (volume.VolumeDriver, error) {
host, ok := params["url"]
if !ok {
return nil, ErrApiUrlRequired
}
token, ok := params["token"]
if !ok {
return nil, ErrApiAuthTokenRequired
}
// create a coprhd api client instance
client := coprhd.NewClient(host, token)
d := &driver{
DefaultEnumerator: volume.NewDefaultEnumerator(Name, kvdb.Instance()),
client: client,
}
if projectName, ok := params["project"]; ok {
if project, err := client.Project().Name(projectName).Query(); err != nil {
return nil, err
} else {
d.project = project
}
} else {
dlog.Warnln("Default coprhd 'project' not set")
}
if varrayName, ok := params["varray"]; ok {
if varray, err := client.VArray().Name(varrayName).Query(); err != nil {
return nil, err
} else {
d.varray = varray
}
} else {
dlog.Warnf("Default coprhd 'varray' not set")
}
if vpoolName, ok := params["vpool"]; ok {
if vpool, err := client.VPool().Name(vpoolName).Query(); err != nil {
return nil, err
} else {
d.vpool = vpool
}
} else {
dlog.Warnf("Default coprhd 'vpool' not set")
}
if port, ok := params["port"]; ok {
if initiator, err := client.Initiator().Port(port).Query(); err != nil {
return nil, err
} else {
d.initiator = initiator
}
} else {
return nil, ErrPortRequired
}
return d, nil
}
开发者ID:ModelRocket,项目名称:openstorage,代码行数:61,代码来源:coprhd.go
示例11: Init
// Init Driver intialization.
func Init(params volume.DriverParams) (volume.VolumeDriver, error) {
return &driver{
DefaultEnumerator: volume.NewDefaultEnumerator(Name, kvdb.Instance())}, nil
}
开发者ID:kunalkushwaha,项目名称:openstorage,代码行数:5,代码来源:vfs.go
注:本文中的github.com/libopenstorage/openstorage/volume.NewDefaultEnumerator函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论