blob: c3000ba2f3f4ee67ac3003fe4444b40f1b11813a [file] [log] [blame]
/*
* test_gc.c
*
* (C) Copyright IBM Corp. 2005
* (C) Copyright Intel Corp. 2005
*
* THIS FILE IS PROVIDED UNDER THE TERMS OF THE ECLIPSE PUBLIC LICENSE
* ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE
* CONSTITUTES RECIPIENTS ACCEPTANCE OF THE AGREEMENT.
*
* You can obtain a current copy of the Eclipse Public License from
* http://www.opensource.org/licenses/eclipse-1.0.php
*
* Author: Adrian Schuur <schuur@de.ibm.com>
*
* Description:
*
* Test for getClass() library API.
*/
#include <cimc.h>
#include <cmci.h>
#include <native.h>
#include <unistd.h>
#include <stdlib.h>
#include "show.h"
/* ********************************************************
* environment variables
* CIM_HOST
* CIM_HOST_USERID
* CIM_HOST_PASSWD
* CIM_HOST_PORT
*
*
* ********************************************************
* comment out v2local define to use v2 http XML interface
*
* ********************************************************
*/
#define v2local
int main()
{
CIMCEnv *ce;
char *msg = NULL;
int rc;
CIMCStatus status;
CIMCClient *client;
CMPIObjectPath * op;
CMPIConstClass * class;
char *cim_host, *cim_host_passwd, *cim_host_userid , *cim_host_port;
/*
* Setup a connection to the CIMOM by checking environment
* if not found we default those values
*/
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 getClass \n") ;
printf(" checking with bad input : host = %s userid = %s\n",
cim_host,cim_host_userid) ;
ce = NewCIMCEnv("bogus",0,&rc,&msg);
if (rc == 3) {
printf (" bad input caught OK,\n\tmsg = %s\n\n",msg);
} else {
printf (" bad input NOT caught.\n");
}
#ifdef v2local
printf(" using SfcbLocal interface : host = %s userid = %s\n",
cim_host,cim_host_userid) ;
ce = NewCIMCEnv("SfcbLocal",0,&rc,&msg);
#else
printf(" using XML HTTP interface : host = %s userid = %s port=%s\n",
cim_host,cim_host_userid,cim_host_port) ;
ce = NewCIMCEnv("XML",0,&rc,&msg);
#endif
if (rc == 0 ) {
client = ce->ft->connect(ce, cim_host , "http", cim_host_port, cim_host_userid, cim_host_passwd , &status);
if (client == NULL) {
printf("Coudn't connect to the server. Check if sfcb is running.\n");
return 1;
}
op = (CMPIObjectPath *)ce->ft->newObjectPath(ce, "root/cimv2", "CIM_ComputerSystem" , &status);
class =(CMPIConstClass *) client->ft->getClass(client,(CIMCObjectPath *) op, CMPI_FLAG_IncludeQualifiers, NULL, &status);
/* Print the results */
printf( "getClass() rc=%d, msg=%s\n",
status.rc, (status.msg)? (char *)status.msg->hdl : NULL);
if (!status.rc) {
printf("result:\n");
showClass(class);
}
if (class) class->ft->release((CMPIConstClass *)class);
if (op) op->ft->release(op);
if (client) client->ft->release(client);
if(ce) ReleaseCIMCEnv(ce);
if (status.msg) CMRelease(status.msg);
return 0;
} else {
printf ("Call to NewCIMCEnv failed, rc = %d\n\tmsg = %s\n",rc,msg);
return 1;
}
}