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


Python archipelPlugin.TNArchipelPlugin类代码示例

本文整理汇总了Python中archipelcore.archipelPlugin.TNArchipelPlugin的典型用法代码示例。如果您正苦于以下问题:Python TNArchipelPlugin类的具体用法?Python TNArchipelPlugin怎么用?Python TNArchipelPlugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

 def __init__(self, configuration, entity, entry_point_group):
     """
     Initialize the class.
     @type configuration: Configuration object
     @param configuration: the configuration
     @type entity: L{TNArchipelEntity}
     @param entity: the entity that owns the plugin
     @type entry_point_group: string
     @param entry_point_group: the group name of plugin entry_point
     """
     TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group)
     ## create directories if neede
     if not os.path.exists(self.configuration.get("VMCASTING", "repository_path")):
         os.makedirs(self.configuration.get("VMCASTING", "repository_path"))
     if not os.path.exists(self.configuration.get("VMCASTING", "temp_path")):
         os.makedirs(self.configuration.get("VMCASTING", "temp_path"))
     if not os.path.exists(self.configuration.get("VMCASTING", "own_vmcast_path")):
         os.makedirs(self.configuration.get("VMCASTING", "own_vmcast_path"))
     self.disks_extensions       =  self.configuration.get("VMCASTING", "disks_extensions").split(";")
     self.temp_directory         = self.configuration.get("VMCASTING", "temp_path")
     self.hypervisor_repo_path   = self.configuration.get("VMCASTING", "own_vmcast_path")
     self.is_installing          = False
     self.installing_media_uuid  = None
     self.is_installed           = False
     self.database_connection = sqlite3.connect(self.configuration.get("VMCASTING", "vmcasting_database_path"), check_same_thread = False)
     self.cursor = self.database_connection.cursor()
     # permissions
     self.entity.permission_center.create_permission("appliance_get", "Authorizes user to get installed appliances", False)
     self.entity.permission_center.create_permission("appliance_attach", "Authorizes user attach appliance to virtual machine", False)
     self.entity.permission_center.create_permission("appliance_detach", "Authorizes user to detach appliance_detach from virtual machine", False)
     self.entity.permission_center.create_permission("appliance_package", "Authorizes user to package new appliance from virtual machine", False)
开发者ID:basicer,项目名称:Archipel,代码行数:31,代码来源:vmappliancemanager.py

示例2: __init__

    def __init__(self, configuration, entity, entry_point_group):
        """
        Initialize the plugin.
        @type configuration: Configuration object
        @param configuration: the configuration
        @type entity: L{TNArchipelEntity}
        @param entity: the entity that owns the plugin
        @type entry_point_group: string
        @param entry_point_group: the group name of plugin entry_point
        """
        TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group)

        if self.entity.__class__.__name__ == "TNArchipelHypervisor":
            self.entity.register_hook("HOOK_ARCHIPELENTITY_XMPP_AUTHENTICATED", method=self.hypervisor_hook_xmpp_authenticated)
            self.entity.register_hook("HOOK_HYPERVISOR_WOKE_UP", method=self.push_vms_in_central_db)
            self.entity.register_hook("HOOK_HYPERVISOR_FREE",  method=self.hook_vm_unregistered)


        if self.entity.__class__.__name__ == "TNArchipelVirtualMachine":
            self.entity.register_hook("HOOK_VM_INITIALIZE", method=self.hook_missed_vms, oneshot=True)
            self.entity.register_hook("HOOK_VM_DEFINE",     method=self.hook_vm_event)

        self.central_agent_jid_val = None
        self.last_keepalive_heard = None
        self.keepalive_interval = int(ARCHIPEL_CENTRAL_AGENT_TIMEOUT * 2)
        self.hypervisor_timeout_threshold = int(ARCHIPEL_CENTRAL_AGENT_TIMEOUT)
        self.delayed_tasks = TNTasks(self.entity.log)
        self.vms_to_hook = set()

        self.xmpp_authenticated    = False
