Skip to content

Commit 8e4be6d

Browse files
committed
Merge branch '4.13'
2 parents b406e1d + 2637a86 commit 8e4be6d

7 files changed

Lines changed: 50 additions & 4 deletions

File tree

framework/jobs/src/main/java/org/apache/cloudstack/framework/jobs/impl/AsyncJobManagerImpl.java

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ public class AsyncJobManagerImpl extends ManagerBase implements AsyncJobManager,
104104
private static final ConfigKey<Integer> VmJobLockTimeout = new ConfigKey<Integer>("Advanced",
105105
Integer.class, "vm.job.lock.timeout", "1800",
106106
"Time in seconds to wait in acquiring lock to submit a vm worker job", false);
107+
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);
107108

108109
private static final Logger s_logger = Logger.getLogger(AsyncJobManagerImpl.class);
109110

@@ -159,7 +160,7 @@ public String getConfigComponentName() {
159160

160161
@Override
161162
public ConfigKey<?>[] getConfigKeys() {
162-
return new ConfigKey<?>[] {JobExpireMinutes, JobCancelThresholdMinutes, VmJobLockTimeout};
163+
return new ConfigKey<?>[] {JobExpireMinutes, JobCancelThresholdMinutes, VmJobLockTimeout, HidePassword};
163164
}
164165

165166
@Override
@@ -255,9 +256,11 @@ public Long doInTransaction(TransactionStatus status) {
255256
@DB
256257
public void completeAsyncJob(final long jobId, final Status jobStatus, final int resultCode, final String resultObject) {
257258
if (s_logger.isDebugEnabled()) {
258-
s_logger.debug("Complete async job-" + jobId + ", jobStatus: " + jobStatus + ", resultCode: " + resultCode + ", result: " + resultObject);
259+
String resultObj = obfuscatePassword(resultObject, HidePassword.value());
260+
s_logger.debug("Complete async job-" + jobId + ", jobStatus: " + jobStatus + ", resultCode: " + resultCode + ", result: " + resultObj);
259261
}
260262

263+
261264
final AsyncJobVO job = _jobDao.findById(jobId);
262265
if (job == null) {
263266
if (s_logger.isDebugEnabled()) {
@@ -460,6 +463,20 @@ public AsyncJob queryJob(final long jobId, final boolean updatePollTime) {
460463
return job;
461464
}
462465

466+
private String obfuscatePassword(String result, boolean hidePassword) {
467+
if (hidePassword) {
468+
String pattern = "\"password\":";
469+
if (result != null) {
470+
if (result.contains(pattern)) {
471+
String[] resp = result.split(pattern);
472+
String psswd = resp[1].toString().split(",")[0];
473+
result = resp[0] + pattern + psswd.replace(psswd.substring(2, psswd.length() - 1), "*****") + "," + resp[1].split(",", 2)[1];
474+
}
475+
}
476+
}
477+
return result;
478+
}
479+
463480
private void scheduleExecution(final AsyncJobVO job) {
464481
scheduleExecution(job, false);
465482
}

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDeleteVMSnapshotCommandWrapper.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.log4j.Logger;
2525
import org.libvirt.Connect;
2626
import org.libvirt.Domain;
27+
import org.libvirt.DomainInfo.DomainState;
2728
import org.libvirt.DomainSnapshot;
2829
import org.libvirt.LibvirtException;
2930

@@ -58,6 +59,9 @@ public Answer execute(final DeleteVMSnapshotCommand cmd, final LibvirtComputingR
5859

5960
snapshot = dm.snapshotLookupByName(cmd.getTarget().getSnapshotName());
6061

62+
s_logger.debug("Suspending domain " + vmName);
63+
dm.suspend(); // suspend the vm to avoid image corruption
64+
6165
snapshot.delete(0); // only remove this snapshot, not children
6266

6367
return new DeleteVMSnapshotAnswer(cmd, cmd.getVolumeTOs());
@@ -100,6 +104,10 @@ public Answer execute(final DeleteVMSnapshotCommand cmd, final LibvirtComputingR
100104
} finally {
101105
if (dm != null) {
102106
try {
107+
if (dm.getInfo().state == DomainState.VIR_DOMAIN_PAUSED) {
108+
s_logger.debug("Resuming domain " + vmName);
109+
dm.resume();
110+
}
103111
dm.free();
104112
} catch (LibvirtException l) {
105113
s_logger.trace("Ignoring libvirt error.", l);

server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManager.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkA
7171
"If true, router minimum required version is checked before sending command", false);
7272
static final ConfigKey<Boolean> UseExternalDnsServers = new ConfigKey<Boolean>(Boolean.class, "use.external.dns", "Advanced", "false",
7373
"Bypass internal dns, use external dns1 and dns2", true, ConfigKey.Scope.Zone, null);
74+
static final ConfigKey<Boolean> ExposeDnsAndBootpServer = new ConfigKey<Boolean>(Boolean.class, "expose.dns.externally", "Advanced", "true",
75+
"open dns, dhcp and bootp on the public interface", true, ConfigKey.Scope.Zone, null);
7476

7577
// Health checks
7678
static final ConfigKey<Boolean> RouterHealthChecksEnabled = new ConfigKey<Boolean>(Boolean.class, "router.health.checks.enabled", "Advanced", "true",

server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2125,6 +2125,10 @@ public boolean finalizeVirtualMachineProfile(final VirtualMachineProfile profile
21252125
}
21262126
}
21272127

2128+
if (Boolean.TRUE.equals(ExposeDnsAndBootpServer.valueIn(dc.getId()))) {
2129+
buf.append(" exposedns=true");
2130+
}
2131+
21282132
if (Boolean.valueOf(_configDao.getValue(Config.BaremetalProvisionDoneNotificationEnabled.key()))) {
21292133
final QueryBuilder<UserVO> acntq = QueryBuilder.create(UserVO.class);
21302134
acntq.and(acntq.entity().getUsername(), SearchCriteria.Op.EQ, "baremetal-system-account");
@@ -3251,7 +3255,8 @@ public ConfigKey<?>[] getConfigKeys() {
32513255
RouterHealthChecksToExclude,
32523256
RouterHealthChecksFreeDiskSpaceThreshold,
32533257
RouterHealthChecksMaxCpuUsageThreshold,
3254-
RouterHealthChecksMaxMemoryUsageThreshold
3258+
RouterHealthChecksMaxMemoryUsageThreshold,
3259+
ExposeDnsAndBootpServer
32553260
};
32563261
}
32573262

systemvm/debian/opt/cloud/bin/baremetal-vr.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import base64
2323
import traceback
2424
import logging
25+
import re
2526

2627
from flask import Flask
2728

@@ -147,11 +148,18 @@ def notify_provisioning_done(self, mac):
147148
@app.route('/baremetal/provisiondone/<mac>', methods=['GET'])
148149
def notify_provisioning_done(mac):
149150
try:
151+
if not is_a_mac(mac):
152+
raise "there is an issue with that '%s'. Not a mac?" % mac
150153
return server.notify_provisioning_done(mac)
151154
except:
152155
logger.warn(traceback.format_exc())
153156
return ''
154157

158+
def is_a_mac(mac):
159+
if re.match("[0-9a-f]{2}([-:]?)[0-9a-f]{2}(\\1[0-9a-f]{2}){4}$", mac.lower()):
160+
return True
161+
else:
162+
return False
155163

156164
if __name__ == '__main__':
157165
server = Server()

systemvm/debian/opt/cloud/bin/cs/CsAddress.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,9 +566,12 @@ def post_config_change(self, method):
566566
logging.error(
567567
"Not able to setup source-nat for a regular router yet")
568568

569-
if self.config.has_dns() or self.config.is_dhcp():
569+
if (self.config.has_dns() or self.config.is_dhcp()) and self.config.expose_dns():
570+
logging.info("Making dns publicly available")
570571
dns = CsDnsmasq(self)
571572
dns.add_firewall_rules()
573+
else:
574+
logging.info("Not making dns publicly available")
572575

573576
if self.config.has_metadata():
574577
app = CsApache(self)

systemvm/debian/opt/cloud/bin/cs/CsConfig.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ def get_domain(self):
7878
def use_extdns(self):
7979
return self.cmdline().idata().get('useextdns', 'false') == 'true'
8080

81+
def expose_dns(self):
82+
return self.cmdline().idata().get('exposedns', 'false') == 'true'
83+
8184
def get_dns(self):
8285
conf = self.cmdline().idata()
8386
dns = []

0 commit comments

Comments
 (0)