示例#1
0
    def test_create_and_delete(self):
        """test creation and deletion of 1 site"""

        sites.create_site(self.ldb, self.ldb.get_config_basedn(), "testsamba")

        self.assertRaises(sites.SiteAlreadyExistsException, sites.create_site,
                          self.ldb, self.ldb.get_config_basedn(), "testsamba")

        sites.delete_site(self.ldb, self.ldb.get_config_basedn(), "testsamba")

        self.assertRaises(sites.SiteNotFoundException, sites.delete_site,
                          self.ldb, self.ldb.get_config_basedn(), "testsamba")
示例#2
0
文件: sites.py 项目: nrensen/samba
    def run(self, sitename, H=None, sambaopts=None, credopts=None, versionopts=None):
        lp = sambaopts.get_loadparm()
        creds = credopts.get_credentials(lp, fallback_machine=True)
        samdb = SamDB(url=H, session_info=system_session(), credentials=creds, lp=lp)

        samdb.transaction_start()
        try:
            sites.delete_site(samdb, samdb.get_config_basedn(), sitename)
            samdb.transaction_commit()
        except sites.SiteException, e:
            samdb.transaction_cancel()
            raise CommandError("Error while removing site %s, error: %s" % (sitename, str(e)))
示例#3
0
    def run(self, sitename, H=None, sambaopts=None, credopts=None,
            versionopts=None):
        lp = sambaopts.get_loadparm()
        creds = credopts.get_credentials(lp, fallback_machine=True)
        samdb = SamDB(url=H, session_info=system_session(),
                      credentials=creds, lp=lp)

        samdb.transaction_start()
        try:
            sites.delete_site(samdb, samdb.get_config_basedn(), sitename)
            samdb.transaction_commit()
        except sites.SiteException as e:
            samdb.transaction_cancel()
            raise CommandError(
                "Error while removing site %s, error: %s" % (sitename, str(e)))

        self.outf.write("Site %s removed!\n" % sitename)
示例#4
0
文件: sites.py 项目: runt18/samba
    def test_create_and_delete(self):
        """test creation and deletion of 1 site"""

        sites.create_site(self.ldb, self.ldb.get_config_basedn(),
                          "testsamba")

        self.assertRaises(sites.SiteAlreadyExistsException,
                          sites.create_site, self.ldb,
                          self.ldb.get_config_basedn(),
                          "testsamba")

        sites.delete_site(self.ldb, self.ldb.get_config_basedn(),
                          "testsamba")

        self.assertRaises(sites.SiteNotFoundException,
                          sites.delete_site, self.ldb,
                          self.ldb.get_config_basedn(),
                          "testsamba")
示例#5
0
    def test_delete(self):
        """test removal of 1 site"""

        self.ldb_admin.transaction_start()
        ok = sites.delete_site(self.ldb_admin,
                               self.ldb_admin.get_config_basedn(), "testsamba")

        self.ldb_admin.transaction_commit()

        self.assertRaises(sites.SiteNotFoundException,
                          sites.delete_site, self.ldb_admin,
                          self.ldb_admin.get_config_basedn(), "testsamba")
示例#6
0
    def test_delete(self):
        """test removal of 1 site"""

        self.ldb_admin.transaction_start()
        ok = sites.delete_site(self.ldb_admin, self.ldb_admin.get_config_basedn(),
                            "testsamba")

        self.ldb_admin.transaction_commit()

        self.assertRaises(sites.SiteNotFoundException,
                            sites.delete_site, self.ldb_admin, self.ldb_admin.get_config_basedn(),
                            "testsamba")
示例#7
0
文件: sites.py 项目: sprymak/samba
    def run(self, sitename, sambaopts=None, credopts=None, versionopts=None):
        lp = sambaopts.get_loadparm()
        creds = credopts.get_credentials(lp, fallback_machine=True)
        url =  lp.private_path("sam.ldb")

        if not os.path.exists(url):
            raise CommandError("secret database not found at %s " % url)
        samdb = SamDB(url=url, session_info=system_session(),
            credentials=creds, lp=lp)

        samdb.transaction_start()
        try:
            ok = sites.delete_site(samdb, samdb.get_config_basedn(), sitename)
            samdb.transaction_commit()
        except sites.SiteException, e:
            samdb.transaction_cancel()
            raise CommandError("Error while removing site %s, error: %s" % (sitename, str(e)))
示例#8
0
    def run(self, sitename, sambaopts=None, credopts=None, versionopts=None):
        lp = sambaopts.get_loadparm()
        creds = credopts.get_credentials(lp, fallback_machine=True)
        url = lp.private_path("sam.ldb")

        if not os.path.exists(url):
            raise CommandError("secret database not found at %s " % url)
        samdb = SamDB(url=url,
                      session_info=system_session(),
                      credentials=creds,
                      lp=lp)

        samdb.transaction_start()
        try:
            ok = sites.delete_site(samdb, samdb.get_config_basedn(), sitename)
            samdb.transaction_commit()
        except sites.SiteException, e:
            samdb.transaction_cancel()
            raise CommandError("Error while removing site %s, error: %s" %
                               (sitename, str(e)))
示例#9
0
 def tearDown(self):
     self.samdb.transaction_start()
     sites.delete_site(self.samdb, self.config_dn, self.sitename)
     sites.delete_site(self.samdb, self.config_dn, self.sitename2)
     self.samdb.transaction_commit()
     super(SitesSubnetCmdTestCase, self).tearDown()
示例#10
0
 def tearDown(self):
     self.ldb.transaction_start()
     sites.delete_site(self.ldb, self.basedn, self.sitename)
     sites.delete_site(self.ldb, self.basedn, self.sitename2)
     self.ldb.transaction_commit()
     super(SimpleSubnetTests, self).tearDown()
示例#11
0
文件: sites.py 项目: runt18/samba
 def tearDown(self):
     self.ldb.transaction_start()
     sites.delete_site(self.ldb, self.basedn, self.sitename)
     sites.delete_site(self.ldb, self.basedn, self.sitename2)
     self.ldb.transaction_commit()
     super(SimpleSubnetTests, self).tearDown()
示例#12
0
文件: sites.py 项目: runt18/samba
 def tearDown(self):
     self.samdb.transaction_start()
     sites.delete_site(self.samdb, self.config_dn, self.sitename)
     sites.delete_site(self.samdb, self.config_dn, self.sitename2)
     self.samdb.transaction_commit()
     super(SitesSubnetCmdTestCase, self).tearDown()