开发者ID:ArchipelProject,项目名称:Archipel,代码行数:30,代码来源:centraldb.py

示例3: __init__

 def __init__(self, configuration, entity, entry_point_group):
     """
     Initialize the plugin.
     @type configuration: Configuration object
     @param configuration: the configuration
     @type entity: L{TNArchipelEntity}
     @param entity: the entity that owns the plugin
     @type entry_point_group: string
     @param entry_point_group: the group name of plugin entry_point
     """
     TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group)
     self.scheduler = Scheduler()
     self.scheduler.start()
     self.database = sqlite3.connect(self.configuration.get("SCHEDULER", "database"), check_same_thread=False)
     self.database.execute("create table if not exists scheduler (entity_uuid text, job_uuid text, action text, year text, month text, day text, hour text, minute text, second text, comment text, params text)")
     self.database.commit()
     self.cursor = self.database.cursor()
     self.restore_jobs()
     self.supported_actions_for_vm = ("create", "shutdown", "destroy", "suspend", "resume", "reboot", "migrate", "pause")
     self.supported_actions_for_hypervisor = ("alloc", "free")
     # permissions
     self.entity.permission_center.create_permission("scheduler_jobs", "Authorizes user to get the list of task", False)
     self.entity.permission_center.create_permission("scheduler_schedule", "Authorizes user to schedule a task", False)
     self.entity.permission_center.create_permission("scheduler_unschedule", "Authorizes user to unschedule a task", False)
     self.entity.permission_center.create_permission("scheduler_actions", "Authorizes user to get available actions", False)
     # hooks
     if self.entity.__class__.__name__ == "TNArchipelVirtualMachine":
         self.entity.register_hook("HOOK_VM_TERMINATE", method=self.vm_terminate)
开发者ID:Dogild,项目名称:Archipel,代码行数:28,代码来源:actionscheduler.py

示例4: __init__

    def __init__(self, configuration, entity, entry_point_group):
        """
        Initialize the plugin.
        @type configuration: Configuration object
        @param configuration: the configuration
        @type entity: L{TNArchipelEntity}
        @param entity: the entity that owns the plugin
        @type entry_point_group: string
        @param entry_point_group: the group name of plugin entry_point
        """
        TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group)
        self.novnc_proxy = None

        # vocabulary
        registrar_item = {  "commands" : ["vnc", "screen"],
                            "parameters": [],
                            "method": self.message_display,
                            "permissions": ["vnc_display"],
                            "description": "I'll show my VNC port" }
        self.entity.add_message_registrar_item(registrar_item)
        # permissions
        self.entity.permission_center.create_permission("vnc_display", "Authorizes users to access the vnc display port", False)
        # hooks
        self.entity.register_hook("HOOK_VM_CREATE", method=self.create_novnc_proxy)
        self.entity.register_hook("HOOK_VM_CRASH", method=self.stop_novnc_proxy)
        self.entity.register_hook("HOOK_VM_STOP", method=self.stop_novnc_proxy)
        self.entity.register_hook("HOOK_VM_DESTROY", method=self.stop_novnc_proxy)
        self.entity.register_hook("HOOK_VM_TERMINATE", method=self.stop_novnc_proxy)
        self.entity.register_hook("HOOK_VM_MIGRATED", method=self.stop_novnc_proxy)
        self.entity.register_hook("HOOK_VM_INITIALIZE", method=self.awake_from_initialization)

        self.websocket_verbose = False
        if self.configuration.has_option("VNC", "vnc_enable_websocket_debug"):
            self.websocket_verbose = self.configuration.getboolean("VNC", "vnc_enable_websocket_debug")
开发者ID:ArchipelProject,项目名称:Archipel,代码行数:34,代码来源:vnc.py

