diff options
Diffstat (limited to 'cloudinit/sources/DataSourceAzure.py')
| -rw-r--r-- | cloudinit/sources/DataSourceAzure.py | 34 | 
1 files changed, 27 insertions, 7 deletions
diff --git a/cloudinit/sources/DataSourceAzure.py b/cloudinit/sources/DataSourceAzure.py index 66d7728b..b18c57e7 100644 --- a/cloudinit/sources/DataSourceAzure.py +++ b/cloudinit/sources/DataSourceAzure.py @@ -44,8 +44,21 @@ BUILTIN_DS_CONFIG = {          'policy': True,          'command': BOUNCE_COMMAND,          'hostname_command': 'hostname', -    } +        }, +    'disk_aliases': {'ephemeral0': '/dev/sdb'},  } + +BUILTIN_CLOUD_CONFIG = { +    'disk_setup': { +        'ephemeral0': {'table_type': 'mbr', +                       'layout': True, +                       'overwrite': False} +         }, +    'fs_setup': [{'filesystem': 'ext4', +                  'device': 'ephemeral0.1', +                  'replace_fs': 'ntfs'}] +} +  DS_CFG_PATH = ['datasource', DS_NAME] @@ -94,7 +107,7 @@ class DataSourceAzureNet(sources.DataSource):              (md, self.userdata_raw, cfg, files) = ret              self.seed = cdev              self.metadata = util.mergemanydict([md, DEFAULT_METADATA]) -            self.cfg = cfg +            self.cfg = util.mergemanydict([cfg, BUILTIN_CLOUD_CONFIG])              found = cdev              LOG.debug("found datasource in %s", cdev) @@ -106,9 +119,14 @@ class DataSourceAzureNet(sources.DataSource):          if found == ddir:              LOG.debug("using files cached in %s", ddir) +        # azure / hyper-v provides random data here +        seed = util.load_file("/sys/firmware/acpi/tables/OEM0", quiet=True) +        if seed: +            self.metadata['random_seed'] = seed +          # now update ds_cfg to reflect contents pass in config -        usercfg = util.get_cfg_by_path(self.cfg, DS_CFG_PATH, {}) -        self.ds_cfg = util.mergemanydict([usercfg, self.ds_cfg]) +        user_ds_cfg = util.get_cfg_by_path(self.cfg, DS_CFG_PATH, {}) +        self.ds_cfg = util.mergemanydict([user_ds_cfg, self.ds_cfg])          mycfg = self.ds_cfg          # walinux agent writes files world readable, but expects @@ -156,9 +174,11 @@ class DataSourceAzureNet(sources.DataSource):          pubkeys = pubkeys_from_crt_files(fp_files)          self.metadata['public-keys'] = pubkeys -          return True +    def device_name_to_device(self, name): +        return self.ds_cfg['disk_aliases'].get(name) +      def get_config_obj(self):          return self.cfg @@ -344,7 +364,7 @@ def read_azure_ovf(contents):      try:          dom = minidom.parseString(contents)      except Exception as e: -        raise NonAzureDataSource("invalid xml: %s" % e) +        raise BrokenAzureDataSource("invalid xml: %s" % e)      results = find_child(dom.documentElement,          lambda n: n.localName == "ProvisioningSection") @@ -390,7 +410,7 @@ def read_azure_ovf(contents):              simple = True              value = child.childNodes[0].wholeText -        attrs = {k: v for k, v in child.attributes.items()} +        attrs = dict([(k, v) for k, v in child.attributes.items()])          # we accept either UserData or CustomData.  If both are present          # then behavior is undefined.  | 
