~smoser/ubuntu/quantal/cloud-init/sru

« back to all changes in this revision

Viewing changes to cloudinit/stages.py

  • Committer: Scott Moser
  • Date: 2012-12-05 22:05:48 UTC
  • Revision ID: smoser@ubuntu.com-20121205220548-ibqx29a3rveacuay
update lp-1076811-fix-userdata-update-to-distro-config.patch

The previous patch for this was not complete, as it left the
DataSourceNone without a distro.  I saw this inadvertantly when
testing the package.  To reproduce the issue, I did:

 * launch instance
 * echo "datasource_list: [ None ]" |
    sudo tee /etc/cloud/cloud.cfg.d/99-nocloud.cfg
 * sudo rm -Rf /var/lib/cloud
 * sudo cloud-init init --local ; sudo cloud-init init
   # the above will find the DataSourceNone
 * sudo cloud-init single --name=apt-configure --frequency=always
   # in 12.10 and prior:
   # sudo cloud-init single --name=apt-update-upgrade --frequency=always

This would have left cloud-init broken for using the DataSourceNone path
which is actually relied upon in some cases. (Ie, if you had no DataSource,
but had a runcmd in /etc/cloud.cfg.d you still want that to run.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
 
50
50
LOG = logging.getLogger(__name__)
51
51
 
 
52
NULL_DATA_SOURCE = None
 
53
 
52
54
 
53
55
class Init(object):
54
56
    def __init__(self, ds_deps=None):
61
63
        self._paths = None
62
64
        self._distro = None
63
65
        # Changed only when a fetch occurs
64
 
        self.datasource = DataSourceNone.DataSourceNone({}, None, None)
 
66
        self.datasource = NULL_DATA_SOURCE
65
67
 
66
68
    def _reset(self, ds=False):
67
69
        # Recreated on access
69
71
        self._paths = None
70
72
        self._distro = None
71
73
        if ds:
72
 
            self.datasource = DataSourceNone.DataSourceNone({}, None, None)
 
74
            self.datasource = NULL_DATA_SOURCE
73
75
 
74
76
    @property
75
77
    def distro(self):
201
203
            return None
202
204
 
203
205
    def _write_to_cache(self):
204
 
        if not self.datasource:
 
206
        if self.datasource is NULL_DATA_SOURCE:
205
207
            return False
206
208
        pickled_fn = self.paths.get_ipath_cur("obj_pkl")
207
209
        try:
227
229
        return (cfg_list, pkg_list)
228
230
 
229
231
    def _get_data_source(self):
230
 
        if self.datasource:
 
232
        if self.datasource is not NULL_DATA_SOURCE:
231
233
            return self.datasource
232
234
        ds = self._restore_from_cache()
233
235
        if ds: