本文整理汇总了C++中PromiseResultUpdate函数的典型用法代码示例。如果您正苦于以下问题:C++ PromiseResultUpdate函数的具体用法?C++ PromiseResultUpdate怎么用?C++ PromiseResultUpdate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PromiseResultUpdate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: MakeHardLink
bool MakeHardLink(EvalContext *ctx, const char *from, const char *to, Attributes attr, const Promise *pp,
PromiseResult *result)
{
if (DONTDO)
{
Log(LOG_LEVEL_ERR, "Need to hard link files '%s' -> '%s'", from, to);
return false;
}
else
{
if (link(to, from) == -1)
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, attr, "Couldn't hard link '%s' to '%s'. (link: %s)",
to, from, GetErrorStr());
*result = PromiseResultUpdate(*result, PROMISE_RESULT_FAIL);
return false;
}
else
{
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, attr, "Hard linked files '%s' -> '%s'", from, to);
*result = PromiseResultUpdate(*result, PROMISE_RESULT_CHANGE);
return true;
}
}
}
开发者ID:maciejmrowiec,项目名称:core,代码行数:25,代码来源:files_links.c
示例2: VerifyServices
static PromiseResult VerifyServices(EvalContext *ctx, Attributes a, const Promise *pp)
{
CfLock thislock;
thislock = AcquireLock(ctx, pp->promiser, VUQNAME, CFSTARTTIME, a.transaction, pp, false);
if (thislock.lock == NULL)
{
return PROMISE_RESULT_SKIPPED;
}
PromiseBanner(ctx, pp);
PromiseResult result = PROMISE_RESULT_SKIPPED;
if (strcmp(a.service.service_type, "windows") == 0)
{
#ifdef __MINGW32__
result = PromiseResultUpdate(result, VerifyWindowsService(ctx, a, pp));
#else
Log(LOG_LEVEL_INFO, "Service type windows not supported on this platform.");
#endif
}
else
{
result = PromiseResultUpdate(result, DoVerifyServices(ctx, a, pp));
}
YieldCurrentLock(thislock);
return result;
}
开发者ID:maciejmrowiec,项目名称:core,代码行数:30,代码来源:verify_services.c
示例3: MakeLink
static bool MakeLink(EvalContext *ctx, const char *from, const char *to, Attributes attr, const Promise *pp,
PromiseResult *result)
{
if (DONTDO || (attr.transaction.action == cfa_warn))
{
Log(LOG_LEVEL_WARNING, "Need to link files '%s' -> '%s'", from, to);
return false;
}
else
{
if (symlink(to, from) == -1)
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, attr, "Couldn't link '%s' to '%s'. (symlink: %s)",
to, from, GetErrorStr());
*result = PromiseResultUpdate(*result, PROMISE_RESULT_FAIL);
return false;
}
else
{
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, attr, "Linked files '%s' -> '%s'", from, to);
*result = PromiseResultUpdate(*result, PROMISE_RESULT_CHANGE);
return true;
}
}
}
开发者ID:maciejmrowiec,项目名称:core,代码行数:25,代码来源:files_links.c
示例4: DeleteVirtNetwork
static PromiseResult DeleteVirtNetwork(EvalContext *ctx, virConnectPtr vc, Attributes a, const Promise *pp)
{
virNetworkPtr network;
if ((network = virNetworkLookupByName(vc, pp->promiser)) == NULL)
{
cfPS(ctx, LOG_LEVEL_VERBOSE, PROMISE_RESULT_NOOP, pp, a, "Couldn't find a network called '%s' - promise assumed kept",
pp->promiser);
return PROMISE_RESULT_NOOP;
}
PromiseResult result = PROMISE_RESULT_NOOP;
if (virNetworkDestroy(network) == 0)
{
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, a, "Deleted network '%s' - promise repaired", pp->promiser);
result = PromiseResultUpdate(result, PROMISE_RESULT_CHANGE);
}
else
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Network deletion of '%s' failed", pp->promiser);
result = PromiseResultUpdate(result, PROMISE_RESULT_FAIL);
}
virNetworkFree(network);
return result;
}
开发者ID:atsaloli,项目名称:core,代码行数:26,代码来源:verify_environments.c
示例5: DeleteVirt
static PromiseResult DeleteVirt(EvalContext *ctx, virConnectPtr vc, Attributes a, const Promise *pp)
{
virDomainPtr dom;
dom = virDomainLookupByName(vc, pp->promiser);
PromiseResult result = PROMISE_RESULT_NOOP;
if (dom)
{
if (virDomainDestroy(dom) == -1)
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Failed to delete virtual domain '%s'", pp->promiser);
result = PromiseResultUpdate(result, PROMISE_RESULT_FAIL);
}
else
{
cfPS(ctx, LOG_LEVEL_VERBOSE, PROMISE_RESULT_CHANGE, pp, a, "Deleted virtual domain '%s'", pp->promiser);
result = PromiseResultUpdate(result, PROMISE_RESULT_CHANGE);
}
virDomainFree(dom);
}
else
{
cfPS(ctx, LOG_LEVEL_VERBOSE, PROMISE_RESULT_NOOP, pp, a, "No such virtual domain called '%s' - promise kept", pp->promiser);
}
return result;
}
开发者ID:atsaloli,项目名称:core,代码行数:29,代码来源:verify_environments.c
示例6: VerifyServices
static PromiseResult VerifyServices(EvalContext *ctx, Attributes a, Promise *pp)
{
CfLock thislock;
thislock = AcquireLock(ctx, pp->promiser, VUQNAME, CFSTARTTIME, a.transaction, pp, false);
if (thislock.lock == NULL)
{
return PROMISE_RESULT_SKIPPED;
}
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, "promiser", pp->promiser, DATA_TYPE_STRING, "goal=state,source=promise");
PromiseBanner(pp);
PromiseResult result = PROMISE_RESULT_NOOP;
if (strcmp(a.service.service_type, "windows") == 0)
{
result = PromiseResultUpdate(result, VerifyWindowsService(ctx, a, pp));
}
else
{
result = PromiseResultUpdate(result, DoVerifyServices(ctx, a, pp));
}
EvalContextVariableRemoveSpecial(ctx, SPECIAL_SCOPE_THIS, "promiser");
YieldCurrentLock(thislock);
return result;
}
开发者ID:dardevelin,项目名称:core-1,代码行数:28,代码来源:verify_services.c
示例7: VerifyServices
static PromiseResult VerifyServices(EvalContext *ctx, Attributes a, const Promise *pp)
{
CfLock thislock;
thislock = AcquireLock(ctx, pp->promiser, VUQNAME, CFSTARTTIME, a.transaction, pp, false);
if (thislock.lock == NULL)
{
return PROMISE_RESULT_SKIPPED;
}
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, "promiser", pp->promiser, CF_DATA_TYPE_STRING, "source=promise");
PromiseBanner(pp);
PromiseResult result = PROMISE_RESULT_NOOP;
if (strcmp(a.service.service_type, "windows") == 0)
{
#ifdef __MINGW32__
result = PromiseResultUpdate(result, VerifyWindowsService(ctx, a, pp));
#else
Log(LOG_LEVEL_INFO, "Service type windows not supported on this platform.");
#endif
}
else
{
result = PromiseResultUpdate(result, DoVerifyServices(ctx, a, pp));
}
EvalContextVariableRemoveSpecial(ctx, SPECIAL_SCOPE_THIS, "promiser");
YieldCurrentLock(thislock);
return result;
}
开发者ID:cfengineers-net,项目名称:core,代码行数:32,代码来源:verify_services.c
示例8: DoAllSignals
int DoAllSignals(EvalContext *ctx, Item *siglist, Attributes a, const Promise *pp, PromiseResult *result)
{
Item *ip;
Rlist *rp;
pid_t pid;
int killed = false;
if (siglist == NULL)
{
return 0;
}
if (a.signals == NULL)
{
Log(LOG_LEVEL_VERBOSE, "No signals to send for '%s'", pp->promiser);
return 0;
}
for (ip = siglist; ip != NULL; ip = ip->next)
{
pid = ip->counter;
for (rp = a.signals; rp != NULL; rp = rp->next)
{
int signal = SignalFromString(RlistScalarValue(rp));
if (!DONTDO)
{
if ((signal == SIGKILL) || (signal == SIGTERM))
{
killed = true;
}
if (kill((pid_t) pid, signal) < 0)
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a,
"Couldn't send promised signal '%s' (%d) to pid %jd (might be dead). (kill: %s)", RlistScalarValue(rp),
signal, (intmax_t)pid, GetErrorStr());
*result = PromiseResultUpdate(*result, PROMISE_RESULT_FAIL);
}
else
{
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, a, "Signalled '%s' (%d) to process %jd (%s)",
RlistScalarValue(rp), signal, (intmax_t)pid, ip->name);
*result = PromiseResultUpdate(*result, PROMISE_RESULT_CHANGE);
}
}
else
{
Log(LOG_LEVEL_ERR, "Need to keep signal promise '%s' in process entry '%s'",
RlistScalarValue(rp), ip->name);
}
}
}
return killed;
}
开发者ID:awsiv,项目名称:core,代码行数:57,代码来源:verify_processes.c
示例9: ExpandPromiseAndDo
static PromiseResult ExpandPromiseAndDo(EvalContext *ctx, PromiseIterator *iterctx,
PromiseActuator *act_on_promise, void *param)
{
PromiseResult result = PROMISE_RESULT_SKIPPED;
/* TODO this loop could be completely skipped for for non vars/classes if
* act_on_promise is CommonEvalPromise(). */
while (PromiseIteratorNext(iterctx, ctx))
{
/*
* ACTUAL WORK PART 1: Get a (another) copy of the promise.
*
* Basically this evaluates all constraints. As a result it evaluates
* all functions, even if they are not to be used immediately (for
* example promises that the actuator skips because of ifvarclass).
*/
const Promise *pexp = /* expanded promise */
EvalContextStackPushPromiseIterationFrame(ctx, iterctx);
if (pexp == NULL) /* is the promise excluded? */
{
result = PromiseResultUpdate(result, PROMISE_RESULT_SKIPPED);
continue;
}
/* ACTUAL WORK PART 2: run the actuator */
PromiseResult iteration_result = act_on_promise(ctx, pexp, param);
/* iteration_result is always NOOP for PRE-EVAL. */
result = PromiseResultUpdate(result, iteration_result);
/* Redmine#6484: Do not store promise handles during PRE-EVAL, to
* avoid package promise always running. */
if (act_on_promise != &CommonEvalPromise)
{
NotifyDependantPromises(ctx, pexp, iteration_result);
}
/* EVALUATE VARS PROMISES again, allowing redefinition of
* variables. The theory behind this is that the "sampling rate" of
* vars promise needs to be double than the rest. */
if (strcmp(pexp->parent_promise_type->name, "vars") == 0 ||
strcmp(pexp->parent_promise_type->name, "meta") == 0)
{
if (act_on_promise != &VerifyVarPromise)
{
VerifyVarPromise(ctx, pexp, NULL);
}
}
/* Why do we push/pop an iteration frame, if all iterated variables
* are Put() on the previous scope? */
EvalContextStackPopFrame(ctx);
}
return result;
}
开发者ID:kkaempf,项目名称:core,代码行数:56,代码来源:expand.c
示例10: DoVerifyServices
static PromiseResult DoVerifyServices(EvalContext *ctx, Attributes a, const Promise *pp)
{
FnCall *service_bundle = PromiseGetConstraintAsRval(pp, "service_bundle", RVAL_TYPE_FNCALL);
PromiseResult result = PROMISE_RESULT_NOOP;
if (!service_bundle)
{
service_bundle = PromiseGetConstraintAsRval(pp, "service_bundle", RVAL_TYPE_SCALAR);
}
if (!service_bundle)
{
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_FAIL, pp, a, "Service '%s' cannot be resolved as a bundle", pp->promiser);
return PromiseResultUpdate(result, PROMISE_RESULT_FAIL);
}
switch (a.service.service_policy)
{
case SERVICE_POLICY_START:
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, "service_policy", "start", CF_DATA_TYPE_STRING, "source=promise");
break;
case SERVICE_POLICY_RESTART:
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, "service_policy", "restart", CF_DATA_TYPE_STRING, "source=promise");
break;
case SERVICE_POLICY_RELOAD:
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, "service_policy", "reload", CF_DATA_TYPE_STRING, "source=promise");
break;
case SERVICE_POLICY_STOP:
case SERVICE_POLICY_DISABLE:
default:
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, "service_policy", "stop", CF_DATA_TYPE_STRING, "source=promise");
break;
}
const Bundle *bp = PolicyGetBundle(PolicyFromPromise(pp), NULL, "agent", service_bundle->name);
if (!bp)
{
bp = PolicyGetBundle(PolicyFromPromise(pp), NULL, "common", service_bundle->name);
}
if (!bp)
{
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_FAIL, pp, a, "Service '%s' could not be invoked successfully", pp->promiser);
result = PromiseResultUpdate(result, PROMISE_RESULT_FAIL);
}
if (!DONTDO)
{
result = PromiseResultUpdate(result, VerifyMethod(ctx, "service_bundle", a, pp)); // Send list of classes to set privately?
}
return result;
}
开发者ID:ajlill,项目名称:core,代码行数:55,代码来源:verify_services.c
示例11: VerifyVirtDomain
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;
}
开发者ID:atsaloli,项目名称:core,代码行数:54,代码来源:verify_environments.c
示例12: ExpandPromiseAndDo
static PromiseResult ExpandPromiseAndDo(EvalContext *ctx, const Promise *pp,
Rlist *lists, Rlist *containers,
PromiseActuator *ActOnPromise, void *param)
{
const char *handle = PromiseGetHandle(pp);
EvalContextStackPushPromiseFrame(ctx, pp, true);
PromiseIterator *iter_ctx = NULL;
size_t i = 0;
PromiseResult result = PROMISE_RESULT_NOOP;
Buffer *expbuf = BufferNew();
for (iter_ctx = PromiseIteratorNew(ctx, pp, lists, containers); PromiseIteratorHasMore(iter_ctx); i++, PromiseIteratorNext(iter_ctx))
{
if (handle)
{
// This ordering is necessary to get automated canonification
BufferClear(expbuf);
ExpandScalar(ctx, NULL, "this", handle, expbuf);
CanonifyNameInPlace(BufferGet(expbuf));
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, "handle", BufferData(expbuf), CF_DATA_TYPE_STRING, "source=promise");
}
else
{
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, "handle", PromiseID(pp), CF_DATA_TYPE_STRING, "source=promise");
}
const Promise *pexp = EvalContextStackPushPromiseIterationFrame(ctx, i, iter_ctx);
if (!pexp)
{
// excluded
result = PromiseResultUpdate(result, PROMISE_RESULT_SKIPPED);
continue;
}
PromiseResult iteration_result = ActOnPromise(ctx, pexp, param);
NotifyDependantPromises(ctx, pexp, iteration_result);
result = PromiseResultUpdate(result, iteration_result);
if (strcmp(pp->parent_promise_type->name, "vars") == 0 || strcmp(pp->parent_promise_type->name, "meta") == 0)
{
VerifyVarPromise(ctx, pexp, true);
}
EvalContextStackPopFrame(ctx);
}
BufferDestroy(expbuf);
PromiseIteratorDestroy(iter_ctx);
EvalContextStackPopFrame(ctx);
return result;
}
开发者ID:awsiv,项目名称:core,代码行数:54,代码来源:expand.c
示例13: VerifyExecPromise
PromiseResult VerifyExecPromise(EvalContext *ctx, const Promise *pp)
{
Attributes a = GetExecAttributes(ctx, pp);
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, "promiser", pp->promiser, DATA_TYPE_STRING, "source=promise");
if (!SyntaxCheckExec(a, pp))
{
EvalContextVariableRemoveSpecial(ctx, SPECIAL_SCOPE_THIS, "promiser");
return PROMISE_RESULT_FAIL;
}
if (PromiseKeptExec(a, pp))
{
EvalContextVariableRemoveSpecial(ctx, SPECIAL_SCOPE_THIS, "promiser");
return PROMISE_RESULT_NOOP;
}
char *lock_name = GetLockNameExec(a, pp);
CfLock thislock = AcquireLock(ctx, lock_name, VUQNAME, CFSTARTTIME, a.transaction, pp, false);
free(lock_name);
if (thislock.lock == NULL)
{
EvalContextVariableRemoveSpecial(ctx, SPECIAL_SCOPE_THIS, "promiser");
return PROMISE_RESULT_SKIPPED;
}
PromiseBanner(pp);
PromiseResult result = PROMISE_RESULT_NOOP;
switch (RepairExec(ctx, a, pp, &result))
{
case ACTION_RESULT_OK:
result = PromiseResultUpdate(result, PROMISE_RESULT_CHANGE);
break;
case ACTION_RESULT_TIMEOUT:
result = PromiseResultUpdate(result, PROMISE_RESULT_TIMEOUT);
break;
case ACTION_RESULT_FAILED:
result = PromiseResultUpdate(result, PROMISE_RESULT_FAIL);
break;
default:
ProgrammingError("Unexpected ActionResult value");
}
YieldCurrentLock(thislock);
EvalContextVariableRemoveSpecial(ctx, SPECIAL_SCOPE_THIS, "promiser");
return result;
}
开发者ID:tzz,项目名称:core,代码行数:53,代码来源:verify_exec.c
示例14: VerifyUnmount
PromiseResult VerifyUnmount(EvalContext *ctx, char *name, const Attributes *a, const Promise *pp)
{
char comm[CF_BUFSIZE];
FILE *pfp;
char *mountpt;
mountpt = name;
PromiseResult result = PROMISE_RESULT_NOOP;
if (!DONTDO)
{
snprintf(comm, CF_BUFSIZE, "%s %s", VUNMOUNTCOMM[VSYSTEMHARDCLASS], mountpt);
if ((pfp = cf_popen(comm, "r", true)) == NULL)
{
Log(LOG_LEVEL_ERR, "Failed to open pipe from %s", VUNMOUNTCOMM[VSYSTEMHARDCLASS]);
return result;
}
size_t line_size = CF_BUFSIZE;
char *line = xmalloc(line_size);
ssize_t res = CfReadLine(&line, &line_size, pfp);
if (res == -1)
{
cf_pclose(pfp);
free(line);
if (!feof(pfp))
{
Log(LOG_LEVEL_ERR, "Unable to read output of unmount command. (fread: %s)", GetErrorStr());
return result;
}
}
else if (res > 0 && ((strstr(line, "busy")) || (strstr(line, "Busy"))))
{
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_INTERRUPTED, pp, a, "The device under '%s' cannot be unmounted", mountpt);
result = PromiseResultUpdate(result, PROMISE_RESULT_INTERRUPTED);
cf_pclose(pfp);
free(line);
return result;
}
}
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, a, "Unmounting '%s' to keep promise", mountpt);
result = PromiseResultUpdate(result, PROMISE_RESULT_CHANGE);
return result;
}
开发者ID:basvandervlies,项目名称:core,代码行数:48,代码来源:nfs.c
示例15: RunCmpCommand
static VersionCmpResult RunCmpCommand(EvalContext *ctx, const char *command, const char *v1, const char *v2, Attributes a,
const Promise *pp, PromiseResult *result)
{
Buffer *expanded_command = BufferNew();
{
VarRef *ref_v1 = VarRefParseFromScope("v1", PACKAGES_CONTEXT);
EvalContextVariablePut(ctx, ref_v1, v1, CF_DATA_TYPE_STRING, "source=promise");
VarRef *ref_v2 = VarRefParseFromScope("v2", PACKAGES_CONTEXT);
EvalContextVariablePut(ctx, ref_v2, v2, CF_DATA_TYPE_STRING, "source=promise");
ExpandScalar(ctx, NULL, PACKAGES_CONTEXT, command, expanded_command);
EvalContextVariableRemove(ctx, ref_v1);
VarRefDestroy(ref_v1);
EvalContextVariableRemove(ctx, ref_v2);
VarRefDestroy(ref_v2);
}
FILE *pfp = a.packages.package_commands_useshell ? cf_popen_sh(BufferData(expanded_command), "w") : cf_popen(BufferData(expanded_command), "w", true);
if (pfp == NULL)
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Can not start package version comparison command '%s'. (cf_popen: %s)",
BufferData(expanded_command), GetErrorStr());
*result = PromiseResultUpdate(*result, PROMISE_RESULT_FAIL);
BufferDestroy(expanded_command);
return VERCMP_ERROR;
}
Log(LOG_LEVEL_VERBOSE, "Executing '%s'", BufferData(expanded_command));
int retcode = cf_pclose(pfp);
if (retcode == -1)
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Error during package version comparison command execution '%s'. (cf_pclose: %s)",
BufferData(expanded_command), GetErrorStr());
*result = PromiseResultUpdate(*result, PROMISE_RESULT_FAIL);
BufferDestroy(expanded_command);
return VERCMP_ERROR;
}
BufferDestroy(expanded_command);
return retcode == 0;
}
开发者ID:ddurieux,项目名称:core,代码行数:48,代码来源:vercmp.c
示例16: DoVerifyServices
static PromiseResult DoVerifyServices(EvalContext *ctx, Attributes a, const Promise *pp)
{
Rval call;
{
const Constraint *cp = PromiseGetConstraint(pp, "service_bundle");
if (cp)
{
call = RvalCopy(cp->rval);
}
else
{
call = (Rval) { DefaultServiceBundleCall(pp, a.service.service_policy), RVAL_TYPE_FNCALL };
}
}
a.havebundle = true;
EvalContextVariablePutSpecial(ctx, SPECIAL_SCOPE_THIS, "service_policy", a.service.service_policy, CF_DATA_TYPE_STRING, "source=promise");
PromiseResult result = PROMISE_RESULT_NOOP;
result = PromiseResultUpdate(result, VerifyMethod(ctx, call, a, pp)); // Send list of classes to set privately?
RvalDestroy(call);
return result;
}
开发者ID:maciejmrowiec,项目名称:core,代码行数:25,代码来源:verify_services.c
示例17: KillGhostLink
bool KillGhostLink(EvalContext *ctx, const char *name, Attributes attr, const Promise *pp, PromiseResult *result)
{
Log(LOG_LEVEL_VERBOSE, "Windows does not support symbolic links (at KillGhostLink())");
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, attr, "Windows does not support killing link '%s'", name);
PromiseResultUpdate(*result, PROMISE_RESULT_FAIL);
return false;
}
开发者ID:maciejmrowiec,项目名称:core,代码行数:7,代码来源:files_links.c
示例18: CreateVirtNetwork
static PromiseResult CreateVirtNetwork(EvalContext *ctx, virConnectPtr vc, char **networks, Attributes a, const Promise *pp)
{
virNetworkPtr network;
char *xml_file;
char defaultxml[CF_MAXVARSIZE];
int i, found = false;
snprintf(defaultxml, CF_MAXVARSIZE - 1,
"<network>"
"<name>%s</name>"
"<bridge name=\"virbr0\" />"
"<forward mode=\"nat\"/>"
"<ip address=\"192.168.122.1\" netmask=\"255.255.255.0\">"
"<dhcp>"
"<range start=\"192.168.122.2\" end=\"192.168.122.254\" />" "</dhcp>" "</ip>" "</network>", pp->promiser);
for (i = 0; networks[i] != NULL; i++)
{
Log(LOG_LEVEL_VERBOSE, "Discovered a running network '%s'", networks[i]);
if (strcmp(networks[i], pp->promiser) == 0)
{
found = true;
}
}
if (found)
{
cfPS(ctx, LOG_LEVEL_VERBOSE, PROMISE_RESULT_NOOP, pp, a, "Network '%s' exists - promise kept", pp->promiser);
return PROMISE_RESULT_NOOP;
}
if (a.env.spec)
{
xml_file = xstrdup(a.env.spec);
}
else
{
xml_file = xstrdup(defaultxml);
}
PromiseResult result = PROMISE_RESULT_NOOP;
if ((network = virNetworkCreateXML(vc, xml_file)) == NULL)
{
cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Unable to create network '%s'", pp->promiser);
free(xml_file);
return PROMISE_RESULT_FAIL;
}
else
{
cfPS(ctx, LOG_LEVEL_INFO, PROMISE_RESULT_CHANGE, pp, a, "Created network '%s' - promise repaired", pp->promiser);
result = PromiseResultUpdate(result, PROMISE_RESULT_CHANGE);
}
free(xml_file);
virNetworkFree(network);
return result;
}
开发者ID:atsaloli,项目名称:core,代码行数:59,代码来源:verify_environments.c
示例19: FindFilePromiserObjects
static PromiseResult FindFilePromiserObjects(EvalContext *ctx, const Promise *pp)
{
char *val = PromiseGetConstraintAsRval(pp, "pathtype", RVAL_TYPE_SCALAR);
int literal = (PromiseGetConstraintAsBoolean(ctx, "copy_from", pp)) || ((val != NULL) && (strcmp(val, "literal") == 0));
/* Check if we are searching over a regular expression */
PromiseResult result = PROMISE_RESULT_SKIPPED;
if (literal)
{
// Prime the promiser temporarily, may override later
result = PromiseResultUpdate(result, VerifyFilePromise(ctx, pp->promiser, pp));
}
else // Default is to expand regex paths
{
result = PromiseResultUpdate(result, LocateFilePromiserGroup(ctx, pp->promiser, pp, VerifyFilePromise));
}
return result;
}
开发者ID:lra,项目名称:core,代码行数:20,代码来源:verify_files.c
示例20: VerifyVirtNetwork
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;
}
开发者ID:atsaloli,项目名称:core,代码行数:41,代码来源:verify_environments.c
注:本文中的PromiseResultUpdate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论