Beispiel #1
0
 def setUp(self):
     # Create the database
     self.__dbConfigurator = DBConfigurator("")
     self.__dbConfigurator.runSQLScript("CommandsDBTest",
                                        "./CommandsDBTest.sql")
     # Add a user to it
     self.__dbConfigurator.addUser("cygnuscloud", "cygnuscloud",
                                   "CommandsDBTest")
     self.__connector = CommandsDatabaseConnector("cygnuscloud",
                                                  "cygnuscloud",
                                                  "CommandsDBTest", 1)
class CommandsDBTests(unittest.TestCase):
    
    def setUp(self):
        # Create the database
        self.__dbConfigurator = DBConfigurator("")
        self.__dbConfigurator.runSQLScript("CommandsDBTest", "./CommandsDBTest.sql")
        # Add a user to it
        self.__dbConfigurator.addUser("cygnuscloud", "cygnuscloud", "CommandsDBTest")
        self.__connector = CommandsDatabaseConnector("cygnuscloud", "cygnuscloud", "CommandsDBTest", 1)    
        
    def tearDown(self):
        #self.__dbConfigurator.dropDatabase("CommandsDBTest")
        pass
        
    def test_addAndRemoveCommands(self):
        self.__connector.addCommand(1, 0, "command arguments")
        result = self.__connector.popCommand()
        expectedResult = (1, 0, 'command arguments')
        self.assertEquals(result[0][0], expectedResult[0], "either addCommand or popCommand does not work")
        self.assertEquals(result[1], expectedResult[1], "either addCommand or popCommand does not work")
        self.assertEquals(result[2], expectedResult[2], "either addCommand or popCommand does not work")
        result = self.__connector.addCommand(1, 1, "command2 arguments")
        self.assertEquals(result, None, "addCommand does not work")
        self.__connector.addCommand(2, 2, "command4 arguments")
        self.__connector.addCommand(3, 3, "command5 arguments")
        expectedResults = [(2, 2, "command4 arguments"), (3, 3, "command5 arguments")]
        for expectedResult in expectedResults :
            result = self.__connector.popCommand()
            self.assertEquals(result[0][0], expectedResult[0], "either addCommand or popCommand does not work")
            self.assertEquals(result[1], expectedResult[1], "either addCommand or popCommand does not work")
            self.assertEquals(result[2], expectedResult[2], "either addCommand or popCommand does not work")
            
    def test_addAndRemoveCommandOutputs(self):
        commandID = self.__connector.addCommand(1, 0, "command arguments")
        self.__connector.popCommand()
        self.__connector.addCommandOutput(commandID, 0, "commandOutput")
        result = self.__connector.getCommandOutput(commandID)
        expectedResult = (0, "commandOutput")
        self.assertEquals(result, expectedResult, "either addCommandOutput or getCommandOutput does not work")       

    def test_getPendingNotifications(self):
        commandID = self.__connector.addCommand(1, 0, "commandArguments")
        self.__connector.popCommand()
        self.__connector.addCommandOutput(commandID, 0, "Args1", False, True)
        commandID = self.__connector.addCommand(1, 0, "commandArguments1")
        self.__connector.popCommand()
        self.__connector.addCommandOutput(commandID, 0, "Args2", False, True)
        result = self.__connector.getPendingNotifications(1)
        expectedResult = [(0, u'Args1'), (0, u'Args2')]
        self.assertEquals(result, expectedResult, "getPendingNotifications() error")
 def setUp(self):
     # Create the database
     self.__dbConfigurator = DBConfigurator("")
     self.__dbConfigurator.runSQLScript("CommandsDBTest", "./CommandsDBTest.sql")
     # Add a user to it
     self.__dbConfigurator.addUser("cygnuscloud", "cygnuscloud", "CommandsDBTest")
     self.__connector = CommandsDatabaseConnector("cygnuscloud", "cygnuscloud", "CommandsDBTest", 1)    
 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()
 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()
 def setUp(self):
     dbConfigurator = DBConfigurator("")
     dbConfigurator.runSQLScript("ClusterEndpointDBTest", "./ClusterEndpointDBTest.sql")
     dbConfigurator.addUser("cygnuscloud", "cygnuscloud", "ClusterEndpointDBTest", True)
     self.__connector = ClusterEndpointDBConnector("cygnuscloud", "cygnuscloud", "ClusterEndpointDBTest")
Beispiel #7
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)
 
 # Finish the initialization process
 vmServer = VMServerReactor(parser)  
 while not vmServer.has_finished():
     sleep(10) 
 vmServer.shutdown()       
Beispiel #8
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)
Beispiel #9
0
from imageRepository.reactor.imageRepositoryReactor import ImageRepositoryReactor

