mirror of https://github.com/apache/cloudstack.git
Merge branch '4.11'
Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com>
This commit is contained in:
commit
85750f918b
|
|
@ -19,7 +19,6 @@ package org.apache.cloudstack.storage.configdrive;
|
|||
|
||||
public class ConfigDrive {
|
||||
|
||||
public final static String CONFIGDRIVEFILENAME = "configdrive.iso";
|
||||
public final static String CONFIGDRIVEDIR = "configdrive";
|
||||
|
||||
public static final String cloudStackConfigDriveName = "/cloudstack/";
|
||||
|
|
@ -27,11 +26,20 @@ public class ConfigDrive {
|
|||
|
||||
/**
|
||||
* Creates the path to ISO file relative to mount point.
|
||||
* The config driver path will have the following formated: {@link #CONFIGDRIVEDIR} + / + instanceName + / + {@link #CONFIGDRIVEFILENAME}
|
||||
* The config driver path will have the following format: {@link #CONFIGDRIVEDIR} + / + instanceName + ".iso"
|
||||
*
|
||||
* @return config drive ISO file path
|
||||
*/
|
||||
public static String createConfigDrivePath(String instanceName) {
|
||||
return ConfigDrive.CONFIGDRIVEDIR + "/" + instanceName + "/" + ConfigDrive.CONFIGDRIVEFILENAME;
|
||||
return ConfigDrive.CONFIGDRIVEDIR + "/" + configIsoFileName(instanceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Config Drive iso file name for an instance name
|
||||
* @param instanceName
|
||||
* @return
|
||||
*/
|
||||
public static String configIsoFileName(String instanceName) {
|
||||
return instanceName + ".iso";
|
||||
}
|
||||
}
|
||||
|
|
@ -79,6 +79,11 @@ public class ConfigDriveBuilder {
|
|||
public static File base64StringToFile(String encodedIsoData, String folder, String fileName) throws IOException {
|
||||
byte[] decoded = Base64.decodeBase64(encodedIsoData.getBytes(StandardCharsets.US_ASCII));
|
||||
Path destPath = Paths.get(folder, fileName);
|
||||
try {
|
||||
Files.createDirectories(destPath.getParent());
|
||||
} catch (final IOException e) {
|
||||
LOG.warn("Exception hit while trying to recreate directory: " + destPath.getParent().toString());
|
||||
}
|
||||
return Files.write(destPath, decoded).toFile();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class ConfigDriveTest {
|
|||
|
||||
@Test
|
||||
public void testConfigDriveIsoPath() throws IOException {
|
||||
Assert.assertEquals(ConfigDrive.createConfigDrivePath("i-x-y"), "configdrive/i-x-y/configdrive.iso");
|
||||
Assert.assertEquals(ConfigDrive.createConfigDrivePath("i-x-y"), "configdrive/i-x-y.iso");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -104,6 +104,7 @@ Obsoletes: cloud-daemonize < 4.1.0
|
|||
Group: System Environment/Libraries
|
||||
%description common
|
||||
The Apache CloudStack files shared between agent and management server
|
||||
%global __requires_exclude ^libuuid\\.so\\.1$
|
||||
|
||||
%package agent
|
||||
Summary: CloudStack Agent for KVM hypervisors
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ Requires: python-netaddr
|
|||
Group: System Environment/Libraries
|
||||
%description common
|
||||
The Apache CloudStack files shared between agent and management server
|
||||
%global __requires_exclude ^libuuid\\.so\\.1$
|
||||
|
||||
%package agent
|
||||
Summary: CloudStack Agent for KVM hypervisors
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import java.nio.file.Path;
|
|||
import java.nio.file.Paths;
|
||||
|
||||
import org.apache.cloudstack.storage.configdrive.ConfigDriveBuilder;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
|
@ -67,7 +66,7 @@ public final class LibvirtHandleConfigDriveCommandWrapper extends CommandWrapper
|
|||
}
|
||||
} else {
|
||||
try {
|
||||
FileUtils.deleteDirectory(isoPath.getParent().toFile());
|
||||
Files.deleteIfExists(isoPath);
|
||||
} catch (IOException e) {
|
||||
LOG.warn("Failed to delete config drive: " + isoPath.toAbsolutePath().toString());
|
||||
return new Answer(command, false, "Failed due to exception: " + e.getMessage());
|
||||
|
|
|
|||
|
|
@ -375,8 +375,9 @@ public class ConfigDriveNetworkElement extends AdapterBase implements NetworkEle
|
|||
|
||||
LOG.debug("Creating config drive ISO for vm: " + profile.getInstanceName());
|
||||
|
||||
final String isoFileName = ConfigDrive.configIsoFileName(profile.getInstanceName());
|
||||
final String isoPath = ConfigDrive.createConfigDrivePath(profile.getInstanceName());
|
||||
final String isoData = ConfigDriveBuilder.buildConfigDrive(profile.getVmData(), ConfigDrive.CONFIGDRIVEFILENAME, profile.getConfigDriveLabel());
|
||||
final String isoData = ConfigDriveBuilder.buildConfigDrive(profile.getVmData(), isoFileName, profile.getConfigDriveLabel());
|
||||
final HandleConfigDriveIsoCommand configDriveIsoCommand = new HandleConfigDriveIsoCommand(isoPath, isoData, dataStore.getTO(), true);
|
||||
|
||||
final Answer answer = agentManager.easySend(agentId, configDriveIsoCommand);
|
||||
|
|
|
|||
|
|
@ -1810,6 +1810,8 @@ public class AccountManagerImpl extends ManagerBase implements AccountManager, M
|
|||
UserVO newUser = new UserVO(user);
|
||||
user.setExternalEntity(user.getUuid());
|
||||
user.setUuid(UUID.randomUUID().toString());
|
||||
user.setApiKey(null);
|
||||
user.setSecretKey(null);
|
||||
_userDao.update(user.getId(), user);
|
||||
newUser.setAccountId(newAccountId);
|
||||
boolean success = _userDao.remove(user.getId());
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import java.io.UnsupportedEncodingException;
|
|||
import java.net.InetAddress;
|
||||
import java.net.URI;
|
||||
import java.net.UnknownHostException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
|
|
@ -337,7 +338,7 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||
Path tempDir = null;
|
||||
try {
|
||||
tempDir = java.nio.file.Files.createTempDirectory(ConfigDrive.CONFIGDRIVEDIR);
|
||||
File tmpIsoFile = ConfigDriveBuilder.base64StringToFile(cmd.getIsoData(), tempDir.toAbsolutePath().toString(), ConfigDrive.CONFIGDRIVEFILENAME);
|
||||
File tmpIsoFile = ConfigDriveBuilder.base64StringToFile(cmd.getIsoData(), tempDir.toAbsolutePath().toString(), cmd.getIsoFile());
|
||||
copyLocalToNfs(tmpIsoFile, new File(cmd.getIsoFile()), cmd.getDestStore());
|
||||
} catch (IOException | ConfigurationException e) {
|
||||
return new Answer(cmd, false, "Failed due to exception: " + e.getMessage());
|
||||
|
|
@ -355,11 +356,11 @@ public class NfsSecondaryStorageResource extends ServerResourceBase implements S
|
|||
DataStoreTO dstore = cmd.getDestStore();
|
||||
if (dstore instanceof NfsTO) {
|
||||
NfsTO nfs = (NfsTO) dstore;
|
||||
String relativeTemplatePath = new File(cmd.getIsoFile()).getParent();
|
||||
String relativeTemplatePath = new File(cmd.getIsoFile()).getPath();
|
||||
String nfsMountPoint = getRootDir(nfs.getUrl(), _nfsVersion);
|
||||
File tmpltPath = new File(nfsMountPoint, relativeTemplatePath);
|
||||
try {
|
||||
FileUtils.deleteDirectory(tmpltPath);
|
||||
Files.deleteIfExists(tmpltPath.toPath());
|
||||
} catch (IOException e) {
|
||||
return new Answer(cmd, e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -937,12 +937,9 @@ class CsForwardingRules(CsDataBag):
|
|||
self.fw.append(["filter", "",
|
||||
"-A FORWARD -i %s -o eth0 -d %s -m state --state NEW -j ACCEPT " % (device, rule["internal_ip"])])
|
||||
|
||||
# Configure the hairpin nat
|
||||
self.fw.append(["nat", "front",
|
||||
"-A PREROUTING -d %s -i eth0 -j DNAT --to-destination %s" % (rule["public_ip"], rule["internal_ip"])])
|
||||
|
||||
self.fw.append(["nat", "front", "-A POSTROUTING -s %s -d %s -j SNAT -o eth0 --to-source %s" %
|
||||
(self.getNetworkByIp(rule['internal_ip']), rule["internal_ip"], self.getGuestIp())])
|
||||
# Configure the hairpin snat
|
||||
self.fw.append(["nat", "front", "-A POSTROUTING -s %s -d %s -j SNAT -o %s --to-source %s" %
|
||||
(self.getNetworkByIp(rule['internal_ip']), rule["internal_ip"], self.getDeviceByIp(rule["internal_ip"]), self.getGuestIp())])
|
||||
|
||||
|
||||
class IpTablesExecutor:
|
||||
|
|
|
|||
|
|
@ -476,9 +476,10 @@ class CsIP:
|
|||
self.fw.append(["", "front", "-A NETWORK_STATS_%s -o %s -s %s" %
|
||||
("eth1", "eth1", guestNetworkCidr)])
|
||||
|
||||
self.fw.append(["nat", "front",
|
||||
"-A POSTROUTING -s %s -o %s -j SNAT --to-source %s" %
|
||||
(guestNetworkCidr, self.dev, self.address['public_ip'])])
|
||||
if self.address["source_nat"]:
|
||||
self.fw.append(["nat", "front",
|
||||
"-A POSTROUTING -o %s -j SNAT --to-source %s" %
|
||||
(self.dev, self.address['public_ip'])])
|
||||
|
||||
if self.get_type() in ["public"]:
|
||||
self.fw.append(
|
||||
|
|
|
|||
|
|
@ -78,11 +78,13 @@ function install_packages() {
|
|||
apt-get clean
|
||||
apt-get autoclean
|
||||
|
||||
#32 bit architecture support:: not required for 32 bit template
|
||||
${apt_get} install links
|
||||
|
||||
#32 bit architecture support for vhd-util: not required for 32 bit template
|
||||
if [ "${arch}" != "i386" ]; then
|
||||
dpkg --add-architecture i386
|
||||
apt-get update
|
||||
${apt_get} install links:i386 libuuid1:i386 libc6:i386
|
||||
${apt_get} install libuuid1:i386 libc6:i386
|
||||
fi
|
||||
|
||||
# Install xenserver guest utilities as debian repos don't have it
|
||||
|
|
|
|||
Loading…
Reference in New Issue