示例5: __init__

    def __init__(self, configuration, entity, entry_point_group):
        """
        intialize the plugin
        """
        TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group)
        
        self.credentials = []
        creds = self.configuration.get("IPHONENOTIFICATION", "credentials_key")

        for cred in creds.split(",,"):
            self.credentials.append(cred)
        
        if self.entity.__class__.__name__ == "TNArchipelVirtualMachine":
            self.entity.register_hook("HOOK_VM_CREATE", method=self.vm_create)
            self.entity.register_hook("HOOK_VM_SHUTOFF", method=self.vm_shutoff)
            self.entity.register_hook("HOOK_VM_STOP", method=self.vm_stop)
            self.entity.register_hook("HOOK_VM_DESTROY", method=self.vm_destroy)
            self.entity.register_hook("HOOK_VM_SUSPEND", method=self.vm_suspend)
            self.entity.register_hook("HOOK_VM_RESUME", method=self.vm_resume)
            self.entity.register_hook("HOOK_VM_UNDEFINE", method=self.vm_undefine)
            self.entity.register_hook("HOOK_VM_DEFINE", method=self.vm_define)
        elif self.entity.__class__.__name__ == "TNArchipelHypervisor":
            self.entity.register_hook("HOOK_HYPERVISOR_ALLOC", method=self.hypervisor_alloc)
            self.entity.register_hook("HOOK_HYPERVISOR_FREE", method=self.hypervisor_free)
            self.entity.register_hook("HOOK_HYPERVISOR_MIGRATEDVM_LEAVE", method=self.hypervisor_migrate_leave)
            self.entity.register_hook("HOOK_HYPERVISOR_MIGRATEDVM_ARRIVE", method=self.hypervisor_migrate_arrive)
            self.entity.register_hook("HOOK_HYPERVISOR_CLONE", method=self.hypervisor_clone)
开发者ID:flazcano,项目名称:Archipel,代码行数:27,代码来源:appnotificator.py

示例6: __init__

 def __init__(self, configuration, entity, entry_point_group):
     """
     initialize the module
     @type entity TNArchipelEntity
     @param entity the module entity
     """
     TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group)
     
     self.novnc_proxy = None
     
     # vocabulary
     registrar_item = {  "commands" : ["vnc", "screen"], 
                         "parameters": [],
                         "method": self.message_display,
                         "permissions": ["vnc_display"],
                         "description": "I'll show my VNC port" }
     self.entity.add_message_registrar_item(registrar_item)
     
     # permissions
     self.entity.permission_center.create_permission("vnc_display", "Authorizes users to access the vnc display port", False)    
     
     # hooks
     self.entity.register_hook("HOOK_VM_CREATE", method=self.create_novnc_proxy)
     self.entity.register_hook("HOOK_VM_CRASH", method=self.stop_novnc_proxy)
     self.entity.register_hook("HOOK_VM_STOP", method=self.stop_novnc_proxy)
     self.entity.register_hook("HOOK_VM_DESTROY", method=self.stop_novnc_proxy)
     self.entity.register_hook("HOOK_VM_TERMINATE", method=self.stop_novnc_proxy)
     self.entity.register_hook("HOOK_XMPP_DISCONNECT", method=self.stop_novnc_proxy)
     self.entity.register_hook("HOOK_VM_INITIALIZE", method=self.awake_from_initialization)
开发者ID:flazcano,项目名称:Archipel,代码行数:29,代码来源:vnc.py

