Applying changes via js-libjuju

Hey @hatch i forgot to ask a very important question after todays hacking… what endpoints know how to deal with the output of bundlw.getChanges or am I supposed to write a parser to do the correct things with it?

I’m assuming from

https://github.com/juju/juju/blob/develop/cmd/juju/application/bundle.go#L303

this stuff in the cli client that I need to write a parser similar to this one to walk through the change array and select the correct stuff.

Also, working on the assumption I need to parse it…

The plan in my head says get the machines from the list and start them, then add applications to the machines as defined later in the list.

In doing that though, I can’t find anywhere that specifies how you add an application to a machine, like the --to call in the CLI…

– Edit –
having looked at the CLI source code it looks like I need a placement directive, not sure what scope and directive are though…

Sorry about the delay.

Yes you’ll need to manually perform the various actions from the returned changes list.

And yeah you’re right about the placement directive. The supported scope options are global and container. Basically you want to use container if the machine is a container, global otherwise. directive can be thought of as the “machine Id” from the juju status, so 2, 2/lxc/3 etc.

Thanks @hatch. If I come up with a half decent wrapper to build a model from a model yaml, should I submit a PR to make it a bit easier for others?

1 Like

That would be hugely appreciated!!