X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=juju%2Fcontroller.py;h=6331c12b7c63563b4b9d67f35eb4978a7355112b;hb=0d70179f2088da28e47bcad569366fb3dddd6e6d;hp=67409ba879c628de63c39be2a53707b07a9f1fb6;hpb=6ba2856fecf224ae3fd589331e889a6587e8153b;p=osm%2FN2VC.git diff --git a/juju/controller.py b/juju/controller.py index 67409ba..6331c12 100644 --- a/juju/controller.py +++ b/juju/controller.py @@ -55,39 +55,46 @@ class Controller(object): self.connection = None async def add_model( - self, model_name, cloud_name, credential_name, + self, model_name, cloud_name=None, credential_name=None, owner=None, config=None, region=None): """Add a model to this controller. :param str model_name: Name to give the new model. :param str cloud_name: Name of the cloud in which to create the - model, e.g. 'aws'. + model, e.g. 'aws'. Defaults to same cloud as controller. :param str credential_name: Name of the credential to use when - creating the model. + creating the model. Defaults to current credential. If you + pass a credential_name, you must also pass a cloud_name, + even if it's the default cloud. :param str owner: Username that will own the model. Defaults to the current user. :param dict config: Model configuration. :param str region: Region in which to create the model. """ - # XXX: We can probably obviate the cloud_name param by getting it - # from the controller itself. - model_facade = client.ModelManagerFacade() model_facade.connect(self.connection) owner = owner or self.connection.info['user-info']['identity'] + # XXX: We should be able to accept a credential_name without + # a cloud_name, and just get the cloud_name from the controller. + if credential_name and cloud_name: + credential = tag.credential( + cloud_name, + tag.untag('user-', owner), + credential_name + ) + else: + credential = None + + log.debug('Creating model %s', model_name) model_info = await model_facade.CreateModel( tag.cloud(cloud_name), config, - tag.credential( - cloud_name, - tag.untag('user-', owner), - credential_name - ), + credential, model_name, owner, region,