]> xenbits.xensource.com Git - xcp/xen-api.git/commitdiff
CA-46108: vmpp message must contain body and data
authorMarcus Granado <marcus.granado@eu.citrix.com>
Tue, 12 Oct 2010 10:08:46 +0000 (11:08 +0100)
committerMarcus Granado <marcus.granado@eu.citrix.com>
Tue, 12 Oct 2010 10:08:46 +0000 (11:08 +0100)
Signed-off-by: Marcus Granado <marcus.granado@eu.citrix.com>
ocaml/xapi/xapi_vmpp.ml
scripts/mail-alarm

index d05ab73a7f9c9e9aaafc9e923f11616a0c525b9c..e94fa1a5146d0dab3974700107a587e07c216ef5 100644 (file)
@@ -59,9 +59,9 @@ let add_to_recent_alerts ~__context ~vmpp ~value =
 
 let create_alert ~__context ~vmpp ~name ~priority ~body ~data =
   assert_licensed ~__context;
-  let value =
-    (*"<message><email>"^body^"</email><data>"^data^"</data></message>"*)
-    data
+  let value = data in
+  let msg = 
+    "<message><email>"^body^"</email><data>"^value^"</data></message>"
   in
   let successful = priority < 5L in
   if successful
@@ -72,7 +72,7 @@ let create_alert ~__context ~vmpp ~name ~priority ~body ~data =
     add_to_recent_alerts ~__context ~vmpp ~value;
     let cls = `VMPP in
     let obj_uuid = Db.VMPP.get_uuid ~__context ~self:vmpp in
-    Xapi_message.create ~__context ~name ~priority ~cls ~obj_uuid ~body;
+    Xapi_message.create ~__context ~name ~priority ~cls ~obj_uuid ~body:msg;
     ()
   )
 
index 93e3ffa1e52dea71c41ff74b689dbf329c3f0d35..1a328b563008b3e6a6198208664a0faa35ec794f 100755 (executable)
@@ -297,11 +297,15 @@ class VmppETG(EmailTextGenerator):
 
     def generate_body(self):
         msg = self.msg
+        msg_body = unescape(msg.body)
         try:
+            xmldoc = minidom.parseString(msg_body)
+            body_message = xmldoc.getElementsByTagName('message')[0]
+            email_message = body_message.getElementsByTagName('email')[0].firstChild.data
             return \
             "Field\t\tValue\n-----\t\t-----\nName:\t\t%s\nPriority:\t%s\nClass:\t\t%s\n" \
             "Object UUID:\t%s\nTimestamp:\t%s\nMessage UUID:\t%s\nPool name:\t%s\nBody:\t\t%s\n" % \
-            (msg.name,msg.priority,msg.cls,msg.obj_uuid,msg.timestamp,msg.uuid,msg.pool_name,msg.body)
+            (msg.name,msg.priority,msg.cls,msg.obj_uuid,msg.timestamp,msg.uuid,msg.pool_name,email_message)
         except:
             log_err("Badly formatted XML, or missing field")
             sys.exit(1)