if __name__ == "__main__" :
    
    if (len(sys.argv) != 2) :
        print "A configuration file path is needed"
        sys.exit()
    try :
        parser = ImageRepositoryConfigurationFileParser()
        parser.parseConfigurationFile(sys.argv[1])
    except Exception as e:
        print e.message
        sys.exit()
    
    rootPassword= parser.getConfigurationParameter('mysqlRootsPassword')
    dbConfigurator = DBConfigurator(rootPassword)
    dbConfigurator.runSQLScript("ImageRepositoryDB", "./database/ImageRepositoryDB.sql", "root", rootPassword)
    dbConfigurator.addUser(parser.getConfigurationParameter('dbUser'), parser.getConfigurationParameter('dbUserPassword'), "ImageRepositoryDB")
    
    if (not os.path.exists(parser.getConfigurationParameter('FTPRootDirectory'))):
        os.mkdir(parser.getConfigurationParameter('FTPRootDirectory'))
    
    imageRepository = ImageRepositoryReactor(parser.getConfigurationParameter('FTPRootDirectory'))
    imageRepository.connectToDatabase("ImageRepositoryDB", parser.getConfigurationParameter("dbUser"), parser.getConfigurationParameter("dbUserPassword"))
    
    imageRepository.startListenning(parser.getConfigurationParameter("FTPListenningInterface"), parser.getConfigurationParameter("useSSL"),
                                    parser.getConfigurationParameter("certificatePath"), parser.getConfigurationParameter("commandsPort"), 
                                    parser.getConfigurationParameter("FTPPort"), parser.getConfigurationParameter('maxConnections'), parser.getConfigurationParameter('maxConnectionsPerIP'),
                                    parser.getConfigurationParameter("uploadBandwidthRatio"), parser.getConfigurationParameter("downloadBandwidthRatio"), parser.getConfigurationParameter("FTPUserName"),
                                    parser.getConfigurationParameter("FTPPasswordLength"))
        
Beispiel #10
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)
Beispiel #11
0
class CommandsDBTests(unittest.TestCase):
    def setUp(self):
        # Create the database
        self.__dbConfigurator = DBConfigurator("")
        self.__dbConfigurator.runSQLScript("CommandsDBTest",
                                           "./CommandsDBTest.sql")
        # Add a user to it
        self.__dbConfigurator.addUser("cygnuscloud", "cygnuscloud",
                                      "CommandsDBTest")
        self.__connector = CommandsDatabaseConnector("cygnuscloud",
                                                     "cygnuscloud",
                                                     "CommandsDBTest", 1)

    def tearDown(self):
        #self.__dbConfigurator.dropDatabase("CommandsDBTest")
        pass

    def test_addAndRemoveCommands(self):
        self.__connector.addCommand(1, 0, "command arguments")
        result = self.__connector.popCommand()
        expectedResult = (1, 0, 'command arguments')
        self.assertEquals(result[0][0], expectedResult[0],
                          "either addCommand or popCommand does not work")
        self.assertEquals(result[1], expectedResult[1],
                          "either addCommand or popCommand does not work")
        self.assertEquals(result[2], expectedResult[2],
                          "either addCommand or popCommand does not work")
        result = self.__connector.addCommand(1, 1, "command2 arguments")
        self.assertEquals(result, None, "addCommand does not work")
        self.__connector.addCommand(2, 2, "command4 arguments")
        self.__connector.addCommand(3, 3, "command5 arguments")
        expectedResults = [(2, 2, "command4 arguments"),
                           (3, 3, "command5 arguments")]
        for expectedResult in expectedResults:
            result = self.__connector.popCommand()
            self.assertEquals(result[0][0], expectedResult[0],
                              "either addCommand or popCommand does not work")
            self.assertEquals(result[1], expectedResult[1],
                              "either addCommand or popCommand does not work")
            self.assertEquals(result[2], expectedResult[2],
                              "either addCommand or popCommand does not work")

    def test_addAndRemoveCommandOutputs(self):
        commandID = self.__connector.addCommand(1, 0, "command arguments")
        self.__connector.popCommand()
        self.__connector.addCommandOutput(commandID, 0, "commandOutput")
        result = self.__connector.getCommandOutput(commandID)
        expectedResult = (0, "commandOutput")
        self.assertEquals(
            result, expectedResult,
            "either addCommandOutput or getCommandOutput does not work")

    def test_getPendingNotifications(self):
        commandID = self.__connector.addCommand(1, 0, "commandArguments")
        self.__connector.popCommand()
        self.__connector.addCommandOutput(commandID, 0, "Args1", False, True)
        commandID = self.__connector.addCommand(1, 0, "commandArguments1")
        self.__connector.popCommand()
        self.__connector.addCommandOutput(commandID, 0, "Args2", False, True)
        result = self.__connector.getPendingNotifications(1)
        expectedResult = [(0, u'Args1'), (0, u'Args2')]
        self.assertEquals(result, expectedResult,
                          "getPendingNotifications() error")
 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)