FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-libjuju/examples/add_machine.py at master · Maxcode123/python-libjuju · GitHub
Maxcode123
python-libjuju
Repository navigation
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-libjuju
/
examples
/
add_machine.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
executable file
·
70 lines (54 loc) · 1.56 KB
Breadcrumbs
python-libjuju
/
examples
/
add_machine.py
Copy path
File metadata and controls
executable file
·
70 lines (54 loc) · 1.56 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
"""
This example:
1. Connects to the current model
2. Creates two machines and a lxd container
3. Deploys charm to the lxd container
"""
import
logging
from
juju
import
jasyncio
from
juju
.
model
import
Model
MB
=
1
GB
=
1024
async
def
main
():
model
=
Model
()
await
model
.
connect
()
try
:
# add a new default machine
machine1
=
await
model
.
add_machine
()
# add a machine with constraints, disks, and series
machine2
=
await
model
.
add_machine
(
constraints
=
{
'mem'
:
256
*
MB
,
},
disks
=
[{
'size'
:
10
*
GB
,
'count'
:
1
,
}],
series
=
'jammy'
,
)
# add a lxd container to machine2
machine3
=
await
model
.
add_machine
(
'lxd:{}'
.
format
(
machine2
.
id
),
series
=
'jammy'
)
# deploy charm to the lxd container
application
=
await
model
.
deploy
(
'ch:ubuntu'
,
application_name
=
'ubuntu'
,
series
=
'jammy'
,
channel
=
'stable'
,
to
=
machine3
.
id
)
await
model
.
wait_for_idle
(
status
=
'active'
)
await
application
.
remove
()
await
machine3
.
destroy
(
force
=
True
)
await
machine2
.
destroy
(
force
=
True
)
await
machine1
.
destroy
(
force
=
True
)
finally
:
await
model
.
disconnect
()
if
__name__
==
'__main__'
:
logging
.
basicConfig
(
level
=
logging
.
DEBUG
)
ws_logger
=
logging
.
getLogger
(
'websockets.protocol'
)
ws_logger
.
setLevel
(
logging
.
INFO
)
jasyncio
.
run
(
main
())
Back
|
FazBrowse Home
|
New Git URL