~ubuntu-branches/ubuntu/natty/cloud-init/natty-proposed

« back to all changes in this revision

Viewing changes to cloudinit/__init__.py

  • Committer: Package Import Robot
  • Author(s): Scott Moser
  • Date: 2011-02-19 01:16:10 UTC
  • mfrom: (60.1.25 natty)
  • Revision ID: package-import@ubuntu.com-20110219011610-rcf4ll5uuzqh9bdn
* New upstream release.
* fix for puppet configuration options (LP: #709946) [Ryan Lane]
* fix pickling of DataSource, which broke seeding.
* turn resize_rootfs default to True
* avoid mounts in DataSourceOVF if 'read' on device fails
  'mount /dev/sr0' for an empty virtual cdrom device was taking 18 seconds
* add 'manual_cache_clean' option to select manual cleaning of
  the /var/lib/cloud/instance/ link, for a data source that might
  not be present on every boot
* make DataSourceEc2 retries and timeout configurable
* add 'bootcmd' like 'runcmd' to cloud-config syntax for running things early
* move from '#opt_include' in config file format to conf_d.
  now local config files should live in /etc/cloud/cloud.cfg.d/
* move /etc/cloud/distro.cfg to /etc/cloud/cloud.cfg.d/90_dpkg.cfg
* allow /etc/hosts to be written from hosts.tmpl. which allows
  getting local-hostname into /etc/hosts (LP: #720440)
* better handle startup if there is no eth0 (LP: #714807)
* update rather than append in puppet config [Marc Cluet]
* add cloud-config for mcollective [Marc Cluet]

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
   "userdata" : "/user-data.txt.i",
43
43
   "obj_pkl" : "/obj.pkl",
44
44
   "cloud_config" : "/cloud-config.txt",
45
 
   "datadir" : "/data",
 
45
   "data" : "/data",
46
46
   None : "",
47
47
}
48
48
 
153
153
            cache = get_ipath_cur('obj_pkl')
154
154
            f=open(cache, "rb")
155
155
            data = cPickle.load(f)
 
156
            f.close()
156
157
            self.datasource = data
157
158
            return True
158
159
        except:
169
170
        try:
170
171
            f=open(cache, "wb")
171
172
            data = cPickle.dump(self.datasource,f)
 
173
            f.close()
172
174
            os.chmod(cache,0400)
173
 
            return True
174
175
        except:
175
 
            return False
 
176
            raise
176
177
        
177
178
    def get_data_source(self):
178
179
        if self.datasource is not None: return True
188
189
        for cls in dslist:
189
190
            ds = cls.__name__
190
191
            try:
191
 
                s = cls(log)
 
192
                s = cls(sys_cfg=self.cfg)
192
193
                if s.get_data():
193
194
                    self.datasource = s
194
195
                    self.datasource_name = ds
218
219
        util.ensure_dirs(dlist)
219
220
 
220
221
        ds = "%s: %s\n" % ( self.datasource.__class__, str(self.datasource) )
221
 
        dp = self.get_cpath('datadir')
 
222
        dp = self.get_cpath('data')
222
223
        util.write_file("%s/%s" % (idir, 'datasource'), ds)
223
224
        util.write_file("%s/%s" % (dp, 'previous-datasource'), ds)
224
225
        util.write_file("%s/%s" % (dp, 'previous-instance-id'), "%s\n" % iid)
500
501
        if g == "-1" or g == "None": g = None
501
502
        util.chownbyname(log_file, u, g)
502
503
 
503
 
def purge_cache():
504
 
    rmlist = ( boot_finished , cur_instance_link )
 
504
def purge_cache(rmcur=True):
 
505
    rmlist = [ boot_finished ]
 
506
    if rmcur: rmlist.append(cur_instance_link)
505
507
    for f in rmlist:
506
508
        try:
507
509
            os.unlink(f)
514
516
 
515
517
# get_ipath_cur: get the current instance path for an item
516
518
def get_ipath_cur(name=None):
517
 
    return("%s/instance/%s" % (varlibdir, pathmap[name]))
 
519
    return("%s/%s%s" % (varlibdir, "instance", pathmap[name]))
518
520
 
519
521
# get_cpath : get the "clouddir" (/var/lib/cloud/<name>)
520
522
# for a name in dirmap