What is the best way to work with multiple models in a controller using the cli?

Akshat Jiwan Sharma akshatjiwan at gmail.com
Thu Oct 5 07:43:43 UTC 2017


Hi,

I have deployed a few models using the local juju controller and I want
to execute a bunch of commands on a particular model using the juju-cli.

Lets say I have these three models defined on my controller

- model1
- model2
- model3

This is the sequence of commands I want to run

1. List all the machines in model1
2. Add storage unit to model2
3. Add a relation between applications in model3

These operations may be run in any order. That is first I might run op 2
then op 3 and then op1.
The only constraint is that an operation must be run on a particular model.
Right now I go about this task like so:-

juju switch model1 && juju machines

 This works fine. I get all my machines listed for model1. The problem with
this  approach is that I'm not sure if
another command is executing a juju switch somewhere and suddenly the model
I'm operating changes from model1 to model2.

For instance suppose that these two commands are run one after the other

juju switch model1 && juju list machines
juju switch model3 && juju add-relation app1 app2

Now how can I be certain that for second command I'm operating on model 3?
As far as I understand juju switches are global.
Meaning a `switch` makes a change "permanent" to all the other commands
that follow.

My question is how do I "lock" the execution of a certain command to a
particular model?

Thanks,
Akshat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/juju/attachments/20171005/67c15b14/attachment.html>


More information about the Juju mailing list