예제 #1
0
    def sync_dhcp(self):
        restart_dhcp = str(self.settings.restart_dhcp).lower()
        which_dhcp_module = module_loader.get_module_name("dhcp", "module").strip()

        if self.settings.manage_dhcp:
            self.write_dhcp()
            if which_dhcp_module == "manage_isc":
                service_name = utils.dhcp_service_name(self.api)
                if restart_dhcp != "0":
                    rc = utils.subprocess_call(self.logger, "dhcpd -t -q", shell=True)
                    if rc != 0:
                        self.logger.error("dhcpd -t failed")
                        return False
                    service_restart = "service %s restart" % service_name
                    rc = utils.subprocess_call(self.logger, service_restart, shell=True)
                    if rc != 0:
                        self.logger.error("%s failed" % service_name)
                        return False
            elif which_dhcp_module == "manage_dnsmasq":
                if restart_dhcp != "0":
                    rc = utils.subprocess_call(self.logger, "service dnsmasq restart")
                    if rc != 0:
                        self.logger.error("service dnsmasq restart failed")
                        return False
        return True
예제 #2
0
    def sync_dhcp(self):
        restart_dhcp = str(self.settings.restart_dhcp).lower()
        which_dhcp_module = module_loader.get_module_from_file(
            "dhcp", "module", just_name=True).strip()

        if self.settings.manage_dhcp:
            self.write_dhcp()
            if which_dhcp_module == "manage_isc":
                service_name = utils.dhcp_service_name(self.api)
                if restart_dhcp != "0":
                    rc = utils.subprocess_call(self.logger,
                                               "dhcpd -t -q",
                                               shell=True)
                    if rc != 0:
                        self.logger.error("dhcpd -t failed")
                        return False
                    service_restart = "service %s restart" % service_name
                    rc = utils.subprocess_call(self.logger,
                                               service_restart,
                                               shell=True)
                    if rc != 0:
                        self.logger.error("%s failed" % service_name)
                        return False
            elif which_dhcp_module == "manage_dnsmasq":
                if restart_dhcp != "0":
                    rc = utils.subprocess_call(self.logger,
                                               "service dnsmasq restart")
                    if rc != 0:
                        self.logger.error("service dnsmasq restart failed")
                        return False
        return True
예제 #3
0
    def sync_dhcp(self):
        restart_dhcp = str(self.settings.restart_dhcp).lower()
        which_dhcp_module = module_loader.get_module_name("dhcp", "module").strip()

        if self.settings.manage_dhcp:
            self.write_dhcp()
            if which_dhcp_module == "manage_isc":
                service_name = utils.dhcp_service_name(self.api)
                if restart_dhcp != "0":
                    rc = utils.subprocess_call(self.logger, "dhcpd -t -q", shell=True)
                    if rc != 0:
                        error_msg = "dhcpd -t failed"
                        self.logger.error(error_msg)
                        raise CX(error_msg)
                    service_restart = "service %s restart" % service_name
                    rc = utils.subprocess_call(self.logger, service_restart, shell=True)
                    if rc != 0:
                        error_msg = "%s failed" % service_name
                        self.logger.error(error_msg)
                        raise CX(error_msg)
            elif which_dhcp_module == "manage_dnsmasq":
                if restart_dhcp != "0":
                    rc = utils.subprocess_call(self.logger, "service dnsmasq restart")
                    if rc != 0:
                        error_msg = "service dnsmasq restart failed"
                        self.logger.error(error_msg)
                        raise CX(error_msg)
예제 #4
0
 def sync_dhcp(self):
     restart_dhcp = str(self.settings.restart_dhcp).lower()
     service_name = utils.dhcp_service_name(self.api)
     if restart_dhcp != "0":
         rc = utils.subprocess_call(self.logger, "dhcpd -t -q", shell=True)
         if rc != 0:
             error_msg = "dhcpd -t failed"
             self.logger.error(error_msg)
             raise CX(error_msg)
         service_restart = "service %s restart" % service_name
         rc = utils.subprocess_call(self.logger, service_restart, shell=True)
         if rc != 0:
             error_msg = "%s failed" % service_name
             self.logger.error(error_msg)
             raise CX(error_msg)
예제 #5
0
 def sync_dhcp(self):
     restart_dhcp = str(self.settings.restart_dhcp).lower()
     service_name = utils.dhcp_service_name(self.api)
     if restart_dhcp != "0":
         rc = utils.subprocess_call(self.logger, "dhcpd -t -q", shell=True)
         if rc != 0:
             error_msg = "dhcpd -t failed"
             self.logger.error(error_msg)
             raise CX(error_msg)
         service_restart = "service %s restart" % service_name
         rc = utils.subprocess_call(self.logger,
                                    service_restart,
                                    shell=True)
         if rc != 0:
             error_msg = "%s failed" % service_name
             self.logger.error(error_msg)
             raise CX(error_msg)