当前位置: 首页>>代码示例>>Python>>正文


Python TNArchipelEntity.__init__方法代码示例

本文整理汇总了Python中archipelcore.archipelEntity.TNArchipelEntity.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python TNArchipelEntity.__init__方法的具体用法?Python TNArchipelEntity.__init__怎么用?Python TNArchipelEntity.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在archipelcore.archipelEntity.TNArchipelEntity的用法示例。


在下文中一共展示了TNArchipelEntity.__init__方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from archipelcore.archipelEntity import TNArchipelEntity [as 别名]
# 或者: from archipelcore.archipelEntity.TNArchipelEntity import __init__ [as 别名]
    def __init__(self, jid, password, configuration):
        """
        This is the constructor of the class.
        @type jid: string
        @param jid: the jid of the hypervisor
        @type password: string
        @param password: the password associated to the JID
        """
        TNArchipelEntity.__init__(self, jid, password, configuration, "central-agent")
        self.log.info("Starting Archipel central agent")

        self.xmppserveraddr            = self.jid.getDomain()
        self.entity_type               = "central-agent"
        self.default_avatar            = self.configuration.get("CENTRALAGENT", "central_agent_default_avatar")
        self.libvirt_event_callback_id = None
        self.vcard_infos               = {}

        self.vcard_infos["TITLE"]      = "Central agent"

        self.log.info("Server address defined as %s" % self.xmppserveraddr)

        # start the permission center
        self.permission_db_file = self.configuration.get("CENTRALAGENT", "centralagent_permissions_database_path")
        self.permission_center.start(database_file=self.permission_db_file)
        self.init_permissions()

        # action on auth
        self.register_hook("HOOK_ARCHIPELENTITY_XMPP_AUTHENTICATED", method=self.hook_xmpp_authenticated)
        self.register_hook("HOOK_ARCHIPELENTITY_XMPP_AUTHENTICATED", method=self.manage_vcard_hook)

        # create hooks
        self.create_hook("HOOK_CENTRALAGENT_VM_REGISTERED")
        self.create_hook("HOOK_CENTRALAGENT_VM_UNREGISTERED")
        self.create_hook("HOOK_CENTRALAGENT_HYP_REGISTERED")
        self.create_hook("HOOK_CENTRALAGENT_HYP_UNREGISTERED")


        self.central_agent_jid_val = None

        self.xmpp_authenticated   = False
        self.is_central_agent     = False
        self.salt                 = random.random()
        self.random_wait          = random.random()
        self.database             = sqlite3.connect(self.configuration.get("CENTRALAGENT", "database"), check_same_thread=False)
        self.database.row_factory = sqlite3.Row

        # defining the structure of the keepalive pubsub event
        self.keepalive_event      = xmpp.Node("event",attrs={"type":"keepalive","jid":self.jid})
        self.last_keepalive_heard = datetime.datetime.now()
        self.last_hyp_check       = datetime.datetime.now()
        self.required_stats_xml   = None

        # module inits
        self.initialize_modules('archipel.plugin.core')
        self.initialize_modules('archipel.plugin.centralagent')

        module_platformrequest    = self.configuration.get("MODULES", "platformrequest")

        if module_platformrequest:

            required_stats = self.get_plugin("platformrequest").computing_unit.required_stats
            self.required_stats_xml = xmpp.Node("required_stats")

            for stat in required_stats:

                self.log.debug("CENTRALAGENT: stat : %s" % stat)
                self.required_stats_xml.addChild("stat", attrs=stat)

            self.keepalive_event.addChild(node = self.required_stats_xml)
开发者ID:kris905,项目名称:Archipel,代码行数:71,代码来源:archipelCentralAgent.py

示例2: __init__

