func (s *provisionerSuite) TestEnsureDead(c *gc.C) { s.setupVolumes(c) args := params.Entities{Entities: []params.Entity{{"volume-0-0"}, {"volume-1"}, {"volume-42"}}} result, err := s.api.EnsureDead(args) c.Assert(err, jc.ErrorIsNil) // TODO(wallyworld) - this test will be updated when EnsureDead is supported c.Assert(result, gc.DeepEquals, params.ErrorResults{ Results: []params.ErrorResult{ {Error: common.ServerError(common.NotSupportedError(names.NewVolumeTag("0/0"), "ensuring death"))}, {Error: common.ServerError(common.NotSupportedError(names.NewVolumeTag("1"), "ensuring death"))}, {Error: common.ServerError(errors.NotFoundf(`volume "42"`))}, }, }) }
func (c *Client) parseEntityTag(tag0 string) (names.Tag, error) { tag, err := names.ParseTag(tag0) if err != nil { return nil, errors.Trace(err) } if tag.Kind() == names.CharmTagKind { return nil, common.NotSupportedError(tag, "client.annotations") } return tag, nil }
func (c *Client) findEntity(tag names.Tag) (state.GlobalEntity, error) { entity0, err := c.api.state.FindEntity(tag) if err != nil { return nil, err } entity, ok := entity0.(state.GlobalEntity) if !ok { return nil, common.NotSupportedError(tag, "annotations") } return entity, nil }
func (api *API) findEntity(tag names.Tag) (state.GlobalEntity, error) { entity0, err := api.access.FindEntity(tag) if err != nil { if errors.IsNotFound(err) { return nil, common.ErrPerm } return nil, err } entity, ok := entity0.(state.GlobalEntity) if !ok { return nil, common.NotSupportedError(tag, "annotations") } return entity, nil }
func (a *InstancePollerAPI) getOneMachine(tag string, canAccess common.AuthFunc) (StateMachine, error) { machineTag, err := names.ParseMachineTag(tag) if err != nil { return nil, err } if !canAccess(machineTag) { return nil, common.ErrPerm } entity, err := a.st.FindEntity(machineTag) if err != nil { return nil, err } machine, ok := entity.(StateMachine) if !ok { return nil, common.NotSupportedError( machineTag, fmt.Sprintf("expected machine, got %T", entity), ) } return machine, nil }
func (api *AgentAPIV2) getEntity(tag names.Tag) (result params.AgentGetEntitiesResult, err error) { // Allow only for the owner agent. // Note: having a bulk API call for this is utter madness, given that // this check means we can only ever return a single object. if !api.auth.AuthOwner(tag) { err = common.ErrPerm return } entity0, err := api.st.FindEntity(tag) if err != nil { return } entity, ok := entity0.(state.Lifer) if !ok { err = common.NotSupportedError(tag, "life cycles") return } result.Life = params.Life(entity.Life().String()) if machine, ok := entity.(*state.Machine); ok { result.Jobs = stateJobsToAPIParamsJobs(machine.Jobs()) result.ContainerType = machine.ContainerType() } return }