本文整理匯總了Golang中github.com/juju/juju/state.StorageInstance.Kind方法的典型用法代碼示例。如果您正苦於以下問題:Golang StorageInstance.Kind方法的具體用法?Golang StorageInstance.Kind怎麽用?Golang StorageInstance.Kind使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/juju/state.StorageInstance
的用法示例。
在下文中一共展示了StorageInstance.Kind方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: isPersistent
// TODO(axw) move this and createParamsStorageInstance to
// apiserver/common/storage.go, alongside StorageAttachmentInfo.
func (api *API) isPersistent(si state.StorageInstance) (bool, error) {
if si.Kind() != state.StorageKindBlock {
// TODO(axw) when we support persistent filesystems,
// e.g. CephFS, we'll need to do the same thing as
// we do for volumes for filesystems.
return false, nil
}
volume, err := api.storage.StorageInstanceVolume(si.StorageTag())
if err != nil {
return false, err
}
// If the volume is not provisioned, we read its config attributes.
if params, ok := volume.Params(); ok {
_, cfg, err := common.StoragePoolConfig(params.Pool, api.poolManager)
if err != nil {
return false, err
}
return cfg.IsPersistent(), nil
}
// If the volume is provisioned, we look at its provisioning info.
info, err := volume.Info()
if err != nil {
return false, err
}
return info.Persistent, nil
}
示例2: 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
}
示例3: 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
}