Permalink
Browse files

Merge branch 'team/clc-dev/EUCA-4545' into testing

  • Loading branch information...
2 parents 49af680 + 7d29d82 commit 85e9403b73be0ff977b928309af1211a2424d68e @gelinasc gelinasc committed Apr 10, 2013
Showing with 27 additions and 25 deletions.
  1. +27 −25 cluster/handlers.c
View
@@ -739,7 +739,7 @@ int ncClientCall(ncMetadata * pMeta, int timeout, int ncLock, char *ncURL, char
rc = write(filedes[1], *outRes, sizeof(ncResource));
rc = 0;
} else {
- (*errMsg) = (char *) axutil_error_get_message(ncs->env->error);
+ (*errMsg) = (char *)axutil_error_get_message(ncs->env->error);
if (*errMsg && (len = strnlen(*errMsg, 1024 - 1))) {
len += 1;
rc = write(filedes[1], &rc, sizeof(int)); //NOTE: we write back rc as well
@@ -3648,32 +3648,38 @@ int doRunInstances(ncMetadata * pMeta, char *amiId, char *kernelId, char *ramdis
//!
int doGetConsoleOutput(ncMetadata * pMeta, char *instanceId, char **consoleOutput)
{
- int i, rc, numInsts, start, stop, done, ret = EUCA_OK, timeout = 0;
- ccInstance *myInstance;
- time_t op_start;
- ccResourceCache resourceCacheLocal;
+ int i = 0;
+ int rc = 0;
+ int numInsts = 0;
+ int start = 0;
+ int stop = 0;
+ int done = 0;
+ int ret = EUCA_OK;
+ int timeout = 0;
+ char *rawconsole = NULL;
+ char pwfile[MAX_PATH] = "";
+ time_t op_start = 0;
+ ccInstance *myInstance = NULL;
+ ccResourceCache resourceCacheLocal = { {{{0}}} };
- i = numInsts = 0;
op_start = time(NULL);
-
- myInstance = NULL;
-
*consoleOutput = NULL;
rc = initialize(pMeta);
if (rc || ccIsEnabled()) {
- return (1);
+ return (EUCA_ERROR);
}
LOGINFO("[%s] requesting console output\n", SP(instanceId));
LOGDEBUG("invoked: instId=%s\n", SP(instanceId));
sem_mywait(RESCACHE);
- memcpy(&resourceCacheLocal, resourceCache, sizeof(ccResourceCache));
+ {
+ memcpy(&resourceCacheLocal, resourceCache, sizeof(ccResourceCache));
+ }
sem_mypost(RESCACHE);
- rc = find_instanceCacheId(instanceId, &myInstance);
- if (!rc) {
+ if ((rc = find_instanceCacheId(instanceId, &myInstance)) == 0) {
// found the instance in the cache
start = myInstance->ncHostIdx;
stop = start + 1;
@@ -3683,51 +3689,47 @@ int doGetConsoleOutput(ncMetadata * pMeta, char *instanceId, char **consoleOutpu
stop = resourceCacheLocal.numResources;
}
- done = 0;
- for (i = start; i < stop && !done; i++) {
+ for (i = start, done = 0; ((i < stop) && !done); i++) {
EUCA_FREE(*consoleOutput);
// if not talking to Eucalyptus NC (but, e.g., a Broker)
if (!strstr(resourceCacheLocal.resources[i].ncURL, "EucalyptusNC")) {
- char pwfile[MAX_PATH];
*consoleOutput = NULL;
snprintf(pwfile, MAX_PATH, EUCALYPTUS_STATE_DIR "/windows/%s/console.append.log", config->eucahome, instanceId);
- char *rawconsole = NULL;
+ rawconsole = NULL;
if (!check_file(pwfile)) { // the console log file should exist for a Windows guest (with encrypted password in it)
rawconsole = file2str(pwfile);
} else { // the console log file will not exist for a Linux guest
rawconsole = strdup("not implemented");
}
+
if (rawconsole) {
- *consoleOutput = base64_enc((unsigned char *)rawconsole, strlen(rawconsole));
+ *consoleOutput = base64_enc(((u8 *) rawconsole), strlen(rawconsole));
EUCA_FREE(rawconsole);
}
// set the return code accordingly
- if (!*consoleOutput) {
+ if (*consoleOutput == NULL) {
rc = 1;
} else {
rc = 0;
}
done++; // quit on the first host, since they are not queried remotely
-
} else { // otherwise, we *are* talking to a Eucalyptus NC, so make the remote call
- timeout = ncGetTimeout(op_start, timeout, (stop - start), i);
+ timeout = ncGetTimeout(op_start, OP_TIMEOUT, (stop - start), i);
rc = ncClientCall(pMeta, timeout, resourceCacheLocal.resources[i].lockidx, resourceCacheLocal.resources[i].ncURL, "ncGetConsoleOutput", instanceId, consoleOutput);
}
if (rc) {
- ret = 1;
+ ret = EUCA_ERROR;
} else {
- ret = 0;
+ ret = EUCA_OK;
done++;
}
}
LOGTRACE("done\n");
-
shawn();
-
return (ret);
}

0 comments on commit 85e9403

Please sign in to comment.