Пример #1
0
static
DWORD
_VMCAStopRestHandle(
    PVMREST_HANDLE    pHandle
    )
{
    DWORD dwError = 0;

    if (pHandle)
    {
        /*
         * REST library have detached threads, maximum time out specified is the max time
         * allowed for the threads to  finish their execution.
         * If finished early, it will return success.
         * If not able to finish in specified time, failure will be returned
         */
        dwError = VmRESTStop(pHandle, VMCA_REST_STOP_TIMEOUT_SEC);
        if (dwError != 0)
        {
            VMCA_LOG_WARNING(
                   "%s: Rest stop error: %d",
                   __FUNCTION__,
                   dwError);
        }
    }

    return dwError;
}
Пример #2
0
static
VOID
_VMCARestFreeHandle(
    PVMREST_HANDLE    pHandle
    )
{
    DWORD iter = 0;
    DWORD dwError = 0;
    DWORD endPointCnt = 0;

    if (pHandle)
    {
       /*
        * REST library have detached threads, maximum time out specified is the max time
        * allowed for the threads to  finish their execution.
        * If finished early, it will return success.
        * If not able to finish in specified time, failure will be returned
        */
       dwError = VmRESTStop(pHandle, VMCA_REST_STOP_TIMEOUT_SEC);

        if (dwError != 0)
        {
            VMCA_LOG_WARNING("%s: rest server stop error:%d", __FUNCTION__, dwError);
        }

        endPointCnt = ARRAY_SIZE(restEndPoints);
        for (iter = 0; iter < endPointCnt; iter++)
        {
            (VOID)VmRESTUnRegisterHandler(
                    pHandle,
                    restEndPoints[iter]);
        }
        VmRESTShutdown(pHandle);
    }
}
Пример #3
0
DWORD
VMCARestServerInit(
    VOID
    )
{
    DWORD dwError = 0;

    MODULE_REG_MAP stRegMap[] =
    {
        //{"endpoint", VMCARestFunctionModule},
        {NULL, NULL}
    };

    /*
     * We can use the same REST_API_SPEC for both HTTP and HTTPS
     * if the rest init code refers to common API definitions
     */
    dwError = coapi_load_from_file(REST_API_SPEC, &gpVMCARestApiDef);
    BAIL_ON_VMCA_ERROR(dwError);

    dwError = coapi_map_api_impl(gpVMCARestApiDef, stRegMap);
    BAIL_ON_VMCA_ERROR(dwError);

    dwError = VMCAOpensslInit();
    BAIL_ON_VMCA_ERROR(dwError);

    dwError = _VMCARestServerInitHTTPS();
    if (dwError != 0)
    {
        /*
         * Before promoting lightwave node, obtaining cert from VECS will fail which is expected
         * hence treat it as soft fail
         */
         VMCA_LOG_WARNING(
                 "VmRESTServerInit: HTTPS port init failed with error %d, (failure is expected before promote)",
                 dwError);
         dwError = 0;
    }

cleanup:
    return dwError;

error:
    if (VMCARestServerStop() == 0)
    {
        VMCARestServerShutdown();
    }
    VMCA_LOG_ERROR(
            "%s failed, error (%d)",
            __FUNCTION__,
            dwError);

    goto cleanup;
}