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


Golang Context.Join方法代码示例

本文整理汇总了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
}
开发者ID:emccode,项目名称:libstorage,代码行数:28,代码来源:registry_integration.go

示例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)
}
开发者ID:emccode,项目名称:libstorage,代码行数:7,代码来源:registry_os.go

示例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
}
开发者ID:emccode,项目名称:libstorage,代码行数:34,代码来源:libstorage_client_xcli.go

示例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)
}
开发者ID:emccode,项目名称:libstorage,代码行数:7,代码来源:registry_os.go

示例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
}
开发者ID:emccode,项目名称:libstorage,代码行数:33,代码来源:registry_integration.go

示例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)
}
开发者ID:emccode,项目名称:libstorage,代码行数:8,代码来源:registry_os.go

示例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)
}
开发者ID:emccode,项目名称:libstorage,代码行数:8,代码来源:libstorage_utils.go

示例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)
}
开发者ID:emccode,项目名称:libstorage,代码行数:8,代码来源:registry_os.go

示例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)
}
开发者ID:emccode,项目名称:libstorage,代码行数:12,代码来源:registry_os.go

示例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)
}
开发者ID:emccode,项目名称:libstorage,代码行数:12,代码来源:registry_integration.go

示例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
}
开发者ID:emccode,项目名称:libstorage,代码行数:53,代码来源:libstorage_client_xcli.go

示例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)

}
开发者ID:emccode,项目名称:libstorage,代码行数:13,代码来源:registry_integration.go

示例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)
}
开发者ID:emccode,项目名称:libstorage,代码行数:16,代码来源:registry_integration.go

示例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)
}
开发者ID:emccode,项目名称:libstorage,代码行数:16,代码来源:registry_integration.go

示例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
}
开发者ID:emccode,项目名称:libstorage,代码行数:44,代码来源:libstorage_client_xcli.go


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