def _check_interfaces(self, interfaces_path): """Uses ifup to check interfaces file. If it is not in the default place, each interface must be checked one by one. Args: interfaces_path (string) : the path to interfaces file Raises: ValueError : if invalid network interfaces """ if interfaces_path == "/etc/network/interfaces": ret, output = toolutils.safe_subprocess(["ifup", "-a", "--no-act"]) else: for adapter in self._adapters: ret, output = toolutils.safe_subprocess([ "ifup", "--no-act", "--interfaces={0}".format(interfaces_path), adapter.attributes["name"] ]) if not ret: break if not ret: raise ValueError("Invalid network interfaces file " "written to disk, restoring to previous " "one : {0}".format(output))
def delete(self): ''' return True/False, command output ''' if self.backup_path: return toolutils.safe_subprocess(["rm", self._path])
def restore(self): ''' return True/False, command output ''' if self.backup_path: return toolutils.safe_subprocess(["cp", self.backup_path, self._path])
def controlService(self, action): ''' return True/False, command output ''' if action not in ["start", "stop", "restart"]: return False, "Invalid action" return toolutils.safe_subprocess(["/etc/init.d/dnsmasq", action])
def downAdapter(self, if_name): ''' return True/False, command output. Use ifdown. ''' return toolutils.safe_subprocess(["ifconfig", if_name, 'down'])
def controlService(self, action): """ return True/False, command output """ if action not in ["start", "stop", "restart"]: return False, "Invalid action" return toolutils.safe_subprocess(["/etc/init.d/dnsmasq", action])
def upAdapter(self, if_name): ''' return True/False, command output. Use ifconfig. ''' return toolutils.safe_subprocess(["ifconfig", if_name, 'up'])
def restore(self): ''' return True/False, command output ''' if self.backup_path: return toolutils.safe_subprocess( ["cp", self.backup_path, self._path])
def delete(self): ''' return True/False, command output ''' if self.backup_path: return toolutils.safe_subprocess(["rm", self._path])
def _restore_interfaces(self): """ return True/False, command output """ if self._backup_path: return toolutils.safe_subprocess(["cp", self._backup_path, self._interfaces_path])
def _restore_interfaces(self): ''' return True/False, command output ''' if self._backup_path: return toolutils.safe_subprocess( ["cp", self._backup_path, self._interfaces_path])
def backup(self): """ return True/False, command output """ if self.backup_path: return toolutils.safe_subprocess(["cp", self._path, self.backup_path])
def downAdapter(self, if_name): """ return True/False, command output. Use ifdown. """ return toolutils.safe_subprocess(["/sbin/ifdown", if_name])
def downAdapter(self, if_name): """ return True/False, command output. Use ifdown. """ return toolutils.safe_subprocess(["/sbin/ifdown", if_name])