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
     {