Exemplo n.º 1
0
    def _find_networking_config(self):
        disable_file = os.path.join(self.paths.get_cpath('data'),
                                    'upgraded-network')
        if os.path.exists(disable_file):
            return (None, disable_file)

        cmdline_cfg = ('cmdline', net.read_kernel_cmdline_config())
        dscfg = ('ds', None)
        if self.datasource and hasattr(self.datasource, 'network_config'):
            dscfg = ('ds', self.datasource.network_config)
        sys_cfg = ('system_cfg', self.cfg.get('network'))

        for loc, ncfg in (cmdline_cfg, dscfg, sys_cfg):
            if net.is_disabled_cfg(ncfg):
                LOG.debug("network config disabled by %s", loc)
                return (None, loc)
            if ncfg:
                return (ncfg, loc)
        return (net.generate_fallback_config(), "fallback")
Exemplo n.º 2
0
    def _find_networking_config(self):
        disable_file = os.path.join(
            self.paths.get_cpath('data'), 'upgraded-network')
        if os.path.exists(disable_file):
            return (None, disable_file)

        cmdline_cfg = ('cmdline', net.read_kernel_cmdline_config())
        dscfg = ('ds', None)
        if self.datasource and hasattr(self.datasource, 'network_config'):
            dscfg = ('ds', self.datasource.network_config)
        sys_cfg = ('system_cfg', self.cfg.get('network'))

        for loc, ncfg in (cmdline_cfg, dscfg, sys_cfg):
            if net.is_disabled_cfg(ncfg):
                LOG.debug("network config disabled by %s", loc)
                return (None, loc)
            if ncfg:
                return (ncfg, loc)
        return (net.generate_fallback_config(), "fallback")
Exemplo n.º 3
0
 def test_cmdline_with_b64_gz(self):
     data = _gzip_data(json.dumps(self.simple_cfg).encode())
     encoded_text = base64.b64encode(data).decode()
     cmdline = 'ro network-config=' + encoded_text + ' root=foo'
     found = net.read_kernel_cmdline_config(cmdline=cmdline)
     self.assertEqual(found, self.simple_cfg)
Exemplo n.º 4
0
 def test_cmdline_with_b64_gz(self):
     data = _gzip_data(json.dumps(self.simple_cfg).encode())
     encoded_text = base64.b64encode(data).decode()
     cmdline = 'ro network-config=' + encoded_text + ' root=foo'
     found = net.read_kernel_cmdline_config(cmdline=cmdline)
     self.assertEqual(found, self.simple_cfg)