Deploying a Charm

There are 3 api calls that need to be made in order to have Juju deploy a charm.

  1. You must add the charm url to the Juju controller
  2. You must make the juju controller aware of any resources attached to that charm
  3. Finally you can deploy.

Adding the Charm

this.CLIENT.Client(request="AddCharm",
                           params={"url": "cs:~containers/trusty/etcd-3"})

Adding Resources

Getting the resources:

In [7]: r = requests.get("https://api.jujucharms.com/charmstore/v5/meta/any?include=resources&id=~containers/trusty/etcd")

In [8]: r.json()
Out[8]: 
{'~containers/trusty/etcd': {'Meta': {'resources': [{'Size': 17408032,
     'Path': 'etcd',
     'Type': 'file',
     'Origin': '',
     'Name': 'etcd',
     'Description': 'Etcd binary release',
     'Revision': 0,
     'Fingerprint': 'y9Qymsubzlxd/WmshtzlQ6EAj0CXSypD3sROSk7BjgVrT4o2MddLBS/GBt+yWSxC'},
    {'Size': 14878944,
     'Path': 'etcdctl',
     'Type': 'file',
     'Origin': '',
     'Name': 'etcdctl',
     'Description': 'Etcdctl binary release',
     'Revision': 0,
     'Fingerprint': 'hleAj63OFxAF9yGNSWTPJ7ED8WGlqiujAuJfGIQOFGqEUDRGfcoNPVChcbSL//5r'}]},
  'Id': 'cs:~containers/trusty/etcd-3'}}
You must set 'Origin' to 'store' manually.

Example:

In [35]: juju.CLIENT.resources(request="AddPendingResources", params={"tag":"application-etcd", "url": "cs:~containers/trusty/etcd-3", "resources":resources})
Out[35]: 
{'PendingIDs': ['3c1d42f8-2cf9-470b-8159-ef3692f870da',
  '11774e87-9e25-4626-8e5d-137b78a586e0']}