mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-23 17:34:21 +03:00
virt-manager: make mode for direct interfaces selectable
Next try ... The following patch adds support to select the mode for direct interfaces. crobinso: small fixes to make check-pylint happy Signed-off-by: Gerhard Stenzel <gerhard.stenzel@de.ibm.com>
This commit is contained in:
parent
f9f4210ec2
commit
a505618f52
@ -378,6 +378,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
|
||||
"on_network_source_combo_changed": self.config_enable_apply,
|
||||
"on_network_bridge_changed": self.config_enable_apply,
|
||||
"on_network-source-mode-combo_changed": self.config_enable_apply,
|
||||
"on_network_model_combo_changed": self.config_enable_apply,
|
||||
|
||||
"on_vport_type_changed": self.config_enable_apply,
|
||||
@ -791,7 +792,14 @@ class vmmDetails(vmmGObjectUI):
|
||||
# Network source
|
||||
net_source = self.window.get_widget("network-source-combo")
|
||||
net_bridge = self.window.get_widget("network-bridge-box")
|
||||
uihelpers.init_network_list(net_source, net_bridge)
|
||||
source_mode_box = self.window.get_widget("network-source-mode-box")
|
||||
source_mode_label = self.window.get_widget("network-source-mode")
|
||||
vport_expander = self.window.get_widget("vport-expander")
|
||||
uihelpers.init_network_list(net_source, net_bridge, source_mode_box, source_mode_label, vport_expander)
|
||||
|
||||
# source mode
|
||||
source_mode = self.window.get_widget("network-source-mode-combo")
|
||||
uihelpers.build_source_mode_combo(self.vm, source_mode)
|
||||
|
||||
# Network model
|
||||
net_model = self.window.get_widget("network-model-combo")
|
||||
@ -1872,6 +1880,11 @@ class vmmDetails(vmmGObjectUI):
|
||||
net_bridge = self.window.get_widget("network-bridge")
|
||||
nettype, source = uihelpers.get_network_selection(net_list, net_bridge)
|
||||
|
||||
if (nettype == "direct"):
|
||||
source_mode = self.get_combo_label_value("network-source-mode")
|
||||
else:
|
||||
source_mode = ""
|
||||
|
||||
model = self.get_combo_label_value("network-model")
|
||||
|
||||
vport_type = self.window.get_widget("vport-type").get_text()
|
||||
@ -1889,7 +1902,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
vport_typeid,
|
||||
vport_idver,
|
||||
vport_instid),
|
||||
(dev_id_info, nettype, source)])
|
||||
(dev_id_info, nettype, source, source_mode)])
|
||||
|
||||
# Graphics options
|
||||
def _do_change_spicevmc(self, gdev, newgtype):
|
||||
@ -2390,6 +2403,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
|
||||
nettype = net.type
|
||||
source = net.get_source()
|
||||
source_mode = net.source_mode
|
||||
model = net.model
|
||||
|
||||
netobj = None
|
||||
@ -2429,6 +2443,11 @@ class vmmDetails(vmmGObjectUI):
|
||||
(nettype, source), label=desc,
|
||||
comparefunc=compare_network)
|
||||
|
||||
# source mode
|
||||
uihelpers.populate_source_mode_combo(self.vm,
|
||||
self.window.get_widget("network-source-mode-combo"))
|
||||
self.set_combo_label("network-source-mode", source_mode)
|
||||
|
||||
# Virtualport config
|
||||
show_vport = (nettype == "direct")
|
||||
vport = net.virtualport
|
||||
|
@ -427,13 +427,14 @@ class vmmDomainBase(vmmLibvirtObject):
|
||||
editdev.bus = newval
|
||||
return self._redefine_device(change, devobj)
|
||||
|
||||
def define_network_source(self, devobj, newtype, newsource):
|
||||
def define_network_source(self, devobj, newtype, newsource, newmode):
|
||||
def change(editdev):
|
||||
if not newtype:
|
||||
return
|
||||
editdev.source = None
|
||||
editdev.type = newtype
|
||||
editdev.source = newsource
|
||||
editdev.source_mode = newmode
|
||||
return self._redefine_device(change, devobj)
|
||||
def define_network_model(self, devobj, newmodel):
|
||||
def change(editdev):
|
||||
|
@ -192,6 +192,26 @@ def build_watchdogaction_combo(vm, combo, no_default=False):
|
||||
if len(dev_model) > 0:
|
||||
combo.set_active(0)
|
||||
|
||||
def build_source_mode_combo(vm, combo):
|
||||
source_mode = gtk.ListStore(str, str)
|
||||
combo.set_model(source_mode)
|
||||
text = gtk.CellRendererText()
|
||||
combo.pack_start(text, True)
|
||||
combo.add_attribute(text, 'text', 1)
|
||||
|
||||
populate_source_mode_combo(vm, combo)
|
||||
combo.set_active(0)
|
||||
|
||||
def populate_source_mode_combo(vm, combo):
|
||||
model = combo.get_model()
|
||||
model.clear()
|
||||
|
||||
# [xml value, label]
|
||||
model.append([None, _("")])
|
||||
model.append(["vepa", "vepa"])
|
||||
model.append(["bridge", "bridge"])
|
||||
model.append(["private", "private"])
|
||||
|
||||
def build_netmodel_combo(vm, combo):
|
||||
dev_model = gtk.ListStore(str, str)
|
||||
combo.set_model(dev_model)
|
||||
@ -311,20 +331,20 @@ def pretty_network_desc(nettype, source=None, netobj=None):
|
||||
|
||||
return ret
|
||||
|
||||
def init_network_list(net_list, bridge_box):
|
||||
def init_network_list(net_list, bridge_box, source_mode_box=None, source_mode_label=None, vport_expander=None):
|
||||
# [ network type, source name, label, sensitive?, net is active,
|
||||
# manual bridge, net instance]
|
||||
net_model = gtk.ListStore(str, str, str, bool, bool, bool, object)
|
||||
net_list.set_model(net_model)
|
||||
|
||||
net_list.connect("changed", net_list_changed, bridge_box)
|
||||
net_list.connect("changed", net_list_changed, bridge_box, source_mode_box,source_mode_label, vport_expander)
|
||||
|
||||
text = gtk.CellRendererText()
|
||||
net_list.pack_start(text, True)
|
||||
net_list.add_attribute(text, 'text', 2)
|
||||
net_list.add_attribute(text, 'sensitive', 3)
|
||||
|
||||
def net_list_changed(net_list, bridge_box):
|
||||
def net_list_changed(net_list, bridge_box, source_mode_box, source_mode_label, vport_expander):
|
||||
active = net_list.get_active()
|
||||
if active < 0:
|
||||
return
|
||||
@ -333,6 +353,13 @@ def net_list_changed(net_list, bridge_box):
|
||||
return
|
||||
|
||||
row = net_list.get_model()[active]
|
||||
|
||||
if source_mode_box != None:
|
||||
show_source_mode = (row[0] == VirtualNetworkInterface.TYPE_DIRECT)
|
||||
source_mode_box.set_property("visible", show_source_mode)
|
||||
source_mode_label.set_property("visible", show_source_mode)
|
||||
vport_expander.set_property("visible", show_source_mode)
|
||||
|
||||
show_bridge = row[5]
|
||||
|
||||
bridge_box.set_property("visible", show_bridge)
|
||||
|
@ -3687,7 +3687,7 @@ I/O:</property>
|
||||
<widget class="GtkTable" id="table31">
|
||||
<property name="visible">True</property>
|
||||
<property name="border_width">3</property>
|
||||
<property name="n_rows">3</property>
|
||||
<property name="n_rows">4</property>
|
||||
<property name="n_columns">2</property>
|
||||
<property name="column_spacing">8</property>
|
||||
<property name="row_spacing">4</property>
|
||||
@ -3852,6 +3852,52 @@ I/O:</property>
|
||||
<property name="right_attach">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkHBox" id="network-source-mode-box">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">6</property>
|
||||
<child>
|
||||
<widget class="GtkComboBox" id="network-source-mode-combo">
|
||||
<property name="visible">True</property>
|
||||
<signal name="changed" handler="on_network-source-mode-combo_changed"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">0</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="network-source-mode-label">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">0</property>
|
||||
<property name="label">unknown mode</property>
|
||||
<property name="selectable">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="left_attach">1</property>
|
||||
<property name="right_attach">2</property>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkLabel" id="network-source-mode">
|
||||
<property name="visible">True</property>
|
||||
<property name="xalign">1</property>
|
||||
<property name="label" translatable="yes">Source mode:</property>
|
||||
<property name="use_underline">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="top_attach">3</property>
|
||||
<property name="bottom_attach">4</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
|
Loading…
Reference in New Issue
Block a user