# 需要导入模块: from archipelcore.archipelEntity import TNArchipelEntity [as 别名]
# 或者: from archipelcore.archipelEntity.TNArchipelEntity import __init__ [as 别名]
    def __init__(self, jid, password, configuration, name, database_file="./database.sqlite3"):
        """
        This is the constructor of the class.
        @type jid: string
        @param jid: the jid of the hypervisor
        @type password: string
        @param password: the password associated to the JID
        @type name: string
        @param name: the name of the hypervisor
        @type database_file: string
        @param database_file: the sqlite3 file to store existing VM for persistance
        """
        TNArchipelEntity.__init__(self, jid, password, configuration, name)
        self.log.info("starting archipel-agent")
        archipelLibvirtEntity.TNArchipelLibvirtEntity.__init__(self, configuration)

        self.virtualmachines            = {}
        self.database_file              = database_file
        self.xmppserveraddr             = self.jid.getDomain()
        self.entity_type                = "hypervisor"
        self.default_avatar             = self.configuration.get("HYPERVISOR", "hypervisor_default_avatar")
        self.libvirt_event_callback_id  = None
        self.vcard_infos                = {}

        # start the permission center
        self.permission_db_file = self.configuration.get("HYPERVISOR", "hypervisor_permissions_database_path")
        self.permission_center.start(database_file=self.permission_db_file)
        self.init_permissions()

        # libvirt connection
        self.connect_libvirt()

        if (self.configuration.has_section("VCARD")):
            for key in ("orgname", "orgunit", "userid", "locality", "url", "categories"):
                if self.configuration.has_option("VCARD", key):
                    self.vcard_infos[key.upper()] = self.configuration.get("VCARD", key)
        self.vcard_infos["TITLE"] = "Hypervisor (%s)" % self.current_hypervisor()

        names_file = open(self.configuration.get("HYPERVISOR", "name_generation_file"), 'r')
        self.generated_names = names_file.readlines()
        names_file.close()
        self.number_of_names = len(self.generated_names) - 1

        self.log.info("Server address defined as %s" % self.xmppserveraddr)

        # hooks
        self.create_hook("HOOK_HYPERVISOR_ALLOC")
        self.create_hook("HOOK_HYPERVISOR_SOFT_ALLOC")
        self.create_hook("HOOK_HYPERVISOR_FREE")
        self.create_hook("HOOK_HYPERVISOR_MIGRATEDVM_LEAVE")
        self.create_hook("HOOK_HYPERVISOR_MIGRATEDVM_ARRIVE")
        self.create_hook("HOOK_HYPERVISOR_CLONE")
        self.create_hook("HOOK_HYPERVISOR_VM_WOKE_UP")
        self.create_hook("HOOK_HYPERVISOR_WOKE_UP")

        # vocabulary
        self.init_vocabulary()

        # module inits
        self.initialize_modules('archipel.plugin.core')
        self.initialize_modules('archipel.plugin.hypervisor')

        if self.is_hypervisor((archipelLibvirtEntity.ARCHIPEL_HYPERVISOR_TYPE_QEMU, archipelLibvirtEntity.ARCHIPEL_HYPERVISOR_TYPE_XEN)):
            try:
                self.libvirt_event_callback_id = self.libvirt_connection.domainEventRegisterAny(None, libvirt.VIR_DOMAIN_EVENT_ID_LIFECYCLE, self.hypervisor_on_domain_event, None)
            except libvirt.libvirtError:
                self.log.error("We are sorry. But your hypervisor doesn't support libvirt virConnectDomainEventRegisterAny. And this really bad. I'm sooo sorry.")
        else:
            self.log.warning("Your hypervisor doesn't support libvirt eventing. Using fake event loop.")
        self.capabilities = self.get_capabilities()

        # action on auth
        self.register_hook("HOOK_ARCHIPELENTITY_XMPP_AUTHENTICATED", method=self.manage_vcard_hook)
        self.register_hook("HOOK_ARCHIPELENTITY_XMPP_AUTHENTICATED", method=self.wake_up_virtual_machines_hook, oneshot=True)
        self.register_hook("HOOK_ARCHIPELENTITY_XMPP_AUTHENTICATED", method=self.update_presence)
