mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
createnet: Allow disabling dhcp for new virtual networks.
This commit is contained in:
parent
b4654310f5
commit
859467b8d0
@ -62,6 +62,7 @@ class vmmCreateNetwork(gobject.GObject):
|
|||||||
"on_create_finish_clicked" : self.finish,
|
"on_create_finish_clicked" : self.finish,
|
||||||
"on_net_forward_toggled" : self.change_forward_type,
|
"on_net_forward_toggled" : self.change_forward_type,
|
||||||
"on_net_network_changed": self.change_network,
|
"on_net_network_changed": self.change_network,
|
||||||
|
"on_net_dhcp_enable_toggled": self.change_dhcp_enable,
|
||||||
"on_net_dhcp_start_changed": self.change_dhcp_start,
|
"on_net_dhcp_start_changed": self.change_dhcp_start,
|
||||||
"on_net_dhcp_end_changed": self.change_dhcp_end,
|
"on_net_dhcp_end_changed": self.change_dhcp_end,
|
||||||
"on_create_help_clicked": self.show_help,
|
"on_create_help_clicked": self.show_help,
|
||||||
@ -109,6 +110,7 @@ class vmmCreateNetwork(gobject.GObject):
|
|||||||
|
|
||||||
self.window.get_widget("net-name").set_text("")
|
self.window.get_widget("net-name").set_text("")
|
||||||
self.window.get_widget("net-network").set_text("192.168.100.0/24")
|
self.window.get_widget("net-network").set_text("192.168.100.0/24")
|
||||||
|
self.window.get_widget("net-dhcp-enable").set_active(True)
|
||||||
self.window.get_widget("net-dhcp-start").set_text("")
|
self.window.get_widget("net-dhcp-start").set_text("")
|
||||||
self.window.get_widget("net-dhcp-end").set_text("")
|
self.window.get_widget("net-dhcp-end").set_text("")
|
||||||
self.window.get_widget("net-forward-none").set_active(True)
|
self.window.get_widget("net-forward-none").set_active(True)
|
||||||
@ -162,6 +164,11 @@ class vmmCreateNetwork(gobject.GObject):
|
|||||||
else:
|
else:
|
||||||
self.window.get_widget("net-info-type").set_text(_("Other"))
|
self.window.get_widget("net-info-type").set_text(_("Other"))
|
||||||
|
|
||||||
|
def change_dhcp_enable(self, src):
|
||||||
|
val = src.get_active()
|
||||||
|
self.window.get_widget("net-dhcp-start").set_sensitive(val)
|
||||||
|
self.window.get_widget("net-dhcp-end").set_sensitive(val)
|
||||||
|
|
||||||
def change_dhcp_start(self, src):
|
def change_dhcp_start(self, src):
|
||||||
end = self.get_config_dhcp_start()
|
end = self.get_config_dhcp_start()
|
||||||
self.change_dhcp(src, end)
|
self.change_dhcp(src, end)
|
||||||
@ -219,6 +226,9 @@ class vmmCreateNetwork(gobject.GObject):
|
|||||||
name = model[active][2]
|
name = model[active][2]
|
||||||
return [True, name]
|
return [True, name]
|
||||||
|
|
||||||
|
def get_config_dhcp_enable(self):
|
||||||
|
return self.window.get_widget("net-dhcp-enable").get_active()
|
||||||
|
|
||||||
def page_changed(self, notebook, page, page_number):
|
def page_changed(self, notebook, page, page_number):
|
||||||
# would you like some spaghetti with your salad, sir?
|
# would you like some spaghetti with your salad, sir?
|
||||||
|
|
||||||
@ -247,10 +257,21 @@ class vmmCreateNetwork(gobject.GObject):
|
|||||||
self.window.get_widget("summary-ip4-gateway").set_text(str(ip[1]))
|
self.window.get_widget("summary-ip4-gateway").set_text(str(ip[1]))
|
||||||
self.window.get_widget("summary-ip4-netmask").set_text(str(ip.netmask()))
|
self.window.get_widget("summary-ip4-netmask").set_text(str(ip.netmask()))
|
||||||
|
|
||||||
start = self.get_config_dhcp_start()
|
if self.get_config_dhcp_enable():
|
||||||
end = self.get_config_dhcp_end()
|
start = self.get_config_dhcp_start()
|
||||||
self.window.get_widget("summary-dhcp-start").set_text(str(start))
|
end = self.get_config_dhcp_end()
|
||||||
self.window.get_widget("summary-dhcp-end").set_text(str(end))
|
self.window.get_widget("summary-dhcp-start").set_text(str(start))
|
||||||
|
self.window.get_widget("summary-dhcp-end").set_text(str(end))
|
||||||
|
self.window.get_widget("label-dhcp-start").set_text( _("Start address:") )
|
||||||
|
self.window.get_widget("label-dhcp-start").show()
|
||||||
|
self.window.get_widget("label-dhcp-end").show()
|
||||||
|
self.window.get_widget("summary-dhcp-start").show()
|
||||||
|
self.window.get_widget("summary-dhcp-end").show()
|
||||||
|
else:
|
||||||
|
self.window.get_widget("label-dhcp-start").set_text( _("Status:") )
|
||||||
|
self.window.get_widget("summary-dhcp-start").set_text( _("Disabled") )
|
||||||
|
self.window.get_widget("label-dhcp-end").hide()
|
||||||
|
self.window.get_widget("summary-dhcp-end").hide()
|
||||||
|
|
||||||
fw = self.get_config_forwarding()
|
fw = self.get_config_forwarding()
|
||||||
if fw[0]:
|
if fw[0]:
|
||||||
@ -289,9 +310,12 @@ class vmmCreateNetwork(gobject.GObject):
|
|||||||
xml += " <forward/>\n"
|
xml += " <forward/>\n"
|
||||||
|
|
||||||
xml += " <ip address='%s' netmask='%s'>\n" % (str(ip[1]), str(ip.netmask()))
|
xml += " <ip address='%s' netmask='%s'>\n" % (str(ip[1]), str(ip.netmask()))
|
||||||
xml += " <dhcp>\n"
|
|
||||||
xml += " <range start='%s' end='%s'/>\n" % (str(start), str(end))
|
if self.get_config_dhcp_enable():
|
||||||
xml += " </dhcp>\n"
|
xml += " <dhcp>\n"
|
||||||
|
xml += " <range start='%s' end='%s'/>\n" % (str(start), str(end))
|
||||||
|
xml += " </dhcp>\n"
|
||||||
|
|
||||||
xml += " </ip>\n"
|
xml += " </ip>\n"
|
||||||
xml += "</network>\n"
|
xml += "</network>\n"
|
||||||
|
|
||||||
|
@ -344,8 +344,12 @@ class vmmHost(gobject.GObject):
|
|||||||
self.window.get_widget("net-ip4-network").set_text(str(network))
|
self.window.get_widget("net-ip4-network").set_text(str(network))
|
||||||
|
|
||||||
dhcp = net.get_ipv4_dhcp_range()
|
dhcp = net.get_ipv4_dhcp_range()
|
||||||
self.window.get_widget("net-ip4-dhcp-start").set_text(str(dhcp[0]))
|
if dhcp is not None:
|
||||||
self.window.get_widget("net-ip4-dhcp-end").set_text(str(dhcp[1]))
|
self.window.get_widget("net-ip4-dhcp-start").set_text(str(dhcp[0]))
|
||||||
|
self.window.get_widget("net-ip4-dhcp-end").set_text(str(dhcp[1]))
|
||||||
|
else:
|
||||||
|
self.window.get_widget("net-ip4-dhcp-start").set_text("Disabled")
|
||||||
|
self.window.get_widget("net-ip4-dhcp-end").set_text("Disabled")
|
||||||
|
|
||||||
(forward, forwardDev) = net.get_ipv4_forward()
|
(forward, forwardDev) = net.get_ipv4_forward()
|
||||||
if forward:
|
if forward:
|
||||||
|
@ -109,6 +109,9 @@ class vmmNetwork(gobject.GObject):
|
|||||||
xml = self.get_xml()
|
xml = self.get_xml()
|
||||||
dhcpstart = util.get_xml_path(xml, "/network/ip/dhcp/range[1]/@start")
|
dhcpstart = util.get_xml_path(xml, "/network/ip/dhcp/range[1]/@start")
|
||||||
dhcpend = util.get_xml_path(xml, "/network/ip/dhcp/range[1]/@end")
|
dhcpend = util.get_xml_path(xml, "/network/ip/dhcp/range[1]/@end")
|
||||||
|
if not dhcpstart or not dhcpend:
|
||||||
|
return None
|
||||||
|
|
||||||
return [IP(dhcpstart), IP(dhcpend)]
|
return [IP(dhcpstart), IP(dhcpend)]
|
||||||
|
|
||||||
def is_read_only(self):
|
def is_read_only(self):
|
||||||
|
@ -787,11 +787,45 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">2</property>
|
<property name="top_attach">4</property>
|
||||||
<property name="bottom_attach">3</property>
|
<property name="bottom_attach">5</property>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="x_options">GTK_FILL</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<!-- MIG -->
|
||||||
|
<child>
|
||||||
|
<widget class="GtkLabel" id="label72">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label" translatable="yes">Enable DHCP:</property>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
<property name="bottom_attach">1</property>
|
||||||
|
<property name="x_options">GTK_FILL</property>
|
||||||
|
<property name="y_options"></property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<widget class="GtkCheckButton" id="net-dhcp-enable">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">True</property>
|
||||||
|
<property name="active">True</property>
|
||||||
|
<property name="use_underline">True</property>
|
||||||
|
<property name="response_id">0</property>
|
||||||
|
<property name="draw_indicator">True</property>
|
||||||
|
<signal name="toggled" handler="on_net_dhcp_enable_toggled"/>
|
||||||
|
</widget>
|
||||||
|
<packing>
|
||||||
|
<property name="left_attach">1</property>
|
||||||
|
<property name="right_attach">2</property>
|
||||||
|
<property name="top_attach">0</property>
|
||||||
|
<property name="bottom_attach">1</property>
|
||||||
|
<property name="x_options">GTK_FILL</property>
|
||||||
|
<property name="y_options"></property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<!-- /MIG -->
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkEntry" id="net-dhcp-end">
|
<widget class="GtkEntry" id="net-dhcp-end">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@ -804,8 +838,8 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
<property name="top_attach">1</property>
|
<property name="top_attach">2</property>
|
||||||
<property name="bottom_attach">2</property>
|
<property name="bottom_attach">3</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
@ -821,6 +855,8 @@
|
|||||||
<packing>
|
<packing>
|
||||||
<property name="left_attach">1</property>
|
<property name="left_attach">1</property>
|
||||||
<property name="right_attach">2</property>
|
<property name="right_attach">2</property>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="bottom_attach">2</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
@ -831,8 +867,8 @@
|
|||||||
<property name="label" translatable="yes">End:</property>
|
<property name="label" translatable="yes">End:</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="top_attach">1</property>
|
<property name="top_attach">2</property>
|
||||||
<property name="bottom_attach">2</property>
|
<property name="bottom_attach">3</property>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="x_options">GTK_FILL</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
@ -844,6 +880,8 @@
|
|||||||
<property name="label" translatable="yes">Start:</property>
|
<property name="label" translatable="yes">Start:</property>
|
||||||
</widget>
|
</widget>
|
||||||
<packing>
|
<packing>
|
||||||
|
<property name="top_attach">1</property>
|
||||||
|
<property name="bottom_attach">2</property>
|
||||||
<property name="x_options">GTK_FILL</property>
|
<property name="x_options">GTK_FILL</property>
|
||||||
<property name="y_options"></property>
|
<property name="y_options"></property>
|
||||||
</packing>
|
</packing>
|
||||||
@ -1195,7 +1233,7 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="label315">
|
<widget class="GtkLabel" id="label-dhcp-end">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="xalign">1</property>
|
<property name="xalign">1</property>
|
||||||
<property name="label" translatable="yes">End address:</property>
|
<property name="label" translatable="yes">End address:</property>
|
||||||
@ -1211,7 +1249,7 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<widget class="GtkLabel" id="label314">
|
<widget class="GtkLabel" id="label-dhcp-start">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="xalign">1</property>
|
<property name="xalign">1</property>
|
||||||
<property name="label" translatable="yes">Start address:</property>
|
<property name="label" translatable="yes">Start address:</property>
|
||||||
|
Loading…
Reference in New Issue
Block a user