Documentation
¶
Index ¶
- Variables
- func CreateCertPool(caCert string) (*x509.CertPool, error)
- func RegisterFacadeVersion(name string, version int) error
- type AllWatcher
- type CharmInfo
- type Client
- func (c *Client) APIHostPorts() ([][]network.HostPort, error)
- func (c *Client) AbortCurrentUpgrade() error
- func (c *Client) AddCharm(curl *charm.URL) error
- func (c *Client) AddCharmWithAuthorization(curl *charm.URL, csMac *macaroon.Macaroon) error
- func (c *Client) AddLocalCharm(curl *charm.URL, ch charm.Charm) (*charm.URL, error)
- func (c *Client) AddMachines(machineParams []params.AddMachineParams) ([]params.AddMachinesResult, error)
- func (c *Client) AgentVersion() (version.Number, error)
- func (c *Client) CharmInfo(charmURL string) (*CharmInfo, error)
- func (c *Client) Close() error
- func (c *Client) DestroyMachines(machines ...string) error
- func (c *Client) DestroyModel() error
- func (c *Client) FindTools(majorVersion, minorVersion int, series, arch string) (result params.FindToolsResult, err error)
- func (c *Client) ForceDestroyMachines(machines ...string) error
- func (c *Client) GetModelConstraints() (constraints.Value, error)
- func (c *Client) ModelGet() (map[string]interface{}, error)
- func (c *Client) ModelInfo() (params.ModelInfo, error)
- func (c *Client) ModelSet(config map[string]interface{}) error
- func (c *Client) ModelUUID() string
- func (c *Client) ModelUnset(keys ...string) error
- func (c *Client) ModelUserInfo() ([]params.ModelUserInfo, error)
- func (c *Client) PrivateAddress(target string) (string, error)
- func (c *Client) ProvisioningScript(args params.ProvisioningScriptParams) (script string, err error)
- func (c *Client) PublicAddress(target string) (string, error)
- func (c *Client) ResolveCharm(ref *charm.URL) (*charm.URL, error)
- func (c *Client) Resolved(unit string, retry bool) error
- func (c *Client) RetryProvisioning(machines ...names.MachineTag) ([]params.ErrorResult, error)
- func (c *Client) Run(run params.RunParams) ([]params.RunResult, error)
- func (c *Client) RunOnAllMachines(commands string, timeout time.Duration) ([]params.RunResult, error)
- func (c *Client) SetModelAgentVersion(version version.Number) error
- func (c *Client) SetModelConstraints(constraints constraints.Value) error
- func (c *Client) ShareModel(users ...names.UserTag) error
- func (c *Client) Status(patterns []string) (*params.FullStatus, error)
- func (c *Client) StatusHistory(kind params.HistoryKind, name string, size int) (*params.StatusHistoryResults, error)
- func (c *Client) UnshareModel(users ...names.UserTag) error
- func (c *Client) UploadTools(r io.ReadSeeker, vers version.Binary, additionalSeries ...string) (*tools.Tools, error)
- func (c *Client) WatchAll() (*AllWatcher, error)
- func (c *Client) WatchDebugLog(args DebugLogParams) (io.ReadCloser, error)
- type Connection
- type DebugLogParams
- type DialOpts
- type Info
- type OpenFunc
- type WatchAll
Constants ¶
This section is empty.
Variables ¶
var ( // PingPeriod defines how often the internal connection health check // will run. PingPeriod = 1 * time.Minute // PingTimeout defines how long a health check can take before we // consider it to have failed. PingTimeout = 30 * time.Second )
TODO(fwereade): we should be injecting a Clock; and injecting these values; across the board, instead of using these global variables.
Functions ¶
func CreateCertPool ¶
CreateCertPool creates a new x509.CertPool and adds in the caCert passed in. All certs from the cert directory (/etc/juju/cert.d on ubuntu) are also added.
Types ¶
type AllWatcher ¶
type AllWatcher struct {
// contains filtered or unexported fields
}
AllWatcher holds information allowing us to get Deltas describing changes to the entire model or all models (depending on the watcher type).
func NewAllModelWatcher ¶
func NewAllModelWatcher(caller base.APICaller, id *string) *AllWatcher
NewAllModelWatcher returns an AllWatcher instance which interacts with a watcher created by the WatchAllModels API call.
There should be no need to call this from outside of the api package. It is only used by Client.WatchAllModels in api/controller.
func NewAllWatcher ¶
func NewAllWatcher(caller base.APICaller, id *string) *AllWatcher
NewAllWatcher returns an AllWatcher instance which interacts with a watcher created by the WatchAll API call.
There should be no need to call this from outside of the api package. It is only used by Client.WatchAll in this package.
func (*AllWatcher) Next ¶
func (watcher *AllWatcher) Next() ([]multiwatcher.Delta, error)
Next returns a new set of deltas from a watcher previously created by the WatchAll or WatchAllModels API calls. It will block until there are deltas to return.
func (*AllWatcher) Stop ¶
func (watcher *AllWatcher) Stop() error
Stop shutdowns down a watcher previously created by the WatchAll or WatchAllModels API calls
type CharmInfo ¶
type CharmInfo struct {
Revision int
URL string
Config *charm.Config
Meta *charm.Meta
Actions *charm.Actions
}
CharmInfo holds information about a charm.
type Client ¶
type Client struct {
base.ClientFacade
// contains filtered or unexported fields
}
Client represents the client-accessible part of the state.
func (*Client) APIHostPorts ¶
APIHostPorts returns a slice of network.HostPort for each API server.
func (*Client) AbortCurrentUpgrade ¶
AbortCurrentUpgrade aborts and archives the current upgrade synchronisation record, if any.
func (*Client) AddCharm ¶
AddCharm adds the given charm URL (which must include revision) to the model, if it does not exist yet. Local charms are not supported, only charm store URLs. See also AddLocalCharm() in the client-side API.
If the AddCharm API call fails because of an authorization error when retrieving the charm from the charm store, an error satisfying params.IsCodeUnauthorized will be returned.
func (*Client) AddCharmWithAuthorization ¶
AddCharmWithAuthorization is like AddCharm except it also provides the given charmstore macaroon for the juju server to use when obtaining the charm from the charm store. The macaroon is conventionally obtained from the /delegatable-macaroon endpoint in the charm store.
If the AddCharmWithAuthorization API call fails because of an authorization error when retrieving the charm from the charm store, an error satisfying params.IsCodeUnauthorized will be returned.
func (*Client) AddLocalCharm ¶
AddLocalCharm prepares the given charm with a local: schema in its URL, and uploads it via the API server, returning the assigned charm URL.
func (*Client) AddMachines ¶
func (c *Client) AddMachines(machineParams []params.AddMachineParams) ([]params.AddMachinesResult, error)
AddMachines adds new machines with the supplied parameters.
func (*Client) AgentVersion ¶
AgentVersion reports the version number of the api server.
func (*Client) CharmInfo ¶
CharmInfo returns information about the requested charm.
func (*Client) Close ¶
Close closes the Client's underlying State connection Client is unique among the api.State facades in closing its own State connection, but it is conventional to use a Client object without any access to its underlying state connection.
func (*Client) DestroyMachines ¶
DestroyMachines removes a given set of machines.
func (*Client) DestroyModel ¶
DestroyModel puts the model into a "dying" state, and removes all non-manager machine instances. DestroyModel will fail if there are any manually-provisioned non-manager machines in state.
func (*Client) FindTools ¶
func (c *Client) FindTools(majorVersion, minorVersion int, series, arch string) (result params.FindToolsResult, err error)
FindTools returns a List containing all tools matching the specified parameters.
func (*Client) ForceDestroyMachines ¶
ForceDestroyMachines removes a given set of machines and all associated units.
func (*Client) GetModelConstraints ¶
func (c *Client) GetModelConstraints() (constraints.Value, error)
GetModelConstraints returns the constraints for the model.
func (*Client) ModelGet ¶
ModelGet returns all model settings.
func (*Client) ModelInfo ¶
ModelInfo returns details about the Juju model.
func (*Client) ModelSet ¶
ModelSet sets the given key-value pairs in the model.
func (*Client) ModelUUID ¶
ModelUUID returns the model UUID from the client connection.
func (*Client) ModelUnset ¶
ModelUnset sets the given key-value pairs in the model.
func (*Client) ModelUserInfo ¶
func (c *Client) ModelUserInfo() ([]params.ModelUserInfo, error)
ModelUserInfo returns information on all users in the model.
func (*Client) PrivateAddress ¶
PrivateAddress returns the private address of the specified machine or unit.
func (*Client) ProvisioningScript ¶
func (c *Client) ProvisioningScript(args params.ProvisioningScriptParams) (script string, err error)
ProvisioningScript returns a shell script that, when run, provisions a machine agent on the machine executing the script.
func (*Client) PublicAddress ¶
PublicAddress returns the public address of the specified machine or unit. For a machine, target is an id not a tag.
func (*Client) ResolveCharm ¶
ResolveCharm resolves the best available charm URLs with series, for charm locations without a series specified.
func (*Client) Resolved ¶
Resolved clears errors on a unit.
func (*Client) RetryProvisioning ¶
func (c *Client) RetryProvisioning(machines ...names.MachineTag) ([]params.ErrorResult, error)
RetryProvisioning updates the provisioning status of a machine allowing the provisioner to retry.
func (*Client) Run ¶
Run the Commands specified on the machines identified through the ids provided in the machines, services and units slices.
func (*Client) RunOnAllMachines ¶
func (c *Client) RunOnAllMachines(commands string, timeout time.Duration) ([]params.RunResult, error)
RunOnAllMachines runs the command on all the machines with the specified timeout.
func (*Client) SetModelAgentVersion ¶
SetModelAgentVersion sets the model agent-version setting to the given value.
func (*Client) SetModelConstraints ¶
func (c *Client) SetModelConstraints(constraints constraints.Value) error
SetModelConstraints specifies the constraints for the model.
func (*Client) ShareModel ¶
ShareModel allows the given users access to the model.
func (*Client) Status ¶
func (c *Client) Status(patterns []string) (*params.FullStatus, error)
Status returns the status of the juju model.
func (*Client) StatusHistory ¶
func (c *Client) StatusHistory(kind params.HistoryKind, name string, size int) (*params.StatusHistoryResults, error)
StatusHistory retrieves the last <size> results of <kind:combined|agent|workload|machine|machineinstance|container|containerinstance> status for <name> unit
func (*Client) UnshareModel ¶
UnshareModel removes access to the model for the given users.
func (*Client) UploadTools ¶
func (c *Client) UploadTools(r io.ReadSeeker, vers version.Binary, additionalSeries ...string) (*tools.Tools, error)
UploadTools uploads tools at the specified location to the API server over HTTPS.
func (*Client) WatchAll ¶
func (c *Client) WatchAll() (*AllWatcher, error)
WatchAll returns an AllWatcher, from which you can request the Next collection of Deltas.
func (*Client) WatchDebugLog ¶
func (c *Client) WatchDebugLog(args DebugLogParams) (io.ReadCloser, error)
WatchDebugLog returns a ReadCloser that the caller can read the log lines from. Only log lines that match the filtering specified in the DebugLogParams are returned. It returns an error that satisfies errors.IsNotImplemented when the API server does not support the end-point.
TODO(dimitern) We already have errors.IsNotImplemented - why do we need to define a different error for this purpose here?
type Connection ¶
type Connection interface {
// This first block of methods is pretty close to a sane Connection interface.
Close() error
Broken() <-chan struct{}
Addr() string
APIHostPorts() [][]network.HostPort
// These are a bit off -- ServerVersion is apparently not known until after
// Login()? Maybe evidence of need for a separate AuthenticatedConnection..?
Login(name names.Tag, password, nonce string) error
ServerVersion() (version.Number, bool)
// APICaller provides the facility to make API calls directly.
// This should not be used outside the api/* packages or tests.
base.APICaller
// ControllerTag returns the model tag of the controller
// (as opposed to the model tag of the currently connected
// model inside that controller).
// This could be defined on base.APICaller.
ControllerTag() (names.ModelTag, error)
// Something-or-other expects Ping to exist, and *maybe* the heartbeat
// *should* be handled outside the State type, but it's also handled
// inside it as well. We should figure this out sometime -- we should
// either expose Ping() or Broken() but not both.
Ping() error
// RPCClient is apparently exported for testing purposes only, but this
// seems to indicate *some* sort of layering confusion.
RPCClient() *rpc.Conn
// I think this is actually dead code. It's tested, at least, so I'm
// keeping it for now, but it's not apparently used anywhere else.
AllFacadeVersions() map[string][]int
// These methods expose a bunch of worker-specific facades, and basically
// just should not exist; but removing them is too noisy for a single CL.
// Client in particular is intimately coupled with State -- and the others
// will be easy to remove, but until we're using them via manifolds it's
// prohibitively ugly to do so.
Client() *Client
Machiner() *machiner.State
Provisioner() *provisioner.State
Uniter() (*uniter.State, error)
Firewaller() *firewaller.State
Agent() *agent.State
Upgrader() *upgrader.State
Reboot() (reboot.State, error)
Deployer() *deployer.State
Addresser() *addresser.API
DiscoverSpaces() *discoverspaces.API
InstancePoller() *instancepoller.API
CharmRevisionUpdater() *charmrevisionupdater.State
Cleaner() *cleaner.API
MetadataUpdater() *imagemetadata.Client
UnitAssigner() unitassigner.API
}
Connection represents a connection to a Juju API server.
func Open ¶
func Open(info *Info, opts DialOpts) (Connection, error)
Open establishes a connection to the API server using the Info given, returning a State instance which can be used to make API requests.
See Connect for details of the connection mechanics.
type DebugLogParams ¶
type DebugLogParams struct {
// IncludeEntity lists entity tags to include in the response. Tags may
// finish with a '*' to match a prefix e.g.: unit-mysql-*, machine-2. If
// none are set, then all lines are considered included.
IncludeEntity []string
// IncludeModule lists logging modules to include in the response. If none
// are set all modules are considered included. If a module is specified,
// all the submodules also match.
IncludeModule []string
// ExcludeEntity lists entity tags to exclude from the response. As with
// IncludeEntity the values may finish with a '*'.
ExcludeEntity []string
// ExcludeModule lists logging modules to exclude from the resposne. If a
// module is specified, all the submodules are also excluded.
ExcludeModule []string
// Limit defines the maximum number of lines to return. Once this many
// have been sent, the socket is closed. If zero, all filtered lines are
// sent down the connection until the client closes the connection.
Limit uint
// Backlog tells the server to try to go back this many lines before
// starting filtering. If backlog is zero and replay is false, then there
// may be an initial delay until the next matching log message is written.
Backlog uint
// Level specifies the minimum logging level to be sent back in the response.
Level loggo.Level
// Replay tells the server to start at the start of the log file rather
// than the end. If replay is true, backlog is ignored.
Replay bool
// NoTail tells the server to only return the logs it has now, and not
// to wait for new logs to arrive.
NoTail bool
}
DebugLogParams holds parameters for WatchDebugLog that control the filtering of the log messages. If the structure is zero initialized, the entire log file is sent back starting from the end, and until the user closes the connection.
type DialOpts ¶
type DialOpts struct {
// DialAddressInterval is the amount of time to wait
// before starting to dial another address.
DialAddressInterval time.Duration
// Timeout is the amount of time to wait contacting
// a controller.
Timeout time.Duration
// RetryDelay is the amount of time to wait between
// unsucssful connection attempts.
RetryDelay time.Duration
// BakeryClient is the httpbakery Client, which
// is used to do the macaroon-based authorization.
// This and the *http.Client inside it are copied
// by Open, and any RoundTripper field
// the HTTP client is ignored.
BakeryClient *httpbakery.Client
// InsecureSkipVerify skips TLS certificate verification
// when connecting to the controller. This should only
// be used in tests, or when verification cannot be
// performed and the communication need not be secure.
InsecureSkipVerify bool
}
DialOpts holds configuration parameters that control the Dialing behavior when connecting to a controller.
type Info ¶
type Info struct {
// Addrs holds the addresses of the controllers.
Addrs []string
// CACert holds the CA certificate that will be used
// to validate the controller's certificate, in PEM format.
CACert string
// ModelTag holds the model tag for the model we are
// trying to connect to.
ModelTag names.ModelTag
// UseMacaroons, when true, enables macaroon-based login and ignores
// the provided username and password.
UseMacaroons bool `yaml:"use-macaroons,omitempty"`
// Tag holds the name of the entity that is connecting.
// If this is nil, and the password is empty, no login attempt will be made.
// (this is to allow tests to access the API to check that operations
// fail when not logged in).
Tag names.Tag
// Password holds the password for the administrator or connecting entity.
Password string
// Nonce holds the nonce used when provisioning the machine. Used
// only by the machine agent.
Nonce string `yaml:",omitempty"`
}
Info encapsulates information about a server holding juju state and can be used to make a connection to it.
type OpenFunc ¶
type OpenFunc func(*Info, DialOpts) (Connection, error)
OpenFunc is the usual form of a function that opens an API connection.
Source Files
¶
- allwatcher.go
- apiclient.go
- certpool.go
- client.go
- facadeversions.go
- http.go
- interface.go
- state.go
Directories
¶
| Path | Synopsis |
|---|---|
|
charms provides a client for accessing the charms API.
|
charms provides a client for accessing the charms API. |
|
Package leadership implements the client to the analog leadership service.
|
Package leadership implements the client to the analog leadership service. |
|
Package logsender implements the API for storing log messages on the API server.
|
Package logsender implements the API for storing log messages on the API server. |
|
Package meterstatus contains an implementation of the api facade to watch the meter status of a unit for changes and return the current meter status.
|
Package meterstatus contains an implementation of the api facade to watch the meter status of a unit for changes and return the current meter status. |
|
Package metricsadder contains an implementation of the api facade to add metrics to the state.
|
Package metricsadder contains an implementation of the api facade to add metrics to the state. |
|
The metricsdebug package contains the implementation of a client to access metrics debug functions within state.
|
The metricsdebug package contains the implementation of a client to access metrics debug functions within state. |
|
The metricsmanager package contains implementation for an api facade to access metrics functions within state
|
The metricsmanager package contains implementation for an api facade to access metrics functions within state |
|
Package service provides access to the service api facade.
|
Package service provides access to the service api facade. |