def match_path(self, backend, path): """Checks path for the configuration file that needs to be generated. :param backend: requesting backend :param path: requested path :return: dict of match params from path, None if no match """ if path == self.bootloader_path.encode(): return { "arch": "s390x", "mac": get_remote_mac(), } else: return None
def match_path(self, backend, path): """Checks path for the configuration file that needs to be generated. :param backend: requesting backend :param path: requested path :return: dict of match params from path, None if no match """ params = self.get_params(backend, path) if params is None: return None params['arch'] = "ppc64el" if 'mac' not in params: mac = get_remote_mac() if mac is not None: params['mac'] = mac return params
def get_reader(self, file_name: TFTPPath): """See `IBackend.get_reader()`. If `file_name` matches a boot method then the response is obtained from that boot method. Otherwise the filesystem is used to service the response. """ # It is possible for a client to request the file with '\' instead # of '/', example being 'bootx64.efi'. Convert all '\' to '/' to be # unix compatiable. file_name = file_name.replace(b'\\', b'/') mac_address = get_remote_mac() if mac_address is not None: log_request(mac_address, file_name) d = self.get_boot_method(file_name) d.addCallback(partial(self.handle_boot_method, file_name)) d.addErrback(self.no_response_errback, file_name) d.addErrback(self.all_is_lost_errback) return d
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)
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, }
def get_node_info(self): """Gets node information via the remote mac.""" remote_mac = get_remote_mac() return request_node_info_by_mac_address(remote_mac)