示例7: __init__

 def __init__(self, configuration, entity, entry_point_group):
     """
     initialize the module
     @type configuration: Configuration object
     @param configuration: the configuration
     @type entity: L{TNArchipelEntity}
     @param entity: the entity that owns the plugin
     @type entry_point_group: string
     @param entry_point_group: the group name of plugin entry_point
     """
     TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group)
     self.shared_isos_folder = self.configuration.get("STORAGE", "iso_base_path") + "/"
     if self.configuration.has_option("STORAGE", "qemu_img_bin_path"):
         self.qemu_img_bin = self.configuration.get("STORAGE", "qemu_img_bin_path")
     else:
         self.qemu_img_bin = "qemu-img"
     if not os.path.exists(self.shared_isos_folder):
         os.makedirs(self.shared_isos_folder)
     # permissions
     self.entity.permission_center.create_permission("drives_create", "Authorizes user to get create a drive", False)
     self.entity.permission_center.create_permission("drives_delete", "Authorizes user to delete a drive", False)
     self.entity.permission_center.create_permission("drives_get", "Authorizes user to get all drives", False)
     self.entity.permission_center.create_permission("drives_getiso", "Authorizes user to get existing ISO images", False)
     self.entity.permission_center.create_permission("drives_convert", "Authorizes user to convert a drive", False)
     self.entity.permission_center.create_permission("drives_rename", "Authorizes user to rename a drive", False)
开发者ID:grantemsley,项目名称:Archipel,代码行数:25,代码来源:storage.py

示例8: __init__

    def __init__(self, configuration, entity, entry_point_group):
        """
        Initialize the plugin.
        @type configuration: Configuration object
        @param configuration: the configuration
        @type entity: L{TNArchipelEntity}
        @param entity: the entity that owns the plugin
        @type entry_point_group: string
        @param entry_point_group: the group name of plugin entry_point
        """
        TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group)

        if self.entity.__class__.__name__ == "TNArchipelHypervisor":

            self.entity.register_hook("HOOK_ARCHIPELENTITY_XMPP_AUTHENTICATED", method=self.hypervisor_hook_xmpp_authenticated)

        if self.entity.__class__.__name__ == "TNArchipelVirtualMachine":

            self.entity.register_hook("HOOK_VM_DEFINE", method=self.hook_vm_event)
            self.entity.register_hook("HOOK_VM_INITIALIZE", method=self.hook_vm_event)
            self.entity.register_hook("HOOK_VM_TERMINATE", method=self.hook_vm_terminate)

        self.central_agent_jid_val = None

        self.xmpp_authenticated    = False
        self.required_statistics        = []
开发者ID:winneryong,项目名称:Archipel,代码行数:26,代码来源:centraldb.py

示例9: __init__

    def __init__(self, configuration, entity, entry_point_group):
        """
        Initialize the plugin.
        @type configuration: Configuration object
        @param configuration: the configuration
        @type entity: L{TNArchipelEntity}
        @param entity: the entity that owns the plugin
        @type entry_point_group: string
        @param entry_point_group: the group name of plugin entry_point
        """
        TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group)
        self.xmpp_server        = entity.jid.getDomain()
        self.xmlrpc_host        = self.configuration.get("XMPPSERVER", "xmlrpc_host")
        self.xmlrpc_port        = self.configuration.getint("XMPPSERVER", "xmlrpc_port")
        self.xmlrpc_user        = self.configuration.get("XMPPSERVER", "xmlrpc_user")
        self.xmlrpc_password    = self.configuration.get("XMPPSERVER", "xmlrpc_password")
        self.xmlrpc_call        = "http://%s:%[email protected]%s:%s/" % (self.xmlrpc_user, self.xmlrpc_password, self.xmlrpc_host, self.xmlrpc_port)
        self.xmlrpc_server      = xmlrpclib.ServerProxy(self.xmlrpc_call)

        self.entity.log.info("XMPPSERVER: Module is using XMLRPC API for managing XMPP server")

        # permissions
        self.entity.permission_center.create_permission("xmppserver_groups_create", "Authorizes user to create shared groups", False)
        self.entity.permission_center.create_permission("xmppserver_groups_delete", "Authorizes user to delete shared groups", False)
        self.entity.permission_center.create_permission("xmppserver_groups_list", "Authorizes user to list shared groups", False)
        self.entity.permission_center.create_permission("xmppserver_groups_addusers", "Authorizes user to add users in shared groups", False)
        self.entity.permission_center.create_permission("xmppserver_groups_deleteusers", "Authorizes user to remove users from shared groups", False)
        self.entity.permission_center.create_permission("xmppserver_users_register", "Authorizes user to register XMPP users", False)
        self.entity.permission_center.create_permission("xmppserver_users_unregister", "Authorizes user to unregister XMPP users", False)
        self.entity.permission_center.create_permission("xmppserver_users_list", "Authorizes user to list XMPP users", False)
