projects
/
osm
/
N2VC.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Add action example and docs
[osm/N2VC.git]
/
examples
/
controller.py
diff --git
a/examples/controller.py
b/examples/controller.py
index
3a492c4
..
7e7f0da
100644
(file)
--- a/
examples/controller.py
+++ b/
examples/controller.py
@@
-4,38
+4,32
@@
This example:
1. Connects to current controller.
2. Creates a new model.
3. Deploys an application on the new model.
1. Connects to current controller.
2. Creates a new model.
3. Deploys an application on the new model.
-
-Note: 'cloudcred' format to add a model should be:
-cloudcred-<cloudname>_<user>_<credentialname>
+4. Disconnects from the model
+5. Destroys the model
"""
import asyncio
import logging
"""
import asyncio
import logging
-from juju.model import Model, ModelObserver
from juju.controller import Controller
from juju.controller import Controller
-class MyModelObserver(ModelObserver):
- async def on_change(self, delta, old, new, model):
- pass
-
-
async def run():
controller = Controller()
await controller.connect_current()
model = await controller.add_model(
async def run():
controller = Controller()
await controller.connect_current()
model = await controller.add_model(
- '
libjuju-test
',
- '
cloud-
aws',
- '
cloudcred-aws_tvansteenburgh@external_
aws-tim',
+ '
my-test-model
',
+ 'aws',
+ 'aws-tim',
)
await model.deploy(
'ubuntu-0',
)
await model.deploy(
'ubuntu-0',
-
service
_name='ubuntu',
+
application
_name='ubuntu',
series='trusty',
channel='stable',
)
await model.disconnect()
series='trusty',
channel='stable',
)
await model.disconnect()
+ await controller.destroy_model(model.info.uuid)
await controller.disconnect()
model.loop.stop()
await controller.disconnect()
model.loop.stop()