示例#1
0
int main()
{
    CMCIClient *cc;
    CMPIObjectPath * objectpath;
    CMPIEnumeration * enumeration;
    CMPIStatus status;
    char 	*cim_host, *cim_host_passwd, *cim_host_userid,
                *cim_host_cert, *cim_client_cert, *cim_client_key;

    /* Setup a connection to the CIMOM */
    cim_host = getenv("CIM_HOST");
    if (cim_host == NULL)
	cim_host = "localhost";
    cim_host_userid = getenv("CIM_HOST_USERID");
    if (cim_host_userid == NULL)
	cim_host_userid = "root";
    cim_host_passwd = getenv("CIM_HOST_PASSWD");
    if (cim_host_passwd == NULL)
	cim_host_passwd = "password";
    cim_host_cert = getenv("CIM_HOST_CERT");
    cim_client_cert = getenv("CIM_CLIENT_CERT");
    cim_client_key = getenv("CIM_CLIENT_KEY");
    cc = cmciConnect2(cim_host, "https", "5989",
		      cim_host_userid, cim_host_passwd, 
		      CMCI_VERIFY_PEER, cim_host_cert, 
		      cim_client_cert, cim_client_key,
		      NULL);
   
    /* Test enumClassNames() */
    printf("\n----------------------------------------------------------\n");
    printf("Testing enumClassNames() ...\n");   
    objectpath = newCMPIObjectPath("root/cimv2", NULL, NULL);
    enumeration = cc->ft->enumClassNames(cc, objectpath, 0, &status);

    /* Print the results */
    printf( "enumClassNames() rc=%d, msg=%s\n", status.rc, 
            (status.msg)? (char *)status.msg->hdl : NULL);

    if (!status.rc) {
        printf("result(s):\n");
        while (enumeration->ft->hasNext(enumeration, NULL)) {
            CMPIData data = enumeration->ft->getNext(enumeration, NULL);
            showObjectPath(data.value.ref);
        }
    }

    if (enumeration) CMRelease(enumeration);
    if (objectpath) CMRelease(objectpath);
    if (status.msg) CMRelease(status.msg);
    if (cc) CMRelease(cc);
    
    return 0;
}
示例#2
0
int main()
{
CIMCEnv *ce;
char *msg = NULL;
int rc;

CIMCStatus status;
CMPIObjectPath *op = NULL ;
CIMCEnumeration *enm = NULL;
CIMCClient *client = NULL;
CIMCInstance *instance = NULL;
CIMCData data;
char 	*cim_host, *cim_host_passwd, *cim_host_userid, *cim_host_port;
int count = 0;

    cim_host = getenv("CIM_HOST");
    if (cim_host == NULL)
       cim_host = "localhost";
    cim_host_userid = getenv("CIM_HOST_USERID");
    if (cim_host_userid == NULL)
       cim_host_userid = "root";
    cim_host_passwd = getenv("CIM_HOST_PASSWD");
    if (cim_host_passwd == NULL)
       cim_host_passwd = "password";
    cim_host_port = getenv("CIM_HOST_PORT");
    if (cim_host_port == NULL)
	     cim_host_port = "5988";
	     
    printf(" Testing enumerateInstanceNames \n") ;
    
    printf(" using SfcbLocal interface : host = %s userid = %s\n",
                          cim_host,cim_host_userid) ;
    ce = NewCIMCEnv("SfcbLocal",0,&rc,&msg);

    if(ce == NULL) {
      printf(" local connect failed call to NewCIMCEnv message = [%s] \n",msg) ;
      return 1;
    }
    printf("do connect \n") ;
    client = ce->ft->connect(ce, cim_host , "http", cim_host_port, cim_host_userid, cim_host_passwd , &status);
    if(client == NULL) 
    {
       printf(" failed the call to connect \n") ;	
    }
    
    printf("do newObjectPath \n") ;
    op = (CMPIObjectPath *)ce->ft->newObjectPath(ce, "root/cimv2", "TEST_Person" , &status);     
    if(op == NULL) 
    {
       printf(" failed the call to newObjectPath \n") ;	
    }
        
    printf("do enumInstances \n") ;
    enm = client->ft->enumInstanceNames(client, (CIMCObjectPath *) op , &status);
    if(enm == NULL) 
    {
       printf(" failed the call to client->ft->enumInstances \n") ;	
    }
       
    /* Print the results */
   
    if (!status.rc) {
       printf("results:\n");
       count = enm->ft->hasNext(enm, NULL) ;
       while (count > 0) {
       	  
          data = enm->ft->getNext(enm, NULL);

          showObjectPath(data.value.ref);
           count = enm->ft->hasNext(enm, NULL) ;   
       }
    } else {
       printf("  ERROR received from enumInstanceNames  status.rc = %d\n",status.rc) ;
       if(msg)
       	 printf("  ERROR msg = %s\n",msg) ;
    }
    
    if(enm) enm->ft->release(enm);
    if(op) op->ft->release(op);
    if(client) client->ft->release(client);
    if(ce) ce->ft->release(ce);
    if(status.msg) CMRelease(status.msg);	
    	
    return 0;
}
示例#3
0
文件: test_ci.c 项目: buccella/SFCB
int
main()
{
  CIMCEnv        *ce;
  char           *msg = NULL;
  int             rc;
  CIMCStatus      status;
  CIMCClient     *client;
  CIMCObjectPath *op,
                 *objectpath_r;
  CMPIConstClass *clas;
  CMPIInstance   *instance;
  CIMCString     *path;
  CMPIString     *classname;
  CIMCData        data;
  CMPIData        cdata;
  char           *cim_host,
                 *cim_host_passwd,
                 *cim_host_userid,
                 *cim_host_port;
  int             i = 0;
  int             retc = 0;
  int             count = 0;
  int             numproperties = 0;
  CMPIString     *propertyname;
  char           *cv;

  /*
   * Setup a connection to the CIMOM 
   */
  cim_host = getenv("CIM_HOST");
  if (cim_host == NULL)
    cim_host = "localhost";
  cim_host_userid = getenv("CIM_HOST_USERID");
  if (cim_host_userid == NULL)
    cim_host_userid = "root";
  cim_host_passwd = getenv("CIM_HOST_PASSWD");
  if (cim_host_passwd == NULL)
    cim_host_passwd = "password";
  cim_host_port = getenv("CIM_HOST_PORT");
  if (cim_host_port == NULL)
    cim_host_port = "5988";

  printf(" Testing CreateInstance \n");
  printf(" using SfcbLocal interface : host = %s userid = %s\n",
         cim_host, cim_host_userid);
  ce = NewCIMCEnv("SfcbLocal", 0, &rc, &msg);

  if (ce == NULL) {
    printf
        (" local connect failed call to NewCIMCEnv rc = %d , message = [%s] \n",
         retc, msg);
    return 1;
  }

  client =
      ce->ft->connect(ce, cim_host, "http", cim_host_port, cim_host_userid,
                      cim_host_passwd, &status);

  op = ce->ft->newObjectPath(ce, "root/cimv2", "TEST_LabeledLineage",
                             &status);

  instance = ce->ft->newInstance(ce, op, NULL);
  CMSetProperty(instance, "label", "Mitchelle", CMPI_chars);

  objectpath_r =
      (CIMCObjectPath *) client->ft->createInstance(client, op, instance,
                                                    &status);

  /*
   * Print the results 
   */
  printf("createInstance() rc=%d, msg=%s\n",
         status.rc, (status.msg) ? (char *) status.msg->hdl : NULL);
  if (!status.rc) {
    printf("result:\n");
    showObjectPath(objectpath_r);
  }

  if (instance)
    CMRelease(instance);
  if (op)
    CMRelease(op);
  if (objectpath_r)
    CMRelease(objectpath_r);
  if (status.msg)
    CMRelease(status.msg);

  return 0;
}