def populateDhcpGlobalSettings(self): ztp = {} ztpGlobalSettings = util.loadClosDefinition()['ztp'] subnet = ztpGlobalSettings['dhcpSubnet'] dhcpBlock = IPNetwork(subnet) ipList = list(dhcpBlock.iter_hosts()) ztp['network'] = str(dhcpBlock.network) ztp['netmask'] = str(dhcpBlock.netmask) ztp['defaultRoute'] = ztpGlobalSettings.get('dhcpOptionRoute') if ztp['defaultRoute'] is None or ztp['defaultRoute'] == '': ztp['defaultRoute'] = str(ipList[0]) ztp['rangeStart'] = ztpGlobalSettings.get('dhcpOptionRangeStart') if ztp['rangeStart'] is None or ztp['rangeStart'] == '': ztp['rangeStart'] = str(ipList[1]) ztp['rangeEnd'] = ztpGlobalSettings.get('dhcpOptionRangeEnd') if ztp['rangeEnd'] is None or ztp['rangeEnd'] == '': ztp['rangeEnd'] = str(ipList[-1]) ztp['broadcast'] = str(dhcpBlock.broadcast) ztp['httpServerIp'] = self.conf['httpServer']['ipAddr'] ztp['imageUrl'] = ztpGlobalSettings.get('junosImage') return ztp
def populateDhcpGlobalSettings(self): ztp = {} ztpGlobalSettings = util.loadClosDefinition()['ztp'] subnet = ztpGlobalSettings['dhcpSubnet'] dhcpBlock = IPNetwork(subnet) ipList = list(dhcpBlock.iter_hosts()) ztp['network'] = str(dhcpBlock.network) ztp['netmask'] = str(dhcpBlock.netmask) ztp['defaultRoute'] = ztpGlobalSettings.get('dhcpOptionRoute') if ztp['defaultRoute'] is None or ztp['defaultRoute'] == '': ztp['defaultRoute'] = str(ipList[0]) ztp['rangeStart'] = ztpGlobalSettings.get('dhcpOptionRangeStart') if ztp['rangeStart'] is None or ztp['rangeStart'] == '': ztp['rangeStart'] = str(ipList[1]) ztp['rangeEnd'] = ztpGlobalSettings.get('dhcpOptionRangeEnd') if ztp['rangeEnd'] is None or ztp['rangeEnd'] == '': ztp['rangeEnd'] = str(ipList[-1]) ztp['broadcast'] = str(dhcpBlock.broadcast) ztp['httpServerIp'] = self.__conf['httpServer']['ipAddr'] if ztpGlobalSettings.get('junosImage') is not None: # don't start url as /openclos/... first / causes ZTP problem ztp['imageUrl'] = 'openclos/images/' + ztpGlobalSettings.get( 'junosImage') return ztp
def createRoutingOption(self, device): routingOptionStanza = self.templateEnv.get_template('routing_options_stanza.txt') loopbackIfl = self.dao.Session.query(InterfaceLogical).join(Device).filter(InterfaceLogical.name == 'lo0.0').filter(Device.id == device.id).one() loopbackIpWithNoCidr = loopbackIfl.ipaddress.split('/')[0] oobNetworks = device.pod.outOfBandAddressList if oobNetworks is not None: oobNetworkList = oobNetworks.split(',') else: oobNetworkList = [] gateway = util.loadClosDefinition()['ztp']['dhcpOptionRoute'] return routingOptionStanza.render(routerId=loopbackIpWithNoCidr, asn=str(device.asn), oobNetworks=oobNetworkList, gateway=gateway)
def _getParamsForOutOfBandNetwork(self, session, pod): ''' add all trap-target to the OOB list ''' oobList = self._getSnmpTrapTargets(session) oobNetworks = pod.outOfBandAddressList if oobNetworks is not None and len(oobNetworks) > 0: oobList += oobNetworks.split(',') # hack to make sure all address has cidr notation for i in xrange(len(oobList)): if '/' not in oobList[i]: oobList[i] += '/32' gateway = pod.outOfBandGateway if gateway is None: gateway = util.loadClosDefinition()['ztp'].get('dhcpOptionRoute') oobList = set(oobList) if oobList and gateway: return {'networks': oobList, 'gateway': gateway} else: return {}