~jsing/juju-deployer/resources-support

« back to all changes in this revision

Viewing changes to deployer/env/watchers.py

  • Committer: Tim Van Steenburgh
  • Date: 2016-07-12 23:43:08 UTC
  • Revision ID: tvansteenburgh@gmail.com-20160712234308-mocfgtxm7datuxyy
Handle juju1/2 status and delta changes

- units/subordinates can be null
- delta structure and key names have changed

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
        on_errors = self.on_errors
95
95
        units_in_error = self.units_in_error
96
96
        for unit_name, data in self.units.items():
97
 
            data = NormalizedDelta(data)
98
97
            try:
99
 
                status = data['Status']
 
98
                err_status = data['Status']
 
99
                goal_status = err_status
100
100
            except KeyError:
101
101
                # 'Status' has been removed from newer versions of Juju.
102
102
                # Respond with the closest status parameter, translating it
103
103
                # through the _status_map. If the status value is not in
104
104
                # _status_map, just use the original value.
105
 
                status = data['agent-status']['current']
106
 
                status = _status_map.get(status, status)
107
 
            if status == 'error':
 
105
                err_status = data['workload-status']['current']
 
106
                goal_status = data['agent-status']['current']
 
107
                goal_status = _status_map.get(goal_status, goal_status)
 
108
            if err_status == 'error':
108
109
                if unit_name not in units_in_error:
109
110
                    units_in_error.append(unit_name)
110
111
                    new_errors.append(data)
111
 
            elif status != goal_state:
 
112
            elif goal_status != goal_state:
112
113
                ready = False
113
114
        if new_errors and goal_state != 'removed' and callable(on_errors):
114
115
            on_errors(new_errors)