tools: trigger verification

Trigger verification via committing to the verify blob id.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Ia3722ff144ba268cd554bac0fda06f0c426edd88
diff --git a/tools/updater.cpp b/tools/updater.cpp
index 2465945..fd72136 100644
--- a/tools/updater.cpp
+++ b/tools/updater.cpp
@@ -33,9 +33,14 @@
 {
     /* TODO(venture): Add optional parameter to specify the flash type, default
      * to legacy for now.
+     *
+     * TODO(venture): Move the strings from the FirmwareHandler object to a
+     * boring utils object so it will be more happly linked cleanly to both the
+     * BMC and host-side.
      */
     std::string goalFirmware = "/flash/image";
     std::string hashFilename = "/flash/hash";
+    std::string verifyFilename = "/flash/verify";
 
     /* Get list of blob_ids, check for /flash/image, or /flash/tarball.
      * TODO(venture) the mechanism doesn't care, but the caller of burn_my_bmc
@@ -129,8 +134,38 @@
 
     blob->closeBlob(session);
 
-    /* Trigger the verification. */
-    /* Check the verification. */
+    /* Trigger the verification by opening the verify file. */
+    std::fprintf(stderr, "Opening the verification file\n");
+    try
+    {
+        session = blob->openBlob(
+            verifyFilename,
+            static_cast<std::uint16_t>(supported) |
+                static_cast<std::uint16_t>(blobs::OpenFlags::write));
+    }
+    catch (const ipmiblob::BlobException& b)
+    {
+        throw ToolException("blob exception received: " +
+                            std::string(b.what()));
+    }
+
+    std::fprintf(
+        stderr,
+        "Committing to verification file to trigger verification service\n");
+    try
+    {
+        blob->commit(session, {});
+    }
+    catch (const ipmiblob::BlobException& b)
+    {
+        throw ToolException("blob exception received: " +
+                            std::string(b.what()));
+    }
+
+    /* TODO: Check the verification via stat(session). */
+
+    /* DO NOT CLOSE the verification session until it's done. */
+    blob->closeBlob(session);
 
     return;
 }