Example #1
0
    def stop(self):
        for iface in Interface.objects.all():
            if not iface.configured:
                logger.debug("%s is not configured" % iface.name)
                continue

            with root():
                run('/sbin/ifdown --force %s' % iface.name)
Example #2
0
    def stop(self):
        for iface in Interface.objects.all():
            if not iface.configured:
                logger.debug("%s is not configured" % iface.name)
                continue

            with root():
                run('/sbin/ifdown --force %s' % iface.name)
Example #3
0
    def save(self):

        # Save con files
        self.smbconf.write()

        with root():
            shutil.copy2(self.SMB_KRB5CONF_FILE, self.KRB5CONF_FILE)
            # XXX FIXME move this to network
            run("echo 'nameserver 127.0.0.1' > /etc/resolv.conf")
Example #4
0
    def save(self):

        # Save con files
        self.smbconf.write()

        with root():
            shutil.copy2(self.SMB_KRB5CONF_FILE, self.KRB5CONF_FILE)
            # XXX FIXME move this to network
            run("echo 'nameserver 127.0.0.1' > /etc/resolv.conf")
Example #5
0
    def start(self):
        for iface in Interface.objects.all():
            if not iface.configured:
                logger.debug("%s is not configured" % iface.name)
                continue

            with root():
                # we run ifup in background
                # it can wait indefinitely for DHCP requests
                run('/sbin/ifup --force %s' % iface.name, background=True)
Example #6
0
    def start(self):
        for iface in Interface.objects.all():
            if not iface.configured:
                logger.debug("%s is not configured" % iface.name)
                continue

            with root():
                # we run ifup in background
                # it can wait indefinitely for DHCP requests
                run('/sbin/ifup --force %s' % iface.name, background=True)
Example #7
0
    def install(self):
        """
        Installation procedure, it writes basic smb.conf and uses samba-tool to
        provision the domain
        """
        domain_settings = DomainSettings.get()

        with root():
            if os.path.exists(self.SMBCONF_FILE):
                os.remove(self.SMBCONF_FILE)

            if domain_settings.mode == "ad":
                domain_settings.adminpass = make_password(15)
                domain_settings.save()

                run(
                    "samba-tool domain provision "
                    "--domain='%s' "
                    "--workgroup='%s' "
                    "--realm='%s' "
                    "--use-xattrs=yes "
                    "--use-rfc2307 "
                    "--server-role='domain controller' "
                    "--use-ntvfs "
                    "--adminpass='******'"
                    % (
                        domain_settings.domain,
                        domain_settings.workgroup,
                        domain_settings.realm,
                        domain_settings.adminpass,
                    )
                )

                self.smbconf.write()

                shutil.copy2(self.SMB_KRB5CONF_FILE, self.KRB5CONF_FILE)

                # XXX FIXME move this to network
                run("echo 'nameserver 127.0.0.1' > /etc/resolv.conf")
                # TODO manage shares
                run("touch /etc/samba/shares.conf")

            elif domain_settings.mode == "member":
                # TODO
                pass
Example #8
0
    def install(self):
        """
        Installation procedure, it writes basic smb.conf and uses samba-tool to
        provision the domain
        """
        domain_settings = DomainSettings.get()

        with root():
            if os.path.exists(self.SMBCONF_FILE):
                os.remove(self.SMBCONF_FILE)

            if domain_settings.mode == 'ad':
                domain_settings.adminpass = make_password(15)
                domain_settings.save()

                run("samba-tool domain provision "
                    "--domain='%s' "
                    "--workgroup='%s' "
                    "--realm='%s' "
                    "--use-xattrs=yes "
                    "--use-rfc2307 "
                    "--server-role='domain controller' "
                    "--use-ntvfs "
                    "--adminpass='******'" %
                    (domain_settings.domain, domain_settings.workgroup,
                     domain_settings.realm, domain_settings.adminpass))

                self.smbconf.write()

                shutil.copy2(self.SMB_KRB5CONF_FILE, self.KRB5CONF_FILE)

                # XXX FIXME move this to network
                run("echo 'nameserver 127.0.0.1' > /etc/resolv.conf")
                # TODO manage shares
                run("touch /etc/samba/shares.conf")

            elif domain_settings.mode == 'member':
                # TODO
                pass
Example #9
0
 def test_run_background(self):
     p = run("exit 27", background=True)
     p.wait()
     self.assertEqual(p.returncode, 27)
Example #10
0
 def test_run(self):
     output = run("echo -n test")
     self.assertEqual(output, "test")