
From: Aline Manera <alinefm@br.ibm.com> Make a integrity verification when user try to deactivate or delete a pool. If pool is used by a template it should not be deactivated or deleted to avoid problems while using the template. Also update the po files as new messages are added to alert the user. Signed-off-by: Aline Manera <alinefm@br.ibm.com> --- po/en_US.po | 66 +++++++++++++++++++++++++++----------- po/kimchi.pot | 57 ++++++++++++++++++++++++-------- po/pt_BR.po | 66 +++++++++++++++++++++++++++----------- po/zh_CN.po | 65 ++++++++++++++++++++++++++----------- src/kimchi/i18n.py | 2 ++ src/kimchi/model/storagepools.py | 21 ++++++++++-- tests/test_model.py | 5 +++ 7 files changed, 210 insertions(+), 72 deletions(-) diff --git a/po/en_US.po b/po/en_US.po index ca1fe86..aeff16e 100644 --- a/po/en_US.po +++ b/po/en_US.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: kimchi 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-02-20 15:26-0300\n" +"POT-Creation-Date: 2014-02-25 15:23-0300\n" "PO-Revision-Date: 2013-07-11 17:32-0400\n" "Last-Translator: Crístian Viana <vianac@linux.vnet.ibm.com>\n" "Language-Team: English\n" @@ -85,18 +85,21 @@ msgstr "Cancel" msgid "Save" msgstr "Save" -msgid "Reset" -msgstr "Reset" - msgid "Start" msgstr "Start" +msgid "Reset" +msgstr "Reset" + msgid "Stop" msgstr "Stop" msgid "Actions" msgstr "Actions" +msgid "Console" +msgstr "" + msgid "Edit" msgstr "Edit" @@ -237,6 +240,9 @@ msgstr "Remove" msgid "Download" msgstr "Download" +msgid "Report name should contain only letters, digits and/or hyphen ('-')." +msgstr "" + msgid "" "This will delete the virtual machine and its virtual disks. This operation " "cannot be undone. Would you like to continue?" @@ -299,12 +305,12 @@ msgstr "Server name can not be blank." msgid "This is not a valid Server Name or IP. please, modify it." msgstr "This is not a valid Server Name or IP. please, modify it." -msgid "Log out" -msgstr "Log out" - msgid "Help" msgstr "" +msgid "Log out" +msgstr "Log out" + msgid "Log In" msgstr "Log In" @@ -322,12 +328,8 @@ msgstr "Report Name" msgid "" "The name used to identify the report. If omitted, a name will be chosen " -"based on current time. Name can contain: letters, digits, \"-\", \"_\", or " -"\".\"." +"based on current time. Name can contain: letters, digits and hyphen (\"-\")." msgstr "" -"The name used to identify the report. If omitted, a name will be chosen " -"based on current time. Name can contain: letters, digits, \"-\", \"_\", or " -"\".\"." msgid "Define a New Storage Pool" msgstr "Define a New Storage Pool" @@ -400,12 +402,12 @@ msgstr "iSCSI Authentication" msgid "CPU" msgstr "CPU" -msgid "Network I/O" -msgstr "Network I/O" - msgid "Disk I/O" msgstr "Disk I/O" +msgid "Network I/O" +msgstr "Network I/O" + msgid "Livetile" msgstr "Livetile" @@ -741,6 +743,10 @@ msgid "" msgstr "" #, python-format +msgid "Unable to start virtual machine %(name)s. Details: %(err)s" +msgstr "" + +#, python-format msgid "Interface %(iface)s does not exist in virtual machine %(name)s" msgstr "" @@ -936,6 +942,18 @@ msgstr "" msgid "The SCSI host adapter name must be a string." msgstr "" +msgid "The storage pool kimchi_isos is reserved for internal use" +msgstr "" + +#, python-format +msgid "" +"Unable to deactivate pool %(name)s as it is associated with some templates" +msgstr "" + +#, python-format +msgid "Unable to delete pool %(name)s as it is associated with some templates" +msgstr "" + #, python-format msgid "Storage volume %(name)s already exists" msgstr "" @@ -1081,6 +1099,13 @@ msgstr "" msgid "Unable to generate debug report %(name)s. Details: %(err)s" msgstr "" +msgid "You should give a name for the debug file report." +msgstr "" + +msgid "" +"Name should be a string. Only letters, digits and hyphen ('-') are allowed." +msgstr "" + #, python-format msgid "Storage server %(server)s was not used by Kimchi" msgstr "" @@ -1139,16 +1164,13 @@ msgid "Invalid storage type. Types supported: 'cdrom'" msgstr "" #, python-format -msgid "The path %(value)s is not valid local/remote path for the device" +msgid "The path '%(value)s' is not valid local/remote path for the device" msgstr "" #, python-format msgid "Device name %(dev_name)s already exists in vm %(vm_name)s" msgstr "" -msgid "Must specify a device name" -msgstr "" - msgid "Can't specify a directory for a CDROM device path" msgstr "" @@ -1171,6 +1193,12 @@ msgstr "" msgid "Do not support guest CDROM hot plug attachment" msgstr "" +msgid "Specify type and path to add a new virtual machine disk" +msgstr "" + +msgid "Specify path to update virtual machine disk" +msgstr "" + msgid "Repository ID must be one word only string." msgstr "" diff --git a/po/kimchi.pot b/po/kimchi.pot index a906ad9..abb7219 100755 --- a/po/kimchi.pot +++ b/po/kimchi.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-02-20 15:26-0300\n" +"POT-Creation-Date: 2014-02-25 15:23-0300\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -85,10 +85,10 @@ msgstr "" msgid "Save" msgstr "" -msgid "Reset" +msgid "Start" msgstr "" -msgid "Start" +msgid "Reset" msgstr "" msgid "Stop" @@ -97,6 +97,9 @@ msgstr "" msgid "Actions" msgstr "" +msgid "Console" +msgstr "" + msgid "Edit" msgstr "" @@ -233,6 +236,9 @@ msgstr "" msgid "Download" msgstr "" +msgid "Report name should contain only letters, digits and/or hyphen ('-')." +msgstr "" + msgid "" "This will delete the virtual machine and its virtual disks. This operation " "cannot be undone. Would you like to continue?" @@ -291,10 +297,10 @@ msgstr "" msgid "This is not a valid Server Name or IP. please, modify it." msgstr "" -msgid "Log out" +msgid "Help" msgstr "" -msgid "Help" +msgid "Log out" msgstr "" msgid "Log In" @@ -314,8 +320,7 @@ msgstr "" msgid "" "The name used to identify the report. If omitted, a name will be chosen " -"based on current time. Name can contain: letters, digits, \"-\", \"_\", or " -"\".\"." +"based on current time. Name can contain: letters, digits and hyphen (\"-\")." msgstr "" msgid "Define a New Storage Pool" @@ -385,10 +390,10 @@ msgstr "" msgid "CPU" msgstr "" -msgid "Network I/O" +msgid "Disk I/O" msgstr "" -msgid "Disk I/O" +msgid "Network I/O" msgstr "" msgid "Livetile" @@ -726,6 +731,10 @@ msgid "" msgstr "" #, python-format +msgid "Unable to start virtual machine %(name)s. Details: %(err)s" +msgstr "" + +#, python-format msgid "Interface %(iface)s does not exist in virtual machine %(name)s" msgstr "" @@ -921,6 +930,18 @@ msgstr "" msgid "The SCSI host adapter name must be a string." msgstr "" +msgid "The storage pool kimchi_isos is reserved for internal use" +msgstr "" + +#, python-format +msgid "" +"Unable to deactivate pool %(name)s as it is associated with some templates" +msgstr "" + +#, python-format +msgid "Unable to delete pool %(name)s as it is associated with some templates" +msgstr "" + #, python-format msgid "Storage volume %(name)s already exists" msgstr "" @@ -1066,6 +1087,13 @@ msgstr "" msgid "Unable to generate debug report %(name)s. Details: %(err)s" msgstr "" +msgid "You should give a name for the debug file report." +msgstr "" + +msgid "" +"Name should be a string. Only letters, digits and hyphen ('-') are allowed." +msgstr "" + #, python-format msgid "Storage server %(server)s was not used by Kimchi" msgstr "" @@ -1124,16 +1152,13 @@ msgid "Invalid storage type. Types supported: 'cdrom'" msgstr "" #, python-format -msgid "The path %(value)s is not valid local/remote path for the device" +msgid "The path '%(value)s' is not valid local/remote path for the device" msgstr "" #, python-format msgid "Device name %(dev_name)s already exists in vm %(vm_name)s" msgstr "" -msgid "Must specify a device name" -msgstr "" - msgid "Can't specify a directory for a CDROM device path" msgstr "" @@ -1156,6 +1181,12 @@ msgstr "" msgid "Do not support guest CDROM hot plug attachment" msgstr "" +msgid "Specify type and path to add a new virtual machine disk" +msgstr "" + +msgid "Specify path to update virtual machine disk" +msgstr "" + msgid "Repository ID must be one word only string." msgstr "" diff --git a/po/pt_BR.po b/po/pt_BR.po index 715e072..db7c579 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: kimchi 1.0\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-02-20 15:26-0300\n" +"POT-Creation-Date: 2014-02-25 15:23-0300\n" "PO-Revision-Date: 2013-06-27 10:48+0000\n" "Last-Translator: Crístian Viana <vianac@linux.vnet.ibm.com>\n" "Language-Team: Aline Manera <alinefm@br.ibm.com>\n" @@ -101,18 +101,21 @@ msgstr "Cancelar" msgid "Save" msgstr "Salvar" -msgid "Reset" -msgstr "Reiniciar" - msgid "Start" msgstr "Iniciar" +msgid "Reset" +msgstr "Reiniciar" + msgid "Stop" msgstr "Parar" msgid "Actions" msgstr "Ações" +msgid "Console" +msgstr "" + msgid "Edit" msgstr "Editar" @@ -255,6 +258,9 @@ msgstr "Remover" msgid "Download" msgstr "Baixar" +msgid "Report name should contain only letters, digits and/or hyphen ('-')." +msgstr "" + msgid "" "This will delete the virtual machine and its virtual disks. This operation " "cannot be undone. Would you like to continue?" @@ -317,12 +323,12 @@ msgstr "" msgid "This is not a valid Server Name or IP. please, modify it." msgstr "" -msgid "Log out" -msgstr "Sair" - msgid "Help" msgstr "" +msgid "Log out" +msgstr "Sair" + msgid "Log In" msgstr "Entrar" @@ -340,12 +346,8 @@ msgstr "Nome do Relatório" msgid "" "The name used to identify the report. If omitted, a name will be chosen " -"based on current time. Name can contain: letters, digits, \"-\", \"_\", or " -"\".\"." +"based on current time. Name can contain: letters, digits and hyphen (\"-\")." msgstr "" -"O nome usado para identificar o relatório. Se omitido, o nome será escolhido " -"baseado no horário. O nome pode conter: letras, números, \"-\", \"_\", ou \"." -"\"." msgid "Define a New Storage Pool" msgstr "Definir novo Storage Pool" @@ -415,12 +417,12 @@ msgstr "" msgid "CPU" msgstr "CPU" -msgid "Network I/O" -msgstr "Rede E/S" - msgid "Disk I/O" msgstr "Disco E/S" +msgid "Network I/O" +msgstr "Rede E/S" + msgid "Livetile" msgstr "Tela ao vivo" @@ -756,6 +758,10 @@ msgid "" msgstr "" #, python-format +msgid "Unable to start virtual machine %(name)s. Details: %(err)s" +msgstr "" + +#, python-format msgid "Interface %(iface)s does not exist in virtual machine %(name)s" msgstr "" @@ -951,6 +957,18 @@ msgstr "" msgid "The SCSI host adapter name must be a string." msgstr "" +msgid "The storage pool kimchi_isos is reserved for internal use" +msgstr "" + +#, python-format +msgid "" +"Unable to deactivate pool %(name)s as it is associated with some templates" +msgstr "" + +#, python-format +msgid "Unable to delete pool %(name)s as it is associated with some templates" +msgstr "" + #, python-format msgid "Storage volume %(name)s already exists" msgstr "" @@ -1096,6 +1114,13 @@ msgstr "" msgid "Unable to generate debug report %(name)s. Details: %(err)s" msgstr "" +msgid "You should give a name for the debug file report." +msgstr "" + +msgid "" +"Name should be a string. Only letters, digits and hyphen ('-') are allowed." +msgstr "" + #, python-format msgid "Storage server %(server)s was not used by Kimchi" msgstr "" @@ -1154,16 +1179,13 @@ msgid "Invalid storage type. Types supported: 'cdrom'" msgstr "" #, python-format -msgid "The path %(value)s is not valid local/remote path for the device" +msgid "The path '%(value)s' is not valid local/remote path for the device" msgstr "" #, python-format msgid "Device name %(dev_name)s already exists in vm %(vm_name)s" msgstr "" -msgid "Must specify a device name" -msgstr "" - msgid "Can't specify a directory for a CDROM device path" msgstr "" @@ -1186,6 +1208,12 @@ msgstr "" msgid "Do not support guest CDROM hot plug attachment" msgstr "" +msgid "Specify type and path to add a new virtual machine disk" +msgstr "" + +msgid "Specify path to update virtual machine disk" +msgstr "" + msgid "Repository ID must be one word only string." msgstr "" diff --git a/po/zh_CN.po b/po/zh_CN.po index 546ccef..0439b04 100644 --- a/po/zh_CN.po +++ b/po/zh_CN.po @@ -20,7 +20,7 @@ msgid "" msgstr "" "Project-Id-Version: kimchi 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2014-02-20 15:26-0300\n" +"POT-Creation-Date: 2014-02-25 15:23-0300\n" "PO-Revision-Date: 2013-06-27 10:48+0000\n" "Last-Translator: ShaoHe Feng <shaohef@linux.vnet.ibm.com>\n" "Language-Team: ShaoHe Feng <shaohef@linux.vnet.ibm.com>\n" @@ -101,18 +101,21 @@ msgstr "取消" msgid "Save" msgstr "保存" -msgid "Reset" -msgstr "重置" - msgid "Start" msgstr "启用" +msgid "Reset" +msgstr "重置" + msgid "Stop" msgstr "停止" msgid "Actions" msgstr "操作" +msgid "Console" +msgstr "" + msgid "Edit" msgstr "编辑" @@ -249,6 +252,9 @@ msgstr "删除" msgid "Download" msgstr "下载" +msgid "Report name should contain only letters, digits and/or hyphen ('-')." +msgstr "" + msgid "" "This will delete the virtual machine and its virtual disks. This operation " "cannot be undone. Would you like to continue?" @@ -307,12 +313,12 @@ msgstr "服务器不能为空" msgid "This is not a valid Server Name or IP. please, modify it." msgstr "这不是一个有效的服务器名或IP,请修改" -msgid "Log out" -msgstr "登出" - msgid "Help" msgstr "" +msgid "Log out" +msgstr "登出" + msgid "Log In" msgstr "登录" @@ -330,11 +336,8 @@ msgstr "诊断报告名" msgid "" "The name used to identify the report. If omitted, a name will be chosen " -"based on current time. Name can contain: letters, digits, \"-\", \"_\", or " -"\".\"." +"based on current time. Name can contain: letters, digits and hyphen (\"-\")." msgstr "" -"该名称用来唯一标识报告,如果不指定,将会基于当前时间自动生成一个名称。名称可" -"以包含: 字母、数字、\"-\"、\"_\" 或者 \".\"" msgid "Define a New Storage Pool" msgstr "定义一个新的存储池" @@ -403,12 +406,12 @@ msgstr "iSCSI认证" msgid "CPU" msgstr "处理器" -msgid "Network I/O" -msgstr "网络I/O" - msgid "Disk I/O" msgstr "磁盘I/O" +msgid "Network I/O" +msgstr "网络I/O" + msgid "Livetile" msgstr "屏幕" @@ -744,6 +747,10 @@ msgid "" msgstr "" #, python-format +msgid "Unable to start virtual machine %(name)s. Details: %(err)s" +msgstr "" + +#, python-format msgid "Interface %(iface)s does not exist in virtual machine %(name)s" msgstr "" @@ -939,6 +946,18 @@ msgstr "" msgid "The SCSI host adapter name must be a string." msgstr "" +msgid "The storage pool kimchi_isos is reserved for internal use" +msgstr "" + +#, python-format +msgid "" +"Unable to deactivate pool %(name)s as it is associated with some templates" +msgstr "" + +#, python-format +msgid "Unable to delete pool %(name)s as it is associated with some templates" +msgstr "" + #, python-format msgid "Storage volume %(name)s already exists" msgstr "" @@ -1084,6 +1103,13 @@ msgstr "" msgid "Unable to generate debug report %(name)s. Details: %(err)s" msgstr "" +msgid "You should give a name for the debug file report." +msgstr "" + +msgid "" +"Name should be a string. Only letters, digits and hyphen ('-') are allowed." +msgstr "" + #, python-format msgid "Storage server %(server)s was not used by Kimchi" msgstr "" @@ -1142,16 +1168,13 @@ msgid "Invalid storage type. Types supported: 'cdrom'" msgstr "" #, python-format -msgid "The path %(value)s is not valid local/remote path for the device" +msgid "The path '%(value)s' is not valid local/remote path for the device" msgstr "" #, python-format msgid "Device name %(dev_name)s already exists in vm %(vm_name)s" msgstr "" -msgid "Must specify a device name" -msgstr "" - msgid "Can't specify a directory for a CDROM device path" msgstr "" @@ -1174,6 +1197,12 @@ msgstr "" msgid "Do not support guest CDROM hot plug attachment" msgstr "" +msgid "Specify type and path to add a new virtual machine disk" +msgstr "" + +msgid "Specify path to update virtual machine disk" +msgstr "" + msgid "Repository ID must be one word only string." msgstr "" diff --git a/src/kimchi/i18n.py b/src/kimchi/i18n.py index fea0184..f766383 100644 --- a/src/kimchi/i18n.py +++ b/src/kimchi/i18n.py @@ -135,6 +135,8 @@ messages = { "KCHPOOL0029E": _("The parameter disks only can be updated for logical storage pool."), "KCHPOOL0030E": _("The SCSI host adapter name must be a string."), "KCHPOOL0031E": _("The storage pool kimchi_isos is reserved for internal use"), + "KCHPOOL0032E": _("Unable to deactivate pool %(name)s as it is associated with some templates"), + "KCHPOOL0033E": _("Unable to delete pool %(name)s as it is associated with some templates"), "KCHVOL0001E": _("Storage volume %(name)s already exists"), "KCHVOL0002E": _("Storage volume %(name)s does not exist in storage pool %(pool)s"), diff --git a/src/kimchi/model/storagepools.py b/src/kimchi/model/storagepools.py index 011feb0..d4a6ee8 100644 --- a/src/kimchi/model/storagepools.py +++ b/src/kimchi/model/storagepools.py @@ -29,8 +29,7 @@ from kimchi.exception import NotFoundError, OperationFailed from kimchi.model.config import CapabilitiesModel from kimchi.model.host import DeviceModel from kimchi.model.libvirtstoragepool import StoragePoolDef -from kimchi.utils import add_task, kimchi_log -from kimchi.utils import run_command +from kimchi.utils import add_task, kimchi_log, pool_name_from_uri, run_command ISO_POOL_NAME = u'kimchi_isos' @@ -190,7 +189,7 @@ class StoragePoolModel(object): elif len(res) == 0: source[key] = "" else: - souce[key] = res + source[key] = res return source @@ -273,7 +272,20 @@ class StoragePoolModel(object): raise OperationFailed("KCHPOOL0009E", {'name': name, 'err': e.get_error_message()}) + def _pool_used_by_template(self, pool_name): + with self.objstore as session: + templates = session.get_list('template') + for tmpl in templates: + t_info = session.get('template', tmpl) + t_pool = pool_name_from_uri(t_info['storagepool']) + if t_pool == pool_name: + return True + return False + def deactivate(self, name): + if self._pool_used_by_template(name): + raise InvalidOperation('KCHPOOL0032E', {'name': name}) + pool = self.get_storagepool(name, self.conn) try: pool.destroy() @@ -282,6 +294,9 @@ class StoragePoolModel(object): {'name': name, 'err': e.get_error_message()}) def delete(self, name): + if self._pool_used_by_template(name): + raise InvalidOperation('KCHPOOL0033E', {'name': name}) + pool = self.get_storagepool(name, self.conn) if pool.isActive(): raise InvalidOperation("KCHPOOL0005E", {'name': name}) diff --git a/tests/test_model.py b/tests/test_model.py index 74e2424..7cf2f08 100644 --- a/tests/test_model.py +++ b/tests/test_model.py @@ -406,6 +406,11 @@ class ModelTests(unittest.TestCase): disk_path = '/tmp/kimchi-images/%s-0.img' % vm_info['uuid'] self.assertTrue(os.access(disk_path, os.F_OK)) + # reset template to default storage pool + # so we can remove the storage pool created 'test-pool' + params = {'storagepool': '/storagepools/default'} + inst.template_update('test', params) + @unittest.skipUnless(utils.running_as_root(), 'Must be run as root') def test_template_create(self): inst = model.Model('test:///default', -- 1.7.10.4