[Kimchi-devel] [PATCH] [Kimchi] Make sure all log messages have required parameters

Lucio Correia luciojhc at linux.vnet.ibm.com
Mon Jun 27 20:29:16 UTC 2016


Signed-off-by: Lucio Correia <luciojhc at linux.vnet.ibm.com>
---
 control/networks.py       | 3 +++
 control/storagepools.py   | 3 +++
 control/storagevolumes.py | 3 +++
 control/templates.py      | 3 +++
 control/vm/hostdevs.py    | 5 +++++
 control/vm/ifaces.py      | 4 ++++
 control/vm/snapshots.py   | 4 ++++
 control/vm/storages.py    | 5 +++++
 control/vms.py            | 5 +++++
 i18n.py                   | 4 ++--
 10 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/control/networks.py b/control/networks.py
index 4b18638..1b8012e 100644
--- a/control/networks.py
+++ b/control/networks.py
@@ -42,7 +42,10 @@ class Networks(Collection):
         self.role_key = 'network'
         self.admin_methods = ['POST']
         self.resource = Network
+
+        # set user log messages and make sure all parameters are present
         self.log_map = NETWORKS_REQUESTS
+        self.log_args.update({'connection': '', 'name': ''})
 
 
 class Network(Resource):
diff --git a/control/storagepools.py b/control/storagepools.py
index 2f25746..e188aae 100644
--- a/control/storagepools.py
+++ b/control/storagepools.py
@@ -52,7 +52,10 @@ class StoragePools(Collection):
         self.resource = StoragePool
         isos = IsoPool(model)
         setattr(self, ISO_POOL_NAME, isos)
+
+        # set user log messages and make sure all parameters are present
         self.log_map = STORAGEPOOLS_REQUESTS
+        self.log_args.update({'name': '', 'type': ''})
 
     def create(self, params, *args):
         try:
diff --git a/control/storagevolumes.py b/control/storagevolumes.py
index c121b5e..a27396f 100644
--- a/control/storagevolumes.py
+++ b/control/storagevolumes.py
@@ -68,9 +68,12 @@ class StorageVolume(Resource):
         self.resize = self.generate_action_handler('resize', ['size'])
         self.wipe = self.generate_action_handler('wipe')
         self.clone = self.generate_action_handler_task('clone')
+
+        # set user log messages and make sure all parameters are present
         self.log_map = STORAGEVOLUME_REQUESTS
         self.log_args.update({
             'pool': self.pool.encode('utf-8') if self.pool else '',
+            'size': '',
         })
 
     @property
diff --git a/control/templates.py b/control/templates.py
index 82697d0..bb2e068 100644
--- a/control/templates.py
+++ b/control/templates.py
@@ -41,7 +41,10 @@ class Templates(Collection):
         self.role_key = 'templates'
         self.admin_methods = ['GET', 'POST']
         self.resource = Template
+
+        # set user log messages and make sure all parameters are present
         self.log_map = TEMPLATES_REQUESTS
+        self.log_args.update({'name': ''})
 
 
 class Template(Resource):
diff --git a/control/vm/hostdevs.py b/control/vm/hostdevs.py
index d21e19d..c39d7fb 100644
--- a/control/vm/hostdevs.py
+++ b/control/vm/hostdevs.py
@@ -40,8 +40,11 @@ class VMHostDevs(AsyncCollection):
         self.vmid = vmid
         self.resource_args = [self.vmid, ]
         self.model_args = [self.vmid, ]
+
+        # set user log messages and make sure all parameters are present
         self.log_map = VMHOSTDEVS_REQUESTS
         self.log_args.update({
+            'name': '',
             'vmid': self.vmid.encode('utf-8') if self.vmid else '',
         })
 
@@ -52,6 +55,8 @@ class VMHostDev(AsyncResource):
         self.vmid = vmid
         self.ident = ident
         self.model_args = [self.vmid, self.ident]
