Skip to content

Commit 4bbfa6d

Browse files
Merge branch 'main' into backports
2 parents ee9e19c + 1907f7a commit 4bbfa6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3224
-120
lines changed

.github/workflows/test.yaml

+7-2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ jobs:
7878
- "3.4/stable"
7979
- "3.5/stable"
8080
- "3.6/stable"
81+
new_wait_for_idle:
82+
- "True"
83+
- "False"
8184
steps:
8285
- uses: actions/checkout@v4
8386
- uses: actions/setup-python@v5
@@ -116,7 +119,9 @@ jobs:
116119
# # set model defaults
117120
# juju model-defaults apt-http-proxy=$PROXY apt-https-proxy=$PROXY juju-http-proxy=$PROXY juju-https-proxy=$PROXY snap-http-proxy=$PROXY snap-https-proxy=$PROXY
118121
# juju model-defaults
119-
- run: uvx -p ${{ matrix.python }} tox -e integration
122+
- run: uvx -p ${{ matrix.python }} tox -s -e integration
123+
env:
124+
JUJU_NEW_WAIT_FOR_IDLE: ${{ matrix.new_wait_for_idle }}
120125

121126
integration-quarantine:
122127
name: Quarantined Integration Tests
@@ -144,4 +149,4 @@ jobs:
144149
with:
145150
provider: lxd
146151
juju-channel: ${{ matrix.juju }}
147-
- run: uvx -p ${{ matrix.python }} tox -e integration-quarantine
152+
- run: uvx -p ${{ matrix.python }} tox -s -e integration-quarantine

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ pytestdebug.log
1616
deb_dist
1717
*.tar.gz
1818
.idea/
19+
build/

docs/changelog.rst

+13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
Changelog
22
---------
33

4+
3.6.1.0
5+
^^^^^^^
6+
7+
Friday 20th Dec 2024
8+
9+
## What's Changed
10+
11+
* add 3.5.5 schema and update SCHEMAS.md by @james-garner-canonical in https://github.com/juju/python-libjuju/pull/1223
12+
* feat: larger default websockets frame size by @dimaqq in https://github.com/juju/python-libjuju/pull/1239
13+
* deprecate juju.jasyncio by @EdmilsonRodrigues in https://github.com/juju/python-libjuju/pull/1221
14+
* remove juju.loop, deprecated before 3.0 by @dimaqq in https://github.com/juju/python-libjuju/pull/1242
15+
* new wait for idle implementation, behind a feature flag ``JUJU_NEW_WAIT_FOR_IDLE`` in https://github.com/juju/python-libjuju/pull/1245
16+
417
3.6.0.0
518
^^^^^^^
619

docs/conf.py

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
"sphinx.ext.viewcode",
4949
"sphinxcontrib.asyncio",
5050
"automembersummary",
51+
# 'sphinx_tabs.tabs',
5152
]
5253

5354
# Add any paths that contain templates here, relative to this directory.

docs/howto/index.rst

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
How-to guides
2+
#############
3+
4+
.. toctree::
5+
:glob:
6+
:maxdepth: 2
7+
8+
Manage python-libjuju <manage-python-libjuju>
9+
Manage clouds <manage-clouds>
10+
Manage credentials <manage-credentials>
11+
Manage controllers <manage-controllers>
12+
Manage users <manage-users>
13+
Manage SSH keys <manage-ssh-keys>
14+
Manage models <manage-models>
15+
Manage charms <manage-charms>
16+
Manage applications <manage-applications>
17+
Manage resources (charms) <manage-charm-resources>
18+
Manage actions <manage-actions>
19+
Manage relations <manage-relations>
20+
Manage offers <manage-offers>
21+
Manage units <manage-units>
22+
Manage secrets <manage-secrets>
23+
Manage secret backends <manage-secret-backends>
24+
Manage machines <manage-machines>
25+
Manage storage <manage-storage>
26+
Manage storage pools <manage-storage-pools>
27+
Manage spaces <manage-spaces>

docs/howto/manage-actions.rst

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
.. _manage-actions:
2+
3+
How to manage actions
4+
=====================
5+
6+
7+
> See also: :ref:`juju:action`
8+
9+
10+
11+
List all actions
12+
----------------
13+
14+
15+
To list the actions defined for a deployed application, use the `get_actions()` method on the `Application` object to get all the actions defined for this application.
16+
17+
.. code:: python
18+
19+
await my_app.get_actions()
20+
21+
22+
> See more: `Application (object) <https://pythonlibjuju.readthedocs.io/en/latest/narrative/application.html>`_, `get_actions (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.get_actions>`_
23+
24+
25+
Run an action
26+
27+
To run an action on a unit, use the `run_action()` method on a Unit object of a deployed application.
28+
29+
Note that "running" an action on a unit, enqueues an action to be performed. The result will be an Action object to interact with. You will need to call `action.wait()` on that object to wait for the action to complete and retrieve the results.
30+
31+
.. code:: python
32+
33+
# Assume we deployed a git application
34+
my_app = await model.deploy('git', application_name='git', channel='stable')
35+
my_unit = my_app.units[0]
36+
37+
action = await my_unit.run_action('add-repo', repo='myrepo')
38+
await action.wait() # will return the result for the action
39+
40+
> See more: `Unit (object) <https://pythonlibjuju.readthedocs.io/en/latest/narrative/unit.html>`_, `Action (object) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.action.html#juju.action.Action>`_, `Unit.run_action (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.unit.html#juju.unit.Unit.run_action>`_, `Action.wait() (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.action.html#juju.action.Action.wait>`_

