~smoser/cloud-init/trunk.transfer-ds

« back to all changes in this revision

Viewing changes to cloudinit/sources/DataSourceAzure.py

  • Committer: Scott Moser
  • Date: 2016-03-22 02:30:56 UTC
  • mfrom: (1187.1.2 trunk.quick)
  • Revision ID: smoser@ubuntu.com-20160322023056-aqcuwhoq7yyier6y
quickly check to see if the previous instance id is still valid

This adds a check in cloud-init to see if the existing (cached)
datasource is still valid.  It relies on support from the Datasource
to implement 'check_instance_id'.  That method should quickly determine
(if possible) if the instance id found in the datasource is still valid.

This means that we can still notice new instance ids without
depending on a network datasource on every boot.

I've also implemented check_instance_id for the superclass and for
sources:
  DataSourceAzure (check dmi data)
  DataSourceConfigDrive (check dmi data)
  DataSourceNocloud (check the seeded data or kernel command line)
  DataSourceOpenstack (check dmi data)

Show diffs side-by-side

added added

removed removed

Lines of Context:
254
254
    def get_config_obj(self):
255
255
        return self.cfg
256
256
 
 
257
    def check_instance_id(self):
 
258
        # quickly (local check only) if self.instance_id is still valid
 
259
        return sources.instance_id_matches_system_uuid(self.get_instance_id())
 
260
 
257
261
 
258
262
def count_files(mp):
259
263
    return len(fnmatch.filter(os.listdir(mp), '*[!cdrom]*'))