mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge branch '4.13'
This commit is contained in:
commit
8e4be6dc60
@ -104,6 +104,7 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
|
|||||||
private static final ConfigKey<Integer> VmJobLockTimeout = new ConfigKey<Integer>("Advanced",
|
private static final ConfigKey<Integer> VmJobLockTimeout = new ConfigKey<Integer>("Advanced",
|
||||||
Integer.class, "vm.job.lock.timeout", "1800",
|
Integer.class, "vm.job.lock.timeout", "1800",
|
||||||
"Time in seconds to wait in acquiring lock to submit a vm worker job", false);
|
"Time in seconds to wait in acquiring lock to submit a vm worker job", false);
|
||||||
|
private static final ConfigKey<Boolean> HidePassword = new ConfigKey<Boolean>("Advanced", Boolean.class, "log.hide.password", "true", "If set to true, the password is hidden", true, ConfigKey.Scope.Global);
|
||||||
|
|
||||||
private static final Logger s_logger = Logger.getLogger(AsyncJobManagerImpl.class);
|
private static final Logger s_logger = Logger.getLogger(AsyncJobManagerImpl.class);
|
||||||
|
|
||||||
@ -159,7 +160,7 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ConfigKey<?>[] getConfigKeys() {
|
public ConfigKey<?>[] getConfigKeys() {
|
||||||
return new ConfigKey<?>[] {JobExpireMinutes, JobCancelThresholdMinutes, VmJobLockTimeout};
|
return new ConfigKey<?>[] {JobExpireMinutes, JobCancelThresholdMinutes, VmJobLockTimeout, HidePassword};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -255,9 +256,11 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
|
|||||||
@DB
|
@DB
|
||||||
public void completeAsyncJob(final long jobId, final Status jobStatus, final int resultCode, final String resultObject) {
|
public void completeAsyncJob(final long jobId, final Status jobStatus, final int resultCode, final String resultObject) {
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
s_logger.debug("Complete async job-" + jobId + ", jobStatus: " + jobStatus + ", resultCode: " + resultCode + ", result: " + resultObject);
|
String resultObj = obfuscatePassword(resultObject, HidePassword.value());
|
||||||
|
s_logger.debug("Complete async job-" + jobId + ", jobStatus: " + jobStatus + ", resultCode: " + resultCode + ", result: " + resultObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final AsyncJobVO job = _jobDao.findById(jobId);
|
final AsyncJobVO job = _jobDao.findById(jobId);
|
||||||
if (job == null) {
|
if (job == null) {
|
||||||
if (s_logger.isDebugEnabled()) {
|
if (s_logger.isDebugEnabled()) {
|
||||||
@ -460,6 +463,20 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
|
|||||||
return job;
|
return job;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String obfuscatePassword(String result, boolean hidePassword) {
|
||||||
|
if (hidePassword) {
|
||||||
|
String pattern = "\"password\":";
|
||||||
|
if (result != null) {
|
||||||
|
if (result.contains(pattern)) {
|
||||||
|
String[] resp = result.split(pattern);
|
||||||
|
String psswd = resp[1].toString().split(",")[0];
|
||||||
|
result = resp[0] + pattern + psswd.replace(psswd.substring(2, psswd.length() - 1), "*****") + "," + resp[1].split(",", 2)[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private void scheduleExecution(final AsyncJobVO job) {
|
private void scheduleExecution(final AsyncJobVO job) {
|
||||||
scheduleExecution(job, false);
|
scheduleExecution(job, false);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,6 +24,7 @@ import org.apache.cloudstack.storage.to.VolumeObjectTO;
|
|||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.libvirt.Connect;
|
import org.libvirt.Connect;
|
||||||
import org.libvirt.Domain;
|
import org.libvirt.Domain;
|
||||||
|
import org.libvirt.DomainInfo.DomainState;
|
||||||
import org.libvirt.DomainSnapshot;
|
import org.libvirt.DomainSnapshot;
|
||||||
import org.libvirt.LibvirtException;
|
import org.libvirt.LibvirtException;
|
||||||
|
|
||||||
@ -58,6 +59,9 @@ public final class LibvirtDeleteVMSnapshotCommandWrapper extends CommandWrapper<
|
|||||||
|
|
||||||
snapshot = dm.snapshotLookupByName(cmd.getTarget().getSnapshotName());
|
snapshot = dm.snapshotLookupByName(cmd.getTarget().getSnapshotName());
|
||||||
|
|
||||||
|
s_logger.debug("Suspending domain " + vmName);
|
||||||
|
dm.suspend(); // suspend the vm to avoid image corruption
|
||||||
|
|
||||||
snapshot.delete(0); // only remove this snapshot, not children
|
snapshot.delete(0); // only remove this snapshot, not children
|
||||||
|
|
||||||
return new DeleteVMSnapshotAnswer(cmd, cmd.getVolumeTOs());
|
return new DeleteVMSnapshotAnswer(cmd, cmd.getVolumeTOs());
|
||||||
@ -100,6 +104,10 @@ public final class LibvirtDeleteVMSnapshotCommandWrapper extends CommandWrapper<
|
|||||||
} finally {
|
} finally {
|
||||||
if (dm != null) {
|
if (dm != null) {
|
||||||
try {
|
try {
|
||||||
|
if (dm.getInfo().state == DomainState.VIR_DOMAIN_PAUSED) {
|
||||||
|
s_logger.debug("Resuming domain " + vmName);
|
||||||
|
dm.resume();
|
||||||
|
}
|
||||||
dm.free();
|
dm.free();
|
||||||
} catch (LibvirtException l) {
|
} catch (LibvirtException l) {
|
||||||
s_logger.trace("Ignoring libvirt error.", l);
|
s_logger.trace("Ignoring libvirt error.", l);
|
||||||
|
|||||||
@ -71,6 +71,8 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
|
|||||||
"If true, router minimum required version is checked before sending command", false);
|
"If true, router minimum required version is checked before sending command", false);
|
||||||
static final ConfigKey<Boolean> UseExternalDnsServers = new ConfigKey<Boolean>(Boolean.class, "use.external.dns", "Advanced", "false",
|
static final ConfigKey<Boolean> UseExternalDnsServers = new ConfigKey<Boolean>(Boolean.class, "use.external.dns", "Advanced", "false",
|
||||||
"Bypass internal dns, use external dns1 and dns2", true, ConfigKey.Scope.Zone, null);
|
"Bypass internal dns, use external dns1 and dns2", true, ConfigKey.Scope.Zone, null);
|
||||||
|
static final ConfigKey<Boolean> ExposeDnsAndBootpServer = new ConfigKey<Boolean>(Boolean.class, "expose.dns.externally", "Advanced", "true",
|
||||||
|
"open dns, dhcp and bootp on the public interface", true, ConfigKey.Scope.Zone, null);
|
||||||
|
|
||||||
// Health checks
|
// Health checks
|
||||||
static final ConfigKey<Boolean> RouterHealthChecksEnabled = new ConfigKey<Boolean>(Boolean.class, "router.health.checks.enabled", "Advanced", "true",
|
static final ConfigKey<Boolean> RouterHealthChecksEnabled = new ConfigKey<Boolean>(Boolean.class, "router.health.checks.enabled", "Advanced", "true",
|
||||||
|
|||||||
@ -2125,6 +2125,10 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Boolean.TRUE.equals(ExposeDnsAndBootpServer.valueIn(dc.getId()))) {
|
||||||
|
buf.append(" exposedns=true");
|
||||||
|
}
|
||||||
|
|
||||||
if (Boolean.valueOf(_configDao.getValue(Config.BaremetalProvisionDoneNotificationEnabled.key()))) {
|
if (Boolean.valueOf(_configDao.getValue(Config.BaremetalProvisionDoneNotificationEnabled.key()))) {
|
||||||
final QueryBuilder<UserVO> acntq = QueryBuilder.create(UserVO.class);
|
final QueryBuilder<UserVO> acntq = QueryBuilder.create(UserVO.class);
|
||||||
acntq.and(acntq.entity().getUsername(), SearchCriteria.Op.EQ, "baremetal-system-account");
|
acntq.and(acntq.entity().getUsername(), SearchCriteria.Op.EQ, "baremetal-system-account");
|
||||||
@ -3251,7 +3255,8 @@ Configurable, StateListener<VirtualMachine.State, VirtualMachine.Event, VirtualM
|
|||||||
RouterHealthChecksToExclude,
|
RouterHealthChecksToExclude,
|
||||||
RouterHealthChecksFreeDiskSpaceThreshold,
|
RouterHealthChecksFreeDiskSpaceThreshold,
|
||||||
RouterHealthChecksMaxCpuUsageThreshold,
|
RouterHealthChecksMaxCpuUsageThreshold,
|
||||||
RouterHealthChecksMaxMemoryUsageThreshold
|
RouterHealthChecksMaxMemoryUsageThreshold,
|
||||||
|
ExposeDnsAndBootpServer
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -22,6 +22,7 @@ import hashlib
|
|||||||
import base64
|
import base64
|
||||||
import traceback
|
import traceback
|
||||||
import logging
|
import logging
|
||||||
|
import re
|
||||||
|
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
|
|
||||||
@ -147,11 +148,18 @@ server = None
|
|||||||
@app.route('/baremetal/provisiondone/<mac>', methods=['GET'])
|
@app.route('/baremetal/provisiondone/<mac>', methods=['GET'])
|
||||||
def notify_provisioning_done(mac):
|
def notify_provisioning_done(mac):
|
||||||
try:
|
try:
|
||||||
|
if not is_a_mac(mac):
|
||||||
|
raise "there is an issue with that '%s'. Not a mac?" % mac
|
||||||
return server.notify_provisioning_done(mac)
|
return server.notify_provisioning_done(mac)
|
||||||
except:
|
except:
|
||||||
logger.warn(traceback.format_exc())
|
logger.warn(traceback.format_exc())
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
def is_a_mac(mac):
|
||||||
|
if re.match("[0-9a-f]{2}([-:]?)[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", mac.lower()):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
server = Server()
|
server = Server()
|
||||||
|
|||||||
@ -566,9 +566,12 @@ class CsIP:
|
|||||||
logging.error(
|
logging.error(
|
||||||
"Not able to setup source-nat for a regular router yet")
|
"Not able to setup source-nat for a regular router yet")
|
||||||
|
|
||||||
if self.config.has_dns() or self.config.is_dhcp():
|
if (self.config.has_dns() or self.config.is_dhcp()) and self.config.expose_dns():
|
||||||
|
logging.info("Making dns publicly available")
|
||||||
dns = CsDnsmasq(self)
|
dns = CsDnsmasq(self)
|
||||||
dns.add_firewall_rules()
|
dns.add_firewall_rules()
|
||||||
|
else:
|
||||||
|
logging.info("Not making dns publicly available")
|
||||||
|
|
||||||
if self.config.has_metadata():
|
if self.config.has_metadata():
|
||||||
app = CsApache(self)
|
app = CsApache(self)
|
||||||
|
|||||||
@ -78,6 +78,9 @@ class CsConfig(object):
|
|||||||
def use_extdns(self):
|
def use_extdns(self):
|
||||||
return self.cmdline().idata().get('useextdns', 'false') == 'true'
|
return self.cmdline().idata().get('useextdns', 'false') == 'true'
|
||||||
|
|
||||||
|
def expose_dns(self):
|
||||||
|
return self.cmdline().idata().get('exposedns', 'false') == 'true'
|
||||||
|
|
||||||
def get_dns(self):
|
def get_dns(self):
|
||||||
conf = self.cmdline().idata()
|
conf = self.cmdline().idata()
|
||||||
dns = []
|
dns = []
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user