Skip to content

Commit

Permalink
net: Add subnet option into config
Browse files Browse the repository at this point in the history
The subnet for IPv6 is now taken from separate parameter
in config file if provided.
  • Loading branch information
almusil committed Jan 29, 2019
1 parent f50b39f commit 1f19f4f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lago/providers/libvirt/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ def name(self):
def gw(self):
return self._spec.get('gw')

def subnet(self):
return self._spec.get('subnet')

def mtu(self):
if self.libvirt_con.getLibVersion() > 3001001:
return self._spec.get('mtu', '1500')
Expand Down Expand Up @@ -180,7 +183,10 @@ def _ipv6_prefix(self, subnet, const='fd8f:1391:3a82:'):
def _libvirt_xml(self):
net_raw_xml = libvirt_utils.get_template('net_nat_template.xml')

subnet = self.gw().split('.')[2]
subnet = self.subnet()
if not subnet:
subnet = self.gw().split('.')[2]

ipv6_prefix = self._ipv6_prefix(subnet=subnet)
mtu = self.mtu()

Expand Down
10 changes: 10 additions & 0 deletions tests/functional-sdk/test_sdk_sanity.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ def init_str(images):
dhcp:
start: 100
end: 254
net-03:
type: nat
subnet: 250
"""
)
template = Environment(loader=BaseLoader()).from_string(init_template)
Expand Down Expand Up @@ -110,6 +114,12 @@ def test_custom_gateway(vms, nets, init_dict):
assert nets[net_name].gw() == net['gw']


def test_custom_subnet(vms, nets, init_dict):
for net_name, net in init_dict['nets'].iteritems():
if 'subnet' in net:
assert nets[net_name].subnet() == net['subnet']


def test_vm_is_running(vms, vm_name):
vm = vms[vm_name]
assert vm.running()
Expand Down

0 comments on commit 1f19f4f

Please sign in to comment.