开发者ID:Zouuup,项目名称:Archipel,代码行数:77,代码来源:archipelHypervisor.py

示例3: __init__

# 需要导入模块: from archipelcore.archipelEntity import TNArchipelEntity [as 别名]
# 或者: from archipelcore.archipelEntity.TNArchipelEntity import __init__ [as 别名]
    def __init__(self, jid, password, configuration, name, database_file="./database.sqlite3"):
        """
        this is the constructor of the class.
        @type jid: string
        @param jid: the jid of the hypervisor
        @type password: string
        @param password: the password associated to the JID
        @type name: string
        @param name: the name of the hypervisor
        @type database_file: string
        @param database_file: the sqlite3 file to store existing VM for persistance
        """
        TNArchipelEntity.__init__(self, jid, password, configuration, name)
        archipelLibvirtEntity.TNArchipelLibvirtEntity.__init__(self, configuration)

        self.virtualmachines = {}
        self.database_file = database_file
        self.xmppserveraddr = self.jid.getDomain()
        self.entity_type = "hypervisor"
        self.default_avatar = self.configuration.get("HYPERVISOR", "hypervisor_default_avatar")
        self.libvirt_event_callback_id = None

        # permissions
        permission_db_file = self.configuration.get("HYPERVISOR", "hypervisor_permissions_database_path")
        permission_admin_name = self.configuration.get("GLOBAL", "archipel_root_admin")
        self.permission_center = TNArchipelPermissionCenter(permission_db_file, permission_admin_name)
        self.init_permissions()

        names_file = open(self.configuration.get("HYPERVISOR", "name_generation_file"), "r")
        self.generated_names = names_file.readlines()
        names_file.close()
        self.number_of_names = len(self.generated_names) - 1

        self.log.info("server address defined as %s" % self.xmppserveraddr)

        # hooks
        self.create_hook("HOOK_HYPERVISOR_ALLOC")
        self.create_hook("HOOK_HYPERVISOR_FREE")
        self.create_hook("HOOK_HYPERVISOR_MIGRATEDVM_LEAVE")
        self.create_hook("HOOK_HYPERVISOR_MIGRATEDVM_ARRIVE")
        self.create_hook("HOOK_HYPERVISOR_CLONE")

        # vocabulary
        self.init_vocabulary()

        # module inits
        self.initialize_modules("archipel.plugin.core")
        self.initialize_modules("archipel.plugin.hypervisor")

        # # libvirt connection
        self.connect_libvirt()

        if self.is_hypervisor(
            (archipelLibvirtEntity.ARCHIPEL_HYPERVISOR_TYPE_QEMU, archipelLibvirtEntity.ARCHIPEL_HYPERVISOR_TYPE_XEN)
        ):
            try:
                self.libvirt_event_callback_id = self.libvirt_connection.domainEventRegisterAny(
                    None, libvirt.VIR_DOMAIN_EVENT_ID_LIFECYCLE, self.hypervisor_on_domain_event, None
                )
            except libvirt.libvirtError:
                self.log.error(
                    "we are sorry. but your hypervisor doesn't support libvirt virConnectDomainEventRegisterAny. And this really bad. I'm sooo sorry"
                )
        else:
            self.log.warning("your hypervisor doesn't support libvirt eventing. using fake event loop.")
        self.capabilities = self.get_capabilities()

        # persistance
        self.manage_persistance()

        # action on auth
        self.register_hook("HOOK_ARCHIPELENTITY_XMPP_AUTHENTICATED", method=self.manage_vcard_hook)
        self.register_hook("HOOK_ARCHIPELENTITY_XMPP_AUTHENTICATED", method=self.update_presence)
开发者ID:grantemsley,项目名称:Archipel,代码行数:75,代码来源:archipelHypervisor.py


注:本文中的archipelcore.archipelEntity.TNArchipelEntity.__init__方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。