Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net: Add subnet option into config #785

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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