本文整理汇总了Golang中github.com/codedellemc/libstorage/api/types.Context.Join方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Join方法的具体用法?Golang Context.Join怎么用?Golang Context.Join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/codedellemc/libstorage/api/types.Context
的用法示例。
在下文中一共展示了Context.Join方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Mount
func (d *idm) Mount(
ctx types.Context,
volumeID, volumeName string,
opts *types.VolumeMountOpts) (string, *types.Volume, error) {
opts.Preempt = d.preempt()
fields := log.Fields{
"volumeName": volumeName,
"volumeID": volumeID,
"opts": opts}
ctx.WithFields(fields).Debug("mounting volume")
mp, vol, err := d.IntegrationDriver.Mount(
ctx.Join(d.ctx), volumeID, volumeName, opts)
if err != nil {
return "", nil, err
}
// if the volume has attachments assign the new mount point to the
// MountPoint field of the first attachment element
if len(vol.Attachments) > 0 {
vol.Attachments[0].MountPoint = mp
}
d.incCount(volumeName)
return mp, vol, err
}
示例2: IsMounted
func (d *odm) IsMounted(
ctx types.Context,
mountPoint string,
opts types.Store) (bool, error) {
return d.OSDriver.IsMounted(ctx.Join(d.Context), mountPoint, opts)
}
示例3: NextDevice
func (c *client) NextDevice(
ctx types.Context,
opts types.Store) (string, error) {
if c.isController() {
return "", utils.NewUnsupportedForClientTypeError(
c.clientType, "NextDevice")
}
if supported, _ := c.Supported(ctx, opts); !supported {
return "", errExecutorNotSupported
}
ctx = context.RequireTX(ctx.Join(c.ctx))
serviceName, ok := context.ServiceName(ctx)
if !ok {
return "", goof.New("missing service name")
}
si, err := c.getServiceInfo(serviceName)
if err != nil {
return "", err
}
driverName := si.Driver.Name
out, err := c.runExecutor(ctx, driverName, types.LSXCmdNextDevice)
if err != nil {
return "", err
}
ctx.Debug("xli nextdevice success")
return gotil.Trim(string(out)), nil
}
示例4: Unmount
func (d *odm) Unmount(
ctx types.Context,
mountPoint string,
opts types.Store) error {
return d.OSDriver.Unmount(ctx.Join(d.Context), mountPoint, opts)
}
示例5: List
func (d *idm) List(
ctx types.Context,
opts types.Store) ([]types.VolumeMapping, error) {
fields := log.Fields{
"opts": opts}
ctx.WithFields(fields).Debug("listing volumes")
volMaps, err := d.IntegrationDriver.List(ctx.Join(d.ctx), opts)
if err != nil {
return nil, err
}
volMapsWithNames := []types.VolumeMapping{}
for _, vm := range volMaps {
if vm.VolumeName() != "" {
volMapsWithNames = append(volMapsWithNames, vm)
}
}
if !d.pathCacheEnabled() {
return volMapsWithNames, nil
}
for _, vm := range volMapsWithNames {
vmn := vm.VolumeName()
if !d.isCounted(vmn) && vm.MountPoint() != "" {
d.initCount(vmn)
}
}
return volMapsWithNames, nil
}
示例6: Mounts
func (d *odm) Mounts(
ctx types.Context,
deviceName, mountPoint string,
opts types.Store) ([]*types.MountInfo, error) {
ctx = ctx.Join(d.Context)
return d.OSDriver.Mounts(ctx.Join(d.Context), deviceName, mountPoint, opts)
}
示例7: requireCtx
func (c *client) requireCtx(ctx types.Context) types.Context {
if ctx == nil {
ctx = c.ctx
} else {
ctx = ctx.Join(c.ctx)
}
return context.RequireTX(ctx)
}
示例8: Mount
func (d *odm) Mount(
ctx types.Context,
deviceName, mountPoint string,
opts *types.DeviceMountOpts) error {
ctx = ctx.Join(d.Context)
return d.OSDriver.Mount(ctx.Join(d.Context), deviceName, mountPoint, opts)
}
示例9: Format
func (d *odm) Format(
ctx types.Context,
deviceName string,
opts *types.DeviceFormatOpts) error {
ctx = ctx.Join(d.Context)
if strings.Contains(deviceName, ":") {
return nil
}
return d.OSDriver.Format(ctx, deviceName, opts)
}
示例10: Inspect
func (d *idm) Inspect(
ctx types.Context,
volumeName string,
opts types.Store) (types.VolumeMapping, error) {
fields := log.Fields{
"volumeName": volumeName,
"opts": opts}
ctx.WithFields(fields).Debug("inspecting volume")
return d.IntegrationDriver.Inspect(ctx.Join(d.ctx), volumeName, opts)
}
示例11: Supported
func (c *client) Supported(
ctx types.Context,
opts types.Store) (bool, error) {
if c.isController() {
return false, utils.NewUnsupportedForClientTypeError(
c.clientType, "Supported")
}
ctx = context.RequireTX(ctx.Join(c.ctx))
serviceName, ok := context.ServiceName(ctx)
if !ok {
return false, goof.New("missing service name")
}
si, err := c.getServiceInfo(serviceName)
if err != nil {
return false, err
}
driverName := strings.ToLower(si.Driver.Name)
// check to see if the driver's executor is supported on this host
if ok := c.supportedCache.IsSet(driverName); ok {
return c.supportedCache.GetBool(driverName), nil
}
out, err := c.runExecutor(ctx, driverName, types.LSXCmdSupported)
if err != nil {
if err == types.ErrNotImplemented {
ctx.WithField("serviceDriver", driverName).Warn(
"supported cmd not implemented")
c.supportedCache.Set(driverName, true)
ctx.WithField("supported", true).Debug("cached supported flag")
return true, nil
}
return false, err
}
if len(out) == 0 {
return false, nil
}
out = bytes.TrimSpace(out)
b, err := strconv.ParseBool(string(out))
if err != nil {
return false, err
}
c.supportedCache.Set(driverName, b)
ctx.WithField("supported", b).Debug("cached supported flag")
return b, nil
}
示例12: Detach
func (d *idm) Detach(
ctx types.Context,
volumeName string,
opts *types.VolumeDetachOpts) error {
fields := log.Fields{
"volumeName": volumeName,
"opts": opts}
ctx.WithFields(fields).Debug("detaching volume")
return d.IntegrationDriver.Detach(ctx.Join(d.ctx), volumeName, opts)
}
示例13: Remove
func (d *idm) Remove(
ctx types.Context,
volumeName string,
opts types.Store) error {
fields := log.Fields{
"volumeName": volumeName,
"opts": opts}
ctx.WithFields(fields).Debug("removing volume")
if d.disableRemove() {
ctx.Debug("disableRemove skipped deletion")
return nil
}
return d.IntegrationDriver.Remove(ctx.Join(d.ctx), volumeName, opts)
}
示例14: Create
func (d *idm) Create(
ctx types.Context,
volumeName string,
opts *types.VolumeCreateOpts) (*types.Volume, error) {
fields := log.Fields{
"volumeName": volumeName,
"opts": opts}
ctx.WithFields(fields).Debug("creating volume")
if d.disableCreate() {
ctx.Debug("disableRemove skipped creation")
return nil, nil
}
return d.IntegrationDriver.Create(ctx.Join(d.ctx), volumeName, opts)
}
示例15: WaitForDevice
func (c *client) WaitForDevice(
ctx types.Context,
opts *types.WaitForDeviceOpts) (bool, *types.LocalDevices, error) {
if c.isController() {
return false, nil, utils.NewUnsupportedForClientTypeError(
c.clientType, "WaitForDevice")
}
if supported, _ := c.Supported(ctx, opts.Opts); !supported {
return false, nil, errExecutorNotSupported
}
ctx = context.RequireTX(ctx.Join(c.ctx))
serviceName, ok := context.ServiceName(ctx)
if !ok {
return false, nil, goof.New("missing service name")
}
si, err := c.getServiceInfo(serviceName)
if err != nil {
return false, nil, err
}
driverName := si.Driver.Name
out, err := c.runExecutor(
ctx, driverName, types.LSXCmdWaitForDevice,
opts.ScanType.String(), opts.Token, opts.Timeout.String())
if err != types.ErrTimedOut {
return false, nil, err
}
matched := err == nil
ld, err := unmarshalLocalDevices(ctx, out)
if err != nil {
return false, nil, err
}
ctx.Debug("xli waitfordevice success")
return matched, ld, nil
}