Exemplo n.º 1
0
 def __startListenning(self):
     """
     Creates the control connection
     Args:
         None
     Returns:
         Nothing
     """    
     networkInterface = self.__parser.getConfigurationParameter("vncNetworkInterface")
     listenningPort = self.__parser.getConfigurationParameter("listenningPort")
     try :
         self.__vncServerIP = get_ip_address(networkInterface)
     except Exception :
         raise Exception("Error: the network interface '{0}' is not ready. Exiting now".format(networkInterface))    
     self.__ftpTimeout = self.__parser.getConfigurationParameter("FTPTimeout")
     self.__listenningPort = listenningPort
     self.__networkManager = NetworkManager(self.__parser.getConfigurationParameter("certificatePath"))
     self.__networkManager.startNetworkService()
     self.__useSSL = self.__parser.getConfigurationParameter("useSSL")
     self.__packetManager = VMServerPacketHandler(self.__networkManager)            
     self.__connectToDatabases("VMServerDB", self.__parser.getConfigurationParameter("databaseUserName"), self.__parser.getConfigurationParameter("databasePassword"))
         
     self.__domainHandler = DomainHandler(self.__commandsDBConnector, self.__vncServerIP, self.__networkManager, self.__packetManager, self.__listenningPort, 
                                              self.__parser.getConfigurationParameter("useQEMUWebsockets"),
                                              self.__parser.getConfigurationParameter("websockifyPath"),
                                              self.__parser.getConfigurationParameter("configFilePath"),
                                              self.__parser.getConfigurationParameter("sourceImagePath"), self.__parser.getConfigurationParameter("executionImagePath"),
                                              self.__parser.getConfigurationParameter("passwordLength"))
     self.__domainHandler.connectToLibvirt(self.__parser.getConfigurationParameter("vncNetworkInterface"), 
                                               self.__parser.getConfigurationParameter("vnName"), self.__parser.getConfigurationParameter("gatewayIP"), 
                                               self.__parser.getConfigurationParameter("netMask"), self.__parser.getConfigurationParameter("dhcpStartIP"), 
                                               self.__parser.getConfigurationParameter("dhcpEndIP"), self.__parser.getConfigurationParameter("createVirtualNetworkAsRoot"))
         
     self.__domainHandler.doInitialCleanup()
     self.__deleteTemporaryZipFiles()
     self.__fileTransferThread = FileTransferThread(self.__networkManager, self.__listenningPort, self.__packetManager,
                                                    self.__parser.getConfigurationParameter("TransferDirectory"),
                                                    self.__parser.getConfigurationParameter("FTPTimeout"), 
                                                    self.__parser.getConfigurationParameter("MaxTransferAttempts"), self.__commandsDBConnector, self.__useSSL)
     self.__compressionThread = CompressionThread(self.__parser.getConfigurationParameter("TransferDirectory"), self.__parser.getConfigurationParameter("sourceImagePath"),
                                                  self.__parser.getConfigurationParameter("configFilePath"),
                                                  self.__commandsDBConnector, self.__domainHandler, self.__networkManager, self.__listenningPort, self.__packetManager)
     self.__fileTransferThread.start()
     self.__compressionThread.start()
     self.__networkManager.listenIn(self.__listenningPort, self, self.__useSSL)
Exemplo n.º 2
0
 def startListenning(self,
                     networkInterface,
                     port,
                     maxConnections,
                     maxConnectionsPerIP,
                     ftpCallback=None,
                     downloadBandwidthRatio=0.8,
                     uploadBandwitdhRatio=0.8):
     """
     Starts the FTP server
     Args:
         networkInterface: the network interface that will be used to perform the FTP transfers
         port: a listenning port
         maxConnections: maximum connection number
         maxConnectionsPerIP: maximum connection number per IP address
         ftpCallback: the callback that will handle the events. If it's none, almost nothing will be
             done to handle them.
         downloadBandwidthRatio: maximum download bandwidth fraction
         uploadBandwidthRatio: maximum upload bandwidth fraction
     Returns:
         Nothing
     """
     ip_address = get_ip_address(networkInterface)
     handler = CygnusCloudFTPHandler
     handler.ftpCallback = ftpCallback
     handler.authorizer = self.__authorizer
     handler.banner = self.__banner
     link_bandwidth = ChildProcessManager.runCommandInForeground(
         "/sbin/ethtool eth0 | grep -i Speed | cut -b 9-", Exception)
     if ("Mb/s" in link_bandwidth):
         power = 1024**2
     else:
         power = 1024**3
     link_bandwidth = int(sub('[^0-9]', '', link_bandwidth))
     dtp_handler = ThrottledDTPHandler
     dtp_handler.read_limit = link_bandwidth * downloadBandwidthRatio * power
     dtp_handler.write_limit = link_bandwidth * uploadBandwitdhRatio * power
     handler.dtp_handler = dtp_handler
     address = (ip_address, port)
     self.__ftpServer = FTPServer(address, handler)
     self.__ftpServer.max_cons = maxConnections
     self.__ftpServer.max_cons_per_ip = maxConnectionsPerIP
     self.__thread = FTPServerThread(self.__ftpServer)
     self.__thread.start()
 def startListenning(self, networkInterface, port, maxConnections, maxConnectionsPerIP, ftpCallback = None,
                     downloadBandwidthRatio=0.8, uploadBandwitdhRatio=0.8):
     """
     Starts the FTP server
     Args:
         networkInterface: the network interface that will be used to perform the FTP transfers
         port: a listenning port
         maxConnections: maximum connection number
         maxConnectionsPerIP: maximum connection number per IP address
         ftpCallback: the callback that will handle the events. If it's none, almost nothing will be
             done to handle them.
         downloadBandwidthRatio: maximum download bandwidth fraction
         uploadBandwidthRatio: maximum upload bandwidth fraction
     Returns:
         Nothing
     """
     ip_address = get_ip_address(networkInterface)
     handler = CygnusCloudFTPHandler
     handler.ftpCallback = ftpCallback
     handler.authorizer = self.__authorizer
     handler.banner = self.__banner  
     link_bandwidth = ChildProcessManager.runCommandInForeground("/sbin/ethtool eth0 | grep -i Speed | cut -b 9-", Exception)
     if ("Mb/s" in link_bandwidth) :
         power = 1024 ** 2
     else :
         power = 1024 ** 3
     link_bandwidth = int(sub('[^0-9]', '', link_bandwidth))
     dtp_handler = ThrottledDTPHandler
     dtp_handler.read_limit = link_bandwidth * downloadBandwidthRatio * power
     dtp_handler.write_limit = link_bandwidth * uploadBandwitdhRatio * power 
     handler.dtp_handler = dtp_handler
     address = (ip_address, port)
     self.__ftpServer = FTPServer(address, handler)
     self.__ftpServer.max_cons = maxConnections
     self.__ftpServer.max_cons_per_ip = maxConnectionsPerIP
     self.__thread = FTPServerThread(self.__ftpServer)
     self.__thread.start()        
