~ubuntu-branches/ubuntu/saucy/cloud-init/saucy

« back to all changes in this revision

Viewing changes to cloudinit/helpers.py

  • Committer: Scott Moser
  • Date: 2013-09-11 21:04:19 UTC
  • mfrom: (1.4.5)
  • Revision ID: smoser@ubuntu.com-20130911210419-3vt5ze6ph3hu8dz1
* New upstream snapshot.
  * Add OpenNebula datasource.
  * Support reading 'random_seed' from metadata and writing to /dev/urandom
  * fix for bug in log_time.

Show diffs side-by-side

added added

removed removed

Lines of Context:
292
292
    def is_registered(self, content_type):
293
293
        return content_type in self.registered
294
294
 
295
 
    def register(self, mod, initialized=False):
 
295
    def register(self, mod, initialized=False, overwrite=True):
296
296
        types = set()
297
297
        for t in mod.list_types():
 
298
            if overwrite:
 
299
                types.add(t)
 
300
            else:
 
301
                if not self.is_registered(t):
 
302
                    types.add(t)
 
303
        for t in types:
298
304
            self.registered[t] = mod
299
 
            types.add(t)
300
305
        if initialized and mod not in self.initialized:
301
306
            self.initialized.append(mod)
302
307
        return types
310
315
    def iteritems(self):
311
316
        return self.registered.iteritems()
312
317
 
313
 
    def register_defaults(self, defs):
314
 
        registered = set()
315
 
        for mod in defs:
316
 
            for t in mod.list_types():
317
 
                if not self.is_registered(t):
318
 
                    self.registered[t] = mod
319
 
                    registered.add(t)
320
 
        return registered
321
 
 
322
318
 
323
319
class Paths(object):
324
320
    def __init__(self, path_cfgs, ds=None):