示例#1
0
        def file_handler(TFTPServerHandler, path):
            # Function that handles virtual files serving
            # Example path: /var/lib/pulse2/imaging/bootmenus/0800275532AF
            try:
                if path in self.file_cache and self.file_cache[path][0] - time(
                ) < 10:
                    data = self.file_cache[path][1]
                else:
                    if 'bootmenus/' in path:
                        # Serving a computer bootmenu
                        x = path.split('bootmenus/')[1]
                        # Get computer mac from path
                        mac = ':'.join(
                            [x[2 * i] + x[2 * i + 1] for i in xrange(6)])

                        data = Imaging().getBuiltMenu(mac)
                    self.file_cache[path] = [int(time()), data]
                    self.logger.error(data)
            except:
                # Serve the default bootmenu
                data = ''

            data = data
            self.logger.error(data)
            _file = StringFileHandler(data)
            _filesize = len(data)

            return _file, _filesize
示例#2
0
    def __init__(self, name, config):
        """
        @param config: Package server config
        @type config: P2PServerCP
        """
        MyXmlrpc.__init__(self)
        self.api = Imaging()
        self.api.init1(config)

        self.name = name
        self.logger = logging.getLogger('imaging')
        self.logger.info("Initializing %s" % self.myType)
示例#3
0
 def xmlrpc_getActiveConvergenceForHost(self, uuid):
     return Imaging().getActiveConvergenceForHost(uuid)