static PromiseResult VerifyVirtNetwork(EvalContext *ctx, char *uri, enum cfhypervisors envtype, Attributes a, const Promise *pp) { int num, i; char *networks[CF_MAX_CONCURRENT_ENVIRONMENTS]; 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++) { networks[i] = NULL; } num = virConnectListNetworks(CFVC[envtype], networks, CF_MAX_CONCURRENT_ENVIRONMENTS); Log(LOG_LEVEL_VERBOSE, "Detected %d active networks", num); PromiseResult result = PROMISE_RESULT_NOOP; switch (a.env.state) { case ENVIRONMENT_STATE_CREATE: result = PromiseResultUpdate(result, CreateVirtNetwork(ctx, CFVC[envtype], networks, a, pp)); break; case ENVIRONMENT_STATE_DELETE: result = PromiseResultUpdate(result, DeleteVirtNetwork(ctx, CFVC[envtype], a, pp)); break; default: Log(LOG_LEVEL_INFO, "No recognized state specified for this network environment"); break; } return result; }
static void VerifyVirtNetwork(char *uri, enum cfhypervisors envtype, Attributes a, Promise *pp) { int num, i; char *networks[CF_MAX_CONCURRENT_ENVIRONMENTS]; 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++) { networks[i] = NULL; } num = virConnectListNetworks(CFVC[envtype], networks, CF_MAX_CONCURRENT_ENVIRONMENTS); CfOut(cf_verbose, "", " -> Detected %d active networks", num); switch (a.env.state) { case cfvs_create: CreateVirtNetwork(CFVC[envtype], networks, a, pp); break; case cfvs_delete: DeleteVirtNetwork(CFVC[envtype], networks, a, pp); break; default: CfOut(cf_inform, "", " !! No recogized state specified for this network environment"); break; } }
static void VerifyVirtNetwork(EvalContext *ctx, char *uri, enum cfhypervisors envtype, Attributes a, Promise *pp) { int num, i; char *networks[CF_MAX_CONCURRENT_ENVIRONMENTS]; 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++) { networks[i] = NULL; } num = virConnectListNetworks(CFVC[envtype], networks, CF_MAX_CONCURRENT_ENVIRONMENTS); CfOut(OUTPUT_LEVEL_VERBOSE, "", " -> Detected %d active networks", num); switch (a.env.state) { case ENVIRONMENT_STATE_CREATE: CreateVirtNetwork(ctx, CFVC[envtype], networks, a, pp); break; case ENVIRONMENT_STATE_DELETE: DeleteVirtNetwork(ctx, CFVC[envtype], a, pp); break; default: CfOut(OUTPUT_LEVEL_INFORM, "", " !! No recogized state specified for this network environment"); break; } }