Skip to content

Commit c6a771a

Browse files
committed
Update the series used in examples
1 parent dfb69fd commit c6a771a

8 files changed

Lines changed: 37 additions & 34 deletions

File tree

examples/add_machine.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,28 @@ async def main():
3030
'mem': 256 * MB,
3131
},
3232
disks=[{
33-
'pool': 'rootfs',
3433
'size': 10 * GB,
3534
'count': 1,
3635
}],
37-
series='xenial',
36+
series='jammy',
3837
)
38+
3939
# add a lxd container to machine2
4040
machine3 = await model.add_machine(
4141
'lxd:{}'.format(machine2.id),
42-
series='xenial'
42+
series='jammy'
4343
)
4444

4545
# deploy charm to the lxd container
4646
application = await model.deploy(
4747
'ch:ubuntu',
4848
application_name='ubuntu',
49-
series='xenial',
49+
series='jammy',
5050
channel='stable',
5151
to=machine3.id
5252
)
5353

54-
await model.block_until(
55-
lambda: all(unit.workload_status == 'active'
56-
for unit in application.units))
54+
await model.wait_for_idle(status='active')
5755

5856
await application.remove()
5957

examples/add_model.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,13 @@ async def main():
3131
application = await model.deploy(
3232
'ch:ubuntu',
3333
application_name='ubuntu',
34-
series='trusty',
34+
series='jammy',
3535
channel='stable',
3636
)
3737

3838
print('Waiting for active')
3939
await asyncio.sleep(10)
40-
await model.block_until(
41-
lambda: all(unit.workload_status == 'active'
42-
for unit in application.units))
40+
await model.wait_for_idle(status='active')
4341

4442
print("Verifying that we can ssh into the created model")
4543
ret = await utils.execute_process(

examples/config.py

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,33 +22,38 @@ async def main():
2222
await model.connect()
2323

2424
ubuntu_app = await model.deploy(
25-
'ch:mysql',
25+
'mysql',
2626
application_name='mysql',
27-
series='trusty',
28-
channel='stable',
27+
series='jammy',
28+
channel='edge',
2929
config={
30-
'tuning-level': 'safest',
30+
'cluster-name': 'foo',
3131
},
3232
constraints={
3333
'mem': 256 * MB,
3434
},
3535
)
36+
await model.wait_for_idle(status='active')
3637

3738
# update and check app config
38-
await ubuntu_app.set_config({'tuning-level': 'fast'})
39+
await ubuntu_app.set_config({'cluster-name': 'bar'})
3940
config = await ubuntu_app.get_config()
40-
assert (config['tuning-level']['value'] == 'fast')
41+
assert (config['cluster-name']['value'] == 'bar')
4142

4243
# update and check app constraints
4344
await ubuntu_app.set_constraints({'mem': 512 * MB})
4445
constraints = await ubuntu_app.get_constraints()
4546
assert (constraints['mem'] == 512 * MB)
4647

48+
print('Removing mysql')
49+
await ubuntu_app.remove()
50+
51+
print('Disconnecting from model')
4752
await model.disconnect()
4853

4954

5055
if __name__ == '__main__':
51-
logging.basicConfig(level=logging.DEBUG)
56+
# logging.basicConfig(level=logging.DEBUG)
5257
ws_logger = logging.getLogger('websockets.protocol')
5358
ws_logger.setLevel(logging.INFO)
5459
jasyncio.run(main())

examples/crossmodel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ async def main():
3131
application = await offering_model.deploy(
3232
'ch:mysql',
3333
application_name='mysql',
34-
series='trusty',
35-
channel='stable',
34+
series='jammy',
35+
channel='edge',
3636
)
3737

3838
print('Waiting for active')

examples/crossmodel_bundle.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,15 @@ async def main():
3131
consuming_model = await controller.add_model('test-cmr-2')
3232

3333
print('Deploying mysql')
34-
application_1 = await offering_model.deploy(
34+
await offering_model.deploy(
3535
'ch:mysql',
3636
application_name='mysql',
37-
series='xenial',
38-
channel='stable',
37+
series='jammy',
38+
channel='edge',
3939
)
4040

4141
print('Waiting for active')
42-
await offering_model.block_until(
43-
lambda: all(unit.workload_status == 'active'
44-
for unit in application_1.units))
42+
await offering_model.wait_for_idle(status='active')
4543

4644
print('Adding offer')
4745
await offering_model.create_offer("mysql:db")

examples/crossmodel_relation.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,15 @@ async def main():
3131
consuming_model = await controller.add_model('test-cmr-2')
3232

3333
print('Deploying mysql')
34-
application_1 = await offering_model.deploy(
34+
await offering_model.deploy(
3535
'ch:mysql',
3636
application_name='mysql',
37-
series='xenial',
38-
channel='stable',
37+
series='jammy',
38+
channel='edge',
3939
)
4040

4141
print('Waiting for active')
42-
await offering_model.block_until(
43-
lambda: all(unit.workload_status == 'active'
44-
for unit in application_1.units))
42+
await offering_model.wait_for_idle(status='active')
4543

4644
print('Adding offer')
4745
await offering_model.create_offer("mysql:db")
@@ -53,6 +51,8 @@ async def main():
5351

5452
print('Show offers', ', '.join("%s: %s" % item for offer in offers.results for item in vars(offer).items()))
5553

54+
# TODO (cderici): wordpress charm is somewhat problematic in 3.0,
55+
# this example needs to be revisited.
5656
print('Deploying wordpress')
5757
application_2 = await consuming_model.deploy(
5858
'ch:trusty/wordpress',

examples/expose-application.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ async def main():
2424
application = await model.deploy(
2525
'ch:ubuntu',
2626
application_name='ubuntu',
27-
series='trusty',
27+
series='jammy',
2828
channel='stable',
2929
)
3030

@@ -57,6 +57,7 @@ async def main():
5757
"ubuntu": ExposedEndpoint(to_cidrs=["10.42.42.0/24"])
5858
})
5959

60+
# TODO (cderici) : this part needs to be revisited
6061
print('Unexpose individual endpoints (other endpoints remain exposed)')
6162
await application.unexpose(exposed_endpoints=["ubuntu"])
6263

examples/status.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ async def main():
2020
application = await model.deploy(
2121
'ch:ubuntu',
2222
application_name='ubuntu',
23-
series='trusty',
23+
series='jammy',
2424
channel='stable',
2525
)
2626
await jasyncio.sleep(10)
@@ -38,7 +38,10 @@ async def main():
3838
print(e)
3939
await jasyncio.sleep(5)
4040

41+
print('Removing ubuntu')
4142
await application.remove()
43+
44+
print('Disconnecting from model')
4245
await model.disconnect()
4346

4447
if __name__ == '__main__':

0 commit comments

Comments
 (0)