New N2VC interface + updated libjuju

This commit introduces the Python3 N2VC module, which acts as a standard
interface to the VCA.

The goal of this is to provide a common way for modules to interface
with the VCA.

- Updated libjuju from 0.6.1 to 0.7.3

Signed-off-by: Adam Israel <adam.israel@canonical.com>
Change-Id: Ide70fb5ae5797eb6486de24653dc09a23f9c009e
diff --git a/modules/libjuju/examples/action.py b/modules/libjuju/examples/action.py
index 0f25647..4a3cc6d 100644
--- a/modules/libjuju/examples/action.py
+++ b/modules/libjuju/examples/action.py
@@ -27,7 +27,7 @@
 
 async def main():
     model = Model()
-    await model.connect_current()
+    await model.connect()
     await model.reset(force=True)
 
     app = await model.deploy(
diff --git a/modules/libjuju/examples/add_machine.py b/modules/libjuju/examples/add_machine.py
index 8ae2d40..33d0c34 100755
--- a/modules/libjuju/examples/add_machine.py
+++ b/modules/libjuju/examples/add_machine.py
@@ -19,7 +19,7 @@
 
 async def main():
     model = Model()
-    await model.connect_current()
+    await model.connect()
 
     try:
         # add a new default machine
diff --git a/modules/libjuju/examples/add_model.py b/modules/libjuju/examples/add_model.py
index 3e46490..0e96fa1 100644
--- a/modules/libjuju/examples/add_model.py
+++ b/modules/libjuju/examples/add_model.py
@@ -19,7 +19,7 @@
 async def main():
     controller = Controller()
     print("Connecting to controller")
-    await controller.connect_current()
+    await controller.connect()
 
     try:
         model_name = "addmodeltest-{}".format(uuid.uuid4())
diff --git a/modules/libjuju/examples/allwatcher.py b/modules/libjuju/examples/allwatcher.py
index c78d689..884230b 100644
--- a/modules/libjuju/examples/allwatcher.py
+++ b/modules/libjuju/examples/allwatcher.py
@@ -16,7 +16,7 @@
 
 
 async def watch():
-    conn = await Connection.connect_current()
+    conn = await Connection.connect()
     allwatcher = client.AllWatcherFacade.from_connection(conn)
     while True:
         change = await allwatcher.Next()
diff --git a/modules/libjuju/examples/config.py b/modules/libjuju/examples/config.py
index bacc840..bad5b6d 100644
--- a/modules/libjuju/examples/config.py
+++ b/modules/libjuju/examples/config.py
@@ -19,7 +19,7 @@
 
 async def main():
     model = Model()
-    await model.connect_current()
+    await model.connect()
     await model.reset(force=True)
 
     ubuntu_app = await model.deploy(
diff --git a/modules/libjuju/examples/controller.py b/modules/libjuju/examples/controller.py
index 6002f68..3f029ab 100644
--- a/modules/libjuju/examples/controller.py
+++ b/modules/libjuju/examples/controller.py
@@ -17,7 +17,7 @@
 
 async def main():
     controller = Controller()
-    await controller.connect_current()
+    await controller.connect()
     model = await controller.add_model(
         'my-test-model',
         'aws',
diff --git a/modules/libjuju/examples/deploy.py b/modules/libjuju/examples/deploy.py
index e6c306a..b14e4ca 100644
--- a/modules/libjuju/examples/deploy.py
+++ b/modules/libjuju/examples/deploy.py
@@ -13,7 +13,7 @@
 async def main():
     model = Model()
     print('Connecting to model')
-    await model.connect_current()
+    await model.connect()
 
     try:
         print('Deploying ubuntu')
diff --git a/modules/libjuju/examples/fullstatus.py b/modules/libjuju/examples/fullstatus.py
index cdaf51d..5548423 100644
--- a/modules/libjuju/examples/fullstatus.py
+++ b/modules/libjuju/examples/fullstatus.py
@@ -5,7 +5,7 @@
 from juju import loop
 
 async def status():
-    conn = await Connection.connect_current()
+    conn = await Connection.connect()
     client = ClientFacade.from_connection(conn)
 
     patterns = None
diff --git a/modules/libjuju/examples/future.py b/modules/libjuju/examples/future.py
index 0180325..c93981a 100644
--- a/modules/libjuju/examples/future.py
+++ b/modules/libjuju/examples/future.py
@@ -11,7 +11,7 @@
 
 async def main():
     model = Model()
-    await model.connect_current()
+    await model.connect()
     await model.reset(force=True)
 
     goal_state = Model.from_yaml('bundle-like-thing')
diff --git a/modules/libjuju/examples/leadership.py b/modules/libjuju/examples/leadership.py
index b231003..dbd1b6e 100644
--- a/modules/libjuju/examples/leadership.py
+++ b/modules/libjuju/examples/leadership.py
@@ -13,7 +13,7 @@
 
 async def report_leadership():
     model = Model()
-    await model.connect_current()
+    await model.connect()
 
     print("Leadership: ")
     for app in model.applications.values():
diff --git a/modules/libjuju/examples/livemodel.py b/modules/libjuju/examples/livemodel.py
index 47eb999..a15e9f7 100644
--- a/modules/libjuju/examples/livemodel.py
+++ b/modules/libjuju/examples/livemodel.py
@@ -21,7 +21,7 @@
 
 async def watch_model():
     model = Model()
-    await model.connect_current()
+    await model.connect()
 
     model.add_observer(on_model_change)
 
diff --git a/modules/libjuju/examples/localcharm.py b/modules/libjuju/examples/localcharm.py
index 978703e..b9481d4 100644
--- a/modules/libjuju/examples/localcharm.py
+++ b/modules/libjuju/examples/localcharm.py
@@ -15,7 +15,7 @@
 
 async def main():
     model = Model()
-    await model.connect_current()
+    await model.connect()
 
     # Deploy a local charm using a path to the charm directory
     await model.deploy(
diff --git a/modules/libjuju/examples/relate.py b/modules/libjuju/examples/relate.py
index 8f1e708..c0ce4c6 100644
--- a/modules/libjuju/examples/relate.py
+++ b/modules/libjuju/examples/relate.py
@@ -40,59 +40,62 @@
 
 async def main():
     model = Model()
-    await model.connect_current()
+    await model.connect()
 
-    model.add_observer(MyRemoveObserver())
-    await model.reset(force=True)
-    model.add_observer(MyModelObserver())
+    try:
+        model.add_observer(MyRemoveObserver())
+        await model.reset(force=True)
+        model.add_observer(MyModelObserver())
 
-    ubuntu_app = await model.deploy(
-        'ubuntu',
-        application_name='ubuntu',
-        series='trusty',
-        channel='stable',
-    )
-    ubuntu_app.on_change(asyncio.coroutine(
-        lambda delta, old_app, new_app, model:
-            print('App changed: {}'.format(new_app.entity_id))
-    ))
-    ubuntu_app.on_remove(asyncio.coroutine(
-        lambda delta, old_app, new_app, model:
-            print('App removed: {}'.format(old_app.entity_id))
-    ))
-    ubuntu_app.on_unit_add(asyncio.coroutine(
-        lambda delta, old_unit, new_unit, model:
-            print('Unit added: {}'.format(new_unit.entity_id))
-    ))
-    ubuntu_app.on_unit_remove(asyncio.coroutine(
-        lambda delta, old_unit, new_unit, model:
-            print('Unit removed: {}'.format(old_unit.entity_id))
-    ))
-    unit_a, unit_b = await ubuntu_app.add_units(count=2)
-    unit_a.on_change(asyncio.coroutine(
-        lambda delta, old_unit, new_unit, model:
-            print('Unit changed: {}'.format(new_unit.entity_id))
-    ))
-    await model.deploy(
-        'nrpe',
-        application_name='nrpe',
-        series='trusty',
-        channel='stable',
-        # subordinates must be deployed without units
-        num_units=0,
-    )
-    my_relation = await model.add_relation(
-        'ubuntu',
-        'nrpe',
-    )
-    my_relation.on_remove(asyncio.coroutine(
-        lambda delta, old_rel, new_rel, model:
-            print('Relation removed: {}'.format(old_rel.endpoints))
-    ))
+        ubuntu_app = await model.deploy(
+            'ubuntu',
+            application_name='ubuntu',
+            series='trusty',
+            channel='stable',
+        )
+        ubuntu_app.on_change(asyncio.coroutine(
+            lambda delta, old_app, new_app, model:
+                print('App changed: {}'.format(new_app.entity_id))
+        ))
+        ubuntu_app.on_remove(asyncio.coroutine(
+            lambda delta, old_app, new_app, model:
+                print('App removed: {}'.format(old_app.entity_id))
+        ))
+        ubuntu_app.on_unit_add(asyncio.coroutine(
+            lambda delta, old_unit, new_unit, model:
+                print('Unit added: {}'.format(new_unit.entity_id))
+        ))
+        ubuntu_app.on_unit_remove(asyncio.coroutine(
+            lambda delta, old_unit, new_unit, model:
+                print('Unit removed: {}'.format(old_unit.entity_id))
+        ))
+        unit_a, unit_b = await ubuntu_app.add_units(count=2)
+        unit_a.on_change(asyncio.coroutine(
+            lambda delta, old_unit, new_unit, model:
+                print('Unit changed: {}'.format(new_unit.entity_id))
+        ))
+        await model.deploy(
+            'nrpe',
+            application_name='nrpe',
+            series='trusty',
+            channel='stable',
+            # subordinates must be deployed without units
+            num_units=0,
+        )
+        my_relation = await model.add_relation(
+            'ubuntu',
+            'nrpe',
+        )
+        my_relation.on_remove(asyncio.coroutine(
+            lambda delta, old_rel, new_rel, model:
+                print('Relation removed: {}'.format(old_rel.endpoints))
+        ))
+    finally:
+        await model.disconnect()
 
 
 if __name__ == '__main__':
-    logging.basicConfig(level=logging.DEBUG)
+    logging.basicConfig(level=logging.INFO)
     ws_logger = logging.getLogger('websockets.protocol')
     ws_logger.setLevel(logging.INFO)
     loop.run(main())
diff --git a/modules/libjuju/examples/unitrun.py b/modules/libjuju/examples/unitrun.py
index 3dfacd6..b6e2240 100644
--- a/modules/libjuju/examples/unitrun.py
+++ b/modules/libjuju/examples/unitrun.py
@@ -24,7 +24,7 @@
 
 async def main():
     model = Model()
-    await model.connect_current()
+    await model.connect()
     await model.reset(force=True)
 
     app = await model.deploy(