func (s *CacheAPIEndpointsSuite) TestPrepareEndpointsForCaching(c *gc.C) { s.assertCreateController(c, "controller-name1") params := juju.UpdateControllerParams{ AgentVersion: "1.2.3", AddrConnectedTo: []network.HostPort{s.apiHostPort}, CurrentHostPorts: s.hostPorts, } err := juju.UpdateControllerDetailsFromLogin(s.ControllerStore, "controller-name1", params) c.Assert(err, jc.ErrorIsNil) controllerDetails, err := s.ControllerStore.ControllerByName("controller-name1") c.Assert(err, jc.ErrorIsNil) s.assertEndpoints(c, controllerDetails) s.assertControllerUpdated(c, "controller-name1") }
func (s *CacheAPIEndpointsSuite) TestUpdateModelMachineCount(c *gc.C) { s.assertCreateController(c, "controller-name1") params := juju.UpdateControllerParams{ AgentVersion: "1.2.3", ControllerMachineCount: intptr(1), ModelCount: intptr(2), MachineCount: intptr(3), } err := juju.UpdateControllerDetailsFromLogin(s.ControllerStore, "controller-name1", params) c.Assert(err, jc.ErrorIsNil) controllerDetails, err := s.ControllerStore.ControllerByName("controller-name1") c.Assert(err, jc.ErrorIsNil) c.Assert(controllerDetails.UnresolvedAPIEndpoints, gc.HasLen, 0) c.Assert(controllerDetails.APIEndpoints, gc.HasLen, 0) c.Assert(controllerDetails.AgentVersion, gc.Equals, "1.2.3") c.Assert(controllerDetails.ControllerMachineCount, gc.Equals, 1) c.Assert(*controllerDetails.ModelCount, gc.Equals, 2) c.Assert(*controllerDetails.MachineCount, gc.Equals, 3) }
// SetBootstrapEndpointAddress writes the API endpoint address of the // bootstrap server, plus the agent version, into the connection information. // This should only be run once directly after Bootstrap. It assumes that // there is just one instance in the environment - the bootstrap instance. func SetBootstrapEndpointAddress( store jujuclient.ControllerStore, controllerName string, agentVersion version.Number, apiPort int, environ environs.Environ, ) error { instances, err := allInstances(environ) if err != nil { return errors.Trace(err) } length := len(instances) if length == 0 { return errors.Errorf("found no instances, expected at least one") } if length > 1 { return errors.Errorf("expected one instance, got %d", length) } bootstrapInstance := instances[0] // Don't use c.ConnectionEndpoint as it attempts to contact the state // server if no addresses are found in connection info. netAddrs, err := bootstrapInstance.Addresses() if err != nil { return errors.Annotate(err, "failed to get bootstrap instance addresses") } apiHostPorts := network.AddressesWithPort(netAddrs, apiPort) // At bootstrap we have 2 models, the controller model and the default. two := 2 params := juju.UpdateControllerParams{ AgentVersion: agentVersion.String(), AddrConnectedTo: apiHostPorts, MachineCount: &length, ControllerMachineCount: &length, ModelCount: &two, } return juju.UpdateControllerDetailsFromLogin(store, controllerName, params) }