Exemplo n.º 1
0
 def __deactiveInterfaces(self):
     """
     Deactive link (ifconfig nic down) for NICs not changes by user.
     Restore initial state for them, i.e., no link
     """
     cmd = "grep -s ONBOOT /etc/sysconfig/network-scripts/ifcfg-*"
     proc = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
     out, err = proc.communicate()
     if proc.returncode == 0:
         interfaces = self.__devices
         deactiveLinkInterfacesAll = []
         for fname in out.split():
             if fname.endswith("no"):
                 iface = fname.split("-")[-1].split(":")[0]
                 deactiveLinkInterfacesAll.append(iface)
         deactiveLinkInterfaces = [f for f in deactiveLinkInterfacesAll if f in interfaces.keys()]
         if len(deactiveLinkInterfaces):
             Network.deactiveLinkInterfaces(deactiveLinkInterfaces)