Exemple #1
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 #2
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 #3
0
def _exec_ifup_by_name(iface_name, cgroup=dhclient.DHCLIENT_CGROUP):
    """
    Actually bring up an interface (by name).
    """
    cmds = [EXT_IFUP, iface_name]

    if cgroup:
        rc, out, err = cmd.exec_systemd_new_unit(cmds, slice_name=cgroup)
    else:
        rc, out, err = cmd.exec_sync(cmds)

    if rc != 0:
        # In /etc/sysconfig/network-scripts/ifup* the last line usually
        # contains the error reason.
        raise ConfigNetworkError(ERR_FAILED_IFUP, out[-1] if out else '')
Exemple #4
0
def _exec_ifup_by_name(iface_name, cgroup=dhclient.DHCLIENT_CGROUP):
    """
    Actually bring up an interface (by name).
    """
    cmds = [constants.EXT_IFUP, iface_name]

    if cgroup:
        rc, out, err = cmd.exec_systemd_new_unit(cmds, slice_name=cgroup)
    else:
        rc, out, err = cmd.exec_sync(cmds)

    if rc != 0:
        # In /etc/sysconfig/network-scripts/ifup* the last line usually
        # contains the error reason.
        raise ConfigNetworkError(ERR_FAILED_IFUP, out[-1] if out else '')
Exemple #5
0
 def test_exec_systemd_new_unit(self):
     rc, out, err = cmd.exec_systemd_new_unit(('echo', 'hello world'),
                                              slice_name='test-group')
     self.assertEqual(rc, 0, err)
     self.assertEqual(out, 'hello world\n')
Exemple #6
0
 def test_exec_systemd_new_unit(self):
     rc, out, err = cmd.exec_systemd_new_unit(('echo', 'hello world'),
                                              slice_name='test-group')
     self.assertEqual(rc, 0, err)
     self.assertEqual(out, 'hello world\n')
Exemple #7
0
 def test_exec_systemd_new_unit(self):
     rc, out, err = cmd.exec_systemd_new_unit(('echo', 'hello world'),
                                              slice_name='test-group')
     assert rc == 0, err
     assert out == 'hello world\n'