mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Allow custom NTP servers for CPVM (#11210)
This commit is contained in:
parent
a51a04efc2
commit
890386e949
@ -24,6 +24,7 @@ import com.cloud.utils.PasswordGenerator;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import org.apache.cloudstack.ca.CAManager;
|
||||
import org.apache.cloudstack.framework.ca.Certificate;
|
||||
import org.apache.cloudstack.framework.config.ConfigKey;
|
||||
import org.apache.cloudstack.utils.security.CertUtils;
|
||||
import org.apache.cloudstack.utils.security.KeyStoreUtils;
|
||||
|
||||
@ -37,6 +38,9 @@ import java.util.Base64;
|
||||
*/
|
||||
public interface VirtualMachineGuru {
|
||||
|
||||
static final ConfigKey<String> NTPServerConfig = new ConfigKey<String>(String.class, "ntp.server.list", "Advanced", null,
|
||||
"Comma separated list of NTP servers to configure in System VMs", true, ConfigKey.Scope.Global, null, null, null, null, null, ConfigKey.Kind.CSV, null);
|
||||
|
||||
boolean finalizeVirtualMachineProfile(VirtualMachineProfile profile, DeployDestination dest, ReservationContext context);
|
||||
|
||||
/**
|
||||
|
||||
@ -1276,6 +1276,10 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
|
||||
buf.append(" vmpassword=").append(configurationDao.getValue("system.vm.password"));
|
||||
}
|
||||
|
||||
if (StringUtils.isNotEmpty(NTPServerConfig.value())) {
|
||||
buf.append(" ntpserverlist=").append(NTPServerConfig.value().replaceAll("\\s+",""));
|
||||
}
|
||||
|
||||
for (NicProfile nic : profile.getNics()) {
|
||||
int deviceId = nic.getDeviceId();
|
||||
if (nic.getIPv4Address() == null) {
|
||||
@ -1506,7 +1510,7 @@ public class ConsoleProxyManagerImpl extends ManagerBase implements ConsoleProxy
|
||||
public Long[] getScannablePools() {
|
||||
List<Long> zoneIds = dataCenterDao.listEnabledNonEdgeZoneIds();
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(String.format("Enabled non-edge zones available for scan: %s", org.apache.commons.lang3.StringUtils.join(zoneIds, ",")));
|
||||
logger.debug(String.format("Enabled non-edge zones available for scan: %s", StringUtils.join(zoneIds, ",")));
|
||||
}
|
||||
return zoneIds.toArray(Long[]::new);
|
||||
}
|
||||
|
||||
@ -268,9 +268,6 @@ 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", true, ConfigKey.Scope.Global, null, null, null, null, null, ConfigKey.Kind.CSV, null);
|
||||
|
||||
static final ConfigKey<Integer> MaxNumberOfSsvmsForMigration = new ConfigKey<Integer>("Advanced", Integer.class, "max.ssvm.count", "5",
|
||||
"Number of additional SSVMs to handle migration of data objects concurrently", true, ConfigKey.Scope.Global);
|
||||
|
||||
@ -1178,7 +1175,7 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
|
||||
buf.append(" vmpassword=").append(_configDao.getValue("system.vm.password"));
|
||||
}
|
||||
|
||||
if (NTPServerConfig.value() != null) {
|
||||
if (StringUtils.isNotEmpty(NTPServerConfig.value())) {
|
||||
buf.append(" ntpserverlist=").append(NTPServerConfig.value().replaceAll("\\s+",""));
|
||||
}
|
||||
|
||||
|
||||
@ -683,7 +683,7 @@ getPublicIp() {
|
||||
|
||||
setup_ntp() {
|
||||
log_it "Setting up NTP"
|
||||
NTP_CONF_FILE="/etc/ntp.conf"
|
||||
NTP_CONF_FILE="/etc/ntpsec/ntp.conf"
|
||||
if [ -f $NTP_CONF_FILE ]
|
||||
then
|
||||
IFS=',' read -a server_list <<< "$NTP_SERVER_LIST"
|
||||
@ -694,7 +694,7 @@ setup_ntp() {
|
||||
PATTERN="server $server"
|
||||
sed -i "0,/^# server/s//$PATTERN\n# server/" $NTP_CONF_FILE
|
||||
done
|
||||
systemctl enable ntp
|
||||
systemctl enable --now --no-block ntp
|
||||
else
|
||||
log_it "NTP configuration file not found"
|
||||
fi
|
||||
|
||||
@ -40,6 +40,10 @@ setup_console_proxy() {
|
||||
disable_rpfilter
|
||||
enable_fwding 0
|
||||
enable_irqbalance 0
|
||||
if [[ -n "$NTP_SERVER_LIST" ]]; then
|
||||
setup_ntp
|
||||
systemctl restart ntp
|
||||
fi
|
||||
rm -f /etc/logrotate.d/cloud
|
||||
|
||||
}
|
||||
|
||||
@ -82,6 +82,7 @@ HTTP
|
||||
enable_fwding 0
|
||||
enable_irqbalance 0
|
||||
setup_ntp
|
||||
systemctl restart ntp
|
||||
|
||||
rm -f /etc/logrotate.d/cloud
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user