开发者ID:Bassbauer,项目名称:Archipel,代码行数:30,代码来源:xmppserver_xmlrpc.py

示例10: __init__

    def __init__(self, configuration, entity, entry_point_group):
        """
        Initialize the plugin.
        @type configuration: Configuration object
        @param configuration: the configuration
        @type entity: L{TNArchipelEntity}
        @param entity: the entity that owns the plugin
        @type entry_point_group: string
        @param entry_point_group: the group name of plugin entry_point
        """
        TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group)
        self.xmpp_server        = entity.jid.getDomain()
        self.entities_types_cache = {}

        self.entity.log.info("XMPPSERVER: module is using XMPP API for managing XMPP server")

        # permissions
        self.entity.permission_center.create_permission("xmppserver_groups_create", "Authorizes user to create shared groups", False)
        self.entity.permission_center.create_permission("xmppserver_groups_delete", "Authorizes user to delete shared groups", False)
        self.entity.permission_center.create_permission("xmppserver_groups_list", "Authorizes user to list shared groups", False)
        self.entity.permission_center.create_permission("xmppserver_groups_addusers", "Authorizes user to add users in shared groups", False)
        self.entity.permission_center.create_permission("xmppserver_groups_deleteusers", "Authorizes user to remove users from shared groups", False)
        self.entity.permission_center.create_permission("xmppserver_users_register", "Authorizes user to register XMPP users", False)
        self.entity.permission_center.create_permission("xmppserver_users_unregister", "Authorizes user to unregister XMPP users", False)
        self.entity.permission_center.create_permission("xmppserver_users_list", "Authorizes user to list XMPP users", False)
开发者ID:Bassbauer,项目名称:Archipel,代码行数:25,代码来源:xmppserver_xmpp.py

示例11: __init__

    def __init__(self, configuration, entity, entry_point_group):
        """
        Initialize the plugin.
        @type configuration: Configuration object
        @param configuration: the configuration
        @type entity: L{TNArchipelEntity}
        @param entity: the entity that owns the plugin
        @type entry_point_group: string
        @param entry_point_group: the group name of plugin entry_point
        """
        TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group)
        self.nuageBridgeName = self.configuration.get("NUAGE", "nuage_bridge")
        self.database = None

        # permissions
        self.entity.permission_center.create_permission("nuagenetwork_get", "Authorizes user to get the existing Nuage networks", False)
        self.entity.permission_center.create_permission("nuagenetwork_getnames", "Authorizes user to get a Nuage network", False)

        if isinstance(self.entity, TNArchipelHypervisor):
            self.entity.permission_center.create_permission("nuagenetwork_create", "Authorizes user to create a Nuage network", False)
            self.entity.permission_center.create_permission("nuagenetwork_delete", "Authorizes user to delete a Nuage network", False)
            self.entity.permission_center.create_permission("nuagenetwork_update", "Authorizes user to update a Nuage network", False)

        if isinstance(self.entity, TNArchipelHypervisor):
            self.manage_database()

        if isinstance(self.entity, TNArchipelVirtualMachine):
            self.entity.add_vm_definition_hook(self.update_vm_xml_hook)
开发者ID:ArchipelProject,项目名称:Archipel,代码行数:28,代码来源:nuageNetwork.py

