-
Notifications
You must be signed in to change notification settings - Fork 0
Implementing environment providers
This document describes how to implement an environment provider for Juju. For the remainder of this document we will use the term "provider" to mean "environment provider", but be aware that there are additional types of providers (e.g. storage providers).
Providers are the bridge between Juju and the cloud environment in which Juju operates, and provides:
- allocation, deallocation, and querying of machines
- cloud-integrated network management
A provider is made up of several different parts:
- Creation (bootstrapping) and destruction of the environment
- Configuration
- Firewalling
- Instance (machine) creation
- Instance querying
These are encompassed by several interfaces in the Juju codebase:
The first thing you should do when creating a new provider is identify the core configuration required, and then implement the EnvironProvider interface. The EnvironProvider methods are described below.
Environment configuration is encapsulated in environs/config.Config, providing accessors for common configuration attributes. Provider-specific configuration can be obtained through the Config.UnknownAttrs
method.
These methods "prepare" an environment, which essentially means adding attributes to the provided configuration as required. For most providers, PrepareForCreateEnvironment will be a no-op, simply returning the provided configuration unmodified. Similarly, for most providers the PrepareForBootstrap method will be a call to PrepareForCreateEnvironment followed by a call to Open.
Validate takes two configurations, and reports whether or not they are valid. There are two use-cases for this method:
- "Is this configuration valid in isolation?" In this case, the first argument will be a non-nil configuration, and the second will be nil.
- "Is this configuration valid, given the existing configuration?" In this case, the first argument will be the new configuration, and the second argument the old. You must check for invalid changes to configuration here.
It is also possible for the Validate method to return a modified configuration, which is often used to implement configuration upgrades (i.e. upgrading configuration for older versions of a provider in a newer version). This exists only because we do not have machinery dedicated to upgrading configuration, and should not be used lightly.
Open returns an Environ for a given configuration.
SecretAttrs identifies which configuration attributes are secrets, which may only be shared with servers in the Juju environment, and will be stripped from the environment configuration that is stored in the database. These are typically only the credentials required to connect to the cloud provider.
There is work ongoing to support multiple environments (i.e. separate sets of machines, services, units, etc.) within the same cloud provider. RestrictedConfigAttributes identifies which attributes should not change between multiple environments for the same Juju server, such as the cloud provider credentials.
BoilerplateConfig returns the provider-specific YAML boilerplate that is added to environments.yaml
when running juju init
. The output should describe the possible configurations and default values.
TODO: tagging TODO: constraint validation TODO: prechecking TODO: distribution
Testing
Releases
Documentation
Development
- READ BEFORE CODING
- Blocking bugs process
- Bug fixes and patching
- Contributing
- Code Review Checklists
- Creating New Repos
-
MongoDB and Consistency
- [mgo/txn Example] (https://github.com/juju/juju/wiki/mgo-txn-example)
- Scripts
- Update Launchpad Dependency
- Writing workers
- Reviewboard Tips
Debugging and QA
- Debugging Juju
- [Faster LXD] (https://github.com/juju/juju/wiki/Faster-LXD)