If deploying a single app, return the App instead of a list
[osm/N2VC.git] / juju / model.py
index 7fe0514..26611fc 100644 (file)
@@ -791,8 +791,11 @@ class Model(object):
             if pending_apps:
                 # new apps will usually be in the model by now, but if some
                 # haven't made it yet we'll need to wait on them to be added
-                await asyncio.wait([self._wait_for_new('application', app_name)
-                                    for app_name in pending_apps])
+                await asyncio.gather(*[
+                    asyncio.ensure_future(
+                        self.model._wait_for_new('application', app_name))
+                    for app_name in pending_apps
+                ])
             return [app for name, app in self.applications.items()
                     if name in handler.applications]
         else:
@@ -815,7 +818,7 @@ class Model(object):
             )
 
             await app_facade.Deploy([app])
-            return [await self._wait_for_new('application', service_name)]
+            return await self._wait_for_new('application', service_name)
 
     def destroy(self):
         """Terminate all machines and resources for this model.
@@ -823,6 +826,21 @@ class Model(object):
         """
         pass
 
+    async def destroy_unit(self, *unit_names):
+        """Destroy units by name.
+
+        """
+        app_facade = client.ApplicationFacade()
+        app_facade.connect(self.connection)
+
+        log.debug(
+            'Destroying unit%s %s',
+            's' if len(unit_names) == 1 else '',
+            ' '.join(unit_names))
+
+        return await app_facade.Destroy(self.name)
+    destroy_units = destroy_unit
+
     def get_backup(self, archive_id):
         """Download a backup archive file.