Merge lp:~tvansteenburgh/python-jujuclient/juju2-fixes into lp:python-jujuclient

Proposed by Tim Van Steenburgh
Status: Merged
Merged at revision: 77
Proposed branch: lp:~tvansteenburgh/python-jujuclient/juju2-fixes
Merge into: lp:python-jujuclient
Diff against target: 104 lines (+19/-14)
2 files modified
jujuclient.py (+14/-10)
test_jujuclient.py (+5/-4)
To merge this branch: bzr merge lp:~tvansteenburgh/python-jujuclient/juju2-fixes
Reviewer Review Type Date Requested Status
David Britton (community) Approve
Review via email: mp+291182@code.launchpad.net
To post a comment you must log in.
76. By Tim Van Steenburgh

Fix out-of-order line

Revision history for this message
David Britton (dpb) wrote :

looks good in general

review: Approve
77. By Tim Van Steenburgh

Remove unnecessary override

Revision history for this message
Tim Van Steenburgh (tvansteenburgh) wrote :

I removed the WaitForNoMachines.run() override as it was unnecessary - an artifact of some earlier testing I was doing.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'jujuclient.py'
2--- jujuclient.py 2016-04-04 20:56:02 +0000
3+++ jujuclient.py 2016-04-11 14:00:37 +0000
4@@ -311,7 +311,7 @@
5
6 data = yaml.safe_load(output)
7 try:
8- if controller_name == None:
9+ if controller_name is None:
10 controller_name = data['current-controller']
11 controller = data['controllers'][controller_name]
12 return controller_name, controller
13@@ -733,7 +733,7 @@
14 conn = HTTPSConnection(host, int(port))
15 path = ""
16 if self._env_uuid:
17- path = self.endpoint_segment + "/%s" % self._env_uuid
18+ path = self.endpoint_segment + "/%s" % self._env_uuid
19 return conn, self._make_headers(), path
20
21 # Charm ops / see charm facade for listing charms in environ.
22@@ -911,8 +911,9 @@
23 return self._rpc({
24 "Type": "Client",
25 "Request": self.set_constraints_request,
26- "Params": {"ServiceName": "",
27- "Constraints": self.env._prepare_constraints(constraints)}})
28+ "Params": {
29+ "ServiceName": "",
30+ "Constraints": self.env._prepare_constraints(constraints)}})
31
32 def get_env_config(self):
33 """Get the environment configuration.
34@@ -956,14 +957,14 @@
35 """
36 return self._rpc({
37 "Type": "Client",
38- "Request": unset_request,
39+ "Request": self.unset_request,
40 "Params": {"Keys": keys}})
41
42 def set_env_agent_version(self, version):
43 """Upgrade an environment to the given agent version."""
44 return self._rpc({
45 "Type": "Client",
46- "Request": agent_version_request,
47+ "Request": self.agent_version_request,
48 "Params": {"Version": version}})
49
50 def agent_version(self):
51@@ -1398,7 +1399,8 @@
52 facade_map[factory.name] = factory
53
54 facades = {}
55- for fenv in server_info.get('Facades', []):
56+ # juju1 - Facades, juju2 - facades
57+ for fenv in server_info.get('Facades') or server_info.get('facades') or []:
58 factory = facade_map.get(fenv['Name'])
59 if factory is None:
60 continue
61@@ -2591,9 +2593,9 @@
62 Wait for all non state servers to be terminated.
63 """
64
65- def __init__(self, watch):
66+ def __init__(self, watch, initial_machines=None):
67 super(WaitForNoMachines, self).__init__(watch)
68- self.machines = {}
69+ self.machines = initial_machines or {}
70
71 def process(self, entity_type, change, data):
72 if entity_type != 'machine':
73@@ -2604,7 +2606,9 @@
74 self.machines[data['Id']] = data
75
76 def complete(self):
77- if list(self.machines.keys()) == ['0']:
78+ if list(self.machines.keys()) == ['0'] and self.watch.version == 0:
79+ return True
80+ elif not self.machines:
81 return True
82
83
84
85=== modified file 'test_jujuclient.py'
86--- test_jujuclient.py 2016-04-04 20:11:17 +0000
87+++ test_jujuclient.py 2016-04-11 14:00:37 +0000
88@@ -54,11 +54,12 @@
89 status = env.status()
90 for s in status['Services'].keys():
91 env.destroy_service(s)
92- env.destroy_machines(
93- sorted(status['Machines'].keys())[1:],
94- force=True)
95+ if env.version == 0:
96+ env.destroy_machines(sorted(status['Machines'].keys())[1:], force=True)
97+ else:
98+ env.destroy_machines(sorted(status['Machines'].keys()), force=True)
99 watch = env.get_watch()
100- WaitForNoMachines(watch).run()
101+ WaitForNoMachines(watch, status['Machines']).run()
102 while True:
103 status = env.status()
104 if len(status['Services']) == 0:

Subscribers

People subscribed via source and target branches