def change_mac_finish(self, ignore): orig = self.widget("change-mac-orig").get_text() new = self.widget("change-mac-new").get_text() row = self.net_list[orig] try: DeviceInterface.is_conflict_net(self.conn.get_backend(), new) row[NETWORK_INFO_NEW_MAC] = new except Exception as e: self.err.show_err(_("Error changing MAC address: %s") % str(e)) return self.change_mac_close()
def populate_network_list(self): net_box = self.widget("clone-network-box") for c in net_box.get_children(): net_box.remove(c) c.destroy() self.net_list = {} self.mac_list = [] def build_net_row(labelstr, origmac, newmac): label = Gtk.Label(label=labelstr + " (%s)" % origmac) label.set_alignment(0, .5) button = Gtk.Button(_("Details...")) button.connect("clicked", self.net_change_mac, origmac) hbox = Gtk.HBox() hbox.set_spacing(12) hbox.pack_start(label, True, True, 0) hbox.pack_end(button, False, False, False) hbox.show_all() net_box.pack_start(hbox, False, False, False) net_row = [] net_row.insert(NETWORK_INFO_LABEL, labelstr) net_row.insert(NETWORK_INFO_ORIG_MAC, origmac) net_row.insert(NETWORK_INFO_NEW_MAC, newmac) self.net_list[origmac] = net_row self.mac_list.append(origmac) for net in self.vm.xmlobj.devices.interface: mac = net.macaddr net_dev = net.source net_type = net.type # Generate a new MAC newmac = DeviceInterface.generate_mac(self.conn.get_backend()) # [ interface type, device name, origmac, newmac, label ] if net_type == DeviceInterface.TYPE_USER: label = _("Usermode") elif net_type == DeviceInterface.TYPE_VIRTUAL: net = None for netobj in self.vm.conn.list_nets(): if netobj.get_name() == net_dev: net = netobj break if net: label = "" desc = net.pretty_forward_mode() label += "%s" % desc else: label = (_("Virtual Network") + (net_dev and " %s" % net_dev or "")) else: # 'bridge' or anything else label = (net_type.capitalize() + (net_dev and (" %s" % net_dev) or "")) build_net_row(label, mac, newmac) no_net = (not list(self.net_list.keys())) self.widget("clone-network-box").set_visible(not no_net) self.widget("clone-no-net").set_visible(no_net)
def populate_network_list(self): net_box = self.widget("clone-network-box") for c in net_box.get_children(): net_box.remove(c) c.destroy() self.net_list = {} self.mac_list = [] def build_net_row(labelstr, origmac, newmac): label = Gtk.Label(label=labelstr + " (%s)" % origmac) label.set_alignment(0, .5) button = Gtk.Button(_("Details...")) button.connect("clicked", self.net_change_mac, origmac) hbox = Gtk.HBox() hbox.set_spacing(12) hbox.pack_start(label, True, True, 0) hbox.pack_end(button, False, False, False) hbox.show_all() net_box.pack_start(hbox, False, False, False) net_row = [] net_row.insert(NETWORK_INFO_LABEL, labelstr) net_row.insert(NETWORK_INFO_ORIG_MAC, origmac) net_row.insert(NETWORK_INFO_NEW_MAC, newmac) self.net_list[origmac] = net_row self.mac_list.append(origmac) for net in self.vm.xmlobj.devices.interface: mac = net.macaddr net_dev = net.source net_type = net.type # Generate a new MAC newmac = DeviceInterface.generate_mac( self.conn.get_backend()) # [ interface type, device name, origmac, newmac, label ] if net_type == DeviceInterface.TYPE_USER: label = _("Usermode") elif net_type == DeviceInterface.TYPE_VIRTUAL: net = None for netobj in self.vm.conn.list_nets(): if netobj.get_name() == net_dev: net = netobj break if net: label = "" desc = net.pretty_forward_mode() label += "%s" % desc else: label = (_("Virtual Network") + (net_dev and " %s" % net_dev or "")) else: # 'bridge' or anything else label = (net_type.capitalize() + (net_dev and (" %s" % net_dev) or "")) build_net_row(label, mac, newmac) no_net = (not list(self.net_list.keys())) self.widget("clone-network-box").set_visible(not no_net) self.widget("clone-no-net").set_visible(no_net)