Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I use amulet as testing framework for charms which we developing. I've already tried to reproduce an example, provided on and it's work fine. But now I'm trying to do the same basic setup for charm, which was developed and stored on hard drive ('cf-nats' charm was cloned from github). Here the list of my actions (I use local environment for deploying):

Python 3.2.3 (default, Feb 27 2014, 21:31:18) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import amulet
>>> import requests
>>> d = amulet.Deployment(series='trusty')
>>> d.add('cf-nats', charm = '/home/ubuntu/cf-charms/charms/trusty/cf-nats')
>>> d.setup()

And I got the next output:

2014-03-10 10:56:09 Starting deployment of local
Traceback (most recent call last):
  File "/usr/bin/juju-deployer", line 9, in <module>
    load_entry_point('juju-deployer==0.2.5', 'console_scripts', 'juju-deployer')()
  File "/usr/lib/python2.7/dist-packages/deployer/", line 118, in main
  File "/usr/lib/python2.7/dist-packages/deployer/", line 204, in run
    importer.Importer(env, deployment, options).run()
  File "/usr/lib/python2.7/dist-packages/deployer/action/", line 142, in run
  File "/usr/lib/python2.7/dist-packages/deployer/action/", line 47, in get_charms
  File "/usr/lib/python2.7/dist-packages/deployer/", line 112, in fetch_charms
  File "/usr/lib/python2.7/dist-packages/deployer/", line 98, in fetch
AttributeError: 'NoneType' object has no attribute 'branch'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/amulet/", line 175, in setup
    self.juju_env], cwd=self.deployer_dir)
  File "/usr/lib/python3.2/", line 489, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['juju-deployer', '-W', '-c', '/tmp/amulet-juju-deployer-myb41r.json', '-e', 'local', 'local']' returned non-zero exit status 1

I've also tried to deploy the same charm manualy with juju command line interface and it's work.

Here is the output from d.schema()

>>> d.schema()
{'local': {'services': {'cf-nats-sentry': {'_has_sentry': True, 'expose': True, 'branch': '/tmp/sentry-sub_16ocg4/cf-nats-sentry'}, 'cf-nats': {'_has_sentry': True, 'branch': '/home/ubuntu/cf-charms/charms/trusty/cf-nats'}, 'relation-sentry': {'expose': True, 'branch': '/tmp/sentry_5cdg4t/relation-sentry'}}, 'series': 'trusty', 'relations': [['cf-nats:juju-info', 'cf-nats-sentry:juju-info']]}}

What is wrong in my code? How can I deploy my local charm with amulet framework? What kind of python packages should be installed?

Thank you in advance.

share|improve this question
What version of amulet are you using? – Marco Ceppi Mar 10 '14 at 15:16
We have tried 1.3.3 and 1.3.4 as well. – DmitryTrofimov Mar 10 '14 at 22:56
Interesting, I've not tested Amulet with trusty, though that should work just fine. It appears that deployer is the one complaining. Could you paste the output of d.schema() before you run d.setup()? – Marco Ceppi Mar 11 '14 at 1:39
Also, the charms on github in are really out of date. The sync mirror hasn't been running for quite a few months while we update the charm store. You may want to pull your charms from Launchpad going forward. – Marco Ceppi Mar 11 '14 at 15:35

I believe I see your problem. So, you pulled this charm from github which is fine. However, tests are usually written and run from within the tests directory. So, amulet applies a little bit of magic to deploy using the charm on disk so you don't have to explicitly put charm= in the d.add line. However, since you're running from interactive shell it makes sense for you to do this. The problem is, it's not a Bazaar branch which is what Juju Deployer is expecting.

Typically, what happens, when you just do d.add('cf-nats') in a charm test, the charm tree gets copied to a temporary location, and a bzr repo is created (if one doesn't exist already). Then that new temp location is fed to deployer. However, since you've given it a firm file path that part isn't happening (by design) and it assumes you have a charm that has a bzr repo and it's just going to use that.

The way around this is to either run export JUJU_TEST_CHARM="cf-nats" (and environment variable the juju test plugin sets) prior to launching your Python3 shell from the $CHARM_DIR (/home/ubuntu/cf-charms/charms/trusty/cf-nats) or after creating d = amulet.Deployment() set d.charm_name = 'cf-nats'. Then just do d.add('cf-nats'), amulet will see that the basename of getcwd is the same as the charm name and transparently perform it's little bit of magic.

That should do it. Ideally, adding support for git based charms to juju deployer will resolve all of this, but try that and let me know if it doesn't work for you.

share|improve this answer
Thank you, Marco. We appreciate your help. We'll try it ASAP. Also currently to deploy a service from local disk I use from charm's directory: juju deploy --repository=../../. local:trusty/cf-go-router It works well, but I'm not sure about '--repository=../../.' Is it right way to specify path to the local repo? – Alex Prismakov Mar 11 '14 at 16:25
Hello, Marco. Yes, it definitely makes sense, but I've tried to add charm from $CHARM_DIR and unfortunately, I got the same results. – DmitryTrofimov Mar 11 '14 at 20:05
So, it helps if I read my own code. You should still launch the python interpreter from the CHARM_DIR, but you'll also need to either set this environment variable prior to launching the interpreter JUJU_TEST_CHARM=cf-nats or, after instantiating amulet.Deployment, set d.charm_name to cf-nats. I'll update my answer with this. – Marco Ceppi Mar 11 '14 at 20:29
@AlexPrismakov that is the correct way to do local repo deployments, yes. – Marco Ceppi Mar 11 '14 at 20:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.