mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-9835 : Management server and SSVM should be in time sync
Added a new configuration paremetar "ntp.server.list" to configure NTP server ip in NTP settings of SSVM
This commit is contained in:
parent
f0dd5994b4
commit
8a4f3e53b6
@ -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<Long>,
|
||||
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<String> NTPServerConfig = new ConfigKey<String>(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};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -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}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user