diff --git a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java index 79c1de13a68..79c6bab1b4b 100644 --- a/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java +++ b/services/secondary-storage/controller/src/org/apache/cloudstack/secondarystorage/SecondaryStorageManagerImpl.java @@ -36,6 +36,8 @@ import org.apache.cloudstack.engine.orchestration.service.NetworkOrchestrationSe import org.apache.cloudstack.engine.subsystem.api.storage.DataStore; import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager; import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope; +import org.apache.cloudstack.framework.config.ConfigKey; +import org.apache.cloudstack.framework.config.Configurable; import org.apache.cloudstack.framework.config.dao.ConfigurationDao; import org.apache.cloudstack.framework.security.keystore.KeystoreManager; import org.apache.cloudstack.storage.datastore.db.ImageStoreDao; @@ -164,7 +166,7 @@ import com.cloud.vm.dao.VMInstanceDao; // because sooner or later, it will be driven into Running state // public class SecondaryStorageManagerImpl extends ManagerBase implements SecondaryStorageVmManager, VirtualMachineGuru, SystemVmLoadScanHandler, - ResourceStateAdapter { + ResourceStateAdapter, Configurable { private static final Logger s_logger = Logger.getLogger(SecondaryStorageManagerImpl.class); private static final int DEFAULT_CAPACITY_SCAN_INTERVAL = 30000; // 30 @@ -257,6 +259,9 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar private final GlobalLock _allocLock = GlobalLock.getInternLock(getAllocLockName()); + static final ConfigKey NTPServerConfig = new ConfigKey(String.class, "ntp.server.list", "Advanced", null, + "Comma separated list of NTP servers to configure in Secondary storage VM", false, ConfigKey.Scope.Global, null); + public SecondaryStorageManagerImpl() { } @@ -1145,6 +1150,10 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar buf.append(" vmpassword=").append(_configDao.getValue("system.vm.password")); } + if (NTPServerConfig.value() != null) { + buf.append(" ntpserverlist=").append(NTPServerConfig.value().replaceAll("\\s+","")); + } + for (NicProfile nic : profile.getNics()) { int deviceId = nic.getDeviceId(); if (nic.getIPv4Address() == null) { @@ -1490,4 +1499,14 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar _ssVmAllocators = ssVmAllocators; } + @Override + public String getConfigComponentName() { + return SecondaryStorageManagerImpl.class.getSimpleName(); + } + + @Override + public ConfigKey[] getConfigKeys() { + return new ConfigKey[] {NTPServerConfig}; + } + } diff --git a/systemvm/patches/debian/config/etc/init.d/cloud-early-config b/systemvm/patches/debian/config/etc/init.d/cloud-early-config index 3675edcb8a6..ac54ebfd1fb 100755 --- a/systemvm/patches/debian/config/etc/init.d/cloud-early-config +++ b/systemvm/patches/debian/config/etc/init.d/cloud-early-config @@ -1139,6 +1139,27 @@ getPublicIp() { echo $public_ip } +setup_ntp() { + log_it "Setting up NTP" + NTP_CONF_FILE="/etc/ntp.conf" + if [ -f $NTP_CONF_FILE ] + then + IFS=',' read -a server_list <<< "$NTP_SERVER_LIST" + for (( iterator=${#server_list[@]}-1 ; iterator>=0 ; iterator-- )) + do + server=$(echo ${server_list[iterator]} | tr -d '\r') + PATTERN="server $server" + if grep -q "^$PATTERN$" $NTP_CONF_FILE ; then + sed -i "/^$PATTERN$/d" $NTP_CONF_FILE + fi + sed -i "0,/^server/s//$PATTERN\nserver/" $NTP_CONF_FILE + done + service ntp restart + else + log_it "NTP configuration file not found" + fi +} + setup_secstorage() { log_it "Setting up secondary storage system vm" sysctl vm.min_free_kbytes=8192 @@ -1191,6 +1212,7 @@ CORS enable_svc cloud-passwd-srvr 0 enable_svc cloud 1 rm /etc/logrotate.d/cloud + setup_ntp } setup_console_proxy() { @@ -1513,6 +1535,9 @@ for i in $CMDLINE advert_int) ADVERT_INT=$VALUE ;; + ntpserverlist) + NTP_SERVER_LIST=$VALUE + ;; esac done echo -e "\n\t}\n}" >> ${CHEF_TMP_FILE}