def _update_hiera_dnsmasq(self, settings): """Update Hiera and dnsmasq PXE related configuration should be written in separate configuration file when you create additional admin network(this behavior was introduced in nailgun's DnsmasqUpdateTask class) """ msg = "Apply changes to Hiera and Dnsmasq" log.info(msg) self.parent.footer.set_text(msg) self.parent.refreshScreen() with open(consts.HIERA_NET_SETTINGS, "r") as hiera_settings: networks = yaml.safe_load(hiera_settings) net = netaddr.IPNetwork( "{0}/{1}".format(settings["ipaddress"], settings["netmask"])) for admin_net in networks["admin_networks"]: if str(net.cidr) == admin_net["cidr"]: admin_net["ip_ranges"] = [ [settings["dhcp_pool_start"], settings["dhcp_pool_end"]] ] admin_net["gateway"] = settings["dhcp_gateway"] with open(consts.HIERA_NET_SETTINGS, "w") as hiera_settings: yaml.safe_dump(networks, hiera_settings) return puppet.puppetApplyManifest(consts.PUPPET_DHCP_RANGES)
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
def apply_to_master(self): """Apply changes to the Fuel master""" msg = "Apply settings to Fuel master." log.info(msg) self.parent.footer.set_text(msg) self.parent.refreshScreen() result, msg = puppet.puppetApplyManifest(consts.PUPPET_FUEL_MASTER) self.parent.footer.set_text(msg) return result
def apply_to_nailgun(self): """Apply changes to the Nailgun""" msg = "Apply settings to Nailgun." log.info(msg) self.parent.footer.set_text(msg) self.parent.refreshScreen() result, msg = puppet.puppetApplyManifest(consts.PUPPET_NAILGUN) if not result: self.parent.footer.set_text(msg) return False self.parent.footer.set_text(msg) return True