Ejemplo n.º 1
0
 def generate_kickstart_network_data(self, network_data_class):
     rv = []
     for cfg in self._device_configurations.get_all():
         network_data = None
         if cfg.device_type != NM.DeviceType.WIFI and cfg.connection_uuid:
             uuid = cfg.connection_uuid
             con = self.nm_client.get_connection_by_uuid(uuid)
             filename = con.get_filename() or ""
             if not is_config_file_for_system(filename):
                 log.debug("Config file for %s not found, not generating ks command.", uuid)
                 continue
             connection = self.nm_client.get_connection_by_uuid(uuid)
             if connection:
                 network_data = get_kickstart_network_data(connection,
                                                           self.nm_client,
                                                           network_data_class)
             else:
                 log.debug("Connection %s for kickstart data generating not found", uuid)
         if not network_data:
             log.debug("Device configuration %s does not generate any kickstart data", cfg)
             continue
         if cfg.device_name:
             if self._is_device_activated(cfg.device_name):
                 network_data.activate = True
             else:
                 # First network command defaults to --activate so we must
                 # use --no-activate explicitly to prevent the default
                 # (Default value is None)
                 if not rv:
                     network_data.activate = False
         rv.append(network_data)
     return rv
Ejemplo n.º 2
0
 def test_is_config_file_for_system(self):
     """Test is_config_file_for_system function."""
     assert is_config_file_for_system(
         os.path.join(KEYFILE_DIR, "ens3.nmconnection"))
     assert is_config_file_for_system(os.path.join(IFCFG_DIR, "ifcfg-ens5"))
     assert not is_config_file_for_system("foo/bar")
     assert not is_config_file_for_system(
         "/run/NetworkManager/system-connections/ens3.nmconnection")
     assert not is_config_file_for_system(
         os.path.join(IFCFG_DIR, "ifcfg-lo"))
     assert not is_config_file_for_system(os.path.join(KEYFILE_DIR, "ens3"))
Ejemplo n.º 3
0
 def is_config_file_for_system_test(self):
     """Test is_config_file_for_system function."""
     self.assertTrue(
         is_config_file_for_system(
             os.path.join(KEYFILE_DIR, "ens3.nmconnection")))
     self.assertTrue(
         is_config_file_for_system(os.path.join(IFCFG_DIR, "ifcfg-ens5")))
     self.assertFalse(is_config_file_for_system("foo/bar"))
     self.assertFalse(
         is_config_file_for_system(
             "/run/NetworkManager/system-connections/ens3.nmconnection"))
     self.assertFalse(
         is_config_file_for_system(os.path.join(IFCFG_DIR, "ifcfg-lo")))
     self.assertFalse(
         is_config_file_for_system(os.path.join(KEYFILE_DIR, "ens3")))