static PromiseResult VerifyVirtDomain(EvalContext *ctx, char *uri, enum cfhypervisors envtype, Attributes a, const Promise *pp) { int num, i; /* set up the library error handler */ virSetErrorFunc(NULL, (void *) EnvironmentErrorHandler); if (CFVC[envtype] == NULL) { if ((CFVC[envtype] = virConnectOpenAuth(uri, virConnectAuthPtrDefault, 0)) == NULL) { Log(LOG_LEVEL_ERR, "Failed to connect to virtualization monitor '%s'", uri); return PROMISE_RESULT_NOOP; } } for (i = 0; i < CF_MAX_CONCURRENT_ENVIRONMENTS; i++) { CF_RUNNING[i] = -1; CF_SUSPENDED[i] = NULL; } num = virConnectListDomains(CFVC[envtype], CF_RUNNING, CF_MAX_CONCURRENT_ENVIRONMENTS); Log(LOG_LEVEL_VERBOSE, "Found %d running guest environments on this host (including enclosure)", num); ShowRunList(CFVC[envtype]); num = virConnectListDefinedDomains(CFVC[envtype], CF_SUSPENDED, CF_MAX_CONCURRENT_ENVIRONMENTS); Log(LOG_LEVEL_VERBOSE, "Found %d dormant guest environments on this host", num); ShowDormant(); PromiseResult result = PROMISE_RESULT_NOOP; switch (a.env.state) { case ENVIRONMENT_STATE_CREATE: result = PromiseResultUpdate(result, CreateVirtDom(ctx, CFVC[envtype], a, pp)); break; case ENVIRONMENT_STATE_DELETE: result = PromiseResultUpdate(result, DeleteVirt(ctx, CFVC[envtype], a, pp)); break; case ENVIRONMENT_STATE_RUNNING: result = PromiseResultUpdate(result, RunningVirt(ctx, CFVC[envtype], a, pp)); break; case ENVIRONMENT_STATE_SUSPENDED: result = PromiseResultUpdate(result, SuspendedVirt(ctx, CFVC[envtype], a, pp)); break; case ENVIRONMENT_STATE_DOWN: result = PromiseResultUpdate(result, DownVirt(ctx, CFVC[envtype], a, pp)); break; default: Log(LOG_LEVEL_INFO, "No state specified for this environment"); break; } return result; }
static void VerifyVirtDomain(char *uri, enum cfhypervisors envtype, Attributes a, Promise *pp) { int num, i; /* set up the library error handler */ virSetErrorFunc(NULL, (void *) EnvironmentErrorHandler); if (CFVC[envtype] == NULL) { if ((CFVC[envtype] = virConnectOpenAuth(uri, virConnectAuthPtrDefault, 0)) == NULL) { CfOut(cf_error, "", " !! Failed to connect to virtualization monitor \"%s\"", uri); return; } } for (i = 0; i < CF_MAX_CONCURRENT_ENVIRONMENTS; i++) { CF_RUNNING[i] = -1; CF_SUSPENDED[i] = NULL; } num = virConnectListDomains(CFVC[envtype], CF_RUNNING, CF_MAX_CONCURRENT_ENVIRONMENTS); CfOut(cf_verbose, "", " -> Found %d running guest environments on this host (including enclosure)", num); ShowRunList(CFVC[envtype]); num = virConnectListDefinedDomains(CFVC[envtype], CF_SUSPENDED, CF_MAX_CONCURRENT_ENVIRONMENTS); CfOut(cf_verbose, "", " -> Found %d dormant guest environments on this host", num); ShowDormant(CFVC[envtype]); switch (a.env.state) { case cfvs_create: CreateVirtDom(CFVC[envtype], uri, a, pp); break; case cfvs_delete: DeleteVirt(CFVC[envtype], uri, a, pp); break; case cfvs_running: RunningVirt(CFVC[envtype], uri, a, pp); break; case cfvs_suspended: SuspendedVirt(CFVC[envtype], uri, a, pp); break; case cfvs_down: DownVirt(CFVC[envtype], uri, a, pp); break; default: CfOut(cf_inform, "", " !! No state specified for this environment"); break; } }
static void VerifyVirtDomain(EvalContext *ctx, char *uri, enum cfhypervisors envtype, Attributes a, Promise *pp) { int num, i; /* set up the library error handler */ virSetErrorFunc(NULL, (void *) EnvironmentErrorHandler); if (CFVC[envtype] == NULL) { if ((CFVC[envtype] = virConnectOpenAuth(uri, virConnectAuthPtrDefault, 0)) == NULL) { CfOut(OUTPUT_LEVEL_ERROR, "", " !! Failed to connect to virtualization monitor \"%s\"", uri); return; } } for (i = 0; i < CF_MAX_CONCURRENT_ENVIRONMENTS; i++) { CF_RUNNING[i] = -1; CF_SUSPENDED[i] = NULL; } num = virConnectListDomains(CFVC[envtype], CF_RUNNING, CF_MAX_CONCURRENT_ENVIRONMENTS); CfOut(OUTPUT_LEVEL_VERBOSE, "", " -> Found %d running guest environments on this host (including enclosure)", num); ShowRunList(CFVC[envtype]); num = virConnectListDefinedDomains(CFVC[envtype], CF_SUSPENDED, CF_MAX_CONCURRENT_ENVIRONMENTS); CfOut(OUTPUT_LEVEL_VERBOSE, "", " -> Found %d dormant guest environments on this host", num); ShowDormant(); switch (a.env.state) { case ENVIRONMENT_STATE_CREATE: CreateVirtDom(ctx, CFVC[envtype], a, pp); break; case ENVIRONMENT_STATE_DELETE: DeleteVirt(ctx, CFVC[envtype], a, pp); break; case ENVIRONMENT_STATE_RUNNING: RunningVirt(ctx, CFVC[envtype], a, pp); break; case ENVIRONMENT_STATE_SUSPENDED: SuspendedVirt(ctx, CFVC[envtype], a, pp); break; case ENVIRONMENT_STATE_DOWN: DownVirt(ctx, CFVC[envtype], a, pp); break; default: CfOut(OUTPUT_LEVEL_INFORM, "", " !! No state specified for this environment"); break; } }