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


Golang Store.GetString方法代码示例

本文整理汇总了Golang中github.com/codedellemc/libstorage/api/types.Store.GetString方法的典型用法代码示例。如果您正苦于以下问题:Golang Store.GetString方法的具体用法?Golang Store.GetString怎么用?Golang Store.GetString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/codedellemc/libstorage/api/types.Store的用法示例。


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

示例1: snapshotRemove

func (r *router) snapshotRemove(
	ctx types.Context,
	w http.ResponseWriter,
	req *http.Request,
	store types.Store) error {

	service := context.MustService(ctx)

	run := func(
		ctx types.Context,
		svc types.StorageService) (interface{}, error) {

		return nil, svc.Driver().SnapshotRemove(
			ctx,
			store.GetString("snapshotID"),
			store)
	}

	return httputils.WriteTask(
		ctx,
		r.config,
		w,
		store,
		service.TaskExecute(ctx, run, nil),
		http.StatusResetContent)
}
开发者ID:emccode,项目名称:libstorage,代码行数:26,代码来源:snapshot_routes.go

示例2: volumeSnapshot

func (r *router) volumeSnapshot(
	ctx types.Context,
	w http.ResponseWriter,
	req *http.Request,
	store types.Store) error {

	service := context.MustService(ctx)

	run := func(
		ctx types.Context,
		svc types.StorageService) (interface{}, error) {

		return svc.Driver().VolumeSnapshot(
			ctx,
			store.GetString("volumeID"),
			store.GetString("snapshotName"),
			store)
	}

	return httputils.WriteTask(
		ctx,
		r.config,
		w,
		store,
		service.TaskExecute(ctx, run, schema.SnapshotSchema),
		http.StatusCreated)
}
开发者ID:emccode,项目名称:libstorage,代码行数:27,代码来源:volume_routes.go

示例3: volumeDetach

func (r *router) volumeDetach(
	ctx types.Context,
	w http.ResponseWriter,
	req *http.Request,
	store types.Store) error {

	service := context.MustService(ctx)
	if _, ok := context.InstanceID(ctx); !ok {
		return utils.NewMissingInstanceIDError(service.Name())
	}

	run := func(
		ctx types.Context,
		svc types.StorageService) (interface{}, error) {

		v, err := svc.Driver().VolumeDetach(
			ctx,
			store.GetString("volumeID"),
			&types.VolumeDetachOpts{
				Force: store.GetBool("force"),
				Opts:  store,
			})

		if err != nil {
			return nil, err
		}

		if v == nil {
			return nil, nil
		}

		if OnVolume != nil {
			ok, err := OnVolume(ctx, req, store, v)
			if err != nil {
				return nil, err
			}
			if !ok {
				return nil, utils.NewNotFoundError(v.ID)
			}
		}

		if v.AttachmentState == 0 {
			v.AttachmentState = types.VolumeAvailable
		}

		return v, nil
	}

	return httputils.WriteTask(
		ctx,
		r.config,
		w,
		store,
		service.TaskExecute(ctx, run, nil),
		http.StatusResetContent)
}
开发者ID:emccode,项目名称:libstorage,代码行数:56,代码来源:volume_routes.go

示例4: volumeAttach

func (r *router) volumeAttach(
	ctx types.Context,
	w http.ResponseWriter,
	req *http.Request,
	store types.Store) error {

	service := context.MustService(ctx)
	if _, ok := context.InstanceID(ctx); !ok {
		return utils.NewMissingInstanceIDError(service.Name())
	}

	run := func(
		ctx types.Context,
		svc types.StorageService) (interface{}, error) {

		v, attTokn, err := svc.Driver().VolumeAttach(
			ctx,
			store.GetString("volumeID"),
			&types.VolumeAttachOpts{
				NextDevice: store.GetStringPtr("nextDeviceName"),
				Force:      store.GetBool("force"),
				Opts:       store,
			})

		if err != nil {
			return nil, err
		}

		if OnVolume != nil {
			ok, err := OnVolume(ctx, req, store, v)
			if err != nil {
				return nil, err
			}
			if !ok {
				return nil, utils.NewNotFoundError(v.ID)
			}
		}

		if v.AttachmentState == 0 {
			v.AttachmentState = types.VolumeAttached
		}

		return &types.VolumeAttachResponse{
			Volume:      v,
			AttachToken: attTokn,
		}, nil
	}

	return httputils.WriteTask(
		ctx,
		r.config,
		w,
		store,
		service.TaskExecute(ctx, run, schema.VolumeAttachResponseSchema),
		http.StatusOK)
}
开发者ID:emccode,项目名称:libstorage,代码行数:56,代码来源:volume_routes.go

示例5: parseFilter

func parseFilter(store types.Store) (*types.Filter, error) {
	if !store.IsSet("filter") {
		return nil, nil
	}
	fsz := store.GetString("filter")
	filter, err := filters.CompileFilter(fsz)
	if err != nil {
		return nil, utils.NewBadFilterErr(fsz, err)
	}
	return filter, nil
}
开发者ID:emccode,项目名称:libstorage,代码行数:11,代码来源:volume_routes.go

示例6: volumeCreate

