本文整理汇总了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)
}
示例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)
}
示例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)
}
示例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)
}
示例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
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}
示例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)
}