mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge branch '4.20'
This commit is contained in:
commit
5c1bf4a4ce
@ -64,11 +64,14 @@ import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.DataCenterDaoImpl;
|
||||
import com.cloud.hypervisor.Hypervisor;
|
||||
import com.cloud.storage.DataStoreRole;
|
||||
import com.cloud.storage.GuestOSVO;
|
||||
import com.cloud.storage.Storage;
|
||||
import com.cloud.storage.Storage.ImageFormat;
|
||||
import com.cloud.storage.VMTemplateStorageResourceAssoc;
|
||||
import com.cloud.storage.VMTemplateVO;
|
||||
import com.cloud.storage.VMTemplateZoneVO;
|
||||
import com.cloud.storage.dao.GuestOSDao;
|
||||
import com.cloud.storage.dao.GuestOSDaoImpl;
|
||||
import com.cloud.storage.dao.VMTemplateDao;
|
||||
import com.cloud.storage.dao.VMTemplateDaoImpl;
|
||||
import com.cloud.storage.dao.VMTemplateZoneDao;
|
||||
@ -102,15 +105,13 @@ public class SystemVmTemplateRegistration {
|
||||
private static final String PARTIAL_TEMPLATE_FOLDER = String.format("/template/tmpl/%d/", Account.ACCOUNT_ID_SYSTEM);
|
||||
private static final String storageScriptsDir = "scripts/storage/secondary";
|
||||
private static final Integer OTHER_LINUX_ID = 99;
|
||||
private static final Integer LINUX_5_ID = 15;
|
||||
private static final Integer LINUX_7_ID = 183;
|
||||
private static Integer LINUX_12_ID = 363;
|
||||
private static final Integer SCRIPT_TIMEOUT = 1800000;
|
||||
private static final Integer LOCK_WAIT_TIMEOUT = 1200;
|
||||
protected static final List<CPU.CPUArch> DOWNLOADABLE_TEMPLATE_ARCH_TYPES = Arrays.asList(
|
||||
CPU.CPUArch.arm64
|
||||
);
|
||||
|
||||
|
||||
public static String CS_MAJOR_VERSION = null;
|
||||
public static String CS_TINY_VERSION = null;
|
||||
|
||||
@ -132,6 +133,8 @@ public class SystemVmTemplateRegistration {
|
||||
ClusterDao clusterDao;
|
||||
@Inject
|
||||
ConfigurationDao configurationDao;
|
||||
@Inject
|
||||
private GuestOSDao guestOSDao;
|
||||
|
||||
private String systemVmTemplateVersion;
|
||||
|
||||
@ -147,6 +150,7 @@ public class SystemVmTemplateRegistration {
|
||||
imageStoreDetailsDao = new ImageStoreDetailsDaoImpl();
|
||||
clusterDao = new ClusterDaoImpl();
|
||||
configurationDao = new ConfigurationDaoImpl();
|
||||
guestOSDao = new GuestOSDaoImpl();
|
||||
tempDownloadDir = new File(System.getProperty("java.io.tmpdir"));
|
||||
}
|
||||
|
||||
@ -320,7 +324,7 @@ public class SystemVmTemplateRegistration {
|
||||
|
||||
public static final Map<String, MetadataTemplateDetails> NewTemplateMap = new HashMap<>();
|
||||
|
||||
public static final Map<Hypervisor.HypervisorType, String> RouterTemplateConfigurationNames = new HashMap<Hypervisor.HypervisorType, String>() {
|
||||
public static final Map<Hypervisor.HypervisorType, String> RouterTemplateConfigurationNames = new HashMap<>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, "router.template.kvm");
|
||||
put(Hypervisor.HypervisorType.VMware, "router.template.vmware");
|
||||
@ -331,14 +335,14 @@ public class SystemVmTemplateRegistration {
|
||||
}
|
||||
};
|
||||
|
||||
public static final Map<Hypervisor.HypervisorType, Integer> hypervisorGuestOsMap = new HashMap<Hypervisor.HypervisorType, Integer>() {
|
||||
public static Map<Hypervisor.HypervisorType, Integer> hypervisorGuestOsMap = new HashMap<>() {
|
||||
{
|
||||
put(Hypervisor.HypervisorType.KVM, LINUX_5_ID);
|
||||
put(Hypervisor.HypervisorType.KVM, LINUX_12_ID);
|
||||
put(Hypervisor.HypervisorType.XenServer, OTHER_LINUX_ID);
|
||||
put(Hypervisor.HypervisorType.VMware, OTHER_LINUX_ID);
|
||||
put(Hypervisor.HypervisorType.Hyperv, LINUX_5_ID);
|
||||
put(Hypervisor.HypervisorType.LXC, LINUX_5_ID);
|
||||
put(Hypervisor.HypervisorType.Ovm3, LINUX_7_ID);
|
||||
put(Hypervisor.HypervisorType.Hyperv, LINUX_12_ID);
|
||||
put(Hypervisor.HypervisorType.LXC, LINUX_12_ID);
|
||||
put(Hypervisor.HypervisorType.Ovm3, LINUX_12_ID);
|
||||
}
|
||||
};
|
||||
|
||||
@ -595,6 +599,23 @@ public class SystemVmTemplateRegistration {
|
||||
vmInstanceDao.updateSystemVmTemplateId(templateId, hypervisorType);
|
||||
}
|
||||
|
||||
private void updateSystemVmTemplateGuestOsId() {
|
||||
String systemVmGuestOsName = "Debian GNU/Linux 12 (64-bit)"; // default
|
||||
try {
|
||||
GuestOSVO guestOS = guestOSDao.findOneByDisplayName(systemVmGuestOsName);
|
||||
if (guestOS != null) {
|
||||
LOGGER.debug("Updating SystemVM Template Guest OS [{}] id", systemVmGuestOsName);
|
||||
SystemVmTemplateRegistration.LINUX_12_ID = Math.toIntExact(guestOS.getId());
|
||||
hypervisorGuestOsMap.put(Hypervisor.HypervisorType.KVM, LINUX_12_ID);
|
||||
hypervisorGuestOsMap.put(Hypervisor.HypervisorType.Hyperv, LINUX_12_ID);
|
||||
hypervisorGuestOsMap.put(Hypervisor.HypervisorType.LXC, LINUX_12_ID);
|
||||
hypervisorGuestOsMap.put(Hypervisor.HypervisorType.Ovm3, LINUX_12_ID);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("Couldn't update SystemVM Template Guest OS id, due to {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void updateConfigurationParams(Map<String, String> configParams) {
|
||||
for (Map.Entry<String, String> config : configParams.entrySet()) {
|
||||
boolean updated = configurationDao.update(config.getKey(), config.getValue());
|
||||
@ -813,7 +834,8 @@ public class SystemVmTemplateRegistration {
|
||||
section.get("filename"),
|
||||
section.get("downloadurl"),
|
||||
section.get("checksum"),
|
||||
hypervisorType.second()));
|
||||
hypervisorType.second(),
|
||||
section.get("guestos")));
|
||||
}
|
||||
Ini.Section defaultSection = ini.get("default");
|
||||
return defaultSection.get("version").trim();
|
||||
@ -965,6 +987,10 @@ public class SystemVmTemplateRegistration {
|
||||
private void updateRegisteredTemplateDetails(Long templateId, MetadataTemplateDetails templateDetails) {
|
||||
VMTemplateVO templateVO = vmTemplateDao.findById(templateId);
|
||||
templateVO.setTemplateType(Storage.TemplateType.SYSTEM);
|
||||
GuestOSVO guestOS = guestOSDao.findOneByDisplayName(templateDetails.getGuestOs());
|
||||
if (guestOS != null) {
|
||||
templateVO.setGuestOSId(guestOS.getId());
|
||||
}
|
||||
boolean updated = vmTemplateDao.update(templateVO.getId(), templateVO);
|
||||
if (!updated) {
|
||||
String errMsg = String.format("updateSystemVmTemplates:Exception while updating template with id %s to be marked as 'system'", templateId);
|
||||
@ -980,9 +1006,13 @@ public class SystemVmTemplateRegistration {
|
||||
updateConfigurationParams(configParams);
|
||||
}
|
||||
|
||||
private void updateTemplateUrlAndChecksum(VMTemplateVO templateVO, MetadataTemplateDetails templateDetails) {
|
||||
private void updateTemplateUrlChecksumAndGuestOsId(VMTemplateVO templateVO, MetadataTemplateDetails templateDetails) {
|
||||
templateVO.setUrl(templateDetails.getUrl());
|
||||
templateVO.setChecksum(templateDetails.getChecksum());
|
||||
GuestOSVO guestOS = guestOSDao.findOneByDisplayName(templateDetails.getGuestOs());
|
||||
if (guestOS != null) {
|
||||
templateVO.setGuestOSId(guestOS.getId());
|
||||
}
|
||||
boolean updated = vmTemplateDao.update(templateVO.getId(), templateVO);
|
||||
if (!updated) {
|
||||
String errMsg = String.format("updateSystemVmTemplates:Exception while updating 'url' and 'checksum' for hypervisor type %s", templateDetails.getHypervisorType());
|
||||
@ -1020,7 +1050,7 @@ public class SystemVmTemplateRegistration {
|
||||
VMTemplateVO templateVO = vmTemplateDao.findLatestTemplateByTypeAndHypervisorAndArch(
|
||||
templateDetails.getHypervisorType(), templateDetails.getArch(), Storage.TemplateType.SYSTEM);
|
||||
if (templateVO != null) {
|
||||
updateTemplateUrlAndChecksum(templateVO, templateDetails);
|
||||
updateTemplateUrlChecksumAndGuestOsId(templateVO, templateDetails);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1029,6 +1059,7 @@ public class SystemVmTemplateRegistration {
|
||||
|
||||
public void updateSystemVmTemplates(final Connection conn) {
|
||||
LOGGER.debug("Updating System Vm template IDs");
|
||||
updateSystemVmTemplateGuestOsId();
|
||||
Transaction.execute(new TransactionCallbackNoReturn() {
|
||||
@Override
|
||||
public void doInTransactionWithoutResult(final TransactionStatus status) {
|
||||
@ -1076,15 +1107,17 @@ public class SystemVmTemplateRegistration {
|
||||
private final String checksum;
|
||||
private final CPU.CPUArch arch;
|
||||
private String downloadedFilePath;
|
||||
private final String guestOs;
|
||||
|
||||
MetadataTemplateDetails(Hypervisor.HypervisorType hypervisorType, String name, String filename, String url,
|
||||
String checksum, CPU.CPUArch arch) {
|
||||
String checksum, CPU.CPUArch arch, String guestOs) {
|
||||
this.hypervisorType = hypervisorType;
|
||||
this.name = name;
|
||||
this.filename = filename;
|
||||
this.url = url;
|
||||
this.checksum = checksum;
|
||||
this.arch = arch;
|
||||
this.guestOs = guestOs;
|
||||
}
|
||||
|
||||
public Hypervisor.HypervisorType getHypervisorType() {
|
||||
@ -1111,6 +1144,10 @@ public class SystemVmTemplateRegistration {
|
||||
return arch;
|
||||
}
|
||||
|
||||
public String getGuestOs() {
|
||||
return guestOs;
|
||||
}
|
||||
|
||||
public String getDownloadedFilePath() {
|
||||
return downloadedFilePath;
|
||||
}
|
||||
|
||||
@ -192,7 +192,7 @@ public class SystemVmTemplateRegistrationTest {
|
||||
public void testValidateTemplateFile_fileNotFound() {
|
||||
SystemVmTemplateRegistration.MetadataTemplateDetails details =
|
||||
new SystemVmTemplateRegistration.MetadataTemplateDetails(Hypervisor.HypervisorType.KVM,
|
||||
"name", "file", "url", "checksum", CPU.CPUArch.amd64);
|
||||
"name", "file", "url", "checksum", CPU.CPUArch.amd64, "guestos");
|
||||
SystemVmTemplateRegistration.NewTemplateMap.put(SystemVmTemplateRegistration.getHypervisorArchKey(
|
||||
details.getHypervisorType(), details.getArch()), details);
|
||||
doReturn(null).when(systemVmTemplateRegistration).getTemplateFile(details);
|
||||
@ -209,7 +209,7 @@ public class SystemVmTemplateRegistrationTest {
|
||||
public void testValidateTemplateFile_checksumMismatch() {
|
||||
SystemVmTemplateRegistration.MetadataTemplateDetails details =
|
||||
new SystemVmTemplateRegistration.MetadataTemplateDetails(Hypervisor.HypervisorType.KVM,
|
||||
"name", "file", "url", "checksum", CPU.CPUArch.amd64);
|
||||
"name", "file", "url", "checksum", CPU.CPUArch.amd64, "guestos");
|
||||
File dummyFile = new File("dummy.txt");
|
||||
SystemVmTemplateRegistration.NewTemplateMap.put(SystemVmTemplateRegistration.getHypervisorArchKey(
|
||||
details.getHypervisorType(), details.getArch()), details);
|
||||
@ -228,7 +228,7 @@ public class SystemVmTemplateRegistrationTest {
|
||||
public void testValidateTemplateFile_success() {
|
||||
SystemVmTemplateRegistration.MetadataTemplateDetails details =
|
||||
new SystemVmTemplateRegistration.MetadataTemplateDetails(Hypervisor.HypervisorType.KVM,
|
||||
"name", "file", "url", "checksum", CPU.CPUArch.amd64);
|
||||
"name", "file", "url", "checksum", CPU.CPUArch.amd64, "guestos");
|
||||
File dummyFile = new File("dummy.txt");
|
||||
SystemVmTemplateRegistration.NewTemplateMap.put(SystemVmTemplateRegistration.getHypervisorArchKey(
|
||||
details.getHypervisorType(), details.getArch()), details);
|
||||
@ -285,7 +285,7 @@ public class SystemVmTemplateRegistrationTest {
|
||||
SystemVmTemplateRegistration.MetadataTemplateDetails details =
|
||||
new SystemVmTemplateRegistration.MetadataTemplateDetails(Hypervisor.HypervisorType.KVM,
|
||||
"name", "nonexistent.qcow2", "http://example.com/file.qcow2",
|
||||
"", CPU.CPUArch.arm64);
|
||||
"", CPU.CPUArch.arm64, "guestos");
|
||||
try (MockedStatic<Files> filesMock = Mockito.mockStatic(Files.class);
|
||||
MockedStatic<HttpUtils> httpMock = Mockito.mockStatic(HttpUtils.class)) {
|
||||
filesMock.when(() -> Files.isWritable(any(Path.class))).thenReturn(true);
|
||||
@ -301,7 +301,7 @@ public class SystemVmTemplateRegistrationTest {
|
||||
SystemVmTemplateRegistration.MetadataTemplateDetails details =
|
||||
new SystemVmTemplateRegistration.MetadataTemplateDetails(Hypervisor.HypervisorType.KVM,
|
||||
"name", "file.qcow2", "http://example.com/file.qcow2",
|
||||
"", CPU.CPUArch.arm64);
|
||||
"", CPU.CPUArch.arm64, "guestos");
|
||||
try (MockedStatic<Files> filesMock = Mockito.mockStatic(Files.class);
|
||||
MockedStatic<HttpUtils> httpMock = Mockito.mockStatic(HttpUtils.class)) {
|
||||
filesMock.when(() -> Files.isWritable(any(Path.class))).thenReturn(false);
|
||||
|
||||
@ -42,6 +42,15 @@ function getGenericName() {
|
||||
fi
|
||||
}
|
||||
|
||||
function getGuestOS() {
|
||||
hypervisor=$(echo "$1" | tr "[:upper:]" "[:lower:]")
|
||||
if [[ "$hypervisor" == "vmware" || "$hypervisor" == "xenserver" ]]; then
|
||||
echo "Other Linux (64-bit)"
|
||||
else
|
||||
echo "Debian GNU/Linux 12 (64-bit)"
|
||||
fi
|
||||
}
|
||||
|
||||
function getChecksum() {
|
||||
local fileData="$1"
|
||||
local hvName=$2
|
||||
@ -60,13 +69,14 @@ function createMetadataFile() {
|
||||
section="${template%%:*}"
|
||||
sectionHv="${section%%-*}"
|
||||
hvName=$(getGenericName $sectionHv)
|
||||
guestos=$(getGuestOS $sectionHv)
|
||||
|
||||
downloadurl="${template#*:}"
|
||||
arch=$(echo ${downloadurl#*"/systemvmtemplate-$VERSION-"} | cut -d'-' -f 1)
|
||||
templatename="systemvm-${sectionHv%.*}-${VERSION}-${arch}"
|
||||
checksum=$(getChecksum "$fileData" "$VERSION-${arch}-$hvName")
|
||||
filename=$(echo ${downloadurl##*'/'})
|
||||
echo -e "["$section"]\ntemplatename = $templatename\nchecksum = $checksum\ndownloadurl = $downloadurl\nfilename = $filename\narch = $arch\n" >> $METADATAFILE
|
||||
echo -e "["$section"]\ntemplatename = $templatename\nchecksum = $checksum\ndownloadurl = $downloadurl\nfilename = $filename\narch = $arch\nguestos = $guestos\n" >> $METADATAFILE
|
||||
done
|
||||
}
|
||||
|
||||
|
||||
@ -33,6 +33,7 @@
|
||||
|
||||
<script>
|
||||
import InfiniteScrollSelect from '@/components/widgets/InfiniteScrollSelect'
|
||||
import eventBus from '@/config/eventBus'
|
||||
|
||||
export default {
|
||||
name: 'ProjectMenu',
|
||||
@ -42,7 +43,8 @@ export default {
|
||||
data () {
|
||||
return {
|
||||
selectedProjectId: null,
|
||||
loading: false
|
||||
loading: false,
|
||||
timestamp: new Date().getTime()
|
||||
}
|
||||
},
|
||||
created () {
|
||||
@ -59,7 +61,8 @@ export default {
|
||||
projectsApiParams () {
|
||||
return {
|
||||
details: 'min',
|
||||
listall: true
|
||||
listall: true,
|
||||
timestamp: this.timestamp
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -70,6 +73,9 @@ export default {
|
||||
this.selectedProjectId = newId
|
||||
}
|
||||
)
|
||||
eventBus.on('projects-updated', (args) => {
|
||||
this.timestamp = new Date().getTime()
|
||||
})
|
||||
},
|
||||
beforeUnmount () {
|
||||
if (this.unwatchProject) {
|
||||
|
||||
@ -1528,6 +1528,9 @@ export default {
|
||||
if ('successMethod' in action) {
|
||||
action.successMethod(this, result)
|
||||
}
|
||||
if (['createProject', 'updateProject', 'deleteProject'].includes(action.api)) {
|
||||
eventBus.emit('projects-updated', { action: action.api, project: this.resource })
|
||||
}
|
||||
resolve(true)
|
||||
},
|
||||
errorMethod: () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user