Example #1
0
static
DWORD
VmAfdCliLeaveVmDir(
    PVM_AFD_CLI_CONTEXT pContext
    )
{
    DWORD dwError = 0;
    PSTR pszAccount = NULL;
    PSTR pszPassword = NULL;

    if (!pContext)
    {
        dwError = ERROR_INVALID_PARAMETER;
        BAIL_ON_VMAFD_ERROR(dwError);
    }

    if (!pContext->pszUserName || !pContext->pszPassword)
    {
        dwError = VmAfdGetMachineAccountInfoA(NULL, &pszAccount, &pszPassword);
    } else
    {
        dwError = VmAfdAllocateStringA(pContext->pszUserName, &pszAccount);
        BAIL_ON_VMAFD_ERROR(dwError);
        dwError = VmAfdAllocateStringA(pContext->pszPassword, &pszPassword);
    }
    BAIL_ON_VMAFD_ERROR(dwError);

    dwError = VmAfdLeaveVmDirA(pContext->pszServerName, pszAccount, pszPassword, 0);
    BAIL_ON_VMAFD_ERROR(dwError);

cleanup:
    VMAFD_SAFE_FREE_MEMORY(pszAccount);
    VMAFD_SAFE_FREE_MEMORY(pszPassword);
    return dwError;

error:

    goto cleanup;
}
Example #2
0
std::string client::GetMachinePassword()
{
    PSTR pszAccount = NULL;
    PSTR pszPassword = NULL;
    DWORD dwError = 0;
    std::string result;

    dwError = VmAfdGetMachineAccountInfoA(ServerName.c_str(),
                         &pszAccount,&pszPassword);

    BAIL_ON_ERROR(dwError);

    result.assign(pszPassword);

error:
    if (pszAccount != NULL)
    {
        VmAfdFreeString(pszAccount);
        VmAfdFreeString(pszPassword);
    }
    THROW_IF_NEEDED(dwError);
    return result;
}
Example #3
0
static
DWORD
VmAfdCliBeginOrEndUpgrade(
    PVM_AFD_CLI_CONTEXT pContext
    )
{
    DWORD dwError = 0;
    PSTR pszAccount = NULL;
    PSTR pszPassword = NULL;
    PSTR pszDomainName = NULL;
    BOOL bUsingIPC = FALSE;
    PVMAFD_SERVER pServer = NULL;

    if (!pContext)
    {
        dwError = ERROR_INVALID_PARAMETER;
        BAIL_ON_VMAFD_ERROR(dwError);
    }

    dwError = VmAfdGetDomainNameA(NULL,&pszDomainName);
    BAIL_ON_VMAFD_ERROR(dwError);

    if (IsNullOrEmptyString(pContext->pszServerName))
    {
        bUsingIPC = TRUE;
    }

    if (bUsingIPC && !IsNullOrEmptyString(pContext->pszUserName))
    {
        printf ("Getting heartbeat status of local system\n"
                "lightwave user-name will not be used\n"
               );
    }

    if (!bUsingIPC)
    {
      //Factor domain name as well into this equation
        if(IsNullOrEmptyString(pContext->pszUserName))
        {
            dwError = VmAfdGetMachineAccountInfoA(NULL, &pszAccount, &pszPassword);
        }
        else
        {
            if (VmAfdCaselessStrStrA(pContext->pszUserName, "@"))
            {
                dwError = VmAfdAllocateStringA(pContext->pszUserName, &pszAccount);
            }
            else
            {
                dwError = VmAfdAllocateStringPrintf(
                                                  &pszAccount,
                                                  "%s@%s",
                                                  pContext->pszUserName,
                                                  pszDomainName
                                                  );
            }
            BAIL_ON_VMAFD_ERROR(dwError);

            if (IsNullOrEmptyString(pContext->pszPassword))
            {
                dwError = GetPassword(&pszPassword);
            }
            else
            {
                dwError = VmAfdAllocateStringA(pContext->pszPassword, &pszPassword);
            }
            BAIL_ON_VMAFD_ERROR(dwError);
        }
    }
    BAIL_ON_VMAFD_ERROR(dwError);

    dwError = VmAfdOpenServerA(
                          pContext->pszServerName,
                          pszAccount,
                          pszPassword,
                          &pServer
                          );
    BAIL_ON_VMAFD_ERROR(dwError);

    if (pContext->action == VM_AFD_ACTION_BEGIN_UPGRADE)
    {
        dwError = VmAfdBeginUpgrade(pServer);
        BAIL_ON_VMAFD_ERROR(dwError);
        printf ("Begin upgrade state is set\n");
    }
    else if (pContext->action == VM_AFD_ACTION_END_UPGRADE)
    {
        dwError = VmAfdEndUpgrade(pServer);
        BAIL_ON_VMAFD_ERROR(dwError);
        printf ("End upgrade state is set\n");
    }

cleanup:
    VMAFD_SAFE_FREE_MEMORY(pszAccount);
    VMAFD_SAFE_FREE_MEMORY(pszPassword);
    VMAFD_SAFE_FREE_MEMORY(pszDomainName);
    if (pServer)
    {
        VmAfdCloseServer(pServer);
    }
    return dwError;

error:

    goto cleanup;
}
Example #4
0
static
DWORD
VmAfdCliGetHeartbeatStatus(
    PVM_AFD_CLI_CONTEXT pContext
    )
{
    DWORD dwError = 0;
    PSTR pszAccount = NULL;
    PSTR pszPassword = NULL;
    PSTR pszDomainName = NULL;
    BOOL bUsingIPC = FALSE;
    PVMAFD_HB_STATUS_A pHeartbeatStatus = NULL;
    PVMAFD_SERVER pServer = NULL;

    if (!pContext)
    {
        dwError = ERROR_INVALID_PARAMETER;
        BAIL_ON_VMAFD_ERROR(dwError);
    }

    if (IsNullOrEmptyString(pContext->pszServerName))
    {
        bUsingIPC = TRUE;
    }

    if (bUsingIPC && !IsNullOrEmptyString(pContext->pszUserName))
    {
        printf ("Getting heartbeat status of local system\n"
                "lotus user-name will not be used\n"
               );
    }

    if (!bUsingIPC)
    {
      //Factor domain name as well into this equation
        if(!pContext->pszUserName)
        {
            dwError = VmAfdGetMachineAccountInfoA(NULL, &pszAccount, &pszPassword);
        }
        else if (pContext->pszUserName && pContext->pszPassword)
        {
            dwError = VmAfdAllocateStringA(pContext->pszUserName, &pszAccount);
            BAIL_ON_VMAFD_ERROR(dwError);
            dwError = VmAfdAllocateStringA(pContext->pszPassword, &pszPassword);
        }
        else if (pContext->pszUserName && !pContext->pszPassword)
        {
            //getPassword
        }
    }
    BAIL_ON_VMAFD_ERROR(dwError);

    dwError = VmAfdOpenServerA(
                          pContext->pszServerName,
                          pszAccount,
                          pszPassword,
                          &pServer
                          );
    BAIL_ON_VMAFD_ERROR(dwError);

    dwError = VmAfdGetHeartbeatStatusA(
                                  pServer,
                                  &pHeartbeatStatus
                                  );
    BAIL_ON_VMAFD_ERROR(dwError);

    printf ("Current Status of the machine is :\t%d\n",pHeartbeatStatus->bIsAlive);

cleanup:
    VMAFD_SAFE_FREE_MEMORY(pszAccount);
    VMAFD_SAFE_FREE_MEMORY(pszPassword);
    VMAFD_SAFE_FREE_MEMORY(pszDomainName);
    return dwError;

error:

    goto cleanup;

}