~ubuntu-desktop/oneconf/precise

« back to all changes in this revision

Viewing changes to oneconf/networksync/__init__.py

  • Committer: Didier Roche
  • Date: 2012-01-04 17:09:56 UTC
  • Revision ID: didier.roche@canonical.com-20120104170956-nmahuov13h0zqbgs
add all errors testing, and fix a bug when an error occurs (LP: #908759)

Show diffs side-by-side

added added

removed removed

Lines of Context:
194
194
                        if not pending_changes[hostid].pop('share_inventory'):
195
195
                            LOG.debug("Removing machine %s requested as a pending change" % hostid)
196
196
                            self.infraclient.delete_machine(machine_uuid=hostid)
197
 
                    except APIError:
198
 
                        pass
 
197
                    except APIError, e:
 
198
                        LOG.error("WebClient server doesn't want to remove hostid: %s" % e)
199
199
                except KeyError:
200
200
                    pass
201
201
                # after all changes, is hostid still relevant?
248
248
                            pass
249
249
                    packagelist_changed.append(hostid)
250
250
                except APIError, e:
251
 
                    LOG.error ("Invalid data from server: %s", e)
 
251
                    LOG.error ("Invalid package data from server: %s", e)
252
252
                    try:
253
253
                        old_checksum = old_hosts[hostid]['packages_checksum']
254
254
                    except KeyError:
255
 
                        packages_checksum = None
256
 
                    other_hosts[hostid]['packages_checksum'] = packages_checksum
 
255
                        old_checksum = None
 
256
                    other_hosts[hostid]['packages_checksum'] = old_checksum
257
257
 
258
258
            # refresh the logo for every hosts as well
259
259
            # WORKING but not wanted on the isd side for now
287
287
            LOG.debug("Ensure that current host is not shared")
288
288
            try:
289
289
                self.infraclient.delete_machine(machine_uuid=current_hostid)
290
 
            except APIError:
291
 
                pass
 
290
            except APIError, e:
 
291
                # just a debug message as it can be already not shared
 
292
                LOG.debug ("Can't delete current host from infra: %s" % e)
292
293
        else:
293
294
            LOG.debug("Push current host to infra now")
294
295
            # check if current host changed
295
296
            try:
296
297
                if self.hosts.current_host['hostname'] != distant_current_host['hostname']:
 
298
                    try:
 
299
                        self.infraclient.update_machine(machine_uuid=current_hostid, hostname=self.hosts.current_host['hostname'])
 
300
                        LOG.debug ("Host data refreshed")
 
301
                    except APIError, e:
 
302
                        LOG.error ("Can't update machine: %s", e)
 
303
            except KeyError:
 
304
                try:
297
305
                    self.infraclient.update_machine(machine_uuid=current_hostid, hostname=self.hosts.current_host['hostname'])
298
 
                    LOG.debug ("Host data refreshed")
299
 
            except KeyError:
300
 
                self.infraclient.update_machine(machine_uuid=current_hostid, hostname=self.hosts.current_host['hostname'])
301
 
                LOG.debug ("New host registered done")
302
 
                distant_current_host = {'packages_checksum': None, 'logo_checksum': None}
 
306
                    LOG.debug ("New host registered done")
 
307
                    distant_current_host = {'packages_checksum': None, 'logo_checksum': None}
 
308
                except APIError, e:
 
309
                    LOG.error ("Can't register new host: %s", e)
303
310
            
304
311
            # local package list
305
312
            if self.check_if_push_needed(self.hosts.current_host, distant_current_host, 'packages'):
308
315
                    with open(local_packagelist_filename, 'r') as f:
309
316
                        self.infraclient.update_packages(machine_uuid=current_hostid, packages_checksum=self.hosts.current_host['packages_checksum'], package_list=json.load(f))
310
317
                except (APIError, IOError), e:
311
 
                        LOG.error ("Error while pushing current package list: %s", e)
 
318
                        LOG.error ("Can't push current package list: %s", e)
312
319
                        
313
320
            # local logo
314
321
            # WORKING but not wanted on the isd side for now