示例12: __init__

 def __init__(self, configuration, entity, entry_point_group):
     """
     initialize the module
     @type entity TNArchipelEntity
     @param entity the module entity
     @type entity String
     @param entity the path of the ejabberdctl command
     """
     
     TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group)
     
     self.xmpp_server            = entity.jid.getDomain()
     self.xmlrpc_host            = self.configuration.get("XMPPSERVER", "xmlrpc_host")
     self.xmlrpc_port            = self.configuration.getint("XMPPSERVER", "xmlrpc_port")
     self.xmlrpc_user            = self.configuration.get("XMPPSERVER", "xmlrpc_user")
     self.xmlrpc_password        = self.configuration.get("XMPPSERVER", "xmlrpc_password")
     self.xmlrpc_call            = "http://%s:%[email protected]%s:%s/" % (self.xmlrpc_user, self.xmlrpc_password, self.xmlrpc_host, self.xmlrpc_port)
     self.xmlrpc_server          = xmlrpclib.ServerProxy(self.xmlrpc_call)
     
     # permissions
     self.entity.permission_center.create_permission("xmppserver_groups_create", "Authorizes user to create shared groups", False)
     self.entity.permission_center.create_permission("xmppserver_groups_delete", "Authorizes user to delete shared groups", False)
     self.entity.permission_center.create_permission("xmppserver_groups_list", "Authorizes user to list shared groups", False)
     self.entity.permission_center.create_permission("xmppserver_groups_addusers", "Authorizes user to add users in shared groups", False)
     self.entity.permission_center.create_permission("xmppserver_groups_deleteusers", "Authorizes user to remove users from shared groups", False)
     self.entity.permission_center.create_permission("xmppserver_users_register", "Authorizes user to register XMPP users", False)
     self.entity.permission_center.create_permission("xmppserver_users_unregister", "Authorizes user to unregister XMPP users", False)
     self.entity.permission_center.create_permission("xmppserver_users_list", "Authorizes user to list XMPP users", False)
开发者ID:flazcano,项目名称:Archipel,代码行数:28,代码来源:xmppserver.py

示例13: __init__

    def __init__(self, configuration, entity, entry_point_group):
        """
        Initialize the plugin.
        @type configuration: Configuration object
        @param configuration: the configuration
        @type entity: L{TNArchipelEntity}
        @param entity: the entity that owns the plugin
        @type entry_point_group: string
        @param entry_point_group: the group name of plugin entry_point
        """
        TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group)

        # creates permissions
        self.entity.permission_center.create_permission("vmparking_park", "Authorizes user to park a virtual machines", False)

        if isinstance(self.entity, TNArchipelHypervisor):
            self.entity.permission_center.create_permission("vmparking_list", "Authorizes user to list virtual machines in parking", False)
            self.entity.permission_center.create_permission("vmparking_unpark", "Authorizes user to unpark a virtual machines", False)
            self.entity.permission_center.create_permission("vmparking_delete", "Authorizes user to delete parked virtual machines", False)
            self.entity.permission_center.create_permission("vmparking_updatexml", "Authorizes user to delete parked virtual machines", False)
            self.entity.permission_center.create_permission("vmparking_create_parked", "Authorizes user to create a new VM in parking", False)

        # vocabulary
        if isinstance(self.entity, TNArchipelHypervisor):
            registrar_items = [{    "commands" : ["park"],
                                    "parameters": [{"name": "identifiers", "description": "the UUIDs of the VM to park, separated with comas, with no space"}],
                                    "method": self.message_park_hypervisor,
                                    "permissions": ["vmparking_park"],
                                    "description": "Park the virtual machine with the given UUIDs"},

                                {   "commands" : ["unpark"],
                                    "parameters": [{"name": "identifiers", "description": "UUIDs of the virtual machines or parking tickets, separated by comas, with no space"}],
                                    "method": self.message_unpark,
                                    "permissions": ["vmparking_unpark"],
                                    "description": "Unpark the virtual machine parked with the given identifier"},

                                {    "commands" : ["park list"],
                                     "parameters": [],
                                     "method": self.message_list,
                                     "permissions": ["vmparking_list"],
                                     "description": "List all parked virtual machines" }
                                ]
        elif isinstance(self.entity, TNArchipelVirtualMachine):
            registrar_items = [{    "commands" : ["park"],
                                    "parameters": [],
                                    "method": self.message_park_vm,
                                    "permissions": ["vmparking_park"],
                                    "description": "Park the virtual machine"},
                                ]

        self.entity.add_message_registrar_items(registrar_items)

        # register to the node parking and create database if needed
        if isinstance(self.entity, TNArchipelHypervisor):
            self.manage_database()

        if self.entity.__class__.__name__ == "TNArchipelVirtualMachine":
            self.entity.register_hook("HOOK_VM_DEFINE", method=self.hook_vm_define)
            self.entity.register_hook("HOOK_VM_UNDEFINE", method=self.hook_vm_undefine)
