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


Golang Volume.Info方法代码示例

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


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

示例1: convertStateVolumeToParams

func (a *API) convertStateVolumeToParams(st state.Volume) (params.VolumeInstance, error) {
	volume := params.VolumeInstance{VolumeTag: st.VolumeTag().String()}

	if storage, err := st.StorageInstance(); err == nil {
		volume.StorageTag = storage.String()
		storageInstance, err := a.storage.StorageInstance(storage)
		if err != nil {
			err = errors.Annotatef(err,
				"getting storage instance %v for volume %v",
				storage, volume.VolumeTag)
			return params.VolumeInstance{}, err
		}
		owner := storageInstance.Owner()
		// only interested in Unit for now
		if unitTag, ok := owner.(names.UnitTag); ok {
			volume.UnitTag = unitTag.String()
		}
	}
	if info, err := st.Info(); err == nil {
		volume.HardwareId = info.HardwareId
		volume.Size = info.Size
		volume.Persistent = info.Persistent
		volume.VolumeId = info.VolumeId
	}
	status, err := st.Status()
	if err != nil {
		return params.VolumeInstance{}, errors.Trace(err)
	}
	volume.Status = common.EntityStatusFromState(status)
	return volume, nil
}
开发者ID:mhilton,项目名称:juju,代码行数:31,代码来源:storage.go

示例2: VolumeFromState

// VolumeFromState converts a state.Volume to params.Volume.
func VolumeFromState(v state.Volume) (params.Volume, error) {
	info, err := v.Info()
	if err != nil {
		return params.Volume{}, errors.Trace(err)
	}
	return params.Volume{
		v.VolumeTag().String(),
		VolumeInfoFromState(info),
	}, nil
}
开发者ID:bac,项目名称:juju,代码行数:11,代码来源:volumes.go

示例3: VolumeFromState

// VolumeFromState converts a state.Volume to params.Volume.
func VolumeFromState(v state.Volume) (params.Volume, error) {
	info, err := v.Info()
	if err != nil {
		return params.Volume{}, errors.Trace(err)
	}
	return params.Volume{
		v.VolumeTag().String(),
		params.VolumeInfo{
			info.VolumeId,
			info.HardwareId,
			info.Size,
			info.Persistent,
		},
	}, nil
}
开发者ID:mhilton,项目名称:juju,代码行数:16,代码来源:volumes.go

示例4: createVolumeDetails

func createVolumeDetails(
	st storageAccess, v state.Volume, attachments []state.VolumeAttachment,
) (*params.VolumeDetails, error) {

	details := &params.VolumeDetails{
		VolumeTag: v.VolumeTag().String(),
	}

	if info, err := v.Info(); err == nil {
		details.Info = storagecommon.VolumeInfoFromState(info)
	}

	if len(attachments) > 0 {
		details.MachineAttachments = make(map[string]params.VolumeAttachmentInfo, len(attachments))
		for _, attachment := range attachments {
			stateInfo, err := attachment.Info()
			var info params.VolumeAttachmentInfo
			if err == nil {
				info = storagecommon.VolumeAttachmentInfoFromState(stateInfo)
			}
			details.MachineAttachments[attachment.Machine().String()] = info
		}
	}

	status, err := v.Status()
	if err != nil {
		return nil, errors.Trace(err)
	}
	details.Status = common.EntityStatusFromState(status)

	if storageTag, err := v.StorageInstance(); err == nil {
		storageInstance, err := st.StorageInstance(storageTag)
		if err != nil {
			return nil, errors.Trace(err)
		}
		storageDetails, err := createStorageDetails(st, storageInstance)
		if err != nil {
			return nil, errors.Trace(err)
		}
		details.Storage = storageDetails
	}

	return details, nil
}
开发者ID:kat-co,项目名称:juju,代码行数:44,代码来源:storage.go

示例5: VolumeParams

// VolumeParams returns the parameters for creating or destroying
// the given volume.
func VolumeParams(
	v state.Volume,
	storageInstance state.StorageInstance,
	modelUUID, controllerUUID string,
	environConfig *config.Config,
	poolManager poolmanager.PoolManager,
	registry storage.ProviderRegistry,
) (params.VolumeParams, error) {

	var pool string
	var size uint64
	if stateVolumeParams, ok := v.Params(); ok {
		pool = stateVolumeParams.Pool
		size = stateVolumeParams.Size
	} else {
		volumeInfo, err := v.Info()
		if err != nil {
			return params.VolumeParams{}, errors.Trace(err)
		}
		pool = volumeInfo.Pool
		size = volumeInfo.Size
	}

	volumeTags, err := storageTags(storageInstance, modelUUID, controllerUUID, environConfig)
	if err != nil {
		return params.VolumeParams{}, errors.Annotate(err, "computing storage tags")
	}

	providerType, cfg, err := StoragePoolConfig(pool, poolManager, registry)
	if err != nil {
		return params.VolumeParams{}, errors.Trace(err)
	}
	return params.VolumeParams{
		v.Tag().String(),
		size,
		string(providerType),
		cfg.Attrs(),
		volumeTags,
		nil, // attachment params set by the caller
	}, nil
}
开发者ID:bac,项目名称:juju,代码行数:43,代码来源:volumes.go


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