def dhcp_definition(self): hosts_def = {} ip_start = env[self.lab_id]["ip_start"] servers_count = sum([self.config['servers'][i]['params']['count'] for i in self.config['servers']]) ips = [self.net_ip_base + "." + str(ip_start + i) for i in xrange(servers_count)] ip_iter = iter(ips) for server in sorted(self.config['servers'], key=lambda k: ip_order.index(k) if k in ip_order else -1): params = self.config['servers'][server]['params'] hosts_def[server] = [] for num in xrange(params['count']): if params['count'] == 1: hostname = server if not params['hostname'] else params['hostname'] else: hostname = server + "%.2d" % num if not params['hostname'] else params['hostname'] ip = ip_iter.next() ip_base = ip.split(".")[-1] hosts_def[server] += [ {"hostname": hostname, "mac": rand_mac(), "ip": ip, "ip_base": ip_base, "domain": DOMAIN_NAME} ] dhcp_hosts = "\n".join([ netconf["template"]["dhcp_host"].format(**kwargs) for host in hosts_def.values() for kwargs in host]) self.hosts.append(hosts_def) return netconf["template"]["dhcp_def"].format( dhcp_records=dhcp_hosts, net_ip=self.net_ip_base )
def define_hosts(self): ip_start = env[self.lab_id]["ip_start"] servers_count = sum([ self.config['servers'][i]['params']['count'] for i in self.config['servers'] ]) ips = [ self.net_ip_base + "::" + str(ip_start + i) for i in xrange(servers_count) ] ip_iter = iter(ips) hosts_def = {} for server in sorted(self.config['servers'], key=lambda k: ip_order.index(k) if k in ip_order else -1): params = self.config['servers'][server]['params'] hosts_def[server] = [] for num in xrange(params['count']): if params['count'] == 1: hostname = server if not params['hostname'] else params[ 'hostname'] else: hostname = server + "%.2d" % num if not params[ 'hostname'] else params['hostname'] ip = ip_iter.next() ip_base = ip.split(":")[-1] hosts_def[server] += [{ "hostname": hostname, "mac": rand_mac(), "ip": ip, "ip_base": ip_base, "domain": DOMAIN_NAME }] self.hosts.append(hosts_def)
def dhcp_definition(self): hosts_def = {} ip_start = env[self.lab_id]["ip_start"] servers_count = sum([ self.config['servers'][i]['params']['count'] for i in self.config['servers'] ]) ips = [ self.net_ip_base + "." + str(ip_start + i) for i in xrange(servers_count) ] ip_iter = iter(ips) for server in sorted(self.config['servers'], key=lambda k: ip_order.index(k) if k in ip_order else -1): params = self.config['servers'][server]['params'] hosts_def[server] = [] for num in xrange(params['count']): if params['count'] == 1: hostname = server if not params['hostname'] else params[ 'hostname'] else: hostname = server + "%.2d" % num if not params[ 'hostname'] else params['hostname'] ip = ip_iter.next() ip_base = ip.split(".")[-1] hosts_def[server] += [{ "hostname": hostname, "mac": rand_mac(), "ip": ip, "ip_base": ip_base, "domain": DOMAIN_NAME }] dhcp_hosts = "\n".join([ netconf["template"]["dhcp_host"].format(**kwargs) for host in hosts_def.values() for kwargs in host ]) self.hosts.append(hosts_def) return netconf["template"]["dhcp_def"].format(dhcp_records=dhcp_hosts, net_ip=self.net_ip_base)
def define_hosts(self): ip_start = env[self.lab_id]["ip_start"] servers_count = sum([self.config['servers'][i]['params']['count'] for i in self.config['servers']]) ips = [self.net_ip_base + "::" + str(ip_start + i) for i in xrange(servers_count)] ip_iter = iter(ips) hosts_def = {} for server in sorted(self.config['servers'], key=lambda k: ip_order.index(k) if k in ip_order else -1): params = self.config['servers'][server]['params'] hosts_def[server] = [] for num in xrange(params['count']): if params['count'] == 1: hostname = server if not params['hostname'] else params['hostname'] else: hostname = server + "%.2d" % num if not params['hostname'] else params['hostname'] ip = ip_iter.next() ip_base = ip.split(":")[-1] hosts_def[server] += [ {"hostname": hostname, "mac": rand_mac(), "ip": ip, "ip_base": ip_base, "domain": DOMAIN_NAME} ] self.hosts.append(hosts_def)