From 14392af3fc1c11e40463d0b109c8b8f50c9957e2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?S=C3=A9bastien=20Pattyn?= Date: Thu, 28 Sep 2017 15:52:31 -0400 Subject: [PATCH] removing cli command to add ssh keys (#161) * removing cli command to add ssh keys * add ssh-key after model-creation * awaiting method * Update controller.py * adding user ssh-key when model is created * fixed wrong config placement --- juju/controller.py | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/juju/controller.py b/juju/controller.py index 9b452c7..98dd59d 100644 --- a/juju/controller.py +++ b/juju/controller.py @@ -95,6 +95,10 @@ class Controller(object): credential = None log.debug('Creating model %s', model_name) + + if not config or 'authorized-keys' not in config: + config = config or {} + config['authorized-keys'] = await utils.read_ssh_key(loop=self.loop) model_info = await model_facade.CreateModel( tag.cloud(cloud_name), @@ -105,24 +109,6 @@ class Controller(object): region ) - # Add our ssh key to the model, to work around - # https://bugs.launchpad.net/juju/+bug/1643076 - try: - ssh_key = await utils.read_ssh_key(loop=self.loop) - - if self.controller_name: - model_name = "{}:{}".format(self.controller_name, model_name) - - cmd = ['juju', 'add-ssh-key', '-m', model_name, ssh_key] - - await utils.execute_process(*cmd, log=log, loop=self.loop) - except Exception: - log.exception( - "Could not add ssh key to model. You will not be able " - "to ssh into machines in this model. " - "Manually running `juju add-ssh-key ` in the cli " - "may fix this problem.") - model = Model() await model.connect( self.connection.endpoint, @@ -136,6 +122,7 @@ class Controller(object): return model + async def destroy_models(self, *uuids): """Destroy one or more models. -- 2.25.1