Ejemplo n.º 1
0
Archivo: uniter.go Proyecto: bac/juju
// Actions returns the Actions by Tags passed and ensures that the Unit asking
// for them is the same Unit that has the Actions.
func (u *UniterAPIV3) Actions(args params.Entities) (params.ActionResults, error) {
	canAccess, err := u.accessUnit()
	if err != nil {
		return params.ActionResults{}, err
	}

	actionFn := common.AuthAndActionFromTagFn(canAccess, u.st.ActionByTag)
	return common.Actions(args, actionFn), nil
}
Ejemplo n.º 2
0
func (s *actionsSuite) TestGetActions(c *gc.C) {
	args := entities("success", "fail", "notPending")
	actionFn := makeGetActionByTagString(map[string]state.Action{
		"success":    fakeAction{name: "floosh", status: state.ActionPending},
		"notPending": fakeAction{status: state.ActionCancelled},
	})

	results := common.Actions(args, actionFn)

	c.Assert(results, jc.DeepEquals, params.ActionResults{
		[]params.ActionResult{
			{Action: &params.Action{Name: "floosh"}},
			{Error: common.ServerError(actionNotFoundErr)},
			{Error: common.ServerError(common.ErrActionNotAvailable)},
		},
	})
}
Ejemplo n.º 3
0
// Actions returns the Actions by Tags passed and ensures that the machine asking
// for them is the machine that has the actions
func (f *Facade) Actions(args params.Entities) params.ActionResults {
	actionFn := common.AuthAndActionFromTagFn(f.accessMachine, f.backend.ActionByTag)
	return common.Actions(args, actionFn)
}