[Kimchi-devel] [PATCH V3 2/4] network name support unicode.
shaohef at linux.vnet.ibm.com
shaohef at linux.vnet.ibm.com
Thu Jun 19 00:53:29 UTC 2014
From: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
We should allow user to create a network with his local language name.
Signed-off-by: ShaoHe Feng <shaohef at linux.vnet.ibm.com>
---
src/kimchi/model/networks.py | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/kimchi/model/networks.py b/src/kimchi/model/networks.py
index 63886e0..af9e940 100644
--- a/src/kimchi/model/networks.py
+++ b/src/kimchi/model/networks.py
@@ -100,7 +100,7 @@ def create(self, params):
xml = networkxml.to_network_xml(**params)
try:
- network = conn.networkDefineXML(xml)
+ network = conn.networkDefineXML(xml.encode("utf-8"))
network.setAutostart(True)
except libvirt.libvirtError as e:
raise OperationFailed("KCHNET0008E",
@@ -110,7 +110,8 @@ def create(self, params):
def get_list(self):
conn = self.conn.get()
- return sorted(conn.listNetworks() + conn.listDefinedNetworks())
+ names = conn.listNetworks() + conn.listDefinedNetworks()
+ return sorted(map(lambda x: x.decode('utf-8'), names))
def _get_available_address(self, addr_pools=[]):
invalid_addrs = []
@@ -188,7 +189,7 @@ def get_all_networks_interfaces(self):
interfaces = []
for name in net_names:
conn = self.conn.get()
- network = conn.networkLookupByName(name)
+ network = conn.networkLookupByName(name.encode("utf-8"))
xml = network.XMLDesc(0)
net_dict = NetworkModel.get_network_from_xml(xml)
forward = net_dict['forward']
@@ -324,6 +325,7 @@ def delete(self, name):
@staticmethod
def get_network(conn, name):
+ name = name.encode("utf-8")
try:
return conn.networkLookupByName(name)
except libvirt.libvirtError:
--
1.9.3
More information about the Kimchi-devel
mailing list