コード例 #1
0
ファイル: test_im_logic.py プロジェクト: nakos/im
    def test_db(self):
        """ Test DB data access """
        inf = InfrastructureInfo()
        inf.id = "1"
        inf.auth = self.getAuth([0], [], [("Dummy", 0)])
        cloud = CloudInfo()
        cloud.type = "Dummy"
        radl = RADL()
        radl.add(
            system(
                "s0",
                [Feature("disk.0.image.url", "=", "mock0://linux.for.ev.er")]))
        radl.add(deploy("s0", 1))
        vm1 = VirtualMachine(inf, "1", cloud, radl, radl)
        vm2 = VirtualMachine(inf, "2", cloud, radl, radl)
        inf.vm_list = [vm1, vm2]
        inf.vm_master = vm1
        # first create the DB table
        Config.DATA_DB = "sqlite:///tmp/ind.dat"
        InfrastructureList.load_data()

        success = InfrastructureList._save_data_to_db(Config.DATA_DB,
                                                      {"1": inf})
        self.assertTrue(success)

        res = InfrastructureList._get_data_from_db(Config.DATA_DB)
        self.assertEqual(len(res), 1)
        self.assertEqual(len(res['1'].vm_list), 2)
        self.assertEqual(res['1'].vm_list[0], res['1'].vm_master)
        self.assertEqual(
            res['1'].vm_master.info.systems[0].getValue("disk.0.image.url"),
            "mock0://linux.for.ev.er")
        self.assertTrue(res['1'].auth.compare(inf.auth,
                                              "InfrastructureManager"))
コード例 #2
0
ファイル: im_service.py プロジェクト: bbsyaya/im
def launch_daemon():
    """
    Launch the IM daemon
    """
    InfrastructureList.init_table()

    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(GetInfrastructureState)
    server.register_function(GetVersion)
    server.register_function(CreateDiskSnapshot)

    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)
コード例 #3
0
ファイル: test_im.py プロジェクト: victorsndvg/im
    def setUp(self):

        Config.DATA_DB = "/tmp/inf.dat"
        InfrastructureList.load_data()
        IM._reinit()

        ch = logging.StreamHandler(sys.stdout)
        log = logging.getLogger('InfrastructureManager')
        log.setLevel(logging.ERROR)
        log.propagate = 0
        log.addHandler(ch)
        log = logging.getLogger('ConfManager')
        log.setLevel(logging.DEBUG)
        log.propagate = 0
        log.addHandler(ch)