Beispiel #1
0
    def testConfigParsingMultiBackend(self):

        # make temporary files for nrm map files

        aruba_ojs = tempfile.NamedTemporaryFile()
        aruba_ojs.write(ARUBA_OJS_NRM_MAP)
        aruba_ojs.flush()

        aruba_san = tempfile.NamedTemporaryFile()
        aruba_san.write(ARUBA_SAN_NRM_MAP)
        aruba_san.flush()

        # construct config file

        config_file_content = ARUBA_MULTI_DUD_CONFIG.format(database=self.database,
                                                            db_host=self.db_host,
                                                            db_user=self.db_user,
                                                            db_password=self.db_password,
                                                            nrm_ojs=aruba_ojs.name,
                                                            nrm_san=aruba_san.name)
        # parse and verify config

        cfg = configparser.SafeConfigParser()
        cfg.read_string(config_file_content)

        verified_config = config.readVerifyConfig(cfg)

        # do the setup dance to see if all the wiring is working, but don't start anything
        nsa_service = setup.OpenNSAService(verified_config)
        factory, _ = nsa_service.setupServiceFactory()
Beispiel #2
0
    def testConfigParsingNoDatabase(self):

        config_file_content = ARUBA_DUD_CONFIG_NO_DATABASE

        raw_cfg = configparser.SafeConfigParser()
        raw_cfg.read_string(config_file_content)

        try:
            cfg = config.readVerifyConfig(raw_cfg)
            nsa_service = setup.OpenNSAService(cfg)
            factory, _ = nsa_service.setupServiceFactory()
            self.fail('Should have raised config.ConfigurationError')
        except config.ConfigurationError as e:
            pass
Beispiel #3
0
    def testConfigParsingNoNetworkName(self):

        config_file_content = ARUBA_DUD_CONFIG_NO_NETWORK_NAME.format(database=self.database,
                                                                      db_host=self.db_host,
                                                                      db_user=self.db_user,
                                                                      db_password=self.db_password)
        raw_cfg = configparser.SafeConfigParser()
        raw_cfg.read_string(config_file_content)

        try:
            cfg = config.readVerifyConfig(raw_cfg)
            nsa_service = setup.OpenNSAService(cfg)
            factory, _ = nsa_service.setupServiceFactory()
            self.fail('Should have raised config.ConfigurationError')
        except config.ConfigurationError as e:
            pass
Beispiel #4
0
    def testConfigParsing(self):

        aruba_ojs = tempfile.NamedTemporaryFile()
        aruba_ojs.write(ARUBA_OJS_NRM_MAP)
        aruba_ojs.flush()

        config_file_content = ARUBA_DUD_CONFIG.format(database=self.database,
                                                      db_host=self.db_host,
                                                      db_user=self.db_user,
                                                      db_password=self.db_password,
                                                      nrm_map=aruba_ojs.name)

        raw_cfg = configparser.SafeConfigParser()
        raw_cfg.read_string(config_file_content)

        cfg = config.readVerifyConfig(raw_cfg)
        nsa_service = setup.OpenNSAService(cfg)
        factory, _ = nsa_service.setupServiceFactory()
Beispiel #5
0
    def setUp(self):

        # database

        tc = json.load(open(db.CONFIG_FILE))
        self.database = tc['database']
        self.db_user = tc['user']
        self.db_password = tc['password']
        self.db_host = '127.0.0.1'

        # make temporary files for nrm map files

        aruba_ojs_nrm_file = tempfile.NamedTemporaryFile()
        aruba_ojs_nrm_file.write(ARUBA_OJS_NRM)
        aruba_ojs_nrm_file.flush()

        aruba_san_nrm_file = tempfile.NamedTemporaryFile()
        aruba_san_nrm_file.write(ARUBA_SAN_NRM)
        aruba_san_nrm_file.flush()

        bonaire_nrm_file = tempfile.NamedTemporaryFile()
        bonaire_nrm_file.write(ARUBA_SAN_NRM)
        bonaire_nrm_file.flush()

        # construct config files

        aruba_config = ARUBA_CONFIG.format(
            database=self.database,
            dbhost=self.db_host,
            dbuser=self.db_user,
            dbpassword=self.db_password,
            aruba_ojs_nrm=aruba_ojs_nrm_file.name,
            aruba_san_nrm=aruba_san_nrm_file.name)

        bonaire_config = BONAIRE_CONFIG.format(
            database=self.database,
            dbhost=self.db_host,
            dbuser=self.db_user,
            dbpassword=self.db_password,
            bonaire_nrm=bonaire_nrm_file.name)

        # parse and verify config

        aruba_cfg = configparser.SafeConfigParser()
        aruba_cfg.read_string(aruba_config)
        aruba_vc = config.readVerifyConfig(aruba_cfg)

        bonaire_cfg = configparser.SafeConfigParser()
        bonaire_cfg.read_string(bonaire_config)
        bonaire_vc = config.readVerifyConfig(bonaire_cfg)

        # setup service

        aruba_nsa_service = setup.OpenNSAService(aruba_vc)
        bonaire_nsa_service = setup.OpenNSAService(bonaire_vc)

        aruba_factory, _ = aruba_nsa_service.setupServiceFactory()
        bonaire_factory, _ = bonaire_nsa_service.setupServiceFactory()

        self.top_service = service.MultiService()

        internet.TCPServer(aruba_vc[config.PORT],
                           aruba_factory).setServiceParent(self.top_service)
        internet.TCPServer(bonaire_vc[config.PORT],
                           bonaire_factory).setServiceParent(self.top_service)

        return self.top_service.startService()