+
+        # set user log messages and make sure all parameters are present
         self.log_map = VMHOSTDEV_REQUESTS
         self.log_args.update({
             'vmid': self.vmid.encode('utf-8') if self.vmid else '',
diff --git a/control/vm/ifaces.py b/control/vm/ifaces.py
index 7e133a6..cd9bd31 100644
--- a/control/vm/ifaces.py
+++ b/control/vm/ifaces.py
@@ -45,6 +45,8 @@ class VMIfaces(Collection):
         self.vm = vm
         self.resource_args = [self.vm, ]
         self.model_args = [self.vm, ]
+
+        # set user log messages and make sure all parameters are present
         self.log_map = VMIFACES_REQUESTS
         self.log_args.update({
             'network': '',
@@ -60,6 +62,8 @@ class VMIface(Resource):
         self.info = {}
         self.model_args = [self.vm, self.ident]
         self.uri_fmt = '/vms/%s/ifaces/%s'
+
+        # set user log messages and make sure all parameters are present
         self.log_map = VMIFACE_REQUESTS
         self.log_args.update({
             'vm': self.vm.encode('utf-8') if self.vm else '',
diff --git a/control/vm/snapshots.py b/control/vm/snapshots.py
index 20f07a7..d66fa06 100644
--- a/control/vm/snapshots.py
+++ b/control/vm/snapshots.py
@@ -42,6 +42,8 @@ class VMSnapshots(AsyncCollection):
         self.resource_args = [self.vm, ]
         self.model_args = [self.vm, ]
         self.current = CurrentVMSnapshot(model, vm)
+
+        # set user log messages and make sure all parameters are present
         self.log_map = VMSNAPSHOTS_REQUESTS
         self.log_args.update({
             'vm': self.vm.encode('utf-8') if self.vm else '',
@@ -57,6 +59,8 @@ class VMSnapshot(Resource):
         self.model_args = [self.vm, self.ident]
         self.uri_fmt = '/vms/%s/snapshots/%s'
         self.revert = self.generate_action_handler('revert')
+
+        # set user log messages and make sure all parameters are present
         self.log_map = VMSNAPSHOT_REQUESTS
         self.log_args.update({
             'vm': self.vm.encode('utf-8') if self.vm else '',
diff --git a/control/vm/storages.py b/control/vm/storages.py
index 615074a..5ef5f1a 100644
--- a/control/vm/storages.py
+++ b/control/vm/storages.py
@@ -41,10 +41,13 @@ class VMStorages(Collection):
         self.vm = vm
         self.resource_args = [self.vm, ]
         self.model_args = [self.vm, ]
+
+        # set user log messages and make sure all parameters are present
         self.log_map = VMSTORAGES_REQUESTS
         self.log_args.update({
             'vm': self.vm.encode('utf-8') if self.vm else '',
             'path': '',
+            'type': '',
         })
 
 
@@ -56,6 +59,8 @@ class VMStorage(Resource):
         self.info = {}
         self.model_args = [self.vm, self.ident]
         self.uri_fmt = '/vms/%s/storages/%s'
+
+        # set user log messages and make sure all parameters are present
         self.log_map = VMSTORAGE_REQUESTS
         self.log_args.update({
             'vm': self.vm.encode('utf-8') if self.vm else '',
diff --git a/control/vms.py b/control/vms.py
index b351c72..bbf0fa4 100644
--- a/control/vms.py
+++ b/control/vms.py
@@ -54,6 +54,8 @@ class VMs(AsyncCollection):
         self.resource = VM
         self.role_key = 'guests'
         self.admin_methods = ['POST']
+
+        # set user log messages and make sure all parameters are present
         self.log_map = VMS_REQUESTS
         self.log_args.update({'name': '', 'template': ''})
 
@@ -82,7 +84,10 @@ class VM(Resource):
         self.suspend = self.generate_action_handler('suspend')
         self.resume = self.generate_action_handler('resume')
         self.serial = self.generate_action_handler('serial')
+
+        # set user log messages and make sure all parameters are present
         self.log_map = VM_REQUESTS
+        self.log_args.update({'remote_host': ''})
 
     @property
     def data(self):
diff --git a/i18n.py b/i18n.py
index b33c6ec..08a3ac8 100644
--- a/i18n.py
+++ b/i18n.py
@@ -339,12 +339,12 @@ messages = {
     "KCHEVENT0004W": _("I/O error on guest '%(vm)s': storage pool out of space for %(devAlias)s (%(srcPath)s)."),
 
     # These messages (ending with L) are for user log purposes
-    "KCHNET0001L": _("Created %(connection)s virtual network '%(name)s'"),
+    "KCHNET0001L": _("Created virtual network '%(name)s' type '%(connection)s'"),
     "KCHNET0002L": _("Removed virtual network '%(ident)s'"),
     "KCHNET0003L": _("Updated virtual network '%(ident)s'"),
     "KCHNET0004L": _("Activated virtual network '%(ident)s'"),
     "KCHNET0005L": _("Deactivated virtual network '%(ident)s'"),
-    "KCHPOOL0001L": _("Created %(type)s storage pool '%(name)s'"),
+    "KCHPOOL0001L": _("Created storage pool '%(name)s' type '%(type)s'"),
     "KCHPOOL0002L": _("Removed storage pool '%(ident)s'"),
     "KCHPOOL0003L": _("Updated storage pool '%(ident)s'"),
     "KCHPOOL0004L": _("Activated storage pool '%(ident)s'"),
-- 
1.9.1




More information about the Kimchi-devel mailing list