Dan Smith wrote:
+static void snap_job_set_status(struct snap_context *ctx,
+ uint16_t state,
+ const char *status)
+{
+ CMPIInstance *inst;
+ CMPIStatus s;
+ CMPIObjectPath *op;
+
+ op = CMNewObjectPath(_BROKER,
+ ctx->ref_ns,
+ "CIM_ConcreteJob",
+ &s);
+ if (s.rc != CMPI_RC_OK) {
+ CU_DEBUG("Failed to create job path for update");
+ return;
+ }
+
+ CMAddKey(op, "InstanceID", (CMPIValue *)ctx->uuid, CMPI_chars);
+
+ inst = CBGetInstance(_BROKER, ctx->context, op, NULL, &s);
+ if ((inst == NULL) || (s.rc != CMPI_RC_OK)) {
+ CU_DEBUG("Failed to get job instance for update of %s",
+ ctx->uuid);
+ return;
+ }
+
+ CMSetProperty(inst, "JobState",
+ (CMPIValue *)&state, CMPI_uint16);
+ CMSetProperty(inst, "Status",
+ (CMPIValue *)status, CMPI_chars);
It would be good to also add the domain and save_path information to the
Job instance, e.g. as value of the property "Name".
+
+ s = CBModifyInstance(_BROKER, ctx->context, op, inst, NULL);
+ if (s.rc != CMPI_RC_OK) {
+ CU_DEBUG("Failed to update job instance %s: %s",
+ ctx->uuid,
+ CMGetCharPtr(s.msg));
+ return;
+ }
+
+ CU_DEBUG("Set %s status to %i:%s", ctx->uuid, state, status);
+}
+
Somehow I think that success and error scenarios are merged by this
function. Even if a snapshot request failed, the JobState has COMPLETE,
which is in general correct. But the client can only interpret the
Status property then, if the snapshot was created or not. The CIM_Job
mof tells to use ErrorCode and ErrorDescription. I think this is a good
way to communicate a snapshot failure.
--
Regards
Heidi Eckhart
Software Engineer
IBM Linux Technology Center - Open Hypervisor