Пример #1
0
adb_ncDescribeInstancesResponse_t* ncDescribeInstancesMarshal (adb_ncDescribeInstances_t* ncDescribeInstances, const axutil_env_t *env)
{
    pthread_mutex_lock(&ncHandlerLock);
    adb_ncDescribeInstancesType_t * input          = adb_ncDescribeInstances_get_ncDescribeInstances(ncDescribeInstances, env);
    adb_ncDescribeInstancesResponse_t * response   = adb_ncDescribeInstancesResponse_create(env);
    adb_ncDescribeInstancesResponseType_t * output = adb_ncDescribeInstancesResponseType_create(env);

    // get standard fields from input
    axis2_char_t * correlationId = adb_ncDescribeInstancesType_get_correlationId(input, env);
    axis2_char_t * userId = adb_ncDescribeInstancesType_get_userId(input, env);

    // get operation-specific fields from input
    int instIdsLen = adb_ncDescribeInstancesType_sizeof_instanceIds(input, env);
    char ** instIds = malloc(sizeof(char *) * instIdsLen);
    if (instIds==NULL) {
        logprintfl (EUCAERROR, "ERROR: out of memory in ncDescribeInstancesMarshal()\n");
        adb_ncDescribeInstancesResponseType_set_return(output, env, AXIS2_FALSE);

    } else {
        int i;
        for (i=0; i<instIdsLen; i++) {
            instIds[i] = adb_ncDescribeInstancesType_get_instanceIds_at(input, env, i);
        }

        eventlog("NC", userId, correlationId, "DescribeInstances", "begin");
        { // do it
            ncMetadata meta = { correlationId, userId };
            ncInstance **outInsts;
            int outInstsLen;

            int error = doDescribeInstances (&meta, instIds, instIdsLen, &outInsts, &outInstsLen);
                                             
            if (error) {
                logprintfl (EUCAERROR, "ERROR: doDescribeInstances() failed error=%d\n", error);
                adb_ncDescribeInstancesResponseType_set_return(output, env, AXIS2_FALSE);
                
            } else {
                // set standard fields in output
                adb_ncDescribeInstancesResponseType_set_return(output, env, AXIS2_TRUE);
                adb_ncDescribeInstancesResponseType_set_correlationId(output, env, correlationId);
                adb_ncDescribeInstancesResponseType_set_userId(output, env, userId);

                // set operation-specific fields in output
                for (i=0; i<outInstsLen; i++) {
                    adb_instanceType_t * instance = adb_instanceType_create(env);
                    copy_instance_to_adb (instance, env, outInsts[i]); // copy all values outInst->instance
                    if (outInsts[i])
                        free(outInsts[i]);

                    /* TODO: should we free_instance(&outInst) here or not? currently you only have to free outInsts[] */
                    adb_ncDescribeInstancesResponseType_add_instances(output, env, instance);
                }

            
                if (outInstsLen)
                    free ( outInsts );
            }
        }
        eventlog("NC", userId, correlationId, "DescribeInstances", "end");
    }
    
    // set response to output
    adb_ncDescribeInstancesResponse_set_ncDescribeInstancesResponse(response, env, output);
    pthread_mutex_unlock(&ncHandlerLock);
    return response;
}
Пример #2
0
//!
//! Handles the client describe instance request.
//!
//! @param[in]  pStub a pointer to the node controller (NC) stub structure
//! @param[in]  pMeta a pointer to the node controller (NC) metadata structure
//! @param[in]  instIds a pointer the list of instance identifiers to retrieve data for
//! @param[in]  instIdsLen the number of instance identifiers in the instIds list
//! @param[out] outInsts a pointer the list of instances for which we have data
//! @param[out] outInstsLen the number of instances in the outInsts list.
//!
//! @return the result of doDescribeInstances()
//!
//! @see doDescribeInstances()
//!
int ncDescribeInstancesStub(ncStub * pStub, ncMetadata * pMeta, char **instIds, int instIdsLen, ncInstance *** outInsts, int *outInstsLen)
{
    return doDescribeInstances(pMeta, instIds, instIdsLen, outInsts, outInstsLen);
}
Пример #3
0
adb_DescribeInstancesResponse_t *DescribeInstancesMarshal(adb_DescribeInstances_t *describeInstances, const axutil_env_t *env) {
    // output vars
  adb_DescribeInstancesResponse_t *ret=NULL;
  adb_describeInstancesResponseType_t *dirt=NULL;
  
  // input vars
  adb_describeInstancesType_t *dit=NULL;
  
  // working vars
  adb_ccInstanceType_t *it=NULL;
  char **instIds=NULL;
  int instIdsLen, outInstsLen, i, rc;
  axis2_bool_t status=AXIS2_TRUE;
  char statusMessage[256];

  ccInstance *outInsts=NULL, *myInstance=NULL;
  ncMetadata ccMeta;
  
  dit = adb_DescribeInstances_get_DescribeInstances(describeInstances, env);
  EUCA_MESSAGE_UNMARSHAL(describeInstancesType, dit, (&ccMeta));

  instIdsLen = adb_describeInstancesType_sizeof_instanceIds(dit, env);
  instIds = malloc(sizeof(char *) * instIdsLen);
  
  for (i=0; i<instIdsLen; i++) {
    instIds[i] = adb_describeInstancesType_get_instanceIds_at(dit, env, i);
  }

  dirt = adb_describeInstancesResponseType_create(env);

  rc=1;
  if (!DONOTHING) {
    rc = doDescribeInstances(&ccMeta, instIds, instIdsLen, &outInsts, &outInstsLen);
  }
  
  if (instIds) free(instIds);
  if (rc) {
    logprintf("ERROR: doDescribeInstances() failed %d\n", rc);
    status = AXIS2_FALSE;
    snprintf(statusMessage, 255, "ERROR");

  } else {
    for (i=0; i<outInstsLen; i++) {
      myInstance = &(outInsts[i]);
      
      it = adb_ccInstanceType_create(env);
  
      //      myInstance->ccvm.virtualBootRecordLen = 0;
      rc = ccInstanceUnmarshal(it, myInstance, env);
      adb_describeInstancesResponseType_add_instances(dirt, env, it);
    }
    if (outInsts) free(outInsts);
  }

  adb_describeInstancesResponseType_set_correlationId(dirt, env, ccMeta.correlationId);
  adb_describeInstancesResponseType_set_userId(dirt, env, ccMeta.userId);
  adb_describeInstancesResponseType_set_return(dirt, env, status);
  if (status == AXIS2_FALSE) {
    adb_describeInstancesResponseType_set_statusMessage(dirt, env, statusMessage);
  }
  
  ret = adb_DescribeInstancesResponse_create(env);
  adb_DescribeInstancesResponse_set_DescribeInstancesResponse(ret, env, dirt);
  
  return(ret);
}