
This patch modifies the backend error exception return messages to use i18n.py and be tranlatable. Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo@linux.vnet.ibm.com> --- src/kimchi/API.json | 6 ++++-- src/kimchi/i18n.py | 4 ++++ src/kimchi/mockmodel.py | 5 +++-- src/kimchi/model/host.py | 2 +- src/kimchi/model/vms.py | 2 +- 5 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/kimchi/API.json b/src/kimchi/API.json index 84a9da7..f93f540 100644 --- a/src/kimchi/API.json +++ b/src/kimchi/API.json @@ -92,7 +92,8 @@ }, "adapter_name": { "description": "SCSI host name", - "type": "string" + "type": "string", + "error": "KCHPOOL0030E" }, "auth": { "description": "Storage back-end authentication information", @@ -157,7 +158,8 @@ "description": "list of scsi volumes to be assigned to the new VM.", "type": "array", "items": { "type": "string" }, - "uniqueItems": true + "uniqueItems": true, + "error": "KCHVM0018E" } } }, diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py index 03d1052..603adab 100644 --- a/src/kimchi/i18n.py +++ b/src/kimchi/i18n.py @@ -73,6 +73,8 @@ messages = { "KCHVM0014E": _("Supported virtual machine graphics are spice or VNC"), "KCHVM0015E": _("Graphics address to listen on must be IPv4 or IPv6"), "KCHVM0016E": _("Specify a template to create a virtual machine from"), + "KCHVM0017E": _("Volume list (LUNs names) not given."), + "KCHVM0018E": _("Virtual machine volumes must be a list of strings with distinct LUNs names."), "KCHVMIF0001E": _("Interface %(iface)s does not exist in virtual machine %(name)s"), "KCHVMIF0002E": _("Network %(network)s specified for virtual machine %(name)s does not exist"), @@ -129,6 +131,7 @@ messages = { "KCHPOOL0027E": _("%(disk)s is not a valid disk/partition. Could not add it to the pool %(pool)s."), "KCHPOOL0028E": _("Error while extending logical pool %(pool)s. Details: %(err)s"), "KCHPOOL0029E": _("The parameter disks only can be updated for logical storage pool."), + "KCHPOOL0030E": _("The SCSI host adapter name must be a string."), "KCHVOL0001E": _("Storage volume %(name)s already exists"), "KCHVOL0002E": _("Storage volume %(name)s does not exist in storage pool %(pool)s"), @@ -175,6 +178,7 @@ messages = { "KCHHOST0001E": _("Unable to shutdown host machine as there are running virtual machines"), "KCHHOST0002E": _("Unable to reboot host machine as there are running virtual machines"), + "KCHHOST0003E": _("Node device '%(name)s' not found"), "KCHOBJST0001E": _("Unable to find %(item)s in datastore"), diff --git a/src/kimchi/mockmodel.py b/src/kimchi/mockmodel.py index 98715af..481498f 100644 --- a/src/kimchi/mockmodel.py +++ b/src/kimchi/mockmodel.py @@ -160,7 +160,7 @@ class MockModel(object): if pool.info['type'] == 'scsi': vm.disk_paths = [] if not params.get('volumes'): - raise MissingParameter("Volume list (LUNs names) not given.") + raise MissingParameter('KCHVM0017E') for vol in params['volumes']: vm.disk_paths.append({'pool': pool.name, 'volume': vol}) @@ -315,7 +315,8 @@ class MockModel(object): pool.info['path'] = '/dev/disk/by-path' pool.info['source'] = params['source'] if not pool.info['source'].get('adapter_name'): - raise MissingParameter('adapter_name') + raise MissingParameter('KCHPOOL0004E', + {'item': 'adapter_name', 'name': name}) for vol in ['unit:0:0:1','unit:0:0:2', 'unit:0:0:3','unit:0:0:4']: mockvol = MockStorageVolume(name, vol, diff --git a/src/kimchi/model/host.py b/src/kimchi/model/host.py index bc75ec4..514f672 100644 --- a/src/kimchi/model/host.py +++ b/src/kimchi/model/host.py @@ -244,7 +244,7 @@ class DeviceModel(object): try: dev_xml = conn.nodeDeviceLookupByName(nodedev_name).XMLDesc(0) except: - raise NotFoundError('Node device "%s" not found' % nodedev_name) + raise NotFoundError('KCHHOST0003E', {'name': nodedev_name}) cap_type = xmlutils.xpath_get_text( dev_xml, '/device/capability/capability/@type') wwnn = xmlutils.xpath_get_text( diff --git a/src/kimchi/model/vms.py b/src/kimchi/model/vms.py index a215352..d8807ec 100644 --- a/src/kimchi/model/vms.py +++ b/src/kimchi/model/vms.py @@ -197,7 +197,7 @@ class VMsModel(object): vol_list = [] if t._get_storage_type() == 'scsi': if not params.get('volumes'): - raise MissingParameter("Volume list (LUNs names) not given.") + raise MissingParameter('KCHVM0017E') else: # Get system path of the LUNs pool = t.info['storagepool'].split('/')[-1] -- 1.8.5.3