Exemplo n.º 4
0
    def __startListenning(self):
        """
        Creates the control connection
        Args:
            None
        Returns:
            Nothing
        """
        networkInterface = self.__parser.getConfigurationParameter(
            "vncNetworkInterface")
        listenningPort = self.__parser.getConfigurationParameter(
            "listenningPort")
        try:
            self.__vncServerIP = get_ip_address(networkInterface)
        except Exception:
            raise Exception(
                "Error: the network interface '{0}' is not ready. Exiting now".
                format(networkInterface))
        self.__ftpTimeout = self.__parser.getConfigurationParameter(
            "FTPTimeout")
        self.__listenningPort = listenningPort
        self.__networkManager = NetworkManager(
            self.__parser.getConfigurationParameter("certificatePath"))
        self.__networkManager.startNetworkService()
        self.__useSSL = self.__parser.getConfigurationParameter("useSSL")
        self.__packetManager = VMServerPacketHandler(self.__networkManager)
        self.__connectToDatabases(
            "VMServerDB",
            self.__parser.getConfigurationParameter("databaseUserName"),
            self.__parser.getConfigurationParameter("databasePassword"))

        self.__domainHandler = DomainHandler(
            self.__commandsDBConnector, self.__vncServerIP,
            self.__networkManager, self.__packetManager, self.__listenningPort,
            self.__parser.getConfigurationParameter("useQEMUWebsockets"),
            self.__parser.getConfigurationParameter("websockifyPath"),
            self.__parser.getConfigurationParameter("configFilePath"),
            self.__parser.getConfigurationParameter("sourceImagePath"),
            self.__parser.getConfigurationParameter("executionImagePath"),
            self.__parser.getConfigurationParameter("passwordLength"))
        self.__domainHandler.connectToLibvirt(
            self.__parser.getConfigurationParameter("vncNetworkInterface"),
            self.__parser.getConfigurationParameter("vnName"),
            self.__parser.getConfigurationParameter("gatewayIP"),
            self.__parser.getConfigurationParameter("netMask"),
            self.__parser.getConfigurationParameter("dhcpStartIP"),
            self.__parser.getConfigurationParameter("dhcpEndIP"),
            self.__parser.getConfigurationParameter(
                "createVirtualNetworkAsRoot"))

        self.__domainHandler.doInitialCleanup()
        self.__deleteTemporaryZipFiles()
        self.__fileTransferThread = FileTransferThread(
            self.__networkManager, self.__listenningPort, self.__packetManager,
            self.__parser.getConfigurationParameter("TransferDirectory"),
            self.__parser.getConfigurationParameter("FTPTimeout"),
            self.__parser.getConfigurationParameter("MaxTransferAttempts"),
            self.__commandsDBConnector, self.__useSSL)
        self.__compressionThread = CompressionThread(
            self.__parser.getConfigurationParameter("TransferDirectory"),
            self.__parser.getConfigurationParameter("sourceImagePath"),
            self.__parser.getConfigurationParameter("configFilePath"),
            self.__commandsDBConnector, self.__domainHandler,
            self.__networkManager, self.__listenningPort, self.__packetManager)
        self.__fileTransferThread.start()
        self.__compressionThread.start()
        self.__networkManager.listenIn(self.__listenningPort, self,
                                       self.__useSSL)