コード例 #1
0
ファイル: manager.py プロジェクト: queba/haizea
    def __initialize(self):
        # Create the RM components
        
        mode = self.config.get("mode")
        

        if mode == "simulated":
            # Simulated-time simulations always run in the foreground
            clock = self.config.get("clock")
            if clock == constants.CLOCK_SIMULATED:
                self.daemon = False
        elif mode == "opennebula":
            clock = constants.CLOCK_REAL        
        
        self.init_logging()
                
        if clock == constants.CLOCK_SIMULATED:
            starttime = self.config.get("starttime")
            self.clock = SimulatedClock(self, starttime)
            self.rpc_server = None
        elif clock == constants.CLOCK_REAL:
            wakeup_interval = self.config.get("wakeup-interval")
            non_sched = self.config.get("non-schedulable-interval")
            if mode == "opennebula":
                fastforward = self.config.get("dry-run")
            else:
                fastforward = False
            self.clock = RealClock(self, wakeup_interval, non_sched, fastforward)
            if fastforward:
                # No need for an RPC server when doing a dry run
                self.rpc_server = None
            else:
                self.rpc_server = RPCServer(self)
                    
        # Create the RPC singleton client for OpenNebula mode
        if mode == "opennebula":
            host = self.config.get("one.host")
            port = self.config.get("one.port")
            try:
                rv = OpenNebulaXMLRPCClient.get_userpass_from_env()
            except:
                print "ONE_AUTH environment variable is not set or authorization file is malformed"
                exit(1)
                
            user, passw = rv[0], rv[1]
            try:
                OpenNebulaXMLRPCClientSingleton(host, port, user, passw)
            except socket.error, e:
                print "Unable to connect to OpenNebula"
                print "Reason: %s" % e
                exit(1)
コード例 #2
0
ファイル: manager.py プロジェクト: borjasotomayor/haizea
    def __init__(self, config, daemon=False, pidfile=None):
        """Initializes the manager.
        
        Argument:
        config -- a populated instance of haizea.common.config.RMConfig
        daemon -- True if Haizea must run as a daemon, False if it must
                  run in the foreground
        pidfile -- When running as a daemon, file to save pid to
        """
        self.config = config
        
        # Create the RM components
        
        mode = config.get("mode")
        
        self.daemon = daemon
        self.pidfile = pidfile

        if mode == "simulated":
            # Simulated-time simulations always run in the foreground
            clock = self.config.get("clock")
            if clock == constants.CLOCK_SIMULATED:
                self.daemon = False
        elif mode == "opennebula":
            clock = constants.CLOCK_REAL        
        
        self.init_logging()
                
        if clock == constants.CLOCK_SIMULATED:
            starttime = self.config.get("starttime")
            self.clock = SimulatedClock(self, starttime)
            self.rpc_server = None
        elif clock == constants.CLOCK_REAL:
            wakeup_interval = self.config.get("wakeup-interval")
            non_sched = self.config.get("non-schedulable-interval")
            if mode == "opennebula":
                fastforward = self.config.get("dry-run")
            else:
                fastforward = False
            self.clock = RealClock(self, wakeup_interval, non_sched, fastforward)
            if fastforward:
                # No need for an RPC server when doing a dry run
                self.rpc_server = None
            else:
                self.rpc_server = RPCServer(self)
                    
        # Create the RPC singleton client for OpenNebula mode
        if mode == "opennebula":
            host = self.config.get("one.host")
            port = self.config.get("one.port")
            rv = OpenNebulaXMLRPCClient.get_userpass_from_env()
            if rv == None:
                print "ONE_AUTH environment variable is not set"
                exit(1)
            else:
                user, passw = rv[0], rv[1]
                try:
                    OpenNebulaXMLRPCClientSingleton(host, port, user, passw)
                except socket.error, e:
                    print "Unable to connect to OpenNebula"
                    print "Reason: %s" % e
                    exit(1)
コード例 #3
0
    def __init__(self, config, daemon=False, pidfile=None, logging_handler=None, site=None):
        """Initializes the manager.
        
        Argument:site
        config -- a populated instance of haizea.common.config.RMConfig
        daemon -- True if Haizea must run as a daemon, False if it must
                  run in the foreground
        pidfile -- When running as a daemon, file to save pid to
        """
        self.config = config
        self.logging_handler = logging_handler
        # Create the RM components
        
        mode = config.get("mode")
        
        self.daemon = daemon
        self.pidfile = pidfile

        if mode == "simulated":
            # Simulated-time simulations always run in the foreground
            clock = self.config.get("clock")
            if clock == constants.CLOCK_SIMULATED:
                self.daemon = False
        elif mode == "opennebula":
            clock = constants.CLOCK_REAL        
        
        self.init_logging()
                
        if clock == constants.CLOCK_SIMULATED:
            starttime = self.config.get("starttime")
            self.clock = SimulatedClock(self, starttime)
            self.rpc_server = None
        elif clock == constants.CLOCK_REAL:
            wakeup_interval = self.config.get("wakeup-interval")
            non_sched = self.config.get("non-schedulable-interval")
            if mode == "opennebula":
                fastforward = self.config.get("dry-run")
            else:
                fastforward = False
            self.clock = RealClock(self, wakeup_interval, non_sched, fastforward)
            if fastforward:
                # No need for an RPC server when doing a dry run
                self.rpc_server = None
            else:
                self.rpc_server = RPCServer(self)
                    
        # Create the RPC singleton client for OpenNebula mode
        if mode == "opennebula":
            host = self.config.get("one.host")
            port = self.config.get("one.port")
            rv = OpenNebulaXMLRPCClient.get_userpass_from_env()
            if rv == None:
                print "ONE_AUTH environment variable is not set"
                exit(1)
            else:
                user, passw = rv[0], rv[1]
                try:
                    OpenNebulaXMLRPCClientSingleton(host, port, user, passw)
                except socket.error, e:
                    print "Unable to connect to OpenNebula"
                    print "Reason: %s" % e
                    exit(1)
コード例 #4
0
 def __init__(self, *args, **kwargs):
     from haizea.common.opennebula_xmlrpc import OpenNebulaXMLRPCClient
     self.client = OpenNebulaXMLRPCClient(*args, **kwargs)