To keep compatibility, redefine the title.
Signed-off-by: Ramon Medeiros <ramonn(a)linux.vnet.ibm.com>
---
src/kimchi/model/vms.py | 25 +++++++++++++++++++++++--
1 file changed, 23 insertions(+), 2 deletions(-)
diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py
index 97c011d..79967cc 100644
--- a/src/kimchi/model/vms.py
+++ b/src/kimchi/model/vms.py
@@ -59,6 +59,7 @@ DOM_STATE_MAP = {0: 'nostate',
7: 'pmsuspended'}
VM_STATIC_UPDATE_PARAMS = {'name': './name',
+ 'title': './title',
'cpus': './vcpu',
'memory': './memory'}
VM_LIVE_UPDATE_PARAMS = {}
@@ -183,7 +184,8 @@ class VMsModel(object):
continue
# has title: use it
- names.append(title[0])
+ names.append(unicode(title[0]))
+
names = sorted(names, key=unicode.lower)
return names
@@ -211,7 +213,11 @@ class VMModel(object):
dom = self.get_vm(name, self.conn)
dom = self._static_vm_update(dom, params)
self._live_vm_update(dom, params)
- return dom.name().decode('utf-8')
+
+ if params.get("name") != None:
+ return params["name"]
+
+ return name
def clone(self, name):
"""Clone a virtual machine based on an existing one.
@@ -671,6 +677,21 @@ class VMModel(object):
val = val * 1024
if type(val) == int:
val = str(val)
+
+ # name is passed: update name and title
+ if key == "name":
+ new_name = unicode(filter(str.isalnum,
+ params["name"].encode('ascii',
'xmlcharrefreplace')))
+
+ # update name
+ xpath = VM_STATIC_UPDATE_PARAMS[key]
+ new_xml = xml_item_update(new_xml, xpath, new_name)
+
+ # update title
+ xpath = VM_STATIC_UPDATE_PARAMS["title"]
+ new_xml = xml_item_update(new_xml, xpath, val)
+ continue
+
xpath = VM_STATIC_UPDATE_PARAMS[key]
new_xml = xml_item_update(new_xml, xpath, val)
--
2.1.0