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; 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"); } printf(" using SfcbLocal interface : host = %s userid = %s\n", cim_host,cim_host_userid) ; ce = NewCIMCEnv("SfcbLocal",0,&rc,&msg); if (rc == 0 ) { client = ce->ft->connect(ce, cim_host , "http", cim_host_port, cim_host_userid, cim_host_passwd , &status); 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); }
void Init_sfcc() { const char *conn; VALUE cEnvironment; /* class */ VALUE value; /* wrapped value */ int rc; char *msg; #ifdef CIMC_NO_CURL_INIT //defined in cimc/cimc.h since version 2.2.4 char *rails_env = getenv("RAILS_ENV"); #endif /** * SBLIM sfcc ruby API */ mSfcc = rb_define_module("Sfcc"); /** * SBLIM sfcc CIMC API */ mSfccCim= rb_define_module_under(mSfcc, "Cim"); /** * alloc CimcEnvironment once, store as const */ cEnvironment = rb_define_class_under(mSfccCim, "CimcEnvironment", rb_cObject); conn = getenv("RUBY_SFCC_CONNECTION"); /* "SfcbLocal" or "XML" */ if (!conn) conn = "XML"; cimcEnv = NewCIMCEnv(conn, #ifdef CIMC_NO_CURL_INIT /* Don't let sfcc init curl if running in Rails env * (http://sourceforge.net/tracker/?func=detail&aid=3435363&group_id=128809&atid=712784) */ rails_env?CIMC_NO_CURL_INIT: #endif 0, &rc, &msg); if (!cimcEnv) { rb_raise(rb_eLoadError, "Cannot local %s cim client library. %d:%s", conn, rc, msg ? msg : ""); } value = Data_Wrap_Struct(cEnvironment, NULL, Exit_sfcc, cimcEnv); rb_define_const(mSfccCim, "CIMC_ENV", value); cimcEnvType = strdup(conn); rb_define_const(mSfccCim, "CIMC_ENV_TYPE", rb_str_new2(cimcEnvType)); /** * Init other sub-classes */ init_cim_string(); init_cim_object_path(); init_cim_enumeration(); init_cim_class(); init_cim_instance(); init_cim_data(); init_cim_type(); init_cim_flags(); init_cim_client(); }
void Init_sfcc() { const char *conn; VALUE cEnvironment; /* class */ VALUE value; /* wrapped value */ int rc; char *msg; /** * SBLIM sfcc ruby API */ mSfcc = rb_define_module("Sfcc"); /** * SBLIM sfcc CIMC API */ mSfccCim= rb_define_module_under(mSfcc, "Cim"); /** * alloc CimcEnvironment once, store as const */ cEnvironment = rb_define_class_under(mSfccCim, "CimcEnvironment", rb_cObject); conn = getenv("RUBY_SFCC_CONNECTION"); /* "SfcbLocal" or "XML" */ if (!conn) conn = "XML"; cimcEnv = NewCIMCEnv(conn,0,&rc,&msg); if (!cimcEnv) { rb_raise(rb_eLoadError, "Cannot local %s cim client library. %d:%s", conn, rc, msg ? msg : ""); } value = Data_Wrap_Struct(cEnvironment, NULL, Exit_sfcc, cimcEnv); rb_define_const(mSfccCim, "CIMC_ENV", value); /** * Init other sub-classes */ init_cim_string(); init_cim_object_path(); init_cim_enumeration(); init_cim_class(); init_cim_instance(); init_cim_client(); }
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; }
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; }
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); }
CMCIClient *cmciConnect2(const char *hn, const char *scheme, const char *port, const char *user, const char *pwd, const char* auth, int verifyMode, const char * trustStore, const char * certFile, const char * keyFile, CMPIStatus *rc) { CMCIClient *cc = NULL; char *msg; int retc = 0; char *client; char *backend; #ifndef WIN32_PORT pthread_mutex_lock(&ConnectionControl.ccMux); #else if (&ConnectionControl.ccMux == NULL) { ConnectionControl.ccMux = CreateMutex( NULL, FALSE, NULL ); if (ConnectionControl.ccMux == NULL) { printf ("Error creating mutex\n"); return NULL; } } WaitForSingleObject(ConnectionControl.ccMux, INFINITE ); #endif if (ConnectionControl.ccCount == 0) { client = getenv("SFCC_CLIENT"); if (client == NULL) { if (scheme == NULL || strncasecmp(scheme,"http",4) == 0) { client = DefaultClient; } else { client = scheme; } } if ((strcmp (port, "5988") == 0) || (strcmp (port, "5989") == 0)) { backend = "cimxml.dll"; } else if ((strcmp (port, "8889") == 0) || (strcmp (port, "8888") == 0)) { backend = "wsman.dll"; } else { printf ("Invalid port number specified\n"); } ConnectionControl.ccEnv = NewCIMCEnv(client,0,&retc, &msg, backend); } if (retc || ConnectionControl.ccEnv == NULL) { if(rc) { rc->rc=CMPI_RC_ERR_FAILED; rc->msg=NULL; } cc=NULL; } else { ConnectionControl.ccCount += 1; cc = (CMCIClient*)ConnectionControl.ccEnv->ft->connect2(ConnectionControl.ccEnv,hn,scheme,port,user,pwd,auth,verifyMode,trustStore,certFile,keyFile,(CIMCStatus*)rc); if (cc) { if (ConnectionControl.ccRelease == NULL) { ConnectionControl.ccRelease = cc->ft->release; } cc->ft->release=cmciRelease; } } #ifndef WIN32_PORT pthread_mutex_unlock(&ConnectionControl.ccMux); #else ReleaseMutex(ConnectionControl.ccMux); #endif return cc; }
int main() { CIMCEnv *ce; char *msg = NULL; int rc; CIMCStatus status; CIMCClient *client; CIMCObjectPath *op; CMPIConstClass *clas; CIMCEnumeration *enm; 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 enumerateClasses for namespaces \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/interop", "CIM_Namespace", &status); enm = client->ft->enumInstances(client, (CIMCObjectPath *) op, 0, NULL, &status); if (!status.rc) { printf("results:\n"); count = enm->ft->hasNext(enm, NULL); while (count > 0) { data = enm->ft->getNext(enm, NULL); showInstance(data.value.inst); count = enm->ft->hasNext(enm, NULL); } } else { printf(" we have a status.rc value of %d \n", status.rc); } if (ce) ce->ft->release(ce); if (client) client->ft->release(client); if (op) op->ft->release(op); if (enm) enm->ft->release(enm); if (status.msg) CMRelease(status.msg); return 0; }
int main() { CIMCEnv *ce; char *msg = NULL; int rc; CIMCStatus status; CIMCClient *client; CIMCObjectPath *op; CMPIConstClass *clas; CIMCEnumeration *enumeration; 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 Associators \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_Person", &status); CMAddKey(op, "name", "Mike", CMPI_chars); enumeration = client->ft->associators(client, op, "TEST_Lineage", NULL, NULL, NULL, 0, NULL, &status); /* * Print the results */ printf("associators() 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)) { data = enumeration->ft->getNext(enumeration, NULL); showInstance(data.value.inst); } } if (enumeration) CMRelease(enumeration); if (op) CMRelease(op); if (status.msg) CMRelease(status.msg); return 0; }