Exemple #1
0
 def shutdown(self):
     try:
         pid = int(open(self.pidFile).readline().strip())
     except IOError as e:
         if e.errno == os.errno.ENOENT:
             pass
         else:
             raise
     else:
         logging.info('Stopping dhclient-%s on %s', self.family, self.iface)
         _kill_and_rm_pid(pid, self.pidFile)
         if linkiface.exists(self.iface):
             address.flush(self.iface)
Exemple #2
0
 def shutdown(self):
     try:
         pid = int(open(self.pidFile).readline().strip())
     except IOError as e:
         if e.errno == os.errno.ENOENT:
             pass
         else:
             raise
     else:
         logging.info('Stopping dhclient-%s on %s', self.family, self.iface)
         _kill_and_rm_pid(pid, self.pidFile)
         if linkiface.exists(self.iface):
             address.flush(self.iface)
Exemple #3
0
    def _dhclient(self):
        if linkiface.exists(self.iface):
            kill(self.iface, self.family)
            address.flush(self.iface, family=self.family)

        cmds = [DHCLIENT_BINARY.cmd, '-%s' % self.family, '-1', '-pf',
                self.pidFile, '-lf', self.leaseFile]
        if not self.default_route:
            # Instruct Fedora/EL's dhclient-script not to set gateway on iface
            cmds += ['-e', 'DEFROUTE=no']
        if self.duid_source_file and supports_duid_file():
            cmds += ['-df', self.duid_source_file]
        cmds += [self.iface]
        return cmd.exec_systemd_new_unit(cmds, slice_name=self._cgroup)
Exemple #4
0
    def _dhclient(self):
        if linkiface.exists(self.iface):
            kill(self.iface, self.family)
            address.flush(self.iface, family=self.family)

        cmds = [DHCLIENT_BINARY.cmd, '-%s' % self.family, '-1', '-pf',
                self.pidFile, '-lf', self.leaseFile]
        if not self.default_route:
            # Instruct Fedora/EL's dhclient-script not to set gateway on iface
            cmds += ['-e', 'DEFROUTE=no']
        if self.duid_source_file and supports_duid_file():
            cmds += ['-df', self.duid_source_file]
        cmds += [self.iface]
        return cmd.exec_systemd_new_unit(cmds, slice_name=self._cgroup)
Exemple #5
0
def networks_base_info(running_nets, routes=None, ipaddrs=None):
    if routes is None:
        routes = get_routes()
    if ipaddrs is None:
        ipaddrs = getIpAddrs()

    info = {}
    for net, attrs in six.viewitems(running_nets):
        iface = get_net_iface_from_config(net, attrs)
        try:
            if not link_iface.exists(iface):
                raise NetworkIsMissing('Iface %s was not found' % iface)
            info[net] = _getNetInfo(iface, attrs['bridged'], routes, ipaddrs)
        except NetworkIsMissing:
            # Missing networks are ignored, reporting only what exists.
            logging.warning('Missing network detected [%s]: %s', net, attrs)

    return info
Exemple #6
0
def kill(device_name, family=4):
    if not linkiface.exists(device_name):
        return
    for pid, pid_file in _pid_lookup(device_name, family):
        logging.info('Stopping dhclient-%s on %s', family, device_name)
        _kill_and_rm_pid(pid, pid_file)
Exemple #7
0
def kill(device_name, family=4):
    if not linkiface.exists(device_name):
        return
    for pid, pid_file in _pid_lookup(device_name, family):
        logging.info('Stopping dhclient-%s on %s', family, device_name)
        _kill_and_rm_pid(pid, pid_file)