# HG changeset patch
# User Kaitlin Rupert <karupert(a)us.ibm.com>
# Date 1204836824 28800
# Node ID 1e01f52781b5499949f498553b453f23af8feec2
# Parent 0a71dab025defa9d32488753ead9c47a582134df
Reorganize VSMigrationService to prepare for URI support.
Since both MigrateVirtualSystemToHost() and MigrateVirtualSystemToSystem() both need to
get the values from MSD in the same way, might as well put the MSD calls in migrate_do
(since both call this function).
Signed-off-by: Kaitlin Rupert <karupert(a)us.ibm.com>
diff -r 0a71dab025de -r 1e01f52781b5 src/Virt_VSMigrationService.c
--- a/src/Virt_VSMigrationService.c Thu Mar 06 09:59:23 2008 +0800
+++ b/src/Virt_VSMigrationService.c Thu Mar 06 12:53:44 2008 -0800
@@ -674,11 +674,69 @@ static CMPIStatus migrate_create_job_ins
return s;
}
+static CMPIStatus get_msd(const CMPIObjectPath *ref,
+ const CMPIArgs *argsin,
+ CMPIInstance **msd)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ int ret;
+
+ ret = cu_get_inst_arg(argsin, "MigrationSettingData", msd);
+ if ((ret == CMPI_RC_OK) && (*msd != NULL))
+ goto out;
+
+ s = get_migration_sd(ref, msd, _BROKER, false);
+ if ((s.rc != CMPI_RC_OK) || (*msd == NULL)) {
+ cu_statusf(_BROKER, &s,
+ s.rc,
+ "Unable to get default setting data values");
+ goto out;
+ }
+ CU_DEBUG("Using default values for MigrationSettingData param");
+
+ out:
+ return s;
+}
+
+static CMPIStatus get_migration_type(CMPIInstance *msd,
+ uint16_t *type)
+{
+ CMPIStatus s = {CMPI_RC_OK, NULL};
+ int ret;
+
+ ret = cu_get_u16_prop(msd, "MigrationType", type);
+ if (ret != CMPI_RC_OK) {
+ cu_statusf(_BROKER, &s,
+ ret,
+ "Invalid MigrationType value");
+ }
+
+ return s;
+}
+
+static CMPIStatus get_msd_values(const CMPIObjectPath *ref,
+ const CMPIArgs *argsin,
+ struct migration_job *job)
+{
+ CMPIStatus s;
+ CMPIInstance *msd;
+
+ s = get_msd(ref, argsin, &msd);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ s = get_migration_type(msd, &job->type);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
+
+ out:
+ return s;
+}
+
static struct migration_job *migrate_job_prepare(const CMPIContext *context,
const CMPIObjectPath *ref,
const char *domain,
- const char *host,
- uint16_t type)
+ const char *host)
{
struct migration_job *job;
uuid_t uuid;
@@ -691,7 +749,6 @@ static struct migration_job *migrate_job
job->host = strdup(host);
job->ref_cn = strdup(CLASSNAME(ref));
job->ref_ns = strdup(NAMESPACE(ref));
- job->type = type;
uuid_generate(uuid);
uuid_unparse(uuid, job->uuid);
@@ -705,7 +762,7 @@ static CMPIStatus migrate_do(const CMPIO
const CMPIContext *context,
const char *domain,
const char *host,
- uint16_t type,
+ const CMPIArgs *argsin,
const CMPIResult *results,
CMPIArgs *argsout)
{
@@ -715,13 +772,17 @@ static CMPIStatus migrate_do(const CMPIO
CMPI_THREAD_TYPE thread;
uint32_t retcode = 1;
- job = migrate_job_prepare(context, ref, domain, host, type);
+ job = migrate_job_prepare(context, ref, domain, host);
if (job == NULL) {
cu_statusf(_BROKER, &s,
CMPI_RC_ERR_FAILED,
"Unable to prepare migration job");
goto out;
}
+
+ s = get_msd_values(ref, argsin, job);
+ if (s.rc != CMPI_RC_OK)
+ goto out;
CU_DEBUG("Prepared migration job %s", job->uuid);
@@ -737,36 +798,6 @@ static CMPIStatus migrate_do(const CMPIO
out:
CMReturnData(results, (CMPIValue *)&retcode, CMPI_uint32);
-
- return s;
-}
-
-static CMPIStatus get_migration_type(const CMPIObjectPath *ref,
- const CMPIArgs *argsin,
- uint16_t *type)
-{
- CMPIStatus s = {CMPI_RC_OK, NULL};
- CMPIInstance *msd;
- int ret;
-
- ret = cu_get_inst_arg(argsin, "MigrationSettingData", &msd);
- if ((ret != CMPI_RC_OK) || (msd == NULL)) {
- CU_DEBUG("Using default values for MigrationSettingData
param");
- s = get_migration_sd(ref, &msd, _BROKER, false);
- if ((s.rc != CMPI_RC_OK) || (msd == NULL)) {
- cu_statusf(_BROKER, &s,
- s.rc,
- "Unable to get default setting data
values");
- return s;
- }
- }
-
- ret = cu_get_u16_prop(msd, "MigrationType", type);
- if (ret != CMPI_RC_OK) {
- cu_statusf(_BROKER, &s,
- ret,
- "Invalid MigrationType value");
- }
return s;
}
@@ -782,7 +813,6 @@ static CMPIStatus migrate_vs_host(CMPIMe
const char *dhost = NULL;
CMPIObjectPath *system;
const char *name = NULL;
- uint16_t type;
cu_get_str_arg(argsin, "DestinationHost", &dhost);
cu_get_ref_arg(argsin, "ComputerSystem", &system);
@@ -803,13 +833,7 @@ static CMPIStatus migrate_vs_host(CMPIMe
return s;
}
- s = get_migration_type(ref, argsin, &type);
- if (s.rc != CMPI_RC_OK) {
- METHOD_RETURN(results, 1);
- return s;
- }
-
- return migrate_do(ref, ctx, name, dhost, type, results, argsout);
+ return migrate_do(ref, ctx, name, dhost, argsin, results, argsout);
}
static CMPIStatus migrate_vs_system(CMPIMethodMI *self,
@@ -824,7 +848,6 @@ static CMPIStatus migrate_vs_system(CMPI
CMPIObjectPath *sys;
const char *dname;
const char *name;
- uint16_t type;
cu_get_ref_arg(argsin, "DestinationSystem", &dsys);
cu_get_ref_arg(argsin, "ComputerSystem", &sys);
@@ -853,13 +876,7 @@ static CMPIStatus migrate_vs_system(CMPI
return s;
}
- s = get_migration_type(ref, argsin, &type);
- if (s.rc != CMPI_RC_OK) {
- METHOD_RETURN(results, 1);
- return s;
- }
-
- return migrate_do(ref, ctx, name, dname, type, results, argsout);
+ return migrate_do(ref, ctx, name, dname, argsin, results, argsout);
}
static struct method_handler vsimth = {