本文整理匯總了Golang中github.com/juju/juju/state.StorageAttachment.Unit方法的典型用法代碼示例。如果您正苦於以下問題:Golang StorageAttachment.Unit方法的具體用法?Golang StorageAttachment.Unit怎麽用?Golang StorageAttachment.Unit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/juju/juju/state.StorageAttachment
的用法示例。
在下文中一共展示了StorageAttachment.Unit方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: createParamsStorageAttachment
func (api *API) createParamsStorageAttachment(si params.StorageDetails, sa state.StorageAttachment) (params.StorageDetails, error) {
result := params.StorageDetails{Status: "pending"}
result.StorageTag = sa.StorageInstance().String()
if result.StorageTag != si.StorageTag {
panic("attachment does not belong to storage instance")
}
result.UnitTag = sa.Unit().String()
result.OwnerTag = si.OwnerTag
result.Kind = si.Kind
result.Persistent = si.Persistent
// TODO(axw) set status according to whether storage has been provisioned.
// This is only for provisioned attachments
machineTag, err := api.storage.UnitAssignedMachine(sa.Unit())
if err != nil {
return params.StorageDetails{}, errors.Annotate(err, "getting unit for storage attachment")
}
info, err := common.StorageAttachmentInfo(api.storage, sa, machineTag)
if err != nil {
if errors.IsNotProvisioned(err) {
// If Info returns an error, then the storage has not yet been provisioned.
return result, nil
}
return params.StorageDetails{}, errors.Annotate(err, "getting storage attachment info")
}
result.Location = info.Location
if result.Location != "" {
result.Status = "attached"
}
return result, nil
}
示例2: storageAttachmentInfo
func storageAttachmentInfo(st storageAccess, a state.StorageAttachment) (_ names.MachineTag, location string, _ error) {
machineTag, err := st.UnitAssignedMachine(a.Unit())
if errors.IsNotAssigned(err) {
return names.MachineTag{}, "", nil
} else if err != nil {
return names.MachineTag{}, "", errors.Trace(err)
}
info, err := storagecommon.StorageAttachmentInfo(st, a, machineTag)
if errors.IsNotProvisioned(err) {
return machineTag, "", nil
} else if err != nil {
return names.MachineTag{}, "", errors.Trace(err)
}
return machineTag, info.Location, nil
}
示例3: fromStateStorageAttachment
func (s *StorageAPI) fromStateStorageAttachment(stateStorageAttachment state.StorageAttachment) (params.StorageAttachment, error) {
machineTag, err := s.st.UnitAssignedMachine(stateStorageAttachment.Unit())
if err != nil {
return params.StorageAttachment{}, err
}
info, err := common.StorageAttachmentInfo(s.st, stateStorageAttachment, machineTag)
if err != nil {
return params.StorageAttachment{}, err
}
stateStorageInstance, err := s.st.StorageInstance(stateStorageAttachment.StorageInstance())
if err != nil {
return params.StorageAttachment{}, err
}
return params.StorageAttachment{
stateStorageAttachment.StorageInstance().String(),
stateStorageInstance.Owner().String(),
stateStorageAttachment.Unit().String(),
params.StorageKind(stateStorageInstance.Kind()),
info.Location,
params.Life(stateStorageAttachment.Life().String()),
}, nil
}