Update dump create parameters

Dump create parameters are a set of parameters accepted
in dict format while creating the dump. So far the values
can be only strings but now unit64 also added. This commit
address the changes to handle the updated dictionary

Testing:
  - Full build with interface change is successful
  - Created dumps with new interface
    Resource Dump:
    busctl --verbose call xyz.openbmc_project.Dump.Manager /xyz/openbmc_project/dump/resource  xyz.openbmc_project.Dump.Create CreateDump a{sv} 2 "com.ibm.Dump.Create.CreateParameters.VSPString" s "vsp" "com.ibm.Dump.Create.CreateParameters.Password" s "0"
MESSAGE "o" {
        OBJECT_PATH "/xyz/openbmc_project/dump/resource/entry/1";
};

   BMC Dump:
   busctl --verbose call xyz.openbmc_project.Dump.Manager /xyz/openbmc_project/dump/bmc  xyz.openbmc_project.Dump.Create CreateDump a{sv} 0
MESSAGE "o" {
        OBJECT_PATH "/xyz/openbmc_project/dump/bmc/entry/92";
};

   System Dump:
   busctl --verbose call xyz.openbmc_project.Dump.Manager /xyz/openbmc_project/dump/system  xyz.openbmc_project.Dump.Create CreateDump a{sv} 0
MESSAGE "o" {
        OBJECT_PATH "/xyz/openbmc_project/dump/system/entry/1";
};

Signed-off-by: Dhruvaraj Subhashchandran <dhruvaraj@in.ibm.com>
Change-Id: I37ab7d870954e1b52500f5975735286433fbb8df
diff --git a/dump-extensions/openpower-dumps/dump_manager_resource.cpp b/dump-extensions/openpower-dumps/dump_manager_resource.cpp
index de27c94..020556c 100644
--- a/dump-extensions/openpower-dumps/dump_manager_resource.cpp
+++ b/dump-extensions/openpower-dumps/dump_manager_resource.cpp
@@ -73,7 +73,7 @@
 }
 
 sdbusplus::message::object_path
-    Manager::createDump(std::map<std::string, std::string> params)
+    Manager::createDump(phosphor::dump::DumpCreateParams params)
 {
 
     using NotAllowed =
@@ -87,6 +87,10 @@
             Reason("Resource dump can be initiated only when the host is up"));
         return std::string();
     }
+
+    using InvalidArgument =
+        sdbusplus::xyz::openbmc_project::Common::Error::InvalidArgument;
+    using Argument = xyz::openbmc_project::Common::InvalidArgument;
     using CreateParameters =
         sdbusplus::com::ibm::Dump::server::Create::CreateParameters;
 
@@ -95,12 +99,61 @@
     auto objPath = std::filesystem::path(baseEntryPath) / idString;
     std::time_t timeStamp = std::time(nullptr);
 
-    std::string vspString = params[sdbusplus::com::ibm::Dump::server::Create::
-                                       convertCreateParametersToString(
-                                           CreateParameters::VSPString)];
-    std::string pwd =
-        params[sdbusplus::com::ibm::Dump::server::Create::
-                   convertCreateParametersToString(CreateParameters::Password)];
+    std::string vspString;
+    auto iter = params.find(
+        sdbusplus::com::ibm::Dump::server::Create::
+            convertCreateParametersToString(CreateParameters::VSPString));
+    if (iter == params.end())
+    {
+        // Host will generate a default dump if no resource selector string
+        // is provided. The default dump will be a non-disruptive system dump.
+        log<level::INFO>(
+            "VSP string is not provided, a non-disruptive system dump will be "
+            "generated by the host");
+    }
+    else
+    {
+        try
+        {
+            vspString = std::get<std::string>(iter->second);
+        }
+        catch (const std::bad_variant_access& e)
+        {
+            // Exception will be raised if the input is not string
+            log<level::ERR>(
+                fmt::format("An invalid  vsp string is passed errormsg({})",
+                            e.what())
+                    .c_str());
+            elog<InvalidArgument>(Argument::ARGUMENT_NAME("VSP_STRING"),
+                                  Argument::ARGUMENT_VALUE("INVALID INPUT"));
+        }
+    }
+
+    std::string pwd;
+    iter = params.find(
+        sdbusplus::com::ibm::Dump::server::Create::
+            convertCreateParametersToString(CreateParameters::Password));
+    if (iter == params.end())
+    {
+        log<level::ERR>("Required argument password is missing");
+        elog<InvalidArgument>(Argument::ARGUMENT_NAME("PASSOWORD"),
+                              Argument::ARGUMENT_VALUE("MISSING"));
+    }
+
+    try
+    {
+        pwd = std::get<std::string>(iter->second);
+    }
+    catch (const std::bad_variant_access& e)
+    {
+        // Exception will be raised if the input is not string
+        log<level::ERR>(
+            fmt::format("An invalid password string is passed errormsg({})",
+                        e.what())
+                .c_str());
+        elog<InvalidArgument>(Argument::ARGUMENT_NAME("PASSWORD"),
+                              Argument::ARGUMENT_VALUE("INVALID INPUT"));
+    }
 
     try
     {
diff --git a/dump-extensions/openpower-dumps/dump_manager_resource.hpp b/dump-extensions/openpower-dumps/dump_manager_resource.hpp
index 45ee1bf..e30dfec 100644
--- a/dump-extensions/openpower-dumps/dump_manager_resource.hpp
+++ b/dump-extensions/openpower-dumps/dump_manager_resource.hpp
@@ -68,7 +68,7 @@
      *  @return object_path - The object path of the new entry.
      */
     sdbusplus::message::object_path
-        createDump(std::map<std::string, std::string> params) override;
+        createDump(phosphor::dump::DumpCreateParams params) override;
 };
 
 } // namespace resource
