Exemple #1
0
// Machiner returns an object that provides access to the Machiner API
// facade. The id argument is reserved for future use and currently
// needs to be empty.
func (r *srvRoot) Machiner(id string) (*machine.MachinerAPI, error) {
	if id != "" {
		// Safeguard id for possible future use.
		return nil, common.ErrBadId
	}
	return machine.NewMachinerAPI(r.srv.state, r.resources, r)
}
Exemple #2
0
func (s *machinerSuite) TestMachinerFailsWithNonMachineAgentUser(c *C) {
	anAuthorizer := s.authorizer
	anAuthorizer.MachineAgent = false
	aMachiner, err := machine.NewMachinerAPI(s.State, s.resources, anAuthorizer)
	c.Assert(err, NotNil)
	c.Assert(aMachiner, IsNil)
	c.Assert(err, ErrorMatches, "permission denied")
}
Exemple #3
0
func (s *machinerSuite) SetUpTest(c *C) {
	s.commonSuite.SetUpTest(c)

	// Create the resource registry separately to track invocations to
	// Register.
	s.resources = common.NewResources()

	// Create a machiner API for machine 1.
	machiner, err := machine.NewMachinerAPI(
		s.State,
		s.resources,
		s.authorizer,
	)
	c.Assert(err, IsNil)
	s.machiner = machiner
}