开发者ID:ahmedfathy75,项目名称:Archipel,代码行数:59,代码来源:vmparking.py

示例14: __init__

    def __init__(self, configuration, entity, entry_point_group):
        """
        Initialize the plugin.
        @type configuration: Configuration object
        @param configuration: the configuration
        @type entity: L{TNArchipelEntity}
        @param entity: the entity that owns the plugin
        @type entry_point_group: string
        @param entry_point_group: the group name of plugin entry_point
        """
        TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group)

        if configuration.has_option("XMPPSERVER", "auto_group") and configuration.getboolean("XMPPSERVER", "auto_group"):
            self.autogroup_name_hypervisors = "All Hypervisors"
            self.autogroup_name_vms = "All Virtual Machines"
            self.autogroup_name_users = "All Users"
            if configuration.has_option("XMPPSERVER", "auto_group_name_virtualmachines"):
                self.autogroup_name_vms = configuration.get("XMPPSERVER", "auto_group_name_virtualmachines")
            if configuration.has_option("XMPPSERVER", "auto_group_name_hypervisors"):
                self.autogroup_name_hypervisors = configuration.get("XMPPSERVER", "auto_group_name_hypervisors")
            if configuration.has_option("XMPPSERVER", "auto_group_name_users"):
                self.autogroup_name_users = configuration.get("XMPPSERVER", "auto_group_name_users")

            auto_group_filter = "all"
            if configuration.has_option("XMPPSERVER", "auto_group_filter"):
                auto_group_filter = configuration.get("XMPPSERVER", "auto_group_filter")
                if not auto_group_filter in ("virtualmachines", "hypervisors", "all"):
                    raise Exception("Bad configuration", "auto_group_filter must be virtualmachines, hypervisors or all.")
            self.autogroup_vms_id = self.autogroup_name_vms
            self.autogroup_hypervisors_id = self.autogroup_name_hypervisors
            self.autogroup_users_id = self.autogroup_name_users

            self.entity.register_hook("HOOK_ARCHIPELENTITY_PLUGIN_ALL_LOADED", method=self.create_autogroups_if_needed)
            if auto_group_filter in ("all", "hypervisors"):
                self.entity.register_hook("HOOK_HYPERVISOR_WOKE_UP", method=self.handle_autogroup_for_entity)

            if auto_group_filter in ("all", "virtualmachines"):
                self.entity.register_hook("HOOK_HYPERVISOR_ALLOC", method=self.handle_autogroup_for_entity)
                self.entity.register_hook("HOOK_HYPERVISOR_SOFT_ALLOC", method=self.handle_autogroup_for_entity)
                self.entity.register_hook("HOOK_HYPERVISOR_VM_WOKE_UP", method=self.handle_autogroup_for_entity)

        self.user_page_size = 50

        # permissions
        if self.entity.__class__.__name__ == "TNArchipelHypervisor":
            self.entity.permission_center.create_permission("xmppserver_groups_create", "Authorizes user to create shared groups", False)
            self.entity.permission_center.create_permission("xmppserver_groups_delete", "Authorizes user to delete shared groups", False)
            self.entity.permission_center.create_permission("xmppserver_groups_list", "Authorizes user to list shared groups", False)
            self.entity.permission_center.create_permission("xmppserver_groups_addusers", "Authorizes user to add users in shared groups", False)
            self.entity.permission_center.create_permission("xmppserver_groups_deleteusers", "Authorizes user to remove users from shared groups", False)
            self.entity.permission_center.create_permission("xmppserver_users_register", "Authorizes user to register XMPP users", False)
            self.entity.permission_center.create_permission("xmppserver_users_unregister", "Authorizes user to unregister XMPP users", False)

        if self.entity.__class__.__name__ != "TNArchipelCentralAgent":
            self.entity.permission_center.create_permission("xmppserver_users_list", "Authorizes user to list XMPP users", False)
            self.entity.permission_center.create_permission("xmppserver_users_number", "Authorizes user to get the total number of XMPP users", False)
