本文整理汇总了Golang中github.com/juju/juju/state.Filesystem类的典型用法代码示例。如果您正苦于以下问题:Golang Filesystem类的具体用法?Golang Filesystem怎么用?Golang Filesystem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Filesystem类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: createFilesystemDetails
func createFilesystemDetails(
st storageAccess, f state.Filesystem, attachments []state.FilesystemAttachment,
) (*params.FilesystemDetails, error) {
details := ¶ms.FilesystemDetails{
FilesystemTag: f.FilesystemTag().String(),
}
if volumeTag, err := f.Volume(); err == nil {
details.VolumeTag = volumeTag.String()
}
if info, err := f.Info(); err == nil {
details.Info = storagecommon.FilesystemInfoFromState(info)
}
if len(attachments) > 0 {
details.MachineAttachments = make(map[string]params.FilesystemAttachmentInfo, len(attachments))
for _, attachment := range attachments {
stateInfo, err := attachment.Info()
var info params.FilesystemAttachmentInfo
if err == nil {
info = storagecommon.FilesystemAttachmentInfoFromState(stateInfo)
}
details.MachineAttachments[attachment.Machine().String()] = info
}
}
status, err := f.Status()
if err != nil {
return nil, errors.Trace(err)
}
details.Status = common.EntityStatusFromState(status)
if storageTag, err := f.Storage(); 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,代码行数:48,代码来源:storage.go
示例2: FilesystemParams
// FilesystemParams returns the parameters for creating or destroying the
// given filesystem.
func FilesystemParams(
f state.Filesystem,
storageInstance state.StorageInstance,
modelUUID, controllerUUID string,
environConfig *config.Config,
poolManager poolmanager.PoolManager,
registry storage.ProviderRegistry,
) (params.FilesystemParams, error) {
var pool string
var size uint64
if stateFilesystemParams, ok := f.Params(); ok {
pool = stateFilesystemParams.Pool
size = stateFilesystemParams.Size
} else {
filesystemInfo, err := f.Info()
if err != nil {
return params.FilesystemParams{}, errors.Trace(err)
}
pool = filesystemInfo.Pool
size = filesystemInfo.Size
}
filesystemTags, err := storageTags(storageInstance, modelUUID, controllerUUID, environConfig)
if err != nil {
return params.FilesystemParams{}, errors.Annotate(err, "computing storage tags")
}
providerType, cfg, err := StoragePoolConfig(pool, poolManager, registry)
if err != nil {
return params.FilesystemParams{}, errors.Trace(err)
}
result := params.FilesystemParams{
f.Tag().String(),
"", // volume tag
size,
string(providerType),
cfg.Attrs(),
filesystemTags,
nil, // attachment params set by the caller
}
volumeTag, err := f.Volume()
if err == nil {
result.VolumeTag = volumeTag.String()
} else if err != state.ErrNoBackingVolume {
return params.FilesystemParams{}, errors.Trace(err)
}
return result, nil
}
开发者ID:bac,项目名称:juju,代码行数:53,代码来源:filesystems.go
示例3: FilesystemFromState
// FilesystemFromState converts a state.Filesystem to params.Filesystem.
func FilesystemFromState(f state.Filesystem) (params.Filesystem, error) {
info, err := f.Info()
if err != nil {
return params.Filesystem{}, errors.Trace(err)
}
result := params.Filesystem{
f.FilesystemTag().String(),
"",
FilesystemInfoFromState(info),
}
volumeTag, err := f.Volume()
if err == nil {
result.VolumeTag = volumeTag.String()
} else if err != state.ErrNoBackingVolume {
return params.Filesystem{}, errors.Trace(err)
}
return result, nil
}
开发者ID:imoapps,项目名称:juju,代码行数:19,代码来源:filesystems.go
注:本文中的github.com/juju/juju/state.Filesystem类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论