Documentation ¶
Index ¶
- func AddUnits(st *state.State, svc *state.Service, n int, machineIdSpec string) ([]*state.Unit, error)
- func DeployService(st *state.State, args DeployServiceParams) (*state.Service, error)
- func InitJujuHome() error
- func NewAPIClientFromName(envName string) (*api.Client, error)
- func NewAPIFromName(envName string) (*api.State, error)
- func NewAPIState(user names.UserTag, environ environs.Environ, dialOpts api.DialOpts) (*api.State, error)
- func PrepareEndpointsForCaching(info configstore.EnvironInfo, hostPorts [][]network.HostPort, ...) (addresses, hostnames []string, haveChanged bool)
- type DeployServiceParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddUnits ¶
func AddUnits(st *state.State, svc *state.Service, n int, machineIdSpec string) ([]*state.Unit, error)
AddUnits starts n units of the given service and allocates machines to them as necessary.
func DeployService ¶
DeployService takes a charm and various parameters and deploys it.
func InitJujuHome ¶
func InitJujuHome() error
InitJujuHome initializes the charm cache, environs/config and utils/ssh packages to use default paths based on the $JUJU_HOME or $HOME environment variables. This function should be called before running a Juju CLI command.
func NewAPIClientFromName ¶
NewAPIClientFromName returns an api.Client connected to the API Server for the named environment. If envName is "", the default environment will be used.
func NewAPIFromName ¶
NewAPIFromName returns an api.State connected to the API Server for the named environment. If envName is "", the default environment will be used.
func NewAPIState ¶
func NewAPIState(user names.UserTag, environ environs.Environ, dialOpts api.DialOpts) (*api.State, error)
NewAPIState creates an api.State object from an Environ This is almost certainly the wrong thing to do as it assumes the old admin password (stored as admin-secret in the config).
func PrepareEndpointsForCaching ¶
func PrepareEndpointsForCaching(info configstore.EnvironInfo, hostPorts [][]network.HostPort, addrConnectedTo network.HostPort) (addresses, hostnames []string, haveChanged bool)
PrepareEndpointsForCaching performs the necessary operations on the given API hostPorts so they are suitable for caching into the environment's .jenv file, taking into account the addrConnectedTo and the existing config store info:
1. Collapses hostPorts into a single slice. 2. Filters out machine-local and link-local addresses. 3. Removes any duplicates 4. Call network.SortHostPorts() on the list, respecing prefer-ipv6 flag. 5. Puts the addrConnectedTo on top. 6. Compares the result against info.APIEndpoint.Hostnames. 7. If the addresses differ, call network.ResolveOrDropHostnames() on the list and perform all steps again from step 1. 8. Compare the list of resolved addresses against the cached info APIEndpoint.Addresses, and if changed return both addresses and hostnames as strings (so they can be cached on APIEndpoint) and set haveChanged to true. 9. If the hostnames haven't changed, return two empty slices and set haveChanged to false. No DNS resolution is performed to save time.
This is used right after bootstrap to cache the initial API endpoints, as well as on each CLI connection to verify if the cached endpoints need updating.
Types ¶
type DeployServiceParams ¶
type DeployServiceParams struct { ServiceName string ServiceOwner string Charm *state.Charm ConfigSettings charm.Settings Constraints constraints.Value NumUnits int // ToMachineSpec is either: // - an existing machine/container id eg "1" or "1/lxc/2" // - a new container on an existing machine eg "lxc:1" // Use string to avoid ambiguity around machine 0. ToMachineSpec string // Networks holds a list of networks to required to start on boot. Networks []string Storage map[string]storage.Constraints }
DeployServiceParams contains the arguments required to deploy the referenced charm.