host: interface: Allow changing start mode.
This commit is contained in:
parent
b377a740ca
commit
f777773ed9
|
@ -21,7 +21,6 @@
|
|||
import gobject
|
||||
import libvirt
|
||||
import logging
|
||||
import time
|
||||
import difflib
|
||||
|
||||
import virtinst
|
||||
|
|
|
@ -464,7 +464,6 @@ class vmmHost(gobject.GObject):
|
|||
return
|
||||
|
||||
self.window.get_widget("network-pages").set_current_page(0)
|
||||
self.window.get_widget("net-apply").set_sensitive(False)
|
||||
net = self.conn.get_net(selected[0].get_value(selected[1], 0))
|
||||
|
||||
try:
|
||||
|
@ -473,6 +472,8 @@ class vmmHost(gobject.GObject):
|
|||
logging.exception(e)
|
||||
self.set_net_error_page(_("Error selecting network: %s") % e)
|
||||
|
||||
self.window.get_widget("net-apply").set_sensitive(False)
|
||||
|
||||
def populate_net_state(self, net):
|
||||
active = net.is_active()
|
||||
|
||||
|
@ -697,7 +698,6 @@ class vmmHost(gobject.GObject):
|
|||
return
|
||||
|
||||
self.window.get_widget("storage-pages").set_current_page(0)
|
||||
self.window.get_widget("pool-apply").set_sensitive(False)
|
||||
uuid = selected[0].get_value(selected[1], 0)
|
||||
|
||||
try:
|
||||
|
@ -706,6 +706,8 @@ class vmmHost(gobject.GObject):
|
|||
logging.exception(e)
|
||||
self.set_storage_error_page(_("Error selecting pool: %s") % e)
|
||||
|
||||
self.window.get_widget("pool-apply").set_sensitive(False)
|
||||
|
||||
def populate_pool_state(self, uuid):
|
||||
pool = self.conn.get_pool(uuid)
|
||||
auto = pool.get_autostart()
|
||||
|
@ -938,7 +940,6 @@ class vmmHost(gobject.GObject):
|
|||
|
||||
self.window.get_widget("interface-pages").set_current_page(
|
||||
INTERFACE_PAGE_INFO)
|
||||
self.window.get_widget("interface-apply").set_sensitive(False)
|
||||
name = selected[0].get_value(selected[1], 0)
|
||||
|
||||
try:
|
||||
|
@ -948,6 +949,8 @@ class vmmHost(gobject.GObject):
|
|||
self.set_interface_error_page(_("Error selecting interface: %s") %
|
||||
e)
|
||||
|
||||
self.window.get_widget("interface-apply").set_sensitive(False)
|
||||
|
||||
def populate_interface_state(self, name):
|
||||
interface = self.conn.get_interface(name)
|
||||
children = interface.get_slaves()
|
||||
|
@ -967,9 +970,23 @@ class vmmHost(gobject.GObject):
|
|||
self.window.get_widget("interface-state").set_text(
|
||||
(active and _("Active")) or _("Inactive"))
|
||||
|
||||
self.window.get_widget("interface-startmode").hide()
|
||||
self.window.get_widget("interface-startmode-label").show()
|
||||
self.window.get_widget("interface-startmode-label").set_text(startmode)
|
||||
# Set start mode
|
||||
start_list = self.window.get_widget("interface-startmode")
|
||||
start_model = start_list.get_model()
|
||||
start_label = self.window.get_widget("interface-startmode-label")
|
||||
start_list.hide()
|
||||
start_label.show()
|
||||
start_label.set_text(startmode)
|
||||
|
||||
idx = 0
|
||||
for row in start_model:
|
||||
if row[0] == startmode:
|
||||
start_list.set_active(idx)
|
||||
start_list.show()
|
||||
start_label.hide()
|
||||
break
|
||||
idx += 1
|
||||
|
||||
|
||||
used_by = util.iface_in_use_by(self.conn, name)
|
||||
self.window.get_widget("interface-inuseby").set_text(used_by or "-")
|
||||
|
|
|
@ -23,6 +23,7 @@ import gobject
|
|||
import virtinst
|
||||
from virtinst import Interface
|
||||
|
||||
from virtManager import util
|
||||
from virtManager.libvirtobject import vmmLibvirtObject
|
||||
|
||||
class vmmInterface(vmmLibvirtObject):
|
||||
|
@ -49,7 +50,7 @@ class vmmInterface(vmmLibvirtObject):
|
|||
return self.interface.XMLDesc(flags)
|
||||
|
||||
def _define(self, xml):
|
||||
return self.get_connection().interface_define(xml)
|
||||
return self.get_connection().define_interface(xml)
|
||||
|
||||
def set_active(self, state):
|
||||
self.active = state
|
||||
|
@ -96,8 +97,21 @@ class vmmInterface(vmmLibvirtObject):
|
|||
def get_startmode(self):
|
||||
return virtinst.util.get_xml_path(self.get_xml(),
|
||||
"/interface/start/@mode") or "none"
|
||||
def set_startmode(self):
|
||||
return
|
||||
def set_startmode(self, newmode):
|
||||
def set_start_xml(doc, ctx):
|
||||
node = ctx.xpathEval("/interface/start[1]")
|
||||
node = (node and node[0] or None)
|
||||
iface_node = ctx.xpathEval("/interface")[0]
|
||||
|
||||
if not node:
|
||||
node = iface_node.newChild(None, "start", None)
|
||||
|
||||
node.setProp("mode", newmode)
|
||||
|
||||
return doc.serialize()
|
||||
|
||||
self._redefine(util.xml_parse_wrapper, set_start_xml)
|
||||
|
||||
|
||||
def get_slaves(self):
|
||||
typ = self.get_type()
|
||||
|
|
|
@ -1884,6 +1884,7 @@ here</property>
|
|||
<child>
|
||||
<widget class="GtkButton" id="interface-apply">
|
||||
<property name="label">gtk-apply</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="receives_default">True</property>
|
||||
<property name="use_stock">True</property>
|
||||
|
|
Loading…
Reference in New Issue