Skip to content

Commit f07696a

Browse files
Merge branch 'master' into feature/typing
2 parents 50015fb + 64f91f1 commit f07696a

20 files changed

Lines changed: 7446 additions & 2149 deletions

examples/run_action.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
2+
from juju import jasyncio
3+
from juju.model import Model
4+
5+
# logging.basicConfig(level='DEBUG')
6+
7+
# Get a k8s controller
8+
# e.g. juju bootstrap microk8s test-k8s
9+
10+
# Add a model
11+
# e.g. juju add-model test-actions
12+
13+
# Then run this module
14+
# e.g. python examples/run_action.py
15+
16+
17+
async def _get_password():
18+
model = Model()
19+
await model.connect()
20+
await model.deploy('zinc-k8s')
21+
await model.wait_for_idle(status="active")
22+
23+
unit = model.applications['zinc-k8s'].units[0]
24+
action1 = await unit.run_action("get-admin-password")
25+
assert action1.status == 'pending'
26+
27+
action2 = await action1.wait()
28+
assert action2.status == 'completed'
29+
30+
print(action2.results["admin-password"])
31+
32+
# They are the same object
33+
assert action1 is action2
34+
35+
await model.disconnect()
36+
37+
38+
if __name__ == "__main__":
39+
jasyncio.run(_get_password())

juju/action.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ def __init__(self, entity_id, model, history_index=-1, connected=True):
1111
def status(self):
1212
return self.data['status']
1313

14-
async def wait(self):
14+
async def fetch_output(self):
1515
self.results = await self.model.get_action_output(self.id)
16+
17+
async def wait(self):
18+
self.results or await self.fetch_output()
1619
return self

juju/client/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
log = logging.getLogger('juju.client.connection')
1818

1919
client_facades = {
20-
'Action': {'versions': [2, 7]},
20+
'Action': {'versions': [2, 6, 7]},
2121
'ActionPruner': {'versions': [1]},
2222
'Agent': {'versions': [2, 3]},
2323
'AgentTools': {'versions': [1]},

juju/client/old_clients/_client.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from juju.client.old_clients._definitions import *
55

66

7-
from juju.client.old_clients import _client2, _client1, _client3, _client4, _client5, _client8, _client7, _client9, _client10, _client6, _client12, _client11, _client13, _client15, _client16, _client17, _client18
7+
from juju.client.old_clients import _client2, _client1, _client3, _client4, _client5, _client8, _client7, _client9, _client10, _client6, _client12, _client11, _client13, _client15, _client16, _client17, _client18, _client14
88

99

1010
CLIENTS = {
@@ -24,11 +24,11 @@
2424
"15": _client15,
2525
"16": _client16,
2626
"17": _client17,
27-
"18": _client18
27+
"18": _client18,
28+
"14": _client14
2829
}
2930

3031

31-
3232
def lookup_facade(name, version):
3333
"""
3434
Given a facade name and version, attempt to pull that facade out
@@ -46,7 +46,6 @@ def lookup_facade(name, version):
4646
"{}".format(name))
4747

4848

49-
5049
class TypeFactory:
5150
@classmethod
5251
def from_connection(cls, connection):
@@ -260,6 +259,10 @@ class EntityWatcherFacade(TypeFactory):
260259
pass
261260

262261

262+
class EnvironUpgraderFacade(TypeFactory):
263+
pass
264+
265+
263266
class ExternalControllerUpdaterFacade(TypeFactory):
264267
pass
265268

juju/client/old_clients/_client1.py

Lines changed: 586 additions & 576 deletions
Large diffs are not rendered by default.

juju/client/old_clients/_client2.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3610,6 +3610,18 @@ class CAASUnitProvisionerFacade(Type):
36103610
'error': {'$ref': '#/definitions/Error'}},
36113611
'required': ['config'],
36123612
'type': 'object'},
3613+
'DockerImageInfo': {'additionalProperties': False,
3614+
'properties': {'auth': {'type': 'string'},
3615+
'email': {'type': 'string'},
3616+
'identitytoken': {'type': 'string'},
3617+
'image-name': {'type': 'string'},
3618+
'password': {'type': 'string'},
3619+
'registrytoken': {'type': 'string'},
3620+
'repository': {'type': 'string'},
3621+
'serveraddress': {'type': 'string'},
3622+
'username': {'type': 'string'}},
3623+
'required': ['image-name'],
3624+
'type': 'object'},
36133625
'Entities': {'additionalProperties': False,
36143626
'properties': {'entities': {'items': {'$ref': '#/definitions/Entity'},
36153627
'type': 'array'}},
@@ -3736,7 +3748,7 @@ class CAASUnitProvisionerFacade(Type):
37363748
'type': 'array'},
37373749
'filesystems': {'items': {'$ref': '#/definitions/KubernetesFilesystemParams'},
37383750
'type': 'array'},
3739-
'operator-image-path': {'type': 'string'},
3751+
'image-repo': {'$ref': '#/definitions/DockerImageInfo'},
37403752
'pod-spec': {'type': 'string'},
37413753
'raw-k8s-spec': {'type': 'string'},
37423754
'tags': {'patternProperties': {'.*': {'type': 'string'}},
@@ -6999,7 +7011,8 @@ class CrossModelRelationsFacade(Type):
69997011
'unit-count': {'type': 'integer'}},
70007012
'required': ['relation-token',
70017013
'application-token',
7002-
'life'],
7014+
'life',
7015+
'unit-count'],
70037016
'type': 'object'},
70047017
'RemoteRelationDetails': {'additionalProperties': False,
70057018
'properties': {'bakery-version': {'type': 'integer'},
@@ -11858,13 +11871,15 @@ class RemoteRelationsFacade(Type):
1185811871
'remote-application-name': {'type': 'string'},
1185911872
'remote-endpoint-name': {'type': 'string'},
1186011873
'source-model-uuid': {'type': 'string'},
11861-
'suspended': {'type': 'boolean'}},
11874+
'suspended': {'type': 'boolean'},
11875+
'unit-count': {'type': 'integer'}},
1186211876
'required': ['life',
1186311877
'suspended',
1186411878
'id',
1186511879
'key',
1186611880
'application-name',
1186711881
'endpoint',
11882+
'unit-count',
1186811883
'remote-application-name',
1186911884
'remote-endpoint-name',
1187011885
'source-model-uuid'],
@@ -11889,7 +11904,8 @@ class RemoteRelationsFacade(Type):
1188911904
'unit-count': {'type': 'integer'}},
1189011905
'required': ['relation-token',
1189111906
'application-token',
11892-
'life'],
11907+
'life',
11908+
'unit-count'],
1189311909
'type': 'object'},
1189411910
'RemoteRelationResult': {'additionalProperties': False,
1189511911
'properties': {'error': {'$ref': '#/definitions/Error'},

0 commit comments

Comments
 (0)