From: Sébastien Pattyn Date: Thu, 28 Sep 2017 19:52:31 +0000 (-0400) Subject: removing cli command to add ssh keys (#161) X-Git-Tag: 0.6.1~2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=14392af3fc1c11e40463d0b109c8b8f50c9957e2;p=osm%2FN2VC.git 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 --- 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.