diff --git a/dump-extensions/openpower-dumps/dump_manager_system.cpp b/dump-extensions/openpower-dumps/dump_manager_system.cpp
index 531cde8..ae9aaa5 100644
--- a/dump-extensions/openpower-dumps/dump_manager_system.cpp
+++ b/dump-extensions/openpower-dumps/dump_manager_system.cpp
@@ -72,7 +72,7 @@
 }
 
 sdbusplus::message::object_path
-    Manager::createDump(std::map<std::string, std::string> params)
+    Manager::createDump(phosphor::dump::DumpCreateParams params)
 {
     constexpr auto SYSTEMD_SERVICE = "org.freedesktop.systemd1";
     constexpr auto SYSTEMD_OBJ_PATH = "/org/freedesktop/systemd1";
diff --git a/dump-extensions/openpower-dumps/dump_manager_system.hpp b/dump-extensions/openpower-dumps/dump_manager_system.hpp
index a59b692..7170b3f 100644
--- a/dump-extensions/openpower-dumps/dump_manager_system.hpp
+++ b/dump-extensions/openpower-dumps/dump_manager_system.hpp
@@ -68,7 +68,7 @@
      *  @return object_path - The path to the new dump entry.
      */
     sdbusplus::message::object_path
-        createDump(std::map<std::string, std::string> params) override;
+        createDump(phosphor::dump::DumpCreateParams params) override;
 };
 
 } // namespace system
diff --git a/dump_manager.hpp b/dump_manager.hpp
index e4ba730..3f111f3 100644
--- a/dump_manager.hpp
+++ b/dump_manager.hpp
@@ -11,6 +11,8 @@
 namespace dump
 {
 
+using DumpCreateParams =
+    std::map<std::string, std::variant<std::string, uint64_t>>;
 using Iface = sdbusplus::server::object::object<
     sdbusplus::xyz::openbmc_project::Collection::server::DeleteAll>;
 
diff --git a/dump_manager_bmc.cpp b/dump_manager_bmc.cpp
index 2cf23aa..156ea9f 100644
--- a/dump_manager_bmc.cpp
+++ b/dump_manager_bmc.cpp
@@ -39,7 +39,7 @@
 } // namespace internal
 
 sdbusplus::message::object_path
-    Manager::createDump(std::map<std::string, std::string> params)
+    Manager::createDump(phosphor::dump::DumpCreateParams params)
 {
     if (!params.empty())
     {
diff --git a/dump_manager_bmc.hpp b/dump_manager_bmc.hpp
index 604012b..ddc094ae 100644
--- a/dump_manager_bmc.hpp
+++ b/dump_manager_bmc.hpp
@@ -95,7 +95,7 @@
      *  @return object_path - The object path of the new dump entry.
      */
     sdbusplus::message::object_path
-        createDump(std::map<std::string, std::string> params) override;
+        createDump(phosphor::dump::DumpCreateParams params) override;
 
   private:
     /** @brief Create Dump entry d-bus object