Exemplo n.º 1
0
    def _update_nailgun(self, settings):
        msg = "Apply changes to Nailgun"
        log.info(msg)
        self.parent.footer.set_text(msg)
        self.parent.refreshScreen()

        # TODO(mzhnichkov) this manifest apply twice(here and in feature
        # groups). Need to combine this calls
        result, msg = puppet.puppetApplyManifest(consts.PUPPET_NAILGUN)
        if not result:
            ModuleHelper.display_dialog(
                self, error_msg=self.apply_dialog_message["message"],
                title=self.apply_dialog_message["title"])
            return False

        data = {
            "gateway": settings["dhcp_gateway"],
            "ip_ranges": [
                [settings["dhcp_pool_start"], settings["dhcp_pool_end"]]
            ]
        }
        try:
            NetworkGroup(consts.ADMIN_NETWORK_ID).set(data)
        except error.HTTPError as e:
            log.error(e.message)
            ModuleHelper.display_dialog(
                self, error_msg=self.apply_dialog_message["message"],
                title=self.apply_dialog_message["title"])
            return False
        return True
Exemplo n.º 2
0
 def update_dhcp(self):
     settings = self.parent.settings.get("ADMIN_NETWORK")
     if not self._update_nailgun(settings):
         return False
     if os.path.exists(consts.HIERA_NET_SETTINGS):
         result, msg = self._update_hiera_dnsmasq(settings)
     else:
         result = self._update_dnsmasq(settings)
     if not result:
         ModuleHelper.display_dialog(
             self, error_msg=self.apply_dialog_message["message"],
             title=self.apply_dialog_message["title"])
         return False
     cobbler_sync = ["cobbler", "sync"]
     code, out, err = utils.execute(cobbler_sync)
     if code != 0:
         log.error(err)
         ModuleHelper.display_dialog(
             self, error_msg=self.apply_dialog_message["message"],
             title=self.apply_dialog_message["title"])
         return False
     return True