Ejemplo n.º 1
0
def launch_daemon():
	"""
	Launch the IM daemon
	"""
	if os.path.isfile(Config.DATA_FILE) or Config.DATA_DB:
		InfrastructureManager.load_data()
	
	if Config.XMLRCP_SSL:
		# if specified launch the secure version
		import ssl
		from IM.request import AsyncSSLXMLRPCServer
		server = AsyncSSLXMLRPCServer(Config.XMLRCP_ADDRESS, Config.XMLRCP_PORT, Config.XMLRCP_SSL_KEYFILE,
									  Config.XMLRCP_SSL_CERTFILE, Config.XMLRCP_SSL_CA_CERTS,
									  cert_reqs=ssl.CERT_OPTIONAL)
	else:
		# otherwise the standard XML-RPC service
		server = AsyncXMLRPCServer((Config.XMLRCP_ADDRESS, Config.XMLRCP_PORT))
	
	# Register the API functions
	server.register_function(CreateInfrastructure)
	server.register_function(DestroyInfrastructure)
	server.register_function(StartInfrastructure)
	server.register_function(StopInfrastructure)
	server.register_function(GetInfrastructureInfo)
	server.register_function(GetVMInfo)
	server.register_function(GetVMProperty)
	server.register_function(AlterVM)
	server.register_function(RemoveResource)
	server.register_function(AddResource)
	server.register_function(GetInfrastructureList)
	server.register_function(Reconfigure)
	server.register_function(ExportInfrastructure)
	server.register_function(ImportInfrastructure)
	server.register_function(GetInfrastructureRADL)
	server.register_function(GetInfrastructureContMsg)
	server.register_function(GetVMContMsg)
	server.register_function(StartVM)
	server.register_function(StopVM)
	server.register_function(GetInfrastructureState)
	server.register_function(GetVersion)
	
	InfrastructureManager.logger.info('************ Start Infrastructure Manager daemon (v.%s) ************' % version)

	# Launch the API XMLRPC thread
	server.serve_forever_in_thread()
	
	if Config.ACTIVATE_REST:
		# If specified launch the REST server
		import IM.REST
		IM.REST.run_in_thread(host=Config.REST_ADDRESS, port=Config.REST_PORT)
	
	# Start the messages queue
	get_system_queue().timed_process_loop(None, 1, exit_callback = im_stop)
Ejemplo n.º 2
0
def launch_daemon():
    """
    Launch the IM daemon
    """
    if not InfrastructureList.init_table():
        print("Error connecting with the DB!!.")
        sys.exit(2)

    if Config.XMLRCP_SSL:
        # if specified launch the secure version
        import ssl
        from IM.request import AsyncSSLXMLRPCServer
        server = AsyncSSLXMLRPCServer(
            (Config.XMLRCP_ADDRESS, Config.XMLRCP_PORT),
            keyfile=Config.XMLRCP_SSL_KEYFILE,
            certfile=Config.XMLRCP_SSL_CERTFILE,
            ca_certs=Config.XMLRCP_SSL_CA_CERTS,
            cert_reqs=ssl.CERT_OPTIONAL)
    else:
        # otherwise the standard XML-RPC service
        server = AsyncXMLRPCServer((Config.XMLRCP_ADDRESS, Config.XMLRCP_PORT))

    # Register the API functions
    server.register_function(CreateInfrastructure)
    server.register_function(DestroyInfrastructure)
    server.register_function(StartInfrastructure)
    server.register_function(StopInfrastructure)
    server.register_function(GetInfrastructureInfo)
    server.register_function(GetVMInfo)
    server.register_function(GetVMProperty)
    server.register_function(AlterVM)
    server.register_function(RemoveResource)
    server.register_function(AddResource)
    server.register_function(GetInfrastructureList)
    server.register_function(Reconfigure)
    server.register_function(ExportInfrastructure)
    server.register_function(ImportInfrastructure)
    server.register_function(GetInfrastructureRADL)
    server.register_function(GetInfrastructureContMsg)
    server.register_function(GetVMContMsg)
    server.register_function(StartVM)
    server.register_function(StopVM)
    server.register_function(RebootVM)
    server.register_function(GetInfrastructureState)
    server.register_function(GetVersion)
    server.register_function(CreateDiskSnapshot)

    InfrastructureManager.logger.info(
        '************ Start Infrastructure Manager daemon (v.%s) ************'
        % version)

    if Config.ACTIVATE_REST:
        # If specified launch the REST server
        import IM.REST
        if Config.ACTIVATE_XMLRPC:
            IM.REST.run_in_thread(host=Config.REST_ADDRESS,
                                  port=Config.REST_PORT)
        else:
            IM.REST.run(host=Config.REST_ADDRESS, port=Config.REST_PORT)

    if Config.ACTIVATE_XMLRPC:
        # Launch the API XMLRPC thread
        server.serve_forever_in_thread()
        # Start the messages queue
        get_system_queue().timed_process_loop(None, 1, exit_callback=im_stop)
Ejemplo n.º 3
0
def launch_daemon():
    """
    Launch the IM daemon
    """
    if os.path.isfile(Config.DATA_FILE) or Config.DATA_DB:
        InfrastructureManager.load_data()

    if Config.XMLRCP_SSL:
        # if specified launch the secure version
        import ssl
        from IM.request import AsyncSSLXMLRPCServer
        server = AsyncSSLXMLRPCServer(Config.XMLRCP_ADDRESS, Config.XMLRCP_PORT, Config.XMLRCP_SSL_KEYFILE,
                                      Config.XMLRCP_SSL_CERTFILE, Config.XMLRCP_SSL_CA_CERTS,
                                      cert_reqs=ssl.CERT_OPTIONAL)
    else:
        # otherwise the standard XML-RPC service
        server = AsyncXMLRPCServer((Config.XMLRCP_ADDRESS, Config.XMLRCP_PORT))

    # Register the API functions
    server.register_function(CreateInfrastructure)
    server.register_function(DestroyInfrastructure)
    server.register_function(StartInfrastructure)
    server.register_function(StopInfrastructure)
    server.register_function(GetInfrastructureInfo)
    server.register_function(GetVMInfo)
    server.register_function(GetVMProperty)
    server.register_function(AlterVM)
    server.register_function(RemoveResource)
    server.register_function(AddResource)
    server.register_function(GetInfrastructureList)
    server.register_function(Reconfigure)
    server.register_function(ExportInfrastructure)
    server.register_function(ImportInfrastructure)
    server.register_function(GetInfrastructureRADL)
    server.register_function(GetInfrastructureContMsg)
    server.register_function(GetVMContMsg)
    server.register_function(StartVM)
    server.register_function(StopVM)
    server.register_function(GetInfrastructureState)
    server.register_function(GetVersion)

    InfrastructureManager.logger.info(
        '************ Start Infrastructure Manager daemon (v.%s) ************' % version)

    # Launch the API XMLRPC thread
    server.serve_forever_in_thread()

    if Config.ACTIVATE_REST:
        # If specified launch the REST server
        import IM.REST
        IM.REST.run_in_thread(host=Config.REST_ADDRESS, port=Config.REST_PORT)

    # Start the messages queue
    get_system_queue().timed_process_loop(None, 1, exit_callback=im_stop)