本文整理汇总了Golang中github.com/juju/juju/state.StorageInstance.Owner方法的典型用法代码示例。如果您正苦于以下问题:Golang StorageInstance.Owner方法的具体用法?Golang StorageInstance.Owner怎么用?Golang StorageInstance.Owner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/state.StorageInstance
的用法示例。
在下文中一共展示了StorageInstance.Owner方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: createStorageDetails
func createStorageDetails(st storageAccess, si state.StorageInstance) (*params.StorageDetails, error) {
// Get information from underlying volume or filesystem.
var persistent bool
var statusEntity status.StatusGetter
if si.Kind() != state.StorageKindBlock {
// TODO(axw) when we support persistent filesystems,
// e.g. CephFS, we'll need to do set "persistent"
// here too.
filesystem, err := st.StorageInstanceFilesystem(si.StorageTag())
if err != nil {
return nil, errors.Trace(err)
}
statusEntity = filesystem
} else {
volume, err := st.StorageInstanceVolume(si.StorageTag())
if err != nil {
return nil, errors.Trace(err)
}
if info, err := volume.Info(); err == nil {
persistent = info.Persistent
}
statusEntity = volume
}
status, err := statusEntity.Status()
if err != nil {
return nil, errors.Trace(err)
}
// Get unit storage attachments.
var storageAttachmentDetails map[string]params.StorageAttachmentDetails
storageAttachments, err := st.StorageAttachments(si.StorageTag())
if err != nil {
return nil, errors.Trace(err)
}
if len(storageAttachments) > 0 {
storageAttachmentDetails = make(map[string]params.StorageAttachmentDetails)
for _, a := range storageAttachments {
machineTag, location, err := storageAttachmentInfo(st, a)
if err != nil {
return nil, errors.Trace(err)
}
details := params.StorageAttachmentDetails{
a.StorageInstance().String(),
a.Unit().String(),
machineTag.String(),
location,
}
storageAttachmentDetails[a.Unit().String()] = details
}
}
return ¶ms.StorageDetails{
StorageTag: si.Tag().String(),
OwnerTag: si.Owner().String(),
Kind: params.StorageKind(si.Kind()),
Status: common.EntityStatusFromState(status),
Persistent: persistent,
Attachments: storageAttachmentDetails,
}, nil
}
示例2: createParamsStorageInstance
func createParamsStorageInstance(si state.StorageInstance, persistent bool) params.StorageDetails {
result := params.StorageDetails{
OwnerTag: si.Owner().String(),
StorageTag: si.Tag().String(),
Kind: params.StorageKind(si.Kind()),
Status: "pending",
Persistent: persistent,
}
return result
}
示例3: storageTags
// storageTags returns the tags that should be set on a volume or filesystem,
// if the provider supports them.
func storageTags(
storageInstance state.StorageInstance,
cfg *config.Config,
) (map[string]string, error) {
storageTags := tags.ResourceTags(names.NewModelTag(cfg.UUID()), cfg)
if storageInstance != nil {
storageTags[tags.JujuStorageInstance] = storageInstance.Tag().Id()
storageTags[tags.JujuStorageOwner] = storageInstance.Owner().Id()
}
return storageTags, nil
}
示例4: storageTags
// storageTags returns the tags that should be set on a volume or filesystem,
// if the provider supports them.
func storageTags(
storageInstance state.StorageInstance,
modelUUID, controllerUUID string,
tagger tags.ResourceTagger,
) (map[string]string, error) {
storageTags := tags.ResourceTags(
names.NewModelTag(modelUUID),
names.NewControllerTag(controllerUUID),
tagger,
)
if storageInstance != nil {
storageTags[tags.JujuStorageInstance] = storageInstance.Tag().Id()
storageTags[tags.JujuStorageOwner] = storageInstance.Owner().Id()
}
return storageTags, nil
}