none
CLUSTER API RRS feed

  • Pregunta

  • Buenas Tardes, tengo un gran problemas actualmente estoy haciendo una aplicación en C++ utilizando el cluster api(clusapi.h), el objetivo de dicha aplicación es obtener la informacion de la esctructura del Cluster (en windows server 2003). Actualmente ya me regresa los grupos existentes asi como sus nombres, los networkname, los physicaldisk y los file share, lo que me falta poder hacer es conseguir las IP Address por grupo, asi como el nivel de permisos de cada File Share, ya busque por todos lados y no encuentro como hacerlo, ojala alguien me pueda ayudar.

     

     

    Les adjunto el codigo que tengo hasta el momento:

     

     

    #include "stdafx.h"

    #include "ClusDoxEx.h"

    #include <stdio.h>

    #include <string.h>

    #include <stdarg.h>

    #include <stdlib.h>

    #define INFO_BUFFER_SIZE 32767

    void main()

    {

    HCLUSTER hCluster = NULL;

    HGROUP hGroup = NULL;

    HRESOURCE hRes = NULL, hResIP = NULL;

    HRESOURCE hResource = NULL;

     

    TCHAR infoBuf[INFO_BUFFER_SIZE];

    DWORD bufCharCount = INFO_BUFFER_SIZE;

    HCLUSENUM hEnum;

    HGROUPENUM hGroupEnum;

    HRESENUM hResourceEnum;

    CLUSTERVERSIONINFO *clusVer;

    char cTest[200];

    DWORD chName;

    DWORD chNameGroup;

    DWORD chNameResource;

    WCHAR szName[512];

    WCHAR clusterName[512];

    WCHAR szNameGroup[9000];

    WCHAR szNameResource[9000];

    DWORD dwType;

    DWORD dwIndex = 0;

    DWORD dwIndexGroup = 0;

    DWORD dwIndexResource = 0;

    DWORD cbNameSize = 0;

    DWORD dwCluster = ERROR_SUCCESS;

    DWORD dwResult = ERROR_SUCCESS;

    DWORD dwResultGroup = ERROR_SUCCESS;

    DWORD dwResultResource = ERROR_SUCCESS;

    DWORD cchNameSize = MAX_COMPUTERNAME_LENGTH + 1;

    LPWSTR lpszClusterName = (LPWSTR) LocalAlloc(LPTR,cchNameSize * sizeof( WCHAR) );

    LPWSTR lpszClusterGrpName = (LPWSTR) LocalAlloc(LPTR,cchNameSize * sizeof( WCHAR) );

     

    if( lpszClusterName != NULL )

    {

    // Get the name of the local node.

    // Using a name instead of NULL in OpenCluster

    // creates an RPC handle.

    bufCharCount = INFO_BUFFER_SIZE;

    /*if( GetComputerName( infoBuf, &bufCharCount ) )

    printf( "\nComputer name:%s", infoBuf ); */

     

     

    if( GetComputerName( lpszClusterName, &cchNameSize ) ){

    printf("\n openCluster call... ");

    hCluster = OpenCluster( L"CICNAS" );

    if(hCluster == NULL){

    printf("\n cluster nof found...");Sleep(1000);

    }else{

    printf("\n cluster found!! start processing");Sleep(1000);

    printf("\n calling ClusterOpenEnum");

    hEnum = ClusterOpenEnum(hCluster,CLUSTER_ENUM_GROUP);

    if(hEnum == NULL){

    printf("\n\t clusteropenenum failed");Sleep(1000);

    }else{

    printf("\n\t clusterOpenEnum succeded!!! ");Sleep(1000);

    printf("\n\t calling ClusterEnum");Sleep(1000);

    while( dwResult == ERROR_SUCCESS )

    {

    chName = sizeof (szName);

    dwResult = ClusterEnum(hEnum,dwIndex,&dwType, szName,&chName);

    if(dwResult == ERROR_SUCCESS){

    printf("\n\t\t ClusterEnum successfull");Sleep(1000);

    printf("\n\t\t szName Name is = ");Sleep(1000);

    int i=0;

    while(szNameIdea){

    printf("%c",szNameIdea);

    i++;

    }

    //-----------------------GROUP START--------------------

    hGroup = OpenClusterGroup(hCluster,szName);

    if(hGroup == NULL){

    printf("\n\t\t\tunable to open the group");Sleep(1000);

    }else{

    printf("\n\t\t\tOpenClusterGroup succeded for %s",szName);Sleep(1000);

    //hGroupEnum =

    ClusterGroupOpenEnum(hGroup,CLUSTER_GROUP_ENUM_NODES|CLUSTER_GROUP_ENUM_CONTAINS);

    hGroupEnum =

    ClusterGroupOpenEnum(hGroup,CLUSTER_GROUP_ENUM_CONTAINS);

    if(hGroupEnum == NULL){

    printf("\n\t\t\tClusterGroupOpenEnum failed");Sleep(1000);

    }else{

    printf("\n\t\t\tClusterGroupOpenEnum succeeded");Sleep(1000);

    printf("\n\t\t\tCalling ClusterGroupEnum");Sleep(1000);

    dwResultGroup = ERROR_SUCCESS;

    dwIndexGroup = 0;

    while( dwResultGroup == ERROR_SUCCESS )

    {

    chNameGroup = sizeof (szNameGroup);

    printf("\n\t\t\tinside while");Sleep(1000);

    dwResultGroup =

    ClusterGroupEnum(hGroupEnum,dwIndexGroup,&dwType, szNameGroup,

    &chNameGroup);

    if(dwResultGroup == ERROR_SUCCESS)

    {

    printf("\n\t\t\t ClusterGroupEnum successfull");Sleep(1000);

    printf("\n\t\t\t szNameGroup s = ");Sleep(1000);

    int i=0;

    while(szNameGroupIdea){

    printf("%c",szNameGroupIdea);

    i++;

    }

    //

    //-------------------------RESOURCE START---------------------

    hResource = OpenClusterResource(hCluster,szNameGroup);

    if(hResource == NULL){

    printf("\n\t\t\t\t unable to open resource");

    }else{

    printf("\n\t\t\t\t OpenClusterResource succeded for %s",szNameGroup);

    //hResourceEnum =

    ClusterResourceOpenEnum(hResource,CLUSTER_RESOURCE_ENUM_NODES|CLUSTER_RESOURCE_ENUM_DEPENDS);

    hResourceEnum =

    ClusterResourceOpenEnum(hResource,CLUSTER_RESOURCE_ENUM_NODES);

    if(hResourceEnum == NULL){

    printf("\n\t\t\t\t ClusterResouceOpenEnum failed");

    }else{

    printf("\n\t\t\t\t ClusterResouceOpenEnum succeded");

    printf("\n\t\t\t\t Calling ClusterResourceEnum");

    dwResultResource = ERROR_SUCCESS;

    dwIndexResource = 0;

    while( dwResultResource == ERROR_SUCCESS){

    chNameResource = sizeof(szNameResource);

    printf("\n\t\t\t\t inside while");

    printf("\n\t\t\t\t dwIndexResource value is =%d",dwIndexResource);

    dwResultResource =

    ClusterResourceEnum(hResourceEnum,dwIndexResource,&dwType,szNameResource,&chNameResource);

    //if(dwType == CLUSTER_RESOURCE_ENUM_DEPENDS){

    if(dwResultResource == ERROR_SUCCESS){

    printf("\n\t\t\t\t\t ClusterResourceEnum successfull");

    //printf("\n\t\t\t\t\t szName is = %s",szNameResource);

    printf("\n\t\t\t\t\t szNameResource is = ");

    int i=0;

    while(szNameResourceIdea){

    printf("%c",szNameResourceIdea);

    i++;

    }

    HNODE hnode = OpenClusterNode(hCluster,szNameResource);

    if(hnode == NULL){

    printf("\n\t\t\t\t\t not able to open node");

    }else{

    printf("\n\t\t\t\t\t able to open node and returned handle");

    CLUSTER_NODE_STATE WINAPI state =

    GetClusterNodeState(hnode);

    if(state == ClusterNodeUp){

    printf("\n\t\t\t\t\t\t node is active");

    }else if(state == ClusterNodeDown){

    printf("\n\t\t\t\t\t\t node is down");

    }else {

    printf("\n\t\t\t\t\t\t unknown state");

    }

    }

    }

    else{

    printf("\n\t\t\t\t\t dwResultResource is empty");

    }

    //}

    dwIndexResource++;

    }//while

    }

    }

     

    }

    else if(dwResultGroup == ERROR_NO_MORE_ITEMS){

    printf("\n\t\t no more items ");Sleep(3000);

    }else if( dwResultGroup == ERROR_MORE_DATA){

    printf("\n\t\t more data");Sleep(1000);

     

    }else{

    printf("\n\t\t\tdwResult empty");Sleep(1000);

    }

    dwIndexGroup++;

    }//while

    }//else

    }//else

    //-------------------------GROUP END---------------------

    }

    dwIndex++;

    }//while

    }

    }

    }

    dwResult = GetLastError();

    LocalFree( lpszClusterName );

    }

    SetLastError( dwResult );

     

    }

     

     

     

    GRACIAS

    miércoles, 5 de marzo de 2008 1:14