def create_networks(self, name, l2_device_config, address_pools): # TODO(ddmitriev): use 'address_pool' attribute to get the address_pool # for 'l2_device' as an object # Get address_pool from 'address_pools' object if 'address_pool' in l2_device_config: address_pool = address_pools[l2_device_config['address_pool']] networks, prefix = address_pool['net'].split(':') ip_networks = [IPNetwork(x) for x in networks.split(',')] new_prefix = int(prefix) pool = Network.create_network_pool(networks=ip_networks, prefix=new_prefix) else: pool = None if 'forward' in l2_device_config: forward = l2_device_config['forward']['mode'] else: forward = None has_dhcp_server = (l2_device_config.get('dhcp', 'false') == 'true') net = Network.network_create( name=name, environment=self, pool=pool, forward=forward, has_dhcp_server=has_dhcp_server) net.define() return net
def create_networks(self, name): ip_networks = [ IPNetwork(x) for x in settings.POOLS.get(name)[0].split(',') ] new_prefix = int(settings.POOLS.get(name)[1]) pool = Network.create_network_pool(networks=ip_networks, prefix=int(new_prefix)) return Network.network_create(name=name, environment=self, pool=pool, forward=settings.FORWARDING.get(name), has_dhcp_server=settings.DHCP.get(name))
def create_networks(self, name): ip_networks = [ IPNetwork(x) for x in settings.POOLS.get(name)[0].split(',')] new_prefix = int(settings.POOLS.get(name)[1]) pool = Network.create_network_pool(networks=ip_networks, prefix=int(new_prefix)) return Network.network_create( name=name, environment=self, pool=pool, forward=settings.FORWARDING.get(name), has_dhcp_server=settings.DHCP.get(name))