func (r *router) volumeCreate(
	ctx types.Context,
	w http.ResponseWriter,
	req *http.Request,
	store types.Store) error {

	service := context.MustService(ctx)

	run := func(
		ctx types.Context,
		svc types.StorageService) (interface{}, error) {

		v, err := svc.Driver().VolumeCreate(
			ctx,
			store.GetString("name"),
			&types.VolumeCreateOpts{
				AvailabilityZone: store.GetStringPtr("availabilityZone"),
				IOPS:             store.GetInt64Ptr("iops"),
				Size:             store.GetInt64Ptr("size"),
				Type:             store.GetStringPtr("type"),
				Encrypted:        store.GetBoolPtr("encrypted"),
				EncryptionKey:    store.GetStringPtr("encryptionKey"),
				Opts:             store,
			})

		if err != nil {
			return nil, err
		}

		if OnVolume != nil {
			ok, err := OnVolume(ctx, req, store, v)
			if err != nil {
				return nil, err
			}
			if !ok {
				return nil, utils.NewNotFoundError(v.ID)
			}
		}

		if v.AttachmentState == 0 {
			v.AttachmentState = types.VolumeAvailable
		}
		return v, nil
	}

	return httputils.WriteTask(
		ctx,
		r.config,
		w,
		store,
		service.TaskExecute(ctx, run, schema.VolumeSchema),
		http.StatusCreated)
}
开发者ID:emccode,项目名称:libstorage,代码行数:53,代码来源:volume_routes.go

示例7: executorHead

func (r *router) executorHead(
	ctx types.Context,
	w http.ResponseWriter,
	req *http.Request,
	store types.Store) error {

	ei, err := executors.ExecutorInfoInspect(store.GetString("executor"), false)
	if err != nil {
		return err
	}

	return writeFile(w, ei)
}
开发者ID:emccode,项目名称:libstorage,代码行数:13,代码来源:executor_routes.go

示例8: volumeCopy

func (r *router) volumeCopy(
	ctx types.Context,
	w http.ResponseWriter,
	req *http.Request,
	store types.Store) error {

	service := context.MustService(ctx)

	run := func(
		ctx types.Context,
		svc types.StorageService) (interface{}, error) {

		v, err := svc.Driver().VolumeCopy(
			ctx,
			store.GetString("volumeID"),
			store.GetString("volumeName"),
			store)

		if err != nil {
			return nil, err
		}

		if OnVolume != nil {
			ok, err := OnVolume(ctx, req, store, v)
			if err != nil {
				return nil, err
			}
			if !ok {
				return nil, utils.NewNotFoundError(v.ID)
			}
		}

		if v.AttachmentState == 0 {
			v.AttachmentState = types.VolumeAvailable
		}
		return v, nil
	}

	return httputils.WriteTask(
		ctx,
		r.config,
		w,
		store,
		service.TaskExecute(ctx, run, schema.VolumeSchema),
		http.StatusCreated)
}
开发者ID:emccode,项目名称:libstorage,代码行数:46,代码来源:volume_routes.go

示例9: Handle

// Handle is the type's Handler function.
func (h *serviceValidator) Handle(
	ctx types.Context,
	w http.ResponseWriter,
	req *http.Request,
	store types.Store) error {

	if !store.IsSet("service") {
		return utils.NewStoreKeyErr("service")
	}

	serviceName := store.GetString("service")
	service := services.GetStorageService(ctx, serviceName)
	if service == nil {
		return utils.NewNotFoundError(serviceName)
	}

	ctx = context.WithStorageService(ctx, service)
	return h.handler(ctx, w, req, store)
}
开发者ID:emccode,项目名称:libstorage,代码行数:20,代码来源:handlers_service_validator.go

示例10: volumeInspect

func (r *router) volumeInspect(
	ctx types.Context,
	w http.ResponseWriter,
	req *http.Request,
	store types.Store) error {

	attachments := store.GetAttachments()

	service := context.MustService(ctx)
	iid, iidOK := context.InstanceID(ctx)
	if !iidOK && attachments.RequiresInstanceID() {
		return utils.NewMissingInstanceIDError(service.Name())
	}

	opts := &types.VolumeInspectOpts{
		Attachments: attachments,
		Opts:        store,
	}

	var run types.StorageTaskRunFunc
	if store.IsSet("byName") {
		run = func(
			ctx types.Context,
			svc types.StorageService) (interface{}, error) {

			vols, err := svc.Driver().Volumes(
				ctx,
				&types.VolumesOpts{
					Attachments: attachments,
					Opts:        store,
				})

			if err != nil {
				return nil, err
			}

			volID := store.GetString("volumeID")
			for _, v := range vols {
				if strings.EqualFold(v.Name, volID) {
					if !handleVolAttachments(ctx, nil, iid, v, attachments) {
						return nil, utils.NewNotFoundError(volID)
					}
					if OnVolume != nil {
						ok, err := OnVolume(ctx, req, store, v)
						if err != nil {
							return nil, err
						}
						if !ok {
							return nil, utils.NewNotFoundError(volID)
						}
					}

					return v, nil
				}
			}

			return nil, utils.NewNotFoundError(volID)
		}

	} else {

		run = func(
			ctx types.Context,
			svc types.StorageService) (interface{}, error) {

			v, err := svc.Driver().VolumeInspect(
				ctx, store.GetString("volumeID"), opts)

			if err != nil {
				return nil, err
			}

			if !handleVolAttachments(ctx, nil, iid, v, attachments) {
				return nil, utils.NewNotFoundError(v.ID)
			}

			if OnVolume != nil {
				ok, err := OnVolume(ctx, req, store, v)
				if err != nil {
					return nil, err
				}
				if !ok {
					return nil, utils.NewNotFoundError(v.ID)
				}
			}

			return v, nil
		}
	}

	return httputils.WriteTask(
		ctx,
		r.config,
		w,
		store,
		service.TaskExecute(ctx, run, schema.VolumeSchema),
		http.StatusOK)
}
开发者ID:emccode,项目名称:libstorage,代码行数:98,代码来源:volume_routes.go


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