本文整理汇总了Golang中github.com/juju/errors.NotProvisionedf函数的典型用法代码示例。如果您正苦于以下问题:Golang NotProvisionedf函数的具体用法?Golang NotProvisionedf怎么用?Golang NotProvisionedf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了NotProvisionedf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: Authenticate
// Authenticate authenticates the provided entity.
// It takes an entityfinder and the tag used to find the entity that requires authentication.
func (*AgentAuthenticator) Authenticate(entityFinder EntityFinder, tag names.Tag, req params.LoginRequest) (state.Entity, error) {
entity, err := entityFinder.FindEntity(tag)
if errors.IsNotFound(err) {
return nil, errors.Trace(common.ErrBadCreds)
}
if err != nil {
return nil, errors.Trace(err)
}
authenticator, ok := entity.(taggedAuthenticator)
if !ok {
return nil, errors.Trace(common.ErrBadRequest)
}
if !authenticator.PasswordValid(req.Credentials) {
return nil, errors.Trace(common.ErrBadCreds)
}
// If this is a machine agent connecting, we need to check the
// nonce matches, otherwise the wrong agent might be trying to
// connect.
if machine, ok := authenticator.(*state.Machine); ok {
if !machine.CheckProvisioned(req.Nonce) {
return nil, errors.NotProvisionedf("machine %v", machine.Id())
}
}
return entity, nil
}
开发者ID:imoapps,项目名称:juju,代码行数:29,代码来源:agent.go
示例2: TestProviderAddressesFailure
func (s *InstancePollerSuite) TestProviderAddressesFailure(c *gc.C) {
s.st.SetErrors(
errors.New("pow!"), // m1 := FindEntity("1")
nil, // m2 := FindEntity("2")
errors.New("FAIL"), // m2.ProviderAddresses()- unused
errors.NotProvisionedf("machine 42"), // FindEntity("3") (ensure wrapping is preserved)
)
s.st.SetMachineInfo(c, machineInfo{id: "1"})
s.st.SetMachineInfo(c, machineInfo{id: "2"})
result, err := s.api.ProviderAddresses(s.machineEntities)
c.Assert(err, jc.ErrorIsNil)
c.Assert(result, jc.DeepEquals, params.MachineAddressesResults{
Results: []params.MachineAddressesResult{
{Error: apiservertesting.ServerError("pow!")},
{Addresses: nil},
{Error: apiservertesting.NotProvisionedError("42")},
}},
)
s.st.CheckFindEntityCall(c, 0, "1")
s.st.CheckFindEntityCall(c, 1, "2")
s.st.CheckCall(c, 2, "ProviderAddresses")
s.st.CheckFindEntityCall(c, 3, "3")
}
开发者ID:bac,项目名称:juju,代码行数:25,代码来源:instancepoller_test.go
示例3: Authenticate
// Authenticate authenticates the provided entity.
// It takes an entityfinder and the tag used to find the entity that requires authentication.
func (*AgentAuthenticator) Authenticate(entityFinder EntityFinder, tag names.Tag, req params.LoginRequest) (state.Entity, error) {
entity, err := entityFinder.FindEntity(tag)
if errors.IsNotFound(err) {
return nil, errors.Trace(common.ErrBadCreds)
}
if err != nil {
return nil, errors.Trace(err)
}
authenticator, ok := entity.(taggedAuthenticator)
if !ok {
return nil, errors.Trace(common.ErrBadRequest)
}
if !authenticator.PasswordValid(req.Credentials) {
return nil, errors.Trace(common.ErrBadCreds)
}
// If this is a machine agent connecting, we need to check the
// nonce matches, otherwise the wrong agent might be trying to
// connect.
//
// NOTE(axw) with the current implementation of Login, it is
// important that we check the password before checking the
// nonce, or an unprovisioned machine in a hosted model will
// prevent a controller machine from logging into the hosted
// model.
if machine, ok := authenticator.(*state.Machine); ok {
if !machine.CheckProvisioned(req.Nonce) {
return nil, errors.NotProvisionedf("machine %v", machine.Id())
}
}
return entity, nil
}
开发者ID:bac,项目名称:juju,代码行数:35,代码来源:agent.go
示例4: TestSetInstanceStatusFailure
func (s *InstancePollerSuite) TestSetInstanceStatusFailure(c *gc.C) {
s.st.SetErrors(
errors.New("pow!"), // m1 := FindEntity("1")
nil, // m2 := FindEntity("2")
errors.New("FAIL"), // m2.SetInstanceStatus()
errors.NotProvisionedf("machine 42"), // FindEntity("3") (ensure wrapping is preserved)
)
s.st.SetMachineInfo(c, machineInfo{id: "1", instanceStatus: statusInfo("foo")})
s.st.SetMachineInfo(c, machineInfo{id: "2", instanceStatus: statusInfo("")})
result, err := s.api.SetInstanceStatus(params.SetStatus{
Entities: []params.EntityStatusArgs{
{Tag: "machine-1", Status: "new"},
{Tag: "machine-2", Status: "invalid"},
{Tag: "machine-3", Status: ""},
}},
)
c.Assert(err, jc.ErrorIsNil)
c.Assert(result, jc.DeepEquals, s.machineErrorResults)
s.st.CheckFindEntityCall(c, 0, "1")
s.st.CheckFindEntityCall(c, 1, "2")
now := s.clock.Now()
s.st.CheckCall(c, 2, "SetInstanceStatus", status.StatusInfo{Status: "invalid", Since: &now})
s.st.CheckFindEntityCall(c, 3, "3")
}
开发者ID:bac,项目名称:juju,代码行数:26,代码来源:instancepoller_test.go
示例5: TestInstanceIdFailure
func (s *InstancePollerSuite) TestInstanceIdFailure(c *gc.C) {
s.st.SetErrors(
errors.New("pow!"), // m1 := FindEntity("1"); InstanceId not called
nil, // m2 := FindEntity("2")
errors.New("FAIL"), // m2.InstanceId()
errors.NotProvisionedf("machine 42"), // FindEntity("3") (ensure wrapping is preserved)
)
s.st.SetMachineInfo(c, machineInfo{id: "1", instanceId: ""})
s.st.SetMachineInfo(c, machineInfo{id: "2", instanceId: "i-bar"})
result, err := s.api.InstanceId(s.machineEntities)
c.Assert(err, jc.ErrorIsNil)
c.Assert(result, jc.DeepEquals, params.StringResults{
Results: []params.StringResult{
{Error: apiservertesting.ServerError("pow!")},
{Error: apiservertesting.ServerError("FAIL")},
{Error: apiservertesting.NotProvisionedError("42")},
}},
)
s.st.CheckFindEntityCall(c, 0, "1")
s.st.CheckFindEntityCall(c, 1, "2")
s.st.CheckCall(c, 2, "InstanceId")
s.st.CheckFindEntityCall(c, 3, "3")
}
开发者ID:bac,项目名称:juju,代码行数:25,代码来源:instancepoller_test.go
示例6: TestAreManuallyProvisionedFailure
func (s *InstancePollerSuite) TestAreManuallyProvisionedFailure(c *gc.C) {
s.st.SetErrors(
errors.New("pow!"), // m1 := FindEntity("1")
nil, // m2 := FindEntity("2")
errors.New("FAIL"), // m2.IsManual()
errors.NotProvisionedf("machine 42"), // FindEntity("3") (ensure wrapping is preserved)
)
s.st.SetMachineInfo(c, machineInfo{id: "1", isManual: true})
s.st.SetMachineInfo(c, machineInfo{id: "2", isManual: false})
result, err := s.api.AreManuallyProvisioned(s.machineEntities)
c.Assert(err, jc.ErrorIsNil)
c.Assert(result, jc.DeepEquals, params.BoolResults{
Results: []params.BoolResult{
{Error: apiservertesting.ServerError("pow!")},
{Error: apiservertesting.ServerError("FAIL")},
{Error: apiservertesting.NotProvisionedError("42")},
}},
)
s.st.CheckFindEntityCall(c, 0, "1")
s.st.CheckFindEntityCall(c, 1, "2")
s.st.CheckCall(c, 2, "IsManual")
s.st.CheckFindEntityCall(c, 3, "3")
}
开发者ID:bac,项目名称:juju,代码行数:25,代码来源:instancepoller_test.go
示例7: TestVolumesEnviron
func (s *provisionerSuite) TestVolumesEnviron(c *gc.C) {
s.setupVolumes(c)
s.authorizer.Tag = names.NewMachineTag("2") // neither 0 nor 1
results, err := s.api.Volumes(params.Entities{
Entities: []params.Entity{
{"volume-0-0"},
{"volume-1"},
{"volume-2"},
{"volume-42"},
},
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(results, gc.DeepEquals, params.VolumeResults{
Results: []params.VolumeResult{
{Error: ¶ms.Error{Message: "permission denied", Code: "unauthorized access"}},
{Error: common.ServerError(errors.NotProvisionedf(`volume "1"`))},
{Result: params.Volume{
VolumeTag: "volume-2",
Info: params.VolumeInfo{
VolumeId: "def",
HardwareId: "456",
Size: 4096,
},
}},
{Error: ¶ms.Error{Message: "permission denied", Code: "unauthorized access"}},
},
})
}
开发者ID:bac,项目名称:juju,代码行数:29,代码来源:storageprovisioner_test.go
示例8: TestFilesystems
func (s *provisionerSuite) TestFilesystems(c *gc.C) {
s.setupFilesystems(c)
s.authorizer.Tag = names.NewMachineTag("2") // neither 0 nor 1
results, err := s.api.Filesystems(params.Entities{
Entities: []params.Entity{
{"filesystem-0-0"},
{"filesystem-1"},
{"filesystem-2"},
{"filesystem-42"},
},
})
c.Assert(err, jc.ErrorIsNil)
c.Assert(results, jc.DeepEquals, params.FilesystemResults{
Results: []params.FilesystemResult{
{Error: ¶ms.Error{Message: "permission denied", Code: "unauthorized access"}},
{Error: common.ServerError(errors.NotProvisionedf(`filesystem "1"`))},
{Result: params.Filesystem{
FilesystemTag: "filesystem-2",
Info: params.FilesystemInfo{
FilesystemId: "def",
Size: 4096,
},
}},
{Error: ¶ms.Error{Message: "permission denied", Code: "unauthorized access"}},
},
})
}
开发者ID:bac,项目名称:juju,代码行数:28,代码来源:storageprovisioner_test.go
示例9: TestLifeFailure
func (s *InstancePollerSuite) TestLifeFailure(c *gc.C) {
s.st.SetErrors(
errors.New("pow!"), // m1 := FindEntity("1"); Life not called
nil, // m2 := FindEntity("2")
errors.New("FAIL"), // m2.Life() - unused
errors.NotProvisionedf("machine 42"), // FindEntity("3") (ensure wrapping is preserved)
)
s.st.SetMachineInfo(c, machineInfo{id: "1", life: state.Alive})
s.st.SetMachineInfo(c, machineInfo{id: "2", life: state.Dead})
s.st.SetMachineInfo(c, machineInfo{id: "3", life: state.Dying})
result, err := s.api.Life(s.machineEntities)
c.Assert(err, jc.ErrorIsNil)
c.Assert(result, jc.DeepEquals, params.LifeResults{
Results: []params.LifeResult{
{Error: apiservertesting.ServerError("pow!")},
{Life: params.Dead},
{Error: apiservertesting.NotProvisionedError("42")},
}},
)
s.st.CheckFindEntityCall(c, 0, "1")
s.st.CheckFindEntityCall(c, 1, "2")
s.st.CheckCall(c, 2, "Life")
s.st.CheckFindEntityCall(c, 3, "3")
}
开发者ID:bac,项目名称:juju,代码行数:26,代码来源:instancepoller_test.go
示例10: TestSetProviderAddressesFailure
func (s *InstancePollerSuite) TestSetProviderAddressesFailure(c *gc.C) {
s.st.SetErrors(
errors.New("pow!"), // m1 := FindEntity("1")
nil, // m2 := FindEntity("2")
errors.New("FAIL"), // m2.SetProviderAddresses()
errors.NotProvisionedf("machine 42"), // FindEntity("3") (ensure wrapping is preserved)
)
oldAddrs := network.NewAddresses("0.1.2.3", "127.0.0.1", "8.8.8.8")
newAddrs := network.NewAddresses("1.2.3.4", "8.4.4.8", "2001:db8::")
s.st.SetMachineInfo(c, machineInfo{id: "1", providerAddresses: oldAddrs})
s.st.SetMachineInfo(c, machineInfo{id: "2", providerAddresses: nil})
result, err := s.api.SetProviderAddresses(params.SetMachinesAddresses{
MachineAddresses: []params.MachineAddresses{
{Tag: "machine-1"},
{Tag: "machine-2", Addresses: params.FromNetworkAddresses(newAddrs...)},
{Tag: "machine-3"},
}},
)
c.Assert(err, jc.ErrorIsNil)
c.Assert(result, jc.DeepEquals, s.machineErrorResults)
s.st.CheckFindEntityCall(c, 0, "1")
s.st.CheckFindEntityCall(c, 1, "2")
s.st.CheckSetProviderAddressesCall(c, 2, newAddrs)
s.st.CheckFindEntityCall(c, 3, "3")
// Ensure machine 2 wasn't updated.
machine, err := s.st.Machine("2")
c.Assert(err, jc.ErrorIsNil)
c.Assert(machine.ProviderAddresses(), gc.HasLen, 0)
}
开发者ID:bac,项目名称:juju,代码行数:32,代码来源:instancepoller_test.go
示例11: Info
func (v *fakeVolume) Info() (state.VolumeInfo, error) {
if !v.provisioned {
return state.VolumeInfo{}, errors.NotProvisionedf("volume %v", v.tag.Id())
}
return state.VolumeInfo{
Pool: "loop",
Size: 1024,
}, nil
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:9,代码来源:volumes_test.go
示例12: InstanceStatus
// InstanceStatus returns the provider specific instance status for this machine,
// or a NotProvisionedError if instance is not yet provisioned.
func (m *Machine) InstanceStatus() (string, error) {
instData, err := getInstanceData(m.st, m.Id())
if errors.IsNotFound(err) {
err = errors.NotProvisionedf("machine %v", m.Id())
}
if err != nil {
return "", err
}
return instData.Status, err
}
开发者ID:vonwenm,项目名称:juju,代码行数:12,代码来源:machine.go
示例13: checkForValidMachineAgent
func checkForValidMachineAgent(entity state.Entity, req params.LoginRequest) error {
// If this is a machine agent connecting, we need to check the
// nonce matches, otherwise the wrong agent might be trying to
// connect.
if machine, ok := entity.(*state.Machine); ok {
if !machine.CheckProvisioned(req.Nonce) {
return errors.NotProvisionedf("machine %v", machine.Id())
}
}
return nil
}
开发者ID:kakamessi99,项目名称:juju,代码行数:11,代码来源:admin.go
示例14: Volumes
func (v *mockVolumeAccessor) Volumes(volumes []names.VolumeTag) ([]params.VolumeResult, error) {
var result []params.VolumeResult
for _, tag := range volumes {
if vol, ok := v.provisionedVolumes[tag.String()]; ok {
result = append(result, params.VolumeResult{Result: vol})
} else {
result = append(result, params.VolumeResult{
Error: common.ServerError(errors.NotProvisionedf("volume %q", tag.Id())),
})
}
}
return result, nil
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:13,代码来源:mock_test.go
示例15: Filesystems
func (v *mockFilesystemAccessor) Filesystems(filesystems []names.FilesystemTag) ([]params.FilesystemResult, error) {
var result []params.FilesystemResult
for _, tag := range filesystems {
if vol, ok := v.provisionedFilesystems[tag.String()]; ok {
result = append(result, params.FilesystemResult{Result: vol})
} else {
result = append(result, params.FilesystemResult{
Error: common.ServerError(errors.NotProvisionedf("filesystem %q", tag.Id())),
})
}
}
return result, nil
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:13,代码来源:mock_test.go
示例16: FilesystemAttachments
func (v *mockFilesystemAccessor) FilesystemAttachments(ids []params.MachineStorageId) ([]params.FilesystemAttachmentResult, error) {
var result []params.FilesystemAttachmentResult
for _, id := range ids {
if att, ok := v.provisionedAttachments[id]; ok {
result = append(result, params.FilesystemAttachmentResult{Result: att})
} else {
result = append(result, params.FilesystemAttachmentResult{
Error: common.ServerError(errors.NotProvisionedf("filesystem attachment %v", id)),
})
}
}
return result, nil
}
开发者ID:ktsakalozos,项目名称:juju,代码行数:13,代码来源:mock_test.go
示例17: volumeStorageAttachmentInfo
func volumeStorageAttachmentInfo(
st StorageInterface,
storageInstance state.StorageInstance,
machineTag names.MachineTag,
) (*storage.StorageAttachmentInfo, error) {
storageTag := storageInstance.StorageTag()
volume, err := st.StorageInstanceVolume(storageTag)
if err != nil {
return nil, errors.Annotate(err, "getting volume")
}
volumeInfo, err := volume.Info()
if err != nil {
return nil, errors.Annotate(err, "getting volume info")
}
volumeAttachment, err := st.VolumeAttachment(machineTag, volume.VolumeTag())
if err != nil {
return nil, errors.Annotate(err, "getting volume attachment")
}
volumeAttachmentInfo, err := volumeAttachment.Info()
if err != nil {
return nil, errors.Annotate(err, "getting volume attachment info")
}
blockDevices, err := st.BlockDevices(machineTag)
if err != nil {
return nil, errors.Annotate(err, "getting block devices")
}
blockDevice, ok := MatchingBlockDevice(
blockDevices,
volumeInfo,
volumeAttachmentInfo,
)
if !ok {
// We must not say that a block-kind storage attachment is
// provisioned until its block device has shown up on the
// machine, otherwise the charm may attempt to use it and
// fail.
return nil, errors.NotProvisionedf("%v", names.ReadableString(storageTag))
}
devicePath, err := volumeAttachmentDevicePath(
volumeInfo,
volumeAttachmentInfo,
*blockDevice,
)
if err != nil {
return nil, errors.Trace(err)
}
return &storage.StorageAttachmentInfo{
storage.StorageKindBlock,
devicePath,
}, nil
}
开发者ID:bac,项目名称:juju,代码行数:51,代码来源:storage.go
示例18: AvailabilityZone
// AvailabilityZone returns the provier-specific instance availability
// zone in which the machine was provisioned.
func (m *Machine) AvailabilityZone() (string, error) {
instData, err := getInstanceData(m.st, m.Id())
if errors.IsNotFound(err) {
return "", errors.Trace(errors.NotProvisionedf("machine %v", m.Id()))
}
if err != nil {
return "", errors.Trace(err)
}
var zone string
if instData.AvailZone != nil {
zone = *instData.AvailZone
}
return zone, nil
}
开发者ID:vonwenm,项目名称:juju,代码行数:16,代码来源:machine.go
示例19: SetInstanceStatus
// SetInstanceStatus sets the provider specific instance status for a machine.
func (m *Machine) SetInstanceStatus(status string) (err error) {
defer errors.DeferredAnnotatef(&err, "cannot set instance status for machine %q", m)
ops := []txn.Op{
{
C: instanceDataC,
Id: m.doc.DocID,
Assert: txn.DocExists,
Update: bson.D{{"$set", bson.D{{"status", status}}}},
},
}
if err = m.st.runTransaction(ops); err == nil {
return nil
} else if err != txn.ErrAborted {
return err
}
return errors.NotProvisionedf("machine %v", m.Id())
}
开发者ID:vonwenm,项目名称:juju,代码行数:20,代码来源:machine.go
示例20: Authenticate
// Authenticate authenticates the provided entity and returns an error on authentication failure.
func (*AgentAuthenticator) Authenticate(entity state.Entity, password, nonce string) error {
authenticator, ok := entity.(taggedAuthenticator)
if !ok {
return common.ErrBadRequest
}
if !authenticator.PasswordValid(password) {
return common.ErrBadCreds
}
// If this is a machine agent connecting, we need to check the
// nonce matches, otherwise the wrong agent might be trying to
// connect.
if machine, ok := authenticator.(*state.Machine); ok {
if !machine.CheckProvisioned(nonce) {
return errors.NotProvisionedf("machine %v", machine.Id())
}
}
return nil
}
开发者ID:Pankov404,项目名称:juju,代码行数:21,代码来源:agent.go
注:本文中的github.com/juju/errors.NotProvisionedf函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论