Is it possible to a charm to ask juju to start another machine, add instances of a service or destroy instances? For instance, by doing something simular to the juju gui: how juju gui performs the creation of machines, for instance? I´d to have a service that monitors other services and add instances to scale out, for instance.
1 Answer
There are a few ways this is possible.
Installing and calling Juju binaries
The charms.reactive layer at https://github.com/galgalesh/juju-client does this. The basic process is to first bootstrap the environment, then deploy a charm passing in all the configuration, state and secrets files necessary to control the environment. The charm installs the juju client, rebuilds ~/.juju, and can now control the environment from the inside.
This layer is still experimental. If you encounter any issues, file a bug report in the github repo.
Using the Python Juju client
There is a Python client to manage Juju environments. This client calls the Juju api. You could put this in a Charm.
Using the Go API
You can find the go api here: https://godoc.org/github.com/juju/juju/api
Using Perl bindings
If you're into that sort of stuff: https://metacpan.org/release/Juju
Calling the api directly
For more information on that, see this question: Is there a Juju REST API?
-
Thanks for suggesting my layer! I added some more options and a disclaimer. Nov 10, 2015 at 17:07