docs/howto/manage-applications.rst

+241
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,241 @@
1+
.. _manage-applications:
2+
3+
How to manage applications
4+
==========================
5+
6+
> See also: :ref:`juju:application`
7+
8+
Deploy an application
9+
---------------------
10+
11+
To deploy an application, find and deploy a charm / bundle that delivers it.
12+
13+
> See more: :ref:`deploy-a-charm`
14+
15+
View details about an application
16+
---------------------------------
17+
18+
To view details about an application on python-libjuju, you may use various `get_*` methods that are defined for applications.
19+
20+
For example, to get the config for an application, call `get_config()` method on an `Application` object:
21+
22+
.. code:: python
23+
24+
config = await my_app.get_config()
25+
26+
27+
> See more: `Application.get_config (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.get_config>`_, `Application (methods) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application>`_
28+
29+
30+
Trust an application with a credential
31+
--------------------------------------
32+
33+
Some applications may require access to the backing cloud in order to fulfil their purpose (e.g., storage-related tasks). In such cases, the remote credential associated with the current model would need to be shared with the application. When the Juju administrator allows this to occur the application is said to be *trusted*.
34+
35+
To trust an application during deployment in python-libjuju, you may call the `Model.deploy()` with the `trust` parameter:
36+
37+
.. code:: python
38+
39+
await my_model.deploy(..., trust=True, ...)
40+
41+
To trust an application after deployment, you may use the `Application.set_trusted()` method:
42+
43+
.. code:: python
44+
45+
await my_app.set_trusted(True)
46+
47+
48+
> See more: `Application.set_trusted (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.set_trusted>`_, `Application.get_trusted (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.get_trusted>`_
49+
50+
51+
Run an application action
52+
-------------------------
53+
54+
> See more: :ref:`manage-actions`
55+
56+
Configure an application
57+
------------------------
58+
59+
**Get values.** To view the existing configuration for an application on python-libjuju, you may use the `Application.get_config()` method:
60+
61+
.. code:: python
62+
63+
config = await my_app.get_config()
64+
65+
66+
**Set values.** To set configuration values for an application on python-libjuju:
67+
68+
* To configure an application at deployment, simply provide a `config` map during the `Model.deploy()` call:
69+
70+
.. code:: python
71+
72+
await my_model.deploy(..., config={'redirect-map':'https://demo'}, ...)
73+
74+
75+
* To configure an application post deployment, you may use the `Application.set_config()` method, similar to passing config in the deploy call above:
76+
77+
.. code:: python
78+
79+
await my_app.set_config(config={'redirect-map':'https://demo'})
80+
81+
82+
> See more: `Application.set_config (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.set_config>`_, `Application.get_config (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.get_config)>`_
83+
84+
85+
.. _scale-an-application:
86+
Scale an application
87+
--------------------
88+
89+
> See also: :ref:`juju:scaling`
90+
91+
Scale an application vertically
92+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
93+
94+
To scale an application vertically, set constraints for the resources that the application's units will be deployed on.
95+
96+
> See more: :ref:`manage-constraints-for-an-application`
97+
98+
Scale an application horizontally
99+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
100+
101+
To scale an application horizontally, control the number of units.
102+
103+
> See more: :ref:`control-the-number-of-units`
104+
105+
106+
Make an application highly available
107+
------------------------------------
108+
> See also: :ref:`juju:high-availability`
109+
110+
1. Find out if the charm delivering the application supports high availability natively or not. If the latter, find out what you need to do. This could mean integrating with a load balancing reverse proxy, configuring storage etc.
111+
112+
> See more: `Charmhub <https://charmhub.io/>`_
113+
114+
2. Scale up horizontally as usual.
115+
116+
> See more: {ref}`How to scale an application horizontally <5476md>`
117+
118+
Every time a unit is added to an application, Juju will spread out that application's units, distributing them evenly as supported by the provider (e.g., across multiple availability zones) to best ensure high availability. So long as a cloud's availability zones don't all fail at once, and the charm and the charm's application are well written (changing leaders, coordinating across units, etc.), you can rest assured that cloud downtime will not affect your application.
119+
120+
> See more: `Charmhub | wordpress <https://charmhub.io/wordpress>`_, `Charmhub | mediawiki <https://charmhub.io/mediawiki>`_, `Charmhub | haproxy <https://charmhub.io/haproxy>`_
121+
122+
Integrate an application with another application
123+
-------------------------------------------------
124+
125+
> See more: :ref:`manage-relations`
126+
127+
128+
Manage an application’s public availability over the network
129+
------------------------------------------------------------
130+
131+
To expose some or all endpoints of an application over a network, you may use the `Application.expose()` method, as follows:
132+
133+
.. code:: python
134+
135+
await my_app.expose(exposed_endpoints=None) # everything's reachable from 0.0.0.0/0.
136+
137+
138+
To expose to specific CIDRs or spaces, you may use an `ExposedEndpoint` object to describe that, as follows:
139+
140+
.. code:: python
141+
142+
# For spaces
143+
await my_app.expose(exposed_endpoints={"": ExposedEndpoint(to_spaces=["alpha"]) })
144+
145+
# For cidrs
146+
await my_app.expose(exposed_endpoints={"": ExposedEndpoint(to_cidrs=["10.0.0.0/24"])})
147+
148+
# You may use both at the same time too
149+
await my_app.expose(exposed_endpoints={
150+
"ubuntu": ExposedEndpoint(to_spaces=["alpha"], to_cidrs=["10.0.0.0/24"])
151+
})
152+
153+
154+
155+
To unexpose an application, use the `Application.unexpose()` method:
156+
157+
.. code:: python
158+
159+
await my_app.unexpose() # unexposes the entire application
160+
161+
await my_app.unexpose(exposed_endpoints=["ubuntu"]) # unexposes the endpoint named "ubuntu"
162+
163+
164+
> See more: `ExposedEndpoint (methods) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.ExposedEndpoint>`_, `Application.expose() <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.expose>`_, `Application.unexpose() <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.unexpose>`_
165+
166+
167+
.. _manage-constraints-for-an-application:
168+
Manage constraints for an application
169+
-------------------------------------
170+
171+
> See also: :ref:`juju:constraint`
172+
173+
**Set values.** To set constraints for application in python-libjuju:
174+
175+
* To set at deployment, simply provide a `constraints` map during the `Model.deploy()` call:
176+
177+
.. code:: python
178+
179+
await my_model.deploy(..., constraints={'arch': 'amd64', 'mem': 256}, ...)
180+
181+
182+
* To set constraints post deployment, you may use the `Application.set_contraints()` method, similar to passing constraints in the deploy call above:
183+
184+
.. code:: python
185+
186+
await my_app.set_constraints(constraints={'arch': 'amd64', 'mem': 256})
187+
188+
189+
**Get values.** To see what constraints are set on an application, use the `Application.get_constraints()` method:
190+
191+
.. code:: python
192+
193+
await my_app.get_constraints()
194+
195+
196+
> See more: `Application.set_contraints() <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.set_constraints>`_, `Application.get_constraints (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.get_constraints>`_
197+
198+
199+
Change space bindings for an application
200+
----------------------------------------
201+
202+
To set bindings for an application on python-libjuju, simply pass the `bind` parameter at the `Model.deploy()` call:
203+
204+
.. code:: python
205+
206+
await my_model.deploy(..., bind="db=db db-client=db public admin-api=public", ...)
207+
208+
Python-libjuju currently doesn't support resetting space bindings post deployment, please use the `juju-cli` for that.
209+
210+
> See more: [`Model.deploy()` (method) <5476md>`
211+
212+
Upgrade an application
213+
----------------------
214+
215+
To upgrade an application, update its charm.
216+
217+
> See more: :ref:`update-a-charm`
218+
219+
.. _remove-an-application:
220+
221+
Remove an application
222+
---------------------
223+
224+
> See also: :ref:`juju:removing-things`
225+
226+
To remove an application from a model in python-libjuju, you have two choices:
227+
228+
(1) If you have a reference to a connected model object (connected to the model you're working on), then you may use the `Model.remove_application()` method:
229+
230+
.. code:: python
231+
232+
await my_model.remove_application(my_app.name)
233+
234+
235+
(2) If you have a reference to the application you want to remove, then you may use the `Application.destroy()` directly on the application object you want to remove:
236+
237+
.. code:: python
238+
239+
await my_app.destroy()
240+
241+
> See more: `Model.remove_application (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.model.html#juju.model.Model.remove_application>`_, `Application.destroy (method) <https://pythonlibjuju.readthedocs.io/en/latest/api/juju.application.html#juju.application.Application.destroy>`_

0 commit comments

Comments
 (0)