def check_cobbler_dhcp_template(self):
        """Validates Cobbler's DHCP template file."""
        print "Checking DHCP template......",
        if os.path.exists("/etc/cobbler/dhcp.template"):
            var_map = {
                "match_next_server": False,
                "match_subnet": False,
                "match_filename": False,
                "match_range": False,
            }

            ip_regex = re.compile(r'^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$')

            dhcp_template = open("/etc/cobbler/dhcp.template")
            for line in dhcp_template.readlines():
                if line.find("next_server") != -1:
                    elmlist = line.split(" ")
                    for elm in elmlist:
                        if ";" in elm:
                            elm = elm[:-2]

                        if "$next_server" in elm or ip_regex.match(elm):
                            var_map["match_next_server"] = True

                elif line.find("subnet") != -1 and line.find("{") != -1:
                    elmlist = line.split(" ")
                    for elm in elmlist:
                        if ip_regex.match(elm):
                            if elm[-1] == "0" and elm not in "255":
                                var_map["match_subnet"] = True
                            elif elm[-1] != "0":
                                self.messages.append(
                                    "[%s]Error: Subnet should be set "
                                    "in the form of 192.168.0.0 in"
                                    "/etc/cobbler/dhcp.template" % self.NAME)

                elif line.find("filename") != -1:
                    var_map["match_filename"] = True
                elif line.find("range dynamic-bootp") != -1:
                    elmlist = line.split(" ")
                    ip_count = 0
                    for elm in elmlist:
                        if ";" in elm and "\n" in elm:
                            elm = elm[:-2]

                        if ip_regex.match(elm):
                            ip_count += 1

                    if ip_count != 2:
                        self.messages.append(
                            "[%s]Error: DHCP range should be set "
                            "between two IP addresses in "
                            "/etc/cobbler/dhcp.template" % self.NAME)
                    else:
                        var_map["match_range"] = True

            dhcp_template.close()
            fails = []
            for var in var_map.keys():
                if var_map[var] is False:
                    fails.append(var)

            if len(fails) != 0:
                self._set_status(
                    0,
                    "[%s]Info: DHCP template file "
                    "failed components: %s" % (
                        self.NAME, ' '.join(failed for failed in fails)))

        else:
            self._set_status(
                0,
                "[%s]Error: DHCP template file doesn't exist, "
                "health check failed." % self.NAME)

        return True
dataset/ETHPy150Open openstack/compass-core/compass/actions/health_check/check_dhcp.py/DhcpCheck.check_cobbler_dhcp_template/swapped operands of `not in`