~ubuntu-branches/ubuntu/utopic/sblim-sfcc/utopic-proposed

« back to all changes in this revision

Viewing changes to TEST/v2test_ein.c

  • Committer: Bazaar Package Importer
  • Author(s): Thierry Carrez
  • Date: 2009-08-19 14:41:55 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20090819144155-jb46y5kmluacii70
Tags: 2.2.0-0ubuntu1
* New upstream version.
* debian/libcimcclient0.install: Ship missing libcmpisfcc library
* debian/control:
  - Switch to libcurl4-openssl-dev to match the rest of the SBLIM stack
  - Bump debhelper depend to >=5 to match debian/compat
  - Fix section names, add missing ${misc:Depends}
* debian/copyright: Add missing copyright notice
* debian/rules: Removed spurious DH_MAKESHLIBS argument

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <cimc.h>
 
2
#include <cmci.h>
 
3
#include <native.h>
 
4
#include <unistd.h>
 
5
#include <stdlib.h>
 
6
#include "cmcimacs.h"
 
7
 
 
8
extern char *value2Chars(CMPIType type, CMPIValue * value);
 
9
void showProperty( CMPIData , char * );
 
10
void showInstance( CMPIInstance * );
 
11
static char * CMPIState_str(CMPIValueState);
 
12
/*
 
13
 * comment out this define to use v2 http XML interface
 
14
 */
 
15
#define v2local
 
16
 
 
17
int main()
 
18
{
 
19
CIMCEnv *ce;
 
20
char *msg = NULL;
 
21
int rc;
 
22
 
 
23
CIMCStatus status;
 
24
CMPIObjectPath *op = NULL ;
 
25
CIMCEnumeration *enm = NULL;
 
26
CIMCClient *client = NULL;
 
27
CIMCInstance *instance = NULL;
 
28
CIMCData data;
 
29
char    *cim_host, *cim_host_passwd, *cim_host_userid, *cim_host_port;
 
30
int count = 0;
 
31
 
 
32
    /*
 
33
     * Setup a connection to the CIMOM by checking environment 
 
34
     * if not found we default those values
 
35
     */
 
36
    cim_host = getenv("CIM_HOST");
 
37
    if (cim_host == NULL)
 
38
       cim_host = "localhost";
 
39
    cim_host_userid = getenv("CIM_HOST_USERID");
 
40
    if (cim_host_userid == NULL)
 
41
       cim_host_userid = "root";
 
42
    cim_host_passwd = getenv("CIM_HOST_PASSWD");
 
43
    if (cim_host_passwd == NULL)
 
44
       cim_host_passwd = "password";
 
45
    cim_host_port = getenv("CIM_HOST_PORT");
 
46
    if (cim_host_port == NULL)
 
47
             cim_host_port = "5988";
 
48
             
 
49
    printf(" Testing enumerateInstanceNames \n") ;
 
50
    
 
51
#ifdef v2local
 
52
    printf(" using SfcbLocal interface : host = %s userid = %s\n",
 
53
                          cim_host,cim_host_userid) ;
 
54
    ce = NewCIMCEnv("SfcbLocal",0,&rc,&msg);
 
55
#else
 
56
    printf(" using XML HTTP interface : host = %s userid = %s port=%s\n",
 
57
                          cim_host,cim_host_userid,cim_host_port) ;
 
58
    ce = NewCIMCEnv("XML",0,&rc,&msg);
 
59
#endif
 
60
 
 
61
    if(ce == NULL) {
 
62
      printf(" local connect failed call to NewCIMCEnv message = [%s] \n",msg) ;
 
63
      return 1;
 
64
    }
 
65
    printf("do connect \n") ;
 
66
    client = ce->ft->connect(ce, cim_host , "http", cim_host_port, cim_host_userid, cim_host_passwd , &status);
 
67
    if(client == NULL) 
 
68
    {
 
69
       printf(" failed the call to connect \n") ;       
 
70
    }
 
71
    
 
72
    printf("do newObjectPath \n") ;
 
73
    op = (CMPIObjectPath *)ce->ft->newObjectPath(ce, "root/cimv2", "CIM_ManagedElement" , &status);     
 
74
    if(op == NULL) 
 
75
    {
 
76
       printf(" failed the call to newObjectPath \n") ; 
 
77
    }
 
78
        
 
79
    printf("do enumInstances \n") ;
 
80
    enm = client->ft->enumInstanceNames(client, (CIMCObjectPath *) op , &status);
 
81
    if(enm == NULL) 
 
82
    {
 
83
       printf(" failed the call to client->ft->enumInstances \n") ;     
 
84
    }
 
85
       
 
86
    /* Print the results */
 
87
   
 
88
    if (!status.rc) {
 
89
       printf("results:\n");
 
90
       count = enm->ft->hasNext(enm, NULL) ;
 
91
       while (count > 0) {
 
92
          
 
93
          data = enm->ft->getNext(enm, NULL);
 
94
 
 
95
          showObjectPath(data.value.ref);
 
96
          /*
 
97
           * see if we have any more
 
98
           */
 
99
           count = enm->ft->hasNext(enm, NULL) ;   
 
100
       }
 
101
    } else {
 
102
       printf("  ERROR received from enumInstanceNames  status.rc = %d\n",status.rc) ;
 
103
       if(msg)
 
104
         printf("  ERROR msg = %s\n",msg) ;
 
105
    }
 
106
    
 
107
    if(enm) enm->ft->release(enm);
 
108
    if(op) op->ft->release(op);
 
109
    if(client) client->ft->release(client);
 
110
    if(ce) ce->ft->release(ce);
 
111
    if(status.msg) CMRelease(status.msg);       
 
112
        
 
113
    return 0;
 
114
}
 
115
 
 
116
/* */