Listener is auto configured during the install upon MA being started.
Listener is started/stopped automatically when tunnel is enabled/disabled.
}
CAF_CM_EXIT;
CAF_CM_VALIDATE_STRING(filename);
-
+
return filename;
}
+
+std::string FileSystemUtils::executeScript(
+ const std::string& scriptPath,
+ const std::string& scriptResultsDir) {
+ CAF_CM_STATIC_FUNC_LOG_VALIDATE("FileSystemUtils", "executeScript");
+ CAF_CM_VALIDATE_STRING(scriptPath);
+ CAF_CM_VALIDATE_STRING(scriptResultsDir);
+
+ Cdeqstr argv;
+ argv.push_back(scriptPath);
+
+ const std::string basename = FileSystemUtils::getBasename(scriptPath);
+ const std::string stdoutPath = FileSystemUtils::buildPath(
+ scriptResultsDir, basename + ".stdout");
+ const std::string stderrPath = FileSystemUtils::buildPath(
+ scriptResultsDir, basename + ".stderr");
+
+ ProcessUtils::runSyncToFiles(argv, stdoutPath, stderrPath);
+
+ std::string rc;
+ if (FileSystemUtils::doesFileExist(stdoutPath)) {
+ rc = FileSystemUtils::loadTextFile(stdoutPath);
+ }
+
+ return rc;
+}
const std::string &path);
static int64 getFileSize(const std::string& filename);
-
+
static std::string saveTempTextFile(const std::string& filename_template, const std::string& contents);
-
+
static std::string getTempFilename(const std::string& filename_template);
+ static std::string executeScript(
+ const std::string& scriptPath,
+ const std::string& scriptResultsDir);
+
private:
static void saveFileSafely(
const std::string& filePath,
int32 _listenerRetryCnt;
int32 _listenerRetryMax;
+ SmartPtrCMonitorListener _monitorListener;
+
private:
CAF_CM_CREATE;
CAF_CM_CREATE_LOG;
_persistenceRemove = persistenceRemove;
}
} else {
+ _monitorListener.CreateInstance();
+ _monitorListener->initialize();
+
_persistenceRemove = persistenceRemove;
_persistenceDir = AppConfigUtils::getRequiredString("persistence_dir");
CAF_CM_LOCK_UNLOCK;
CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
+ bool preConfigDoneNow = _monitorListener->preConfigureListener();
if (FileSystemUtils::doesFileExist(_listenerConfiguredStage1Path)) {
- if (_persistence.IsNull()) {
+ if (_persistence.IsNull() || preConfigDoneNow) {
_persistence = CPersistenceUtils::loadPersistence(_persistenceDir);
if (FileSystemUtils::doesFileExist(_listenerConfiguredStage2Path)) {
_persistenceUpdated = _persistence;
}
}
- const SmartPtrCPersistenceDoc persistenceTmp =
- CConfigEnvMerge::mergePersistence(_persistence, _cacertPath, _vcidPath);
+ SmartPtrCPersistenceDoc persistenceTmp;
+ if (preConfigDoneNow) {
+ persistenceTmp = CConfigEnvMerge::mergePersistence(
+ _persistence, _cacertPath, _vcidPath);
+ }
if (! persistenceTmp.IsNull()) {
CPersistenceUtils::savePersistence(persistenceTmp, _persistenceDir);
_persistence = CPersistenceUtils::loadPersistence(_persistenceDir);
CAF_CM_LOCK_UNLOCK;
CAF_CM_PRECOND_ISINITIALIZED(_isInitialized);
+ getUpdated(0);
+
const SmartPtrCPersistenceDoc persistenceTmp1 =
CPersistenceMerge::mergePersistence(_persistence, persistence);
SmartPtrCPersistenceDoc _persistence;
SmartPtrCPersistenceDoc _persistenceUpdated;
SmartPtrIPersistence _persistenceRemove;
+ SmartPtrCMonitorListener _monitorListener;
private:
CAF_CM_CREATE;
const std::string& cacertPath,
const std::string& vcidPath);
+ static bool isTunnelEnabledFunc();
+
private:
static std::deque<SmartPtrCPersistenceProtocolDoc> mergePersistenceProtocolCollectionInner(
const std::deque<SmartPtrCPersistenceProtocolDoc>& persistenceProtocolCollectionInner,
const std::string& cacert);
private:
- static bool isTunnelEnabledFunc();
-
static std::string loadTextFile(
const std::string& path);
using namespace Caf;
+#define LISTENER_STARTUP_TYPE_AUTOMATIC "Automatic"
+
CMonitorReadingMessageSource::CMonitorReadingMessageSource() :
_isInitialized(false),
_listenerStartTimeMs(0),
const SmartPtrIDocument pollerDoc = configSection->findOptionalChild("poller");
setPollerMetadata(pollerDoc);
+
+ _monitorListener.CreateInstance();
+ _monitorListener->initialize();
+
_monitorDir = AppConfigUtils::getRequiredString("monitor_dir");
_restartListenerPath = FileSystemUtils::buildPath(_monitorDir, "restartListener.txt");
_listenerConfiguredStage2Path = FileSystemUtils::buildPath(_monitorDir, "listenerConfiguredStage2.txt");
}
std::string reason;
+ // If Listener is pre-configured and Tunnel enabled, start listener
+ // Sets startup type if it is following tunnel
+ _monitorListener->followTunnel(_listenerStartupType);
+
if (FileSystemUtils::doesFileExist(_listenerConfiguredStage2Path)) {
if (FileSystemUtils::doesFileExist(_restartListenerPath)) {
reason = FileSystemUtils::loadTextFile(_restartListenerPath);
+ CStringConv::toString<int32>(_listenerRetryMax);
_listenerRetryCnt++;
_listenerStartTimeMs = CDateTimeUtils::getTimeMs();
- startListener(reason);
+ _monitorListener->startListener(reason);
} else {
reason = "Listener not running... Retries exhausted - "
+ CStringConv::toString<int32>(_listenerRetryCnt + 1) + " of "
#include "CPersistenceInboundChannelAdapterInstance.h"
#include "CPersistenceOutboundChannelAdapterInstance.h"
+#include "CMonitorListener.h"
+
#include "CPersistenceMerge.h"
#include "CConfigEnvMerge.h"
#include "CConfigEnv.h"
#include "CConfigEnvInboundChannelAdapterInstance.h"
#include "CConfigEnvOutboundChannelAdapterInstance.h"
-
#include "CCollectSchemaExecutor.h"
#include "CProviderCollectSchemaExecutor.h"
#include "CProviderExecutor.h"
reply_timeout=5000
[security]
-cms_policy=CAF_Encrypted_And_Signed
-is_signing_enforced=true
-is_encryption_enforced=true
+cms_policy=None
+is_signing_enforced=false
+is_encryption_enforced=false
tls_protocol=TLSv1_2
tls_ciphers=SRP-RSA-AES-128-CBC-SHA
bean_config_file=${config_dir}/ma-context.xml
log_config_file=${config_dir}/ma-log4cpp_config
scripts_dir=${config_dir}/../scripts
+install_dir=${config_dir}/../install
thread_stack_size_kb=0
remap_logging_location=false
[security]
-cms_policy=CAF_Encrypted_And_Signed
+cms_policy=None
[managementAgent]
host_delay_sec=5
listener_retry_max=-1
listener_startup_type=Automatic
listener_restart_hours=48
+listener_ctrl_preconfigure=1
+listener_ctrl_follow_tunnel=1
nsdb_poller_signal_file=${monitor_dir}/nsdbPollerSignal.txt
nsdb_polling_interval_secs=86400
common_packages_dir=${input_dir}/commonPackages
[security]
-cms_policy=CAF_Encrypted_And_Signed
\ No newline at end of file
+cms_policy=None
\ No newline at end of file
--- /dev/null
+#!/bin/sh
+
+#Standard env
+SCRIPT=`basename "$0"`
+
+installDir=$(dirname $(readlink -f $0))
+scriptsDir=$installDir/../scripts
+configDir=$installDir/../config
+
+set_caf_pme_paths()
+{
+ PATH=$PATH:$installDir:$scriptsDir
+ PERSISTENCE_DIR=${CAF_INPUT_DIR}/persistence
+ CERTS_DIR=${CERTS_DIR:-'/etc/vmware-tools/GuestProxyData/server'}
+}
+
+configure_caf_common()
+{
+ mkdir -p ${PERSISTENCE_DIR}/local
+ mkdir -p ${PERSISTENCE_DIR}/remote/remote_default/cmsCertCollection
+ mkdir -p ${PERSISTENCE_DIR}/protocol/amqpBroker_default/tlsCertCollection
+ mkdir -p ${PERSISTENCE_DIR}/protocol/amqpBroker_default/tlsCipherCollection/
+
+ echo "amqpBroker_default" > ${PERSISTENCE_DIR}/remote/remote_default/protocolName.txt
+ echo "remote_default" > ${PERSISTENCE_DIR}/remote/remote_default/remoteId.txt
+ echo "des-ede3-cbc" > ${PERSISTENCE_DIR}/remote/remote_default/cmsCipherName.txt
+
+ echo "SRP-RSA-AES-128-CBC-SHA" > ${PERSISTENCE_DIR}/protocol/amqpBroker_default/tlsCipherCollection/tlsCipher0.txt
+ echo "amqpBroker_default" > ${PERSISTENCE_DIR}/protocol/amqpBroker_default/protocolName.txt
+ echo "TLSv1" > ${PERSISTENCE_DIR}/protocol/amqpBroker_default/tlsProtocol.txt
+
+ cp -rf ${CERTS_DIR}/cert.pem ${PERSISTENCE_DIR}/local/cert.pem
+ cp -rf ${CERTS_DIR}/key.pem ${PERSISTENCE_DIR}/local/privateKey.pem
+
+ cp -rf ${CERTS_DIR}/cert.pem ${PERSISTENCE_DIR}/protocol/amqpBroker_default/tlsCert.pem
+ cp -rf ${CERTS_DIR}/cert.pem ${PERSISTENCE_DIR}/protocol/amqpBroker_default/tlsCertCollection/tlsCert0.pem
+
+ cp -rf ${CERTS_DIR}/cert.pem ${PERSISTENCE_DIR}/remote/remote_default/cmsCertCollection/cmsCert0.pem
+ cp -rf ${CERTS_DIR}/cert.pem ${PERSISTENCE_DIR}/remote/remote_default/cmsCert.pem
+
+ /usr/bin/vmware-guestproxycerttool -a ${PERSISTENCE_DIR}/local/cert.pem
+ /usr/bin/vmware-guestproxycerttool -a ${PERSISTENCE_DIR}/protocol/amqpBroker_default/tlsCert.pem
+ /usr/bin/vmware-guestproxycerttool -a ${PERSISTENCE_DIR}/protocol/amqpBroker_default/tlsCertCollection/tlsCert0.pem
+
+}
+
+##=============================================================================
+## Main
+##=============================================================================
+. $scriptsDir/caf-common
+sourceCafenv "$configDir"
+
+set_caf_pme_paths
+configure_caf_common
+
+#echo QUIT | openssl s_client -connect localhost:6672 -cert ${CERTS_DIR}/cert.pem -key ${CERTS_DIR}/key.pem -CAfile ${CERTS_DIR}/cert.pem -tls1_2
+#echo QUIT | openssl s_client -connect localhost:6672 -cert ${CERTS_DIR}/cert.pem -key ${CERTS_DIR}/key.pem -CAfile ${CERTS_DIR}/cert.pem -tls1_2
+
+echo -n true
+