Description of change
Juju has the ability to add clouds locally to a a current Juju client as well as remotely to a running controller. However, the original implementation took users by surprise. This PR proposes a change to the original implementation to eliminate the element of surprise. As such I have removed the client side feature flag whilst the controller side remains in place.
General logic for adding local and/or remote entities such as cloud and credentials are: * If no controller is specified nor current controller is detected, operation is local only; * If a --local option is specified, operation is local only; * If a controller is specified via -c or --controller, operation is both local as well as remote on the specified controller; * If a controller is not specified but a current controller is detected, operation is local as well as the user is prompted to confirm if the addition should happen remotely to the current controller; * If a controller is not specified but a current controller is detected AND --no-prompt option is specified, operation is both local as well remote (addition to current controller).
There also were some inconsistency is handling file cloud definition vs interactive mode, like inconsistent user messaging, etc. These have all been corrected here.
Drive-by:
- when adding with file, if no cloud name specified but there is only one cloud in the file, use it;
- if there is no cloud specified but there is more than one cloud defined in a file, err out;
- clouds that do not have a region, will be given a default region - https://bugs.launchpad.net/juju/+bug/1819409
QA steps
- add local cloud interactively (no controllers known on this client)
$ juju add-cloud
Cloud Types
lxd
maas
manual
openstack
vsphere
Select cloud type: openstack
Enter a name for your openstack cloud: stratus
Enter the API endpoint url for the cloud []: [REDACTED]
Enter a path to the CA certificate for your cloud if one is required to access it. (optional) [none]:
Auth Types
access-key
userpass
Select one or more auth types separated by commas: userpass
Enter region name: one
Enter the API endpoint url for the region [use cloud api url]:
Enter another region? (y/N): N
Cloud "stratus" successfully added to your local client.
You will need to add a credential for this cloud (`juju add-credential stratus`)
before you can use it to bootstrap a controller (`juju bootstrap stratus`) or
to create a model (`juju add-model <your model name> stratus`).
There are no controllers specified - not adding cloud "stratus" to any controller.
</your>
- adding cloud with a file (no controllers are not known to this client):
$ juju add-cloud fluffystack -f ~/a.yaml
Cloud "fluffystack" successfully added to your local client.
You will need to add a credential for this cloud (`juju add-credential fluffystack`)
before you can use it to bootstrap a controller (`juju bootstrap fluffystack`) or
to create a model (`juju add-model <your model name> fluffystack`).
There are no controllers specified - not adding cloud "fluffystack" to any controller.
</your>
- add cloud to a specified controller with file
$ juju add-cloud fluffystack -f ~/a.yaml -c mycontroller
Adding a cloud of type "openstack" might not function correctly on this controller.
If you really want to do this, use --force.
$ juju add-cloud -c mycontroller fluffystack -f ~/a.yaml --force
Cloud "fluffystack" added to controller "mycontroller".
WARNING loading credentials: credentials for cloud fluffystack not found
To upload a credential to the controller for cloud "fluffystack", use
* 'add-model' with --credential option or
* 'add-credential -c fluffystack'.
- add cloud to the detected current controller with prompt:
$ juju add-cloud fluffystack -f ~/a.yaml --force
Do you want to add cloud "fluffystack" to current controller "mycontroller"? (Y/n):
Cloud "fluffystack" added to controller "mycontroller".
WARNING loading credentials: credentials for cloud fluffystack not found
To upload a credential to the controller for cloud "fluffystack", use
* 'add-model' with --credential option or
* 'add-credential -c fluffystack'.
- add cloud to the detected current controller without prompt:
$ juju add-cloud fluffystack -f ~/a.yaml --force --no-prompt
Cloud "fluffystack" added to controller "mycontroller".
WARNING loading credentials: credentials for cloud fluffystack not found
To upload a credential to the controller for cloud "fluffystack", use
* 'add-model' with --credential option or
* 'add-credential -c fluffystack'.
该提问来源于开源项目:juju/juju