version 1.39, 2002/02/20 23:59:02
|
version 1.44, 2002/05/03 18:15:13
|
|
|
#include <Pegasus/Common/Tracer.h> | #include <Pegasus/Common/Tracer.h> |
#include <Pegasus/Config/ConfigManager.h> | #include <Pegasus/Config/ConfigManager.h> |
#include <Pegasus/Client/CIMClient.h> | #include <Pegasus/Client/CIMClient.h> |
#include <Pegasus/Common/HTTPConnector.h> |
|
#include <Pegasus/Server/ShutdownService.h> | #include <Pegasus/Server/ShutdownService.h> |
#include <Pegasus/Common/Destroyer.h> | #include <Pegasus/Common/Destroyer.h> |
#ifndef PEGASUS_OS_ZOS |
#if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) |
#include <slp/slp.h> | #include <slp/slp.h> |
#endif | #endif |
| |
|
|
| |
static const char OPTION_TIMEOUT = 'T'; | static const char OPTION_TIMEOUT = 'T'; |
| |
static const String NAMESPACE = "root/cimv2"; |
static const String NAMESPACE = "root/PG_Internal"; |
static const String CLASSNAME_SHUTDOWNSERVICE = "PG_ShutdownService"; | static const String CLASSNAME_SHUTDOWNSERVICE = "PG_ShutdownService"; |
static const String PROPERTY_TIMEOUT = "operationTimeout"; | static const String PROPERTY_TIMEOUT = "operationTimeout"; |
| |
|
|
// | // |
// Create CIMClient object | // Create CIMClient object |
// | // |
Monitor* monitor = new Monitor; |
CIMClient client; |
HTTPConnector* httpConnector = new HTTPConnector(monitor); |
|
CIMClient client(monitor, httpConnector); |
|
| |
// | // |
// Get the port number | // Get the port number |
|
|
// | // |
try | try |
{ | { |
client.connect(hostStr.allocateCString()); |
client.connectLocal(); |
} | } |
catch(Exception& e) |
catch(CIMClientException& e) |
{ | { |
Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, | Logger::put(Logger::STANDARD_LOG, "CIMServer", Logger::INFORMATION, |
"Failed to connect to $0 $1.", PEGASUS_NAME, e.getMessage()); | "Failed to connect to $0 $1.", PEGASUS_NAME, e.getMessage()); |
|
|
Array<CIMParamValue> inParams; | Array<CIMParamValue> inParams; |
Array<CIMParamValue> outParams; | Array<CIMParamValue> outParams; |
| |
inParams.append(CIMParamValue( |
inParams.append(CIMParamValue("force", |
CIMParameter("force", CIMType::BOOLEAN), |
|
CIMValue(Boolean(forceOption)))); | CIMValue(Boolean(forceOption)))); |
| |
inParams.append(CIMParamValue( |
inParams.append(CIMParamValue("timeout", |
CIMParameter("timeout", CIMType::UINT32), |
|
CIMValue(Uint32(timeoutValue)))); | CIMValue(Uint32(timeoutValue)))); |
| |
CIMValue retValue = client.invokeMethod( | CIMValue retValue = client.invokeMethod( |
|
|
"$0 terminated on port $1.", PEGASUS_NAME, portNumberStr); | "$0 terminated on port $1.", PEGASUS_NAME, portNumberStr); |
| |
} | } |
|
catch(CIMClientCIMException& e) |
|
{ |
|
PEGASUS_STD(cerr) << "Failed to shutdown server: " << e.getMessage() << PEGASUS_STD(endl); |
|
exit(1); |
|
} |
|
catch(CIMClientException& e) |
|
{ |
|
// this may mean the cimserver has been terminated |
|
} |
catch(Exception& e) | catch(Exception& e) |
{ | { |
PEGASUS_STD(cerr) << "Failed to shutdown server: " << e.getMessage() << PEGASUS_STD(endl); | PEGASUS_STD(cerr) << "Failed to shutdown server: " << e.getMessage() << PEGASUS_STD(endl); |
|
|
// try loop to bind the address, and run the server | // try loop to bind the address, and run the server |
try | try |
{ | { |
#ifndef PEGASUS_OS_ZOS |
#if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) |
slp_client *discovery = new slp_client() ;; | slp_client *discovery = new slp_client() ;; |
String serviceURL; | String serviceURL; |
serviceURL.assign("service:cim.pegasus://"); | serviceURL.assign("service:cim.pegasus://"); |
|
|
Monitor monitor; | Monitor monitor; |
CIMServer server(&monitor, useSSL); | CIMServer server(&monitor, useSSL); |
| |
// bind throws an exception of the bind fails |
// bind throws an exception if the bind fails |
|
#ifdef PEGASUS_LOCAL_DOMAIN_SOCKET |
|
cout << "Binding to domain socket" << endl; |
|
#else |
cout << "Binding to " << address << endl; | cout << "Binding to " << address << endl; |
|
#endif |
| |
char* end = 0; | char* end = 0; |
long portNumber = strtol(address, &end, 10); | long portNumber = strtol(address, &end, 10); |
|
|
// | // |
while( !server.terminated() ) | while( !server.terminated() ) |
{ | { |
#ifndef PEGASUS_OS_ZOS |
#if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) |
if(useSLP ) | if(useSLP ) |
{ | { |
if( (time(NULL) - last ) > 60 ) | if( (time(NULL) - last ) > 60 ) |