示例#1
0
文件: tftp.py 项目: sempervictus/maas
    def handle_boot_method(self, file_name: TFTPPath, result):
        boot_method, params = result
        if boot_method is None:
            return super().get_reader(file_name)

        # Map pxe namespace architecture names to MAAS's.
        arch = params.get("arch")
        if arch is not None:
            maasarch = ArchitectureRegistry.get_by_pxealias(arch)
            if maasarch is not None:
                params["arch"] = maasarch.name.split("/")[0]

        # Send the local and remote endpoint addresses.
        local_host, local_port = tftp.get_local_address()
        params["local_ip"] = local_host
        remote_host, remote_port = tftp.get_remote_address()
        params["remote_ip"] = remote_host
        d = self.get_boot_method_reader(boot_method, params)
        return d
示例#2
0
文件: windows.py 项目: zhangrb/maas
    def match_path(self, backend, path):
        """Checks path to see if the boot method should handle
        the requested file.

        :param backend: requesting backend
        :param path: requested path
        :return: dict of match params from path, None if no match
        """
        # If the node is requesting the initial bootloader, then we
        # need to see if this node is set to boot Windows first.
        local_host, local_port = tftp.get_local_address()
        if path in ['pxelinux.0', 'lpxelinux.0']:
            data = yield self.get_node_info()
            if data is None:
                returnValue(None)

            # Only provide the Windows bootloader when installing
            # PXELINUX chainloading will work for the rest of the time.
            purpose = data.get('purpose')
            if purpose != 'install':
                returnValue(None)

            osystem = data.get('osystem')
            if osystem == 'windows':
                # python-hivex is needed to continue.
                if get_hivex_module() is None:
                    raise BootMethodError('python-hivex package is missing.')

                returnValue({
                    'mac': data.get('mac'),
                    'path': self.bootloader_path,
                    'local_host': local_host,
                })
        # Fix the paths for the other static files, Windows requests.
        elif path.lower() in STATIC_FILES:
            returnValue({
                'mac': get_remote_mac(),
                'path': self.clean_path(path),
                'local_host': local_host,
            })
        returnValue(None)
示例#3
0
    def match_path(self, backend, path):
        """Checks path to see if the boot method should handle
        the requested file.

        :param backend: requesting backend
        :param path: requested path
        :return: dict of match params from path, None if no match
        """
        # If the node is requesting the initial bootloader, then we
        # need to see if this node is set to boot Windows first.
        local_host, local_port = tftp.get_local_address()
        if path in ["pxelinux.0", "lpxelinux.0"]:
            data = yield self.get_node_info()
            if data is None:
                return None

            # Only provide the Windows bootloader when installing
            # PXELINUX chainloading will work for the rest of the time.
            purpose = data.get("purpose")
            if purpose != "install":
                return None

            osystem = data.get("osystem")
            if osystem == "windows":
                # python-hivex is needed to continue.
                if get_hivex_module() is None:
                    raise BootMethodError("python-hivex package is missing.")

                return {
                    "mac": data.get("mac"),
                    "path": self.bootloader_path,
                    "local_host": local_host,
                }
        # Fix the paths for the other static files, Windows requests.
        elif path.lower() in STATIC_FILES:
            return {
                "mac": get_remote_mac(),
                "path": self.clean_path(path),
                "local_host": local_host,
            }