mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-22 13:34:07 +03:00
createnet: Add field for specifying forward device
And drop the explicit forward device listing. Similar to what we did with bridge/macvtap domain <interface> Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
c92c454fde
commit
212c5f813d
@ -165,13 +165,14 @@
|
|||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">0</property>
|
<property name="left_attach">0</property>
|
||||||
<property name="top_attach">3</property>
|
<property name="top_attach">4</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkComboBox" id="net-forward-device">
|
<object class="GtkComboBox" id="net-forward-device">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<signal name="changed" handler="on_net_forward_device_changed" swapped="no"/>
|
||||||
<child internal-child="accessible">
|
<child internal-child="accessible">
|
||||||
<object class="AtkObject" id="net-forward-device-atkobject">
|
<object class="AtkObject" id="net-forward-device-atkobject">
|
||||||
<property name="AtkObject::accessible-name">Physical Network</property>
|
<property name="AtkObject::accessible-name">Physical Network</property>
|
||||||
@ -192,7 +193,7 @@
|
|||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
<property name="top_attach">3</property>
|
<property name="top_attach">4</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
@ -228,6 +229,29 @@
|
|||||||
<property name="top_attach">0</property>
|
<property name="top_attach">0</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel">
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="halign">end</property>
|
||||||
|
<property name="label" translatable="yes">De_vice:</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="justify">right</property>
|
||||||
|
<property name="mnemonic_widget">net-forward-manual</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">0</property>
|
||||||
|
<property name="top_attach">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkEntry" id="net-forward-manual">
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="top_attach">3</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
|
@ -53,6 +53,7 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||||||
"on_create_finish_clicked": self.finish,
|
"on_create_finish_clicked": self.finish,
|
||||||
|
|
||||||
"on_net_forward_mode_changed": self._net_forward_mode_changed_cb,
|
"on_net_forward_mode_changed": self._net_forward_mode_changed_cb,
|
||||||
|
"on_net_forward_device_changed": self._net_forward_device_changed_cb,
|
||||||
"on_net_dns_use_toggled": self._net_dns_use_toggled_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.change_ipv4_enable,
|
||||||
@ -101,20 +102,22 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||||||
blue = Gdk.Color.parse("#0072A8")[1]
|
blue = Gdk.Color.parse("#0072A8")[1]
|
||||||
self.widget("header").modify_bg(Gtk.StateType.NORMAL, blue)
|
self.widget("header").modify_bg(Gtk.StateType.NORMAL, blue)
|
||||||
|
|
||||||
# [ label, dev name ]
|
# [ dev name, label ]
|
||||||
pf_list = self.widget("net-hostdevs")
|
pf_list = self.widget("net-hostdevs")
|
||||||
pf_model = Gtk.ListStore(str, str)
|
pf_model = Gtk.ListStore(str, str)
|
||||||
pf_list.set_model(pf_model)
|
pf_list.set_model(pf_model)
|
||||||
text = uiutil.init_combo_text_column(pf_list, 1)
|
text = uiutil.init_combo_text_column(pf_list, 1)
|
||||||
text.set_property("ellipsize", Pango.EllipsizeMode.MIDDLE)
|
text.set_property("ellipsize", Pango.EllipsizeMode.MIDDLE)
|
||||||
|
|
||||||
# [ label, dev name ]
|
# [ show_manual, label]
|
||||||
fw_list = self.widget("net-forward-device")
|
fw_list = self.widget("net-forward-device")
|
||||||
fw_model = Gtk.ListStore(str, str)
|
fw_model = Gtk.ListStore(bool, str)
|
||||||
fw_list.set_model(fw_model)
|
fw_list.set_model(fw_model)
|
||||||
uiutil.init_combo_text_column(fw_list, 1)
|
uiutil.init_combo_text_column(fw_list, 1)
|
||||||
|
fw_model.append([False, _("Any physical device")])
|
||||||
|
fw_model.append([True, _("Physical device...")])
|
||||||
|
|
||||||
# [ label, mode ]
|
# [ mode, label ]
|
||||||
mode_list = self.widget("net-forward-mode")
|
mode_list = self.widget("net-forward-mode")
|
||||||
mode_model = Gtk.ListStore(str, str)
|
mode_model = Gtk.ListStore(str, str)
|
||||||
mode_list.set_model(mode_model)
|
mode_list.set_model(mode_model)
|
||||||
@ -159,22 +162,9 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||||||
|
|
||||||
|
|
||||||
# Populate physical forward devices
|
# Populate physical forward devices
|
||||||
devnames = []
|
|
||||||
for nodedev in self.conn.filter_nodedevs("net"):
|
|
||||||
devnames.append(nodedev.xmlobj.interface)
|
|
||||||
for iface in self.conn.list_interfaces():
|
|
||||||
if iface.get_name() not in devnames:
|
|
||||||
devnames.append(iface.get_name())
|
|
||||||
|
|
||||||
fw_model = self.widget("net-forward-device").get_model()
|
|
||||||
fw_model.clear()
|
|
||||||
fw_model.append([None, _("Any physical device")])
|
|
||||||
|
|
||||||
for name in devnames:
|
|
||||||
fw_model.append([name, _("Physical device %s") % name])
|
|
||||||
self.widget("net-forward-device").set_active(0)
|
self.widget("net-forward-device").set_active(0)
|
||||||
|
|
||||||
self.widget("net-forward-mode").set_active(0)
|
self.widget("net-forward-mode").set_active(0)
|
||||||
|
self.widget("net-forward-manual").set_text("")
|
||||||
|
|
||||||
|
|
||||||
# Populate hostdev forward devices
|
# Populate hostdev forward devices
|
||||||
@ -254,7 +244,13 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||||||
if mode == "hostdev":
|
if mode == "hostdev":
|
||||||
dev = uiutil.get_list_selection(self.widget("net-hostdevs"))
|
dev = uiutil.get_list_selection(self.widget("net-hostdevs"))
|
||||||
else:
|
else:
|
||||||
dev = uiutil.get_list_selection(self.widget("net-forward-device"))
|
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]
|
return [dev, mode]
|
||||||
|
|
||||||
|
|
||||||
@ -270,12 +266,21 @@ class vmmCreateNetwork(vmmGObjectUI):
|
|||||||
|
|
||||||
uiutil.set_grid_row_visible(
|
uiutil.set_grid_row_visible(
|
||||||
self.widget("net-forward-device"), fw_visible)
|
self.widget("net-forward-device"), fw_visible)
|
||||||
|
self._net_forward_device_changed_cb(self.widget("net-forward-device"))
|
||||||
uiutil.set_grid_row_visible(self.widget("net-hostdevs"), is_hostdev)
|
uiutil.set_grid_row_visible(self.widget("net-hostdevs"), is_hostdev)
|
||||||
|
|
||||||
self.widget("net-ipv4-expander").set_visible(not is_hostdev)
|
self.widget("net-ipv4-expander").set_visible(not is_hostdev)
|
||||||
self.widget("net-ipv6-expander").set_visible(not is_hostdev)
|
self.widget("net-ipv6-expander").set_visible(not is_hostdev)
|
||||||
self.widget("net-dns-expander").set_visible(not is_hostdev)
|
self.widget("net-dns-expander").set_visible(not is_hostdev)
|
||||||
|
|
||||||
|
def _net_forward_device_changed_cb(self, src):
|
||||||
|
manual = uiutil.get_list_selection(
|
||||||
|
self.widget("net-forward-device"))
|
||||||
|
if not src.is_visible():
|
||||||
|
manual = False
|
||||||
|
uiutil.set_grid_row_visible(
|
||||||
|
self.widget("net-forward-manual"), manual)
|
||||||
|
|
||||||
def _net_dns_use_toggled_cb(self, src):
|
def _net_dns_use_toggled_cb(self, src):
|
||||||
custom = self.widget("net-dns-use-custom").get_active()
|
custom = self.widget("net-dns-use-custom").get_active()
|
||||||
self.widget("net-domain-name").set_sensitive(custom)
|
self.widget("net-domain-name").set_sensitive(custom)
|
||||||
|
Loading…
Reference in New Issue
Block a user