+ async def disconnect(self):
+ """Shut down the watcher task and close websockets.
+
+ """
+ if self.connection and self.connection.is_open:
+ log.debug('Closing controller connection')
+ await self.connection.close()
+ self.connection = None
+
+ async def add_model(
+ self, name, cloud, credential, owner=None,
+ config=None, region=None):
+ """Add a model to this controller.
+
+ :param str name: Name of the model
+ :param dict config: Model configuration
+ :param str credential: e.g. '<cloud>:<credential>'
+ :param str owner: Owner username
+
+ """
+ model_facade = client.ModelManagerFacade()
+ model_facade.connect(self.connection)
+
+ log.debug('Creating model %s', name)
+
+ model_info = await model_facade.CreateModel(
+ cloud,
+ config,
+ credential,
+ name,
+ owner or self.connection.info['user-info']['identity'],
+ region,
+ )
+
+ model = Model()
+ await model.connect(
+ self.connection.endpoint,
+ model_info.uuid,
+ self.connection.username,
+ self.connection.password,
+ self.connection.cacert,
+ self.connection.macaroons,
+ )
+
+ return model
+
+ def add_user(self, username, display_name=None, acl=None, models=None):