rewrite Get Session Info to use new yielding D-Bus API

The new yielding API does not use try/catch, and has slightly different
parameters which makes the change look bigger than it is.

Tested:
  Run ipmitool session info active
    session handle                : 1
    slot count                    : 45
    active sessions               : 1
    user id                       : 1
    privilege level               : ADMINISTRATOR
    session type                  : IPMIv2/RMCP+
    channel number                : 0x01
    console ip                    : 0.0.0.0
    console mac                   : 00:00:00:00:00:00
    console port                  : 54884

  Console ip is reported as all zero due to a current netipmid bug.

Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
Change-Id: Ia6574568c7f8863b3acffcf22e403c8be01d312a
diff --git a/include/ipmid/utils.hpp b/include/ipmid/utils.hpp
index cd72ec0..b8b59bf 100644
--- a/include/ipmid/utils.hpp
+++ b/include/ipmid/utils.hpp
@@ -376,6 +376,33 @@
 
 /********* End co-routine yielding alternatives ***************/
 
+/** @brief Retrieve the value from map of variants,
+ *         returning a default if the key does not exist or the
+ *         type of the value does not match the expected type
+ *
+ *  @tparam T - type of expected value to return
+ *  @param[in] props - D-Bus propery map (Map of variants)
+ *  @param[in] name - key name of property to fetch
+ *  @param[in] defaultValue - default value to return on error
+ *  @return - value from propery map at name, or defaultValue
+ */
+template <typename T>
+T mappedVariant(const ipmi::PropertyMap& props, const std::string& name,
+                const T& defaultValue)
+{
+    auto item = props.find(name);
+    if (item == props.end())
+    {
+        return defaultValue;
+    }
+    const T* prop = std::get_if<T>(&item->second);
+    if (!prop)
+    {
+        return defaultValue;
+    }
+    return *prop;
+}
+
 /** @struct VariantToDoubleVisitor
  *  @brief Visitor to convert variants to doubles
  *  @details Performs a static cast on the underlying type