def handle_post_delete()

in gridengine/src/gridengine/driver.py [0:0]


    def handle_post_delete(self, nodes_to_delete: List[Node]) -> None:
        if self.read_only:
            return

        logging.getLogger("gridengine.driver").info("handle_post_delete")

        fqdns = self.ge_env.qbin.qconf(["-sh"]).lower().split()
        admin_hosts = [n.split(".")[0] for n in fqdns]

        fqdns = self.ge_env.qbin.qconf(["-ss"]).lower().split()
        submit_hosts = [n.split(".")[0] for n in fqdns]

        fqdns = self.ge_env.qbin.qconf(["-sel"]).lower().split()
        exec_hosts = [n.split(".")[0] for n in fqdns]

        hostlists = self.ge_env.qbin.qconf(["-shgrpl"]).lower().split()

        by_hostlist: Dict[str, List[str]] = {}
        for hostlist in hostlists:
            fqdns = (
                self.ge_env.qbin.qconf(["-shgrp_resolved", hostlist]).lower().split()
            )
            by_hostlist[hostlist] = [n.split(".")[0] for n in fqdns]

        hostnames_to_delete: Set[str] = set()

        for node in nodes_to_delete:
            if not node.hostname:
                continue

            hostname = node.hostname.lower()

            try:
                logging.info("Removing host %s via qconf -dh, -de and -ds", hostname)
                # we need to remove these from the hostgroups first, otherwise
                # we can't remove the node
                for hostlist_name, hosts in by_hostlist.items():
                    if hostname in hosts:
                        self.ge_env.qbin.qconf(
                            [
                                "-dattr",
                                "hostgroup",
                                "hostlist",
                                node.hostname,
                                hostlist_name,
                            ],
                            check=False,
                        )

                for qname in self.ge_env.queues:
                    self._delete_host_from_slots(qname, hostname)

                hostnames_to_delete.add(hostname)

            except CalledProcessError as e:
                logging.warning(str(e))

        # now that we have removed all slots entries from all queues, we can
        # delete the hosts. If you don't do this, it will complain that the hosts
        # are still referenced.
        try:
            for host_to_delete in hostnames_to_delete:
                if host_to_delete in admin_hosts:
                    self.ge_env.qbin.qconf(["-dh", host_to_delete], check=False)

                if host_to_delete in submit_hosts:
                    self.ge_env.qbin.qconf(["-ds", host_to_delete], check=False)

                if host_to_delete in exec_hosts:
                    self.ge_env.qbin.qconf(["-de", host_to_delete], check=False)

        except CalledProcessError as e:
            logging.warning(str(e))