HI,

We have action_do function to download the packages from the repository in
our amulet test as follows.
   uuid = d.action_do('ibm-db2/0', 'download', {"username": config.get
('ibm-repo').get('sftp_user_name'), "password": config.get('ibm-repo').get
('sftp_password'), "packagename": config.get('ibm-repo').get
('package_name'), "host": config.get('ibm-repo').get('sftp_host')})

With newer version of juju we cannot give the unit name like ibm-db2/0 as
the unit names keeps increasing sequentially with multiple deployment.
We tried to get the unit name as follows and passed it to action_do
function, but it threw error.

db2_unit1 = d.sentry['ibm-db2'][0]
        uuid = d.action_do(db2_unit1, 'download', {"username": config.get
('ibm-repo').get('sftp_user_name'), "password": config.get('ibm-repo').get
('sftp_password'), "packagename": config.get('ibm-repo').get
('package_name'), "host": config.get('ibm-repo').get('sftp_host')})



The error we got is :


======================================================================
ERROR: setUpClass (__main__.BundleTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/10-bundles-test.py", line 47, in setUpClass
    uuid = d.action_do(db2_unit1, 'download', {"username": config.get
('ibm-repo').get('sftp_user_name'), "password": config.get('ibm-repo').get
('sftp_password'), "packagename": config.get('ibm-repo').get
('package_name'), "host": config.get('ibm-repo').get('sftp_host')})
  File "/usr/lib/python2.7/dist-packages/amulet/deployer.py", line 372, in
action_do
    if '/' not in unit:
TypeError: argument of type 'UnitSentry' is not iterable



The action_do function in the above in .py file is defined as follows:

 def action_do(self, unit, action, action_args={}):
        """
        :param unit: Unit to run action on.
        :param action: Action to run.
        :param action_args: Action parameters.

        Runs specified action on specified unit and returns the uuid to
fetch
        results by.

        """
        if '/' not in unit:
            raise ValueError('%s is not a unit' % unit)
        cmd = ['action', 'do', unit, action, '--format', 'json']
        for key, value in action_args.items():
            cmd += ["%s=%s" % (str(key), str(value))]
        result = juju(cmd)
        action_result = json.loads(result)
        results_id = action_result["Action queued with id"]
        return results_id


>From this we understand that "/" is required in the unitname for action to
work .

How do we resolve this issue in latest version of Juju. Is it a limitation
in the newer version for using action commands inside amulet test ?


Thanks,
Sunitha.
-- 
Juju mailing list
Juju@lists.ubuntu.com
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/juju

Reply via email to