本文整理匯總了Golang中github.com/juju/juju/state.Volume.VolumeTag方法的典型用法代碼示例。如果您正苦於以下問題:Golang Volume.VolumeTag方法的具體用法?Golang Volume.VolumeTag怎麽用?Golang Volume.VolumeTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/juju/state.Volume
的用法示例。
在下文中一共展示了Volume.VolumeTag方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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
}
示例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
}
示例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
}
示例4: createVolumeDetails
func createVolumeDetails(
st storageAccess, v state.Volume, attachments []state.VolumeAttachment,
) (*params.VolumeDetails, error) {
details := ¶ms.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
}