juju

package
v0.0.0-...-6cf1bc9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2016 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddUnits

func AddUnits(
	unitAssigner UnitAssigner,
	unitAdder UnitAdder,
	appName string,
	n int,
	placement []*instance.Placement,
) ([]*state.Unit, error)

AddUnits starts n units of the given application using the specified placement directives to allocate the machines.

func DeployApplication

func DeployApplication(st ApplicationDeployer, args DeployApplicationParams) (*state.Application, error)

DeployApplication takes a charm and various parameters and deploys it.

func InitJujuXDGDataHome

func InitJujuXDGDataHome() error

InitJujuXDGDataHome initializes the charm cache, environs/config and utils/ssh packages to use default paths based on the $JUJU_DATA or $HOME environment variables. This function should be called before running a Juju CLI command.

func NewAPIConnection

func NewAPIConnection(args NewAPIConnectionParams) (api.Connection, error)

NewAPIConnection returns an api.Connection to the specified Juju controller, with specified account credentials, optionally scoped to the specified model name.

func PrepareEndpointsForCaching

func PrepareEndpointsForCaching(
	controllerDetails jujuclient.ControllerDetails,
	hostPorts [][]network.HostPort,
	addrConnectedTo ...network.HostPort,
) (addrs, unresolvedAddrs []string, haveChanged bool)

PrepareEndpointsForCaching performs the necessary operations on the given API hostPorts so they are suitable for saving into the controller.yaml 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. 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 saved the initial API endpoints, as well as on each CLI connection to verify if the saved endpoints need updating.

TODO(rogpeppe) this function mixes too many concerns - the logic is difficult to follow and has non-obvious properties.

func UpdateControllerDetailsFromLogin

func UpdateControllerDetailsFromLogin(
	store jujuclient.ControllerStore, controllerName string,
	params UpdateControllerParams,
) error

UpdateControllerDetailsFromLogin writes any new api addresses and other relevant details to the client controller file. Controller may be specified by a UUID or name, and must already exist.

Types

type ApplicationDeployer

type ApplicationDeployer interface {
	AddApplication(state.AddApplicationArgs) (*state.Application, error)
}

type DeployApplicationParams

type DeployApplicationParams struct {
	ApplicationName string
	Series          string
	Charm           *state.Charm
	Channel         csparams.Channel
	ConfigSettings  charm.Settings
	Constraints     constraints.Value
	NumUnits        int
	// Placement is a list of placement directives which may be used
	// instead of a machine spec.
	Placement        []*instance.Placement
	Storage          map[string]storage.Constraints
	EndpointBindings map[string]string
	// Resources is a map of resource name to IDs of pending resources.
	Resources map[string]string
}

DeployApplicationParams contains the arguments required to deploy the referenced charm.

type NewAPIConnectionParams

type NewAPIConnectionParams struct {
	// ControllerName is the name of the controller to connect to.
	ControllerName string

	// Store is the jujuclient.ClientStore from which the controller's
	// details will be fetched, and updated on address changes.
	Store jujuclient.ClientStore

	// OpenAPI is the function that will be used to open API connections.
	OpenAPI api.OpenFunc

	// DialOpts contains the options used to dial the API connection.
	DialOpts api.DialOpts

	// AccountDetails contains the account details to use for logging
	// in to the Juju API. If this is nil, then no login will take
	// place. If AccountDetails.Password and AccountDetails.Macaroon
	// are zero, the login will be as an external user.
	AccountDetails *jujuclient.AccountDetails

	// ModelUUID is an optional model UUID. If specified, the API connection
	// will be scoped to the model with that UUID; otherwise it will be
	// scoped to the controller.
	ModelUUID string
}

NewAPIConnectionParams contains the parameters for creating a new Juju API connection.

type UnitAdder

type UnitAdder interface {
	AddUnit() (*state.Unit, error)
}

type UnitAssigner

type UnitAssigner interface {
	AssignUnit(*state.Unit, state.AssignmentPolicy) error
	AssignUnitWithPlacement(*state.Unit, *instance.Placement) error
}

type UpdateControllerParams

type UpdateControllerParams struct {
	// AgentVersion is the version of the controller agent.
	AgentVersion string

	// CurrentHostPorts are the available api addresses.
	CurrentHostPorts [][]network.HostPort

	// AddrConnectedTo are the previously known api addresses.
	AddrConnectedTo []network.HostPort

	// ModelCount (when set) is the number of models visible to the user.
	ModelCount *int

	// ControllerMachineCount (when set) is the total number of controller machines in the environment.
	ControllerMachineCount *int

	// MachineCount (when set) is the total number of machines in the models.
	MachineCount *int
}

UpdateControllerParams holds values used to update a controller details after bootstrap or a login operation.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL