~smoser/cloud-init/lp-1077700

« back to all changes in this revision

Viewing changes to cloudinit/sources/DataSourceConfigDrive.py

  • Committer: Scott Moser
  • Date: 2012-11-12 02:49:10 UTC
  • Revision ID: smoser@ubuntu.com-20121112024910-skl6lish02cwzbcr
config-drive-v2: populate metadata['public-keys'] from 'public_keys'

other datasources populate 'public-keys' rather than 'public_keys'
and there is a more complete handler in the base DataSource.
So, to take advantage of that, have DataSourceConfigDrive copy
public_keys to public-keys, and remove the 'get_public_ssh_keys'
from the DataSourcEConfigDrive.

Show diffs side-by-side

added added

removed removed

Lines of Context:
218
218
 
219
219
        return True
220
220
 
221
 
    def get_public_ssh_keys(self):
222
 
        if not 'public-keys' in self.metadata:
223
 
            return []
224
 
        return self.metadata['public-keys']
225
 
 
226
221
 
227
222
class DataSourceConfigDriveNet(DataSourceConfigDrive):
228
223
    def __init__(self, sys_cfg, distro, paths):
331
326
        except KeyError:
332
327
            raise BrokenConfigDriveDir("No uuid entry in metadata")
333
328
 
 
329
    # other datasources (and config-drive-v1) populate metadata['public-keys']
 
330
    # where as with config-drive-v2, that would be 'public_keys'.  So, just
 
331
    # copy the field if it is present
 
332
    if ('public_keys' in results['metadata'] and not
 
333
        'public-keys' in results['metadata']):
 
334
        results['public-keys'] = results['public_keys']
 
335
 
334
336
    def read_content_path(item):
335
337
        # do not use os.path.join here, as content_path starts with /
336
338
        cpath = os.path.sep.join((source_dir, "openstack",