Ejemplo n.º 1
0
    def computersMenuSet(self, menus):
        """
        Set computers imaging boot menu.

        @param menus: list of (uuid, menu) couples
        @type menus: list

        @ret: list of the computer uuid which menu have been successfully set
        @rtype: list
        """
        ret = []
        for cuuid in menus:
            menu = menus[cuuid]
            if not isUUID(cuuid):
                self.logger.error('Invalid computer UUID %s' % cuuid)
                continue
            if not isMenuStructure(menu):
                self.logger.error(
                    "Invalid menu structure for computer UUID %s" % cuuid)
                continue

            res = self.myUUIDCache.getByUUID(cuuid)
            if res == False:
                self.logger.warn("Updating MAC address for UUID %s" % cuuid)
                self.myUUIDCache.set(
                    menu['target']['uuid'], menu['target']['macaddress'],
                    menu['target']['name'],
                    '')  # FIXME : domainname '' is probably a wrong idea
                res = self.myUUIDCache.getByUUID(cuuid)
            try:
                macaddress = res['mac']
                hostname = res['shortname']
                self.logger.debug(
                    'Setting menu for computer UUID/MAC/hostname %s/%s/%s' %
                    (cuuid, macaddress, hostname))
                imb = ImagingComputerMenuBuilder(self.config, macaddress, menu)
                imenu = imb.make()
                imenu.write()
                ret.append(cuuid)
                imc = ImagingComputerConfiguration(self.config, cuuid,
                                                   hostname, menu)
                imc.write()
            except Exception, e:
                self.logger.exception(
                    "Error while setting new menu of computer uuid/mac %s: %s"
                    % (cuuid, e))
Ejemplo n.º 2
0
        def _success(menu):
            global menu_data
            if not isMenuStructure(menu):
                self.logger.error("Invalid menu structure for computer MAC %s" % mac)
                # TODO: generate default menu
                menu_data = ''

            try:
                #self.logger.debug('Setting menu for computer UUID/MAC/hostname %s/%s/%s' % (cuuid, macaddress, hostname))
                imb = ImagingComputerMenuBuilder(self.config, mac, menu)
                imenu = imb.make()
                menu_data = imenu.buildMenu()

            except Exception, e:
                self.logger.exception("Error while setting new menu of computer uuid/mac %s", str(e))
                # if cant generate specific menu, use default menu
                # or minimal menu genre "Continue usual startup"
                menu_data = ''
Ejemplo n.º 3
0
        def _success(menu):
            global menu_data
            if not isMenuStructure(menu):
                self.logger.error(
                    "Invalid menu structure for computer MAC %s" % mac)
                # TODO: generate default menu
                menu_data = ''

            try:
                #self.logger.debug('Setting menu for computer UUID/MAC/hostname %s/%s/%s' % (cuuid, macaddress, hostname))
                imb = ImagingComputerMenuBuilder(self.config, mac, menu)
                imenu = imb.make()
                menu_data = imenu.buildMenu()

            except Exception, e:
                self.logger.exception(
                    "Error while setting new menu of computer uuid/mac %s",
                    str(e))
                # if cant generate specific menu, use default menu
                # or minimal menu genre "Continue usual startup"
                menu_data = ''
Ejemplo n.º 4
0
    def computersMenuSet(self, menus):
        """
        Set computers imaging boot menu.

        @param menus: list of (uuid, menu) couples
        @type menus: list

        @ret: list of the computer uuid which menu have been successfully set
        @rtype: list
        """
        ret = []
        for cuuid in menus:
            menu = menus[cuuid]
            if not isUUID(cuuid):
                self.logger.error('Invalid computer UUID %s' % cuuid)
                continue
            if not isMenuStructure(menu):
                self.logger.error("Invalid menu structure for computer UUID %s" % cuuid)
                continue

            res = self.myUUIDCache.getByUUID(cuuid)
            if res == False:
                self.logger.warn("Updating MAC address for UUID %s" % cuuid)
                self.myUUIDCache.set(menu['target']['uuid'], menu['target']['macaddress'], menu['target']['name'], '')  # FIXME : domainname '' is probably a wrong idea
                res = self.myUUIDCache.getByUUID(cuuid)
            try:
                macaddress = res['mac']
                hostname = res['shortname']
                self.logger.debug('Setting menu for computer UUID/MAC/hostname %s/%s/%s' % (cuuid, macaddress, hostname))
                imb = ImagingComputerMenuBuilder(self.config, macaddress, menu)
                imenu = imb.make()
                imenu.write()
                ret.append(cuuid)
                imc = ImagingComputerConfiguration(self.config,
                                                   cuuid,
                                                   hostname,
                                                   menu)
                imc.write()
            except Exception, e:
                self.logger.exception("Error while setting new menu of computer uuid/mac %s: %s" % (cuuid, e))