def set_unmanaged_by_network_manager(cls, interface): Logger.debug( "Adding interface \"%s-%s\" as an unmanaged interface to network manager", interface, cls.get_mac(interface)) with open(constants.PATH_CONF_NETWORK_MANAGER, "r") as conf_read: conf = conf_read.read().splitlines() added = False entry = "mac:" + cls.get_mac(interface) # Add Entry for line in range(0, len(conf)): # Add keyfile plugin if it's not enabled if conf[line].startswith( "plugins=") and "keyfile" not in conf[line]: conf[line] += ",keyfile" # Add unmanaged device if conf[line].startswith( "unmanaged-devices=") and entry not in conf[line]: conf[line] += ";" + entry added = True # Add the initial unmanaged entry if it was not present if not added: conf.append("[keyfile]") conf.append("unmanaged-devices=" + entry) # Write with open(constants.PATH_CONF_NETWORK_MANAGER, "w") as conf_write: for line in conf: conf_write.write(line + "\n") # Restart the service ProcessUtil.call(["service", "network-manager", "restart"]) ProcessUtil.call(["service", "networking", "restart"])
def stop(self): LoggerCli.info("Stopping") ProcessUtil.call(["killall", "dhclient"]) self.getting_key = False if self.drc_sim_c: self.drc_sim_c.stop() if self.wpa_supplicant: self.wpa_supplicant.stop()
def dhclient(cls, interface): ProcessUtil.call(["killall", "dhclient"]) ProcessUtil.call(["dhclient", interface])
def set_metric(cls, interface, metric): ProcessUtil.call(["ifmetric", interface, str(metric)])
def unblock_wlan(): """ Make a system call to unblock wlan :return: None """ ProcessUtil.call(["rfkill", "unblock", "wlan"])
def kill_wpa(): """ Makes a system call to kill wpa_supplicant_drc :return: None """ ProcessUtil.call(["killall", "wpa_supplicant_drc"])
def kill_drc_sim_c(): ProcessUtil.call(["killall", "drc_sim_c"])