version 1.5, 2003/11/05 04:10:42
|
version 1.14, 2005/02/05 23:01:33
|
|
|
//%2003//////////////////////////////////////////////////////////////////////// |
//%2005//////////////////////////////////////////////////////////////////////// |
// | // |
// Copyright (c) 2000, 2001, 2002 BMC Software, Hewlett-Packard Development |
// Copyright (c) 2000, 2001, 2002 BMC Software; Hewlett-Packard Development |
// Company, L. P., IBM Corp., The Open Group, Tivoli Systems. |
// Company, L.P.; IBM Corp.; The Open Group; Tivoli Systems. |
// Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; | // Copyright (c) 2003 BMC Software; Hewlett-Packard Development Company, L. P.; |
// IBM Corp.; EMC Corporation, The Open Group. | // IBM Corp.; EMC Corporation, The Open Group. |
|
// Copyright (c) 2004 BMC Software; Hewlett-Packard Development Company, L.P.; |
|
// IBM Corp.; EMC Corporation; VERITAS Software Corporation; The Open Group. |
|
// Copyright (c) 2005 Hewlett-Packard Development Company, L.P.; IBM Corp.; |
|
// EMC Corporation; VERITAS Software Corporation; The Open Group. |
// | // |
// Permission is hereby granted, free of charge, to any person obtaining a copy | // Permission is hereby granted, free of charge, to any person obtaining a copy |
// of this software and associated documentation files (the "Software"), to | // of this software and associated documentation files (the "Software"), to |
|
|
// | // |
// Modified By: Jair Santos, Hewlett-Packard Company (jair.santos@hp.com) | // Modified By: Jair Santos, Hewlett-Packard Company (jair.santos@hp.com) |
// | // |
|
// Modified By: Dan Gorey (djgorey@us.ibm.com) |
//%///////////////////////////////////////////////////////////////////////////// | //%///////////////////////////////////////////////////////////////////////////// |
| |
| |
|
|
#include <Pegasus/Config/ConfigManager.h> | #include <Pegasus/Config/ConfigManager.h> |
#include <Pegasus/Client/CIMClient.h> | #include <Pegasus/Client/CIMClient.h> |
#include <Pegasus/Server/ShutdownService.h> | #include <Pegasus/Server/ShutdownService.h> |
#include <Pegasus/Common/Destroyer.h> |
|
#if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) && ! defined(PEGASUS_NO_SLP) |
|
#include <slp/slp.h> |
|
#endif |
|
| |
| |
#if defined(PEGASUS_OS_TYPE_WINDOWS) | #if defined(PEGASUS_OS_TYPE_WINDOWS) |
|
|
usage.append (" - sets CIM Server configuration property\n"); | usage.append (" - sets CIM Server configuration property\n"); |
| |
cout << endl; | cout << endl; |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
cout << PEGASUS_PRODUCT_NAME << " " << PEGASUS_PRODUCT_VERSION << endl; |
cout << PLATFORM_PRODUCT_NAME << " " << PLATFORM_PRODUCT_VERSION << endl; |
|
#else |
|
cout << PEGASUS_NAME << PEGASUS_VERSION << endl; |
|
#endif |
|
cout << endl; | cout << endl; |
cout << usage << endl; | cout << usage << endl; |
} | } |
|
|
if (*option == OPTION_VERSION && | if (*option == OPTION_VERSION && |
strlen(option) == 1) | strlen(option) == 1) |
{ | { |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
cout << PEGASUS_PRODUCT_VERSION << endl; |
cout << PLATFORM_PRODUCT_VERSION << endl; |
|
#else |
|
cout << PEGASUS_VERSION << endl; |
|
#endif |
|
exit(0); | exit(0); |
} | } |
// | // |
|
|
// Get an instance of the Config Manager. | // Get an instance of the Config Manager. |
// | // |
configManager = ConfigManager::getInstance(); | configManager = ConfigManager::getInstance(); |
|
configManager->useConfigFiles = true; |
| |
// | // |
// Get options (from command line and from configuration file); this | // Get options (from command line and from configuration file); this |
|
|
configManager->getCurrentValue("enableHttpConnection"), "true"); | configManager->getCurrentValue("enableHttpConnection"), "true"); |
Boolean enableHttpsConnection = String::equal( | Boolean enableHttpsConnection = String::equal( |
configManager->getCurrentValue("enableHttpsConnection"), "true"); | configManager->getCurrentValue("enableHttpsConnection"), "true"); |
|
Boolean enableSSLExportClientVerification = String::equal( |
|
configManager->getCurrentValue("enableSSLExportClientVerification"), "true"); |
| |
// Make sure at least one connection is enabled | // Make sure at least one connection is enabled |
#ifndef PEGASUS_LOCAL_DOMAIN_SOCKET | #ifndef PEGASUS_LOCAL_DOMAIN_SOCKET |
|
|
| |
Uint32 portNumberHttps; | Uint32 portNumberHttps; |
Uint32 portNumberHttp; | Uint32 portNumberHttp; |
|
Uint32 portNumberExportHttps; |
| |
if (enableHttpsConnection) | if (enableHttpsConnection) |
{ | { |
|
|
portNumberHttp = System::lookupPort(WBEM_HTTP_SERVICE_NAME, port); | portNumberHttp = System::lookupPort(WBEM_HTTP_SERVICE_NAME, port); |
} | } |
| |
|
if (enableSSLExportClientVerification) |
|
{ |
|
// |
|
// No config property is looked up to get the default port number. |
|
// Lookup the port defined in /etc/services for the service name |
|
// wbem-exp-https and bind to that port. If the service is not defined |
|
// then log a warning message and do not start the cimserver. |
|
// |
|
Uint32 port = 0; |
|
|
|
portNumberExportHttps = System::lookupPort(WBEM_EXPORT_HTTPS_SERVICE_NAME, port); |
|
|
|
if (portNumberExportHttps == 0) |
|
{ |
|
Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::WARNING, |
|
"src.Server.cimserver.EXPORT_HTTPS_PORT_NOT_DEFINED", |
|
"Port not defined for the service wbem-exp-https. CIMServer will not be started."); |
|
|
|
MessageLoaderParms parms("src.Server.cimserver.EXPORT_HTTPS_PORT_NOT_DEFINED", |
|
"Port not defined for the service wbem-exp-https. CIMServer will not be started."); |
|
|
|
cerr << MessageLoader::getMessage(parms) << endl; |
|
|
|
return(1); |
|
} |
|
} |
|
|
// Put out startup up message. | // Put out startup up message. |
#if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) && \ | #if !defined(PEGASUS_OS_HPUX) && !defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) && \ |
!defined(PEGASUS_OS_OS400) | !defined(PEGASUS_OS_OS400) |
cout << PEGASUS_NAME << PEGASUS_VERSION << endl; |
cout << PEGASUS_PRODUCT_NAME << " " << PEGASUS_PRODUCT_VERSION << endl; |
cout << "Built " << __DATE__ << " " << __TIME__ << endl; | cout << "Built " << __DATE__ << " " << __TIME__ << endl; |
cout <<"Starting..." | cout <<"Starting..." |
<< (useSLP ? " SLP reg. " : " No SLP ") | << (useSLP ? " SLP reg. " : " No SLP ") |
|
|
// try loop to bind the address, and run the server | // try loop to bind the address, and run the server |
try | try |
{ | { |
#if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) && ! defined(PEGASUS_NO_SLP) |
|
char slp_address[32]; |
|
slp_client *discovery = new slp_client() ;; |
|
String serviceURL; |
|
serviceURL.assign("service:cim.pegasus://"); |
|
String host_name = slp_get_host_name(); |
|
serviceURL.append(host_name); |
|
serviceURL.append(":"); |
|
// ATTN: Fix this to work for multiple connections |
|
sprintf(slp_address, "%u", |
|
enableHttpConnection ? portNumberHttp : portNumberHttps); |
|
serviceURL.append(slp_address); |
|
#endif |
|
|
|
Monitor monitor(true); | Monitor monitor(true); |
CIMServer server(&monitor); | CIMServer server(&monitor); |
| |
if (enableHttpConnection) | if (enableHttpConnection) |
{ | { |
server.addAcceptor(false, portNumberHttp, false); |
server.addAcceptor(false, portNumberHttp, false, false); |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, | Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
"Listening on HTTP port $0.", portNumberHttp); | "Listening on HTTP port $0.", portNumberHttp); |
} | } |
if (enableHttpsConnection) | if (enableHttpsConnection) |
{ | { |
server.addAcceptor(false, portNumberHttps, true); |
server.addAcceptor(false, portNumberHttps, true, false); |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, | Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
"Listening on HTTPS port $0.", portNumberHttps); | "Listening on HTTPS port $0.", portNumberHttps); |
} | } |
|
if (enableSSLExportClientVerification) |
|
{ |
|
server.addAcceptor(false, portNumberExportHttps, true, true); |
|
|
|
Logger::put_l(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
"src.Server.cimserver.LISTENING_ON_EXPORT_HTTPS_PORT", |
|
"Listening on Export HTTPS port $0.", portNumberExportHttps); |
|
} |
|
|
#ifdef PEGASUS_LOCAL_DOMAIN_SOCKET | #ifdef PEGASUS_LOCAL_DOMAIN_SOCKET |
server.addAcceptor(true, 0, false); |
server.addAcceptor(true, 0, false, false); |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, | Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
"Listening on local connection socket."); | "Listening on local connection socket."); |
#endif | #endif |
|
|
{ | { |
cout << "Listening on HTTPS port " << portNumberHttps << endl; | cout << "Listening on HTTPS port " << portNumberHttps << endl; |
} | } |
|
if (enableSSLExportClientVerification) |
|
{ |
|
MessageLoaderParms parms("src.Server.cimserver.LISTENING_ON_EXPORT_HTTPS_PORT", |
|
"Listening on Export HTTPS port $0.", portNumberExportHttps); |
|
|
|
cout << MessageLoader::getMessage(parms) << endl; |
|
} |
|
|
|
|
# ifdef PEGASUS_LOCAL_DOMAIN_SOCKET | # ifdef PEGASUS_LOCAL_DOMAIN_SOCKET |
cout << "Listening on local connection socket" << endl; | cout << "Listening on local connection socket" << endl; |
# endif | # endif |
|
|
#endif | #endif |
| |
// Put server started message to the logger | // Put server started message to the logger |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
Logger::INFORMATION, "Started $0 version $1.", |
"Started $0 version $1.", |
PEGASUS_PRODUCT_NAME, PEGASUS_PRODUCT_VERSION); |
PLATFORM_PRODUCT_NAME, PLATFORM_PRODUCT_VERSION); |
|
#else |
|
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
"Started $0 version $1.", |
|
PEGASUS_NAME, PEGASUS_VERSION); |
|
#endif |
|
|
|
| |
// | // |
// Loop to call CIMServer's runForever() method until CIMServer | // Loop to call CIMServer's runForever() method until CIMServer |
|
|
// | // |
while( !server.terminated() ) | while( !server.terminated() ) |
{ | { |
#if !defined(PEGASUS_OS_ZOS) && ! defined(PEGASUS_OS_HPUX) && ! defined(PEGASUS_NO_SLP) |
|
if(useSLP ) |
|
{ |
|
if( (time(NULL) - last ) > 60 ) |
|
{ |
|
if( discovery != NULL && serviceURL.size() ) |
|
discovery->srv_reg_all(serviceURL.getCString(), |
|
"(namespace=root/cimv2)", |
|
"service:cim.pegasus", |
|
"DEFAULT", |
|
70) ; |
|
time(&last); |
|
} |
|
|
|
discovery->service_listener(); |
|
} |
|
#endif |
|
server.runForever(); | server.runForever(); |
} | } |
| |
// | // |
// normal termination | // normal termination |
// | // |
|
|
// Put server shutdown message to the logger | // Put server shutdown message to the logger |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_IA64_GNU) |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, |
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
Logger::INFORMATION, |
"$0 stopped.", PLATFORM_PRODUCT_NAME); |
"$0 stopped.", PEGASUS_PRODUCT_NAME); |
#else |
|
Logger::put(Logger::STANDARD_LOG, System::CIMSERVER, Logger::INFORMATION, |
|
"$0 stopped.", PEGASUS_NAME); |
|
#endif |
|
| |
#if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) | #if defined(PEGASUS_OS_HPUX) || defined(PEGASUS_PLATFORM_LINUX_GENERIC_GNU) || defined(PEGASUS_PLATFORM_ZOS_ZSERIES_IBM) |
// | // |