createnet: Add full uitest coverage
Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
886339e8dd
commit
0babd6b27f
|
@ -21,6 +21,9 @@ class CreateNet(uiutils.UITestCase):
|
|||
##############
|
||||
|
||||
def testCreateNet(self):
|
||||
"""
|
||||
Basic test with object state management afterwards
|
||||
"""
|
||||
hostwin = self._open_host_window("Virtual Networks")
|
||||
win = self._open_create_win(hostwin)
|
||||
|
||||
|
@ -57,6 +60,9 @@ class CreateNet(uiutils.UITestCase):
|
|||
|
||||
|
||||
def testCreateNetXMLEditor(self):
|
||||
"""
|
||||
Test the XML editor
|
||||
"""
|
||||
self.app.open(xmleditor_enabled=True)
|
||||
hostwin = self._open_host_window("Virtual Networks")
|
||||
win = self._open_create_win(hostwin)
|
||||
|
@ -87,3 +93,76 @@ class CreateNet(uiutils.UITestCase):
|
|||
hostwin.keyCombo("<ctrl>w")
|
||||
uiutils.check_in_loop(lambda: not hostwin.showing and
|
||||
not hostwin.active)
|
||||
|
||||
def testCreateNetMulti(self):
|
||||
"""
|
||||
Test remaining create options
|
||||
"""
|
||||
self.app.uri = "test:///default"
|
||||
hostwin = self._open_host_window(
|
||||
"Virtual Networks", conn_label="test default")
|
||||
win = self._open_create_win(hostwin)
|
||||
finish = win.find("Finish", "push button")
|
||||
|
||||
# Create a network with a bunch of options
|
||||
win.find("Name:", "text").text = "default"
|
||||
win.find("net-mode").click()
|
||||
win.find("Isolated", "menu item").click()
|
||||
win.find("IPv4 configuration").click_expander()
|
||||
win.find("ipv4-network").text = "192.168.100.0/25"
|
||||
assert win.find("ipv4-start").text == "192.168.100.64"
|
||||
assert win.find("ipv4-end").text == "192.168.100.126"
|
||||
win.find("Enable DHCPv4").click()
|
||||
win.find("Enable IPv4").click()
|
||||
win.find("IPv6 configuration").click_expander()
|
||||
win.find("Enable IPv6").click()
|
||||
win.find("Enable DHCPv6").click()
|
||||
win.find("ipv6-network").text = "fd00:beef:10:6::1/64"
|
||||
win.find("ipv6-start").text = "fd00:beef:10:6::1:1"
|
||||
win.find("ipv6-end").text = "bad"
|
||||
win.find("DNS domain name").click_expander()
|
||||
win.find("Custom").click()
|
||||
win.find("domain-custom").text = "mydomain"
|
||||
finish.click()
|
||||
# Name collision validation
|
||||
self._click_alert_button("in use by another network", "Close")
|
||||
win.find("Name:", "text").text = "newnet1"
|
||||
finish.click()
|
||||
# XML define error
|
||||
self._click_alert_button("Error creating virtual network", "Close")
|
||||
win.find("ipv6-end").text = "fd00:beef:10:6::1:f1"
|
||||
finish.click()
|
||||
uiutils.check_in_loop(lambda: hostwin.active)
|
||||
|
||||
# More option work
|
||||
win = self._open_create_win(hostwin)
|
||||
win.find("Name:", "text").text = "newnet2"
|
||||
devicelist = win.find("net-devicelist")
|
||||
uiutils.check_in_loop(lambda: not devicelist.visible)
|
||||
win.find("net-mode").click()
|
||||
win.find("SR-IOV", "menu item").click()
|
||||
uiutils.check_in_loop(lambda: devicelist.visible)
|
||||
# Just confirm this is here
|
||||
win.find("No available device", "menu item")
|
||||
win.find("net-mode").click()
|
||||
win.find("Routed", "menu item").click()
|
||||
win.find("net-forward").click()
|
||||
win.find("Physical device", "menu item").click()
|
||||
win.find("net-device").text = "fakedev0"
|
||||
finish.click()
|
||||
uiutils.check_in_loop(lambda: hostwin.active)
|
||||
|
||||
def testCreateNetSRIOV(self):
|
||||
"""
|
||||
We need the full URI to test the SRIOV method
|
||||
"""
|
||||
self.app.open(xmleditor_enabled=True)
|
||||
hostwin = self._open_host_window("Virtual Networks")
|
||||
win = self._open_create_win(hostwin)
|
||||
finish = win.find("Finish", "push button")
|
||||
|
||||
win.find("net-mode").click()
|
||||
win.find("SR-IOV", "menu item").click()
|
||||
win.find("net-devicelist").click()
|
||||
win.find_fuzzy("eth3", "menu item").click()
|
||||
finish.click()
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Generated with glade 3.22.1 -->
|
||||
<!-- Generated with glade 3.36.0 -->
|
||||
<interface>
|
||||
<requires lib="gtk+" version="3.22"/>
|
||||
<object class="GtkImage" id="image2">
|
||||
|
@ -14,9 +14,6 @@
|
|||
<property name="title" translatable="yes">Create a new virtual network</property>
|
||||
<property name="type_hint">dialog</property>
|
||||
<signal name="delete-event" handler="on_vmm_create_delete_event" swapped="no"/>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkBox" id="box1">
|
||||
<property name="visible">True</property>
|
||||
|
@ -127,6 +124,11 @@
|
|||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<signal name="changed" handler="on_net_forward_mode_changed" swapped="no"/>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="net-forward-mode-atkobject">
|
||||
<property name="AtkObject::accessible-name">net-mode</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
@ -181,7 +183,7 @@
|
|||
<signal name="changed" handler="on_net_forward_device_changed" swapped="no"/>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="net-forward-device-atkobject">
|
||||
<property name="AtkObject::accessible-name">Physical Network</property>
|
||||
<property name="AtkObject::accessible-name">net-forward</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
@ -196,6 +198,11 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">start</property>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="net-hostdevs-atkobject">
|
||||
<property name="AtkObject::accessible-name">net-devicelist</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
@ -252,6 +259,11 @@
|
|||
<child>
|
||||
<object class="GtkEntry" id="net-forward-manual">
|
||||
<property name="can_focus">True</property>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="net-forward-manual-atkobject">
|
||||
<property name="AtkObject::accessible-name">net-device</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
@ -338,6 +350,11 @@
|
|||
<property name="invisible_char">●</property>
|
||||
<property name="width_chars">25</property>
|
||||
<signal name="changed" handler="on_net-ipv4-network_changed" swapped="no"/>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="net-ipv4-network-atkobject">
|
||||
<property name="AtkObject::accessible-name">ipv4-network</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -374,6 +391,11 @@
|
|||
<property name="max_length">15</property>
|
||||
<property name="invisible_char">●</property>
|
||||
<property name="width_chars">25</property>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="net-dhcpv4-start-atkobject">
|
||||
<property name="AtkObject::accessible-name">ipv4-start</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
@ -386,6 +408,11 @@
|
|||
<property name="can_focus">True</property>
|
||||
<property name="max_length">15</property>
|
||||
<property name="invisible_char">●</property>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="net-dhcpv4-end-atkobject">
|
||||
<property name="AtkObject::accessible-name">ipv4-end</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
@ -541,6 +568,11 @@
|
|||
<property name="invisible_char">●</property>
|
||||
<property name="width_chars">25</property>
|
||||
<signal name="changed" handler="on_net-ipv6-network_changed" swapped="no"/>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="net-ipv6-network-atkobject">
|
||||
<property name="AtkObject::accessible-name">ipv6-network</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
@ -575,6 +607,11 @@
|
|||
<property name="max_length">40</property>
|
||||
<property name="invisible_char">●</property>
|
||||
<property name="width_chars">25</property>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="net-dhcpv6-start-atkobject">
|
||||
<property name="AtkObject::accessible-name">ipv6-start</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
@ -587,6 +624,11 @@
|
|||
<property name="can_focus">True</property>
|
||||
<property name="max_length">40</property>
|
||||
<property name="invisible_char">●</property>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="net-dhcpv6-end-atkobject">
|
||||
<property name="AtkObject::accessible-name">ipv6-end</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
@ -691,6 +733,11 @@
|
|||
<property name="max_length">20</property>
|
||||
<property name="invisible_char">●</property>
|
||||
<property name="width_chars">20</property>
|
||||
<child internal-child="accessible">
|
||||
<object class="AtkObject" id="net-domain-name-atkobject">
|
||||
<property name="AtkObject::accessible-name">domain-custom</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
|
@ -811,5 +858,8 @@
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child type="titlebar">
|
||||
<placeholder/>
|
||||
</child>
|
||||
</object>
|
||||
</interface>
|
||||
|
|
|
@ -22,11 +22,9 @@ from .xmleditor import vmmXMLEditor
|
|||
|
||||
|
||||
def _make_ipaddr(addrstr):
|
||||
if addrstr is None:
|
||||
return None
|
||||
try:
|
||||
return ipaddress.ip_network(str(addrstr), strict=False)
|
||||
except Exception:
|
||||
except Exception: # pragma: no cover
|
||||
return None
|
||||
|
||||
|
||||
|
@ -50,13 +48,13 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||
"on_net_forward_device_changed": self._net_forward_device_changed_cb,
|
||||
"on_net_dns_use_toggled": self._net_dns_use_toggled_cb,
|
||||
|
||||
"on_net-ipv4-enable_toggled": self.change_ipv4_enable,
|
||||
"on_net-ipv4-enable_toggled": self._ipv4_toggled_cb,
|
||||
"on_net-ipv4-network_changed": self._change_ipv4_network_cb,
|
||||
"on_net-dhcpv4-enable_toggled": self.change_dhcpv4_enable,
|
||||
"on_net-dhcpv4-enable_toggled": self._dhcpv4_toggled_cb,
|
||||
|
||||
"on_net-ipv6-enable_toggled": self.change_ipv6_enable,
|
||||
"on_net-ipv6-enable_toggled": self._ipv6_toggled_cb,
|
||||
"on_net-ipv6-network_changed": self._change_ipv6_network_cb,
|
||||
"on_net-dhcpv6-enable_toggled": self.change_dhcpv6_enable,
|
||||
"on_net-dhcpv6-enable_toggled": self._dhcpv6_toggled_cb,
|
||||
})
|
||||
self.bind_escape_key_close()
|
||||
|
||||
|
@ -147,7 +145,6 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||
self.widget("net-dhcpv6-start").set_text("")
|
||||
self.widget("net-dhcpv6-end").set_text("")
|
||||
|
||||
|
||||
# Populate physical forward devices
|
||||
self.widget("net-forward-device").set_active(0)
|
||||
self.widget("net-forward-mode").set_active(0)
|
||||
|
@ -223,22 +220,15 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||
def get_config_dhcpv6_end(self):
|
||||
return self._get_network_helper("net-dhcpv6-end")
|
||||
|
||||
def get_config_forwarding(self):
|
||||
mode = uiutil.get_list_selection(self.widget("net-forward-mode"))
|
||||
if mode == "isolated":
|
||||
return [None, None]
|
||||
def _get_config_net_forward_dev(self):
|
||||
if not self.widget("net-forward-device").is_visible():
|
||||
return None
|
||||
|
||||
if mode == "hostdev":
|
||||
dev = uiutil.get_list_selection(self.widget("net-hostdevs"))
|
||||
else:
|
||||
manual = uiutil.get_list_selection(
|
||||
self.widget("net-forward-device"))
|
||||
if manual:
|
||||
dev = self.widget("net-forward-manual").get_text()
|
||||
else:
|
||||
dev = None
|
||||
|
||||
return [dev, mode]
|
||||
manual = bool(uiutil.get_list_selection(
|
||||
self.widget("net-forward-device")))
|
||||
if not manual:
|
||||
return None
|
||||
return self.widget("net-forward-manual").get_text()
|
||||
|
||||
|
||||
#############
|
||||
|
@ -272,20 +262,29 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||
custom = self.widget("net-dns-use-custom").get_active()
|
||||
self.widget("net-domain-name").set_sensitive(custom)
|
||||
|
||||
def change_ipv4_enable(self, ignore):
|
||||
enabled = self.get_config_ipv4_enable()
|
||||
def _ipv4_toggled_cb(self, src):
|
||||
self.change_ipv4_enable()
|
||||
def _dhcpv4_toggled_cb(self, src):
|
||||
self.change_dhcpv4_enable()
|
||||
def _ipv6_toggled_cb(self, src):
|
||||
self.change_ipv6_enable()
|
||||
def _dhcpv6_toggled_cb(self, src):
|
||||
self.change_dhcpv6_enable()
|
||||
|
||||
def change_ipv4_enable(self):
|
||||
enabled = self.widget("net-ipv4-enable").get_active()
|
||||
self.widget("net-ipv4-box").set_visible(enabled)
|
||||
def change_ipv6_enable(self, ignore):
|
||||
enabled = self.get_config_ipv6_enable()
|
||||
def change_ipv6_enable(self):
|
||||
enabled = self.widget("net-ipv6-enable").get_active()
|
||||
self.widget("net-ipv6-box").set_visible(enabled)
|
||||
|
||||
def change_dhcpv4_enable(self, ignore):
|
||||
def change_dhcpv4_enable(self):
|
||||
enabled = self.get_config_dhcpv4_enable()
|
||||
start = self.widget("net-dhcpv4-start")
|
||||
end = self.widget("net-dhcpv4-end")
|
||||
uiutil.set_grid_row_visible(start, enabled)
|
||||
uiutil.set_grid_row_visible(end, enabled)
|
||||
def change_dhcpv6_enable(self, ignore):
|
||||
def change_dhcpv6_enable(self):
|
||||
enabled = self.get_config_dhcpv6_enable()
|
||||
start = self.widget("net-dhcpv6-start")
|
||||
end = self.widget("net-dhcpv6-end")
|
||||
|
@ -348,19 +347,20 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||
net.name = self.widget("net-name").get_text()
|
||||
net.domain_name = self.get_config_domain_name()
|
||||
|
||||
dev, mode = self.get_config_forwarding()
|
||||
if mode:
|
||||
net.forward.mode = mode
|
||||
if mode == "open":
|
||||
net.forward.dev = None
|
||||
else:
|
||||
net.forward.dev = dev or None
|
||||
mode = uiutil.get_list_selection(self.widget("net-forward-mode"))
|
||||
dev = self._get_config_net_forward_dev()
|
||||
|
||||
if mode == "isolated":
|
||||
mode = None
|
||||
|
||||
net.forward.mode = mode
|
||||
net.forward.dev = dev
|
||||
|
||||
if net.forward.mode == "hostdev":
|
||||
net.forward.managed = "yes"
|
||||
pfobj = net.forward.pf.add_new()
|
||||
pfobj.dev = net.forward.dev
|
||||
net.forward.dev = None
|
||||
pfobj.dev = uiutil.get_list_selection(
|
||||
self.widget("net-hostdevs"))
|
||||
return net
|
||||
|
||||
if self.get_config_ipv4_enable():
|
||||
|
@ -427,7 +427,7 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||
try:
|
||||
netobj.create()
|
||||
netobj.setAutostart(True)
|
||||
except Exception:
|
||||
except Exception: # pragma: no cover
|
||||
netobj.undefine()
|
||||
raise
|
||||
|
||||
|
|
Loading…
Reference in New Issue