def connectToDatabase(self, mysqlRootsPassword, dbName, dbUser, dbPassword,
                       scriptPath):
     """
     Establishes a connection with the cluster server database
     Args:
         mysqlRootsPassword: the MySQL root user's password
         dbName: a database name
         dbUser: a MySQL user name
         dbPassword: the user's password
         scriptPath: the schema definition script
     Returns:
         Nothing
     """
     configurator = DBConfigurator(mysqlRootsPassword)
     configurator.runSQLScript(dbName, scriptPath, "root",
                               mysqlRootsPassword)
     configurator.addUser(dbUser, dbPassword, dbName, True)
     self.__dbConnector = ClusterServerDatabaseConnector(
         dbUser, dbPassword, dbName)
     self.__dbConnector.initializeVMServersStatus()
Example #2
0
    def connectToDatabases(self, mysqlRootsPassword, endpointDBName,
                           commandsDBName, endpointdbSQLFilePath,
                           commandsDBSQLFilePath, websiteUser,
                           websiteUserPassword, endpointUser,
                           endpointUserPassword, minCommandInterval):
        """
        Establishes the connection with the two databases
        Args:
            mysqlRootsPassword: the MySQL root's password
            endpointDBName: the endpoint database's name
            endpointdbSQLFilePath: the endpoint database's schema definition file path
            websiteUser: the web application's username
            websiteUserPassword: the web application's username
            endpointUser: the endpoint daemon user's name
            endpointUserPassword: the endpoint daemon user's password
        """
        self.__rootsPassword = mysqlRootsPassword
        self.__statusDatabaseName = endpointDBName
        self.__commandsDatabaseName = commandsDBName
        configurator = DBConfigurator(mysqlRootsPassword)
        configurator.runSQLScript(endpointDBName, endpointdbSQLFilePath,
                                  "root", mysqlRootsPassword)
        configurator.runSQLScript(commandsDBName, commandsDBSQLFilePath,
                                  "root", mysqlRootsPassword)

        configurator.addUser(websiteUser, websiteUserPassword, endpointDBName,
                             False)
        configurator.addUser(endpointUser, endpointUserPassword,
                             endpointDBName, True)
        configurator.addUser(websiteUser, websiteUserPassword, commandsDBName,
                             True)
        configurator.addUser(endpointUser, endpointUserPassword,
                             commandsDBName, True)

        self.__commandsDBConnector = CommandsDatabaseConnector(
            endpointUser, endpointUserPassword, commandsDBName,
            minCommandInterval)
        self.__endpointDBConnector = ClusterEndpointDBConnector(
            endpointUser, endpointUserPassword, endpointDBName)
 def setUp(self):
     dbConfigurator = DBConfigurator("")
     dbConfigurator.runSQLScript("ClusterEndpointDBTest", "./ClusterEndpointDBTest.sql")
     dbConfigurator.addUser("cygnuscloud", "cygnuscloud", "ClusterEndpointDBTest", True)
     self.__connector = ClusterEndpointDBConnector("cygnuscloud", "cygnuscloud", "ClusterEndpointDBTest")
Example #4
0
        print e.message
        sys.exit()

    # Read root's password. It's vital to change the downloaded files' permissions.
    password_ok = False
    while (not password_ok):
        try:
            ChildProcessManager.runCommandInForegroundAsRoot("ls", Exception)
            password_ok = True
        except Exception:
            print "Wrong password. Please, key it in again."
            RootPasswordHandler().clear()

    # Configure the database
    rootPassword = parser.getConfigurationParameter("mysqlRootsPassword")
    configurator = DBConfigurator(rootPassword)
    configurator.runSQLScript("VMServerDB", "./database/VMServerDB.sql",
                              "root", rootPassword)
    configurator.addUser(parser.getConfigurationParameter("databaseUserName"),
                         parser.getConfigurationParameter("databasePassword"),
                         "VMServerDB", True)

    # Create the directories (if necessary)
    parameters = [
        "configFilePath", "sourceImagePath", "executionImagePath",
        "TransferDirectory"
    ]
    for param in parameters:
        param_path = parser.getConfigurationParameter(param)
        if (not os.path.exists(param_path)):
            os.mkdir(param_path)