예제 #1
0
 def setUp(self):
     dbConfigurator = DBConfigurator("")
     dbConfigurator.runSQLScript("SystemStatusDBTest",
                                 "./SystemStatusDBTest.sql")
     dbConfigurator.addUser("website", "cygnuscloud", "SystemStatusDBTest",
                            False)
     dbConfigurator.addUser("statusDBUpdater", "cygnuscloud",
                            "SystemStatusDBTest", True)
     self.__reader = SystemStatusDatabaseReader("website", "cygnuscloud",
                                                "SystemStatusDBTest")
     self.__reader.connect()
     self.__writer = SystemStatusDatabaseWriter("statusDBUpdater",
                                                "cygnuscloud",
                                                "SystemStatusDBTest")
     self.__writer.connect()
예제 #2
0
 def connectToDatabases(self, mysqlRootsPassword, statusDBName,
                        commandsDBName, statusdbSQLFilePath,
                        commandsDBSQLFilePath, websiteUser,
                        websiteUserPassword, endpointUser,
                        endpointUserPassword):
     """
     Establishes a connection with the system status database.
     Args:
         mysqlRootsPassword: MySQL root's password
         statusDBName: the status database name
         statusdbSQLFilePath: the database schema definition SQL file path
         websiteUser: the website user's name. 
         websiteUserPassword: the website user's password
         endpointUser: the update user's name. This user will have ALL privileges on the status database.
         endpointUserPassword: the update user's password.
     """
     # Create the status database
     self.__rootsPassword = mysqlRootsPassword
     self.__statusDatabaseName = statusDBName
     self.__commandsDatabaseName = commandsDBName
     configurator = DBConfigurator(mysqlRootsPassword)
     configurator.runSQLScript(statusDBName, statusdbSQLFilePath)
     configurator.runSQLScript(commandsDBName, commandsDBSQLFilePath)
     # Register the website and the endpoint users
     configurator.addUser(websiteUser, websiteUserPassword, statusDBName,
                          False)
     configurator.addUser(endpointUser, endpointUserPassword, statusDBName,
                          True)
     configurator.addUser(websiteUser, websiteUserPassword, commandsDBName,
                          True)
     configurator.addUser(endpointUser, endpointUserPassword,
                          commandsDBName, True)
     # Create the database connectors
     self.__commandsDBConnector = CommandsDatabaseConnector(
         endpointUser, endpointUserPassword, commandsDBName, 1)
     self.__writer = SystemStatusDatabaseWriter(endpointUser,
                                                endpointUserPassword,
                                                statusDBName)
     # Connect to the database
     self.__writer.connect()
     self.__commandsDBConnector.connect()
예제 #3
0
 def connectToDatabase(self, rootsPassword, databaseName, websiteUser,
                       websiteUserPassword, updateUser, updateUserPassword):
     # Create the status database
     self.__rootsPassword = rootsPassword
     self.__databaseName = databaseName
     configurator = DBConfigurator(rootsPassword)
     configurator.runSQLScript(databaseName,
                               "../../database/SystemStatusDB.sql")
     # Register the website and the update users
     configurator.addUser(websiteUser, websiteUserPassword, databaseName,
                          False)
     configurator.addUser(updateUser, updateUserPassword, databaseName,
                          True)
     # Create the database connectors
     self.__reader = SystemStatusDatabaseReader(websiteUser,
                                                websiteUserPassword,
                                                databaseName)
     self.__writer = SystemStatusDatabaseWriter(updateUser,
                                                updateUserPassword,
                                                databaseName)
     # Connect to the database
     self.__reader.connect()
     self.__writer.connect()