开发者ID:Contegix,项目名称:Archipel,代码行数:56,代码来源:xmppserver_base.py

示例15: __init__

    def __init__(self, configuration, entity, entry_point_group):
        """
        Initialize the plugin.
        @type configuration: Configuration object
        @param configuration: the configuration
        @type entity: L{TNArchipelEntity}
        @param entity: the entity that owns the plugin
        @type entry_point_group: string
        @param entry_point_group: the group name of plugin entry_point
        """
        TNArchipelPlugin.__init__(self, configuration=configuration, entity=entity, entry_point_group=entry_point_group)
        self.pubsub_vmparking = None;
        self.inhibit_next_general_push = None

        # creates permissions
        self.entity.permission_center.create_permission("vmparking_park", "Authorizes user to park a virtual machines", False)

        if isinstance(self.entity, TNArchipelHypervisor):
            self.entity.permission_center.create_permission("vmparking_list", "Authorizes user to list virtual machines in parking", False)
            self.entity.permission_center.create_permission("vmparking_unpark", "Authorizes user to unpark a virtual machines", False)
            self.entity.permission_center.create_permission("vmparking_delete", "Authorizes user to delete parked virtual machines", False)
            self.entity.permission_center.create_permission("vmparking_updatexml", "Authorizes user to delete parked virtual machines", False)

        # vocabulary
        if isinstance(self.entity, TNArchipelHypervisor):
            registrar_items = [{    "commands" : ["park"],
                                    "parameters": [{"name": "identifiers", "description": "the UUIDs of the VM to park, separated with comas, with no space"}],
                                    "method": self.message_park_hypervisor,
                                    "permissions": ["vmparking_park"],
                                    "description": "Park the virtual machine with the given UUIDs"},

                                {   "commands" : ["unpark"],
                                    "parameters": [{"name": "identifiers", "description": "UUIDs of the virtual machines or parking tickets, separated by comas, with no space"}],
                                    "method": self.message_unpark,
                                    "permissions": ["vmparking_unpark"],
                                    "description": "Unpark the virtual machine parked with the given identifier"},

                                {    "commands" : ["park list"],
                                     "parameters": [],
                                     "method": self.message_list,
                                     "permissions": ["vmparking_list"],
                                     "description": "List all parked virtual machines" }
                                ]
        elif isinstance(self.entity, TNArchipelVirtualMachine):
            registrar_items = [{    "commands" : ["park"],
                                    "parameters": [],
                                    "method": self.message_park_vm,
                                    "permissions": ["vmparking_park"],
                                    "description": "Park the virtual machine"},
                                ]

        self.entity.add_message_registrar_items(registrar_items)

        # register to the node vmrequest
        if isinstance(self.entity, TNArchipelHypervisor):
            self.entity.register_hook("HOOK_ARCHIPELENTITY_XMPP_AUTHENTICATED", method=self.manage_vmparking_node)
开发者ID:alibam,项目名称:Archipel,代码行数:56,代码来源:vmparking.py


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