mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Merge remote-tracking branch 'apache/4.15' into main
This commit is contained in:
commit
a000361238
@ -179,7 +179,8 @@ public class DataMigrationUtility {
|
|||||||
List<TemplateDataStoreVO> templates = templateDataStoreDao.listByStoreId(srcDataStore.getId());
|
List<TemplateDataStoreVO> templates = templateDataStoreDao.listByStoreId(srcDataStore.getId());
|
||||||
for (TemplateDataStoreVO template : templates) {
|
for (TemplateDataStoreVO template : templates) {
|
||||||
VMTemplateVO templateVO = templateDao.findById(template.getTemplateId());
|
VMTemplateVO templateVO = templateDao.findById(template.getTemplateId());
|
||||||
if (template.getState() == ObjectInDataStoreStateMachine.State.Ready && templateVO != null && !templateVO.isPublicTemplate() &&
|
if (template.getState() == ObjectInDataStoreStateMachine.State.Ready && templateVO != null &&
|
||||||
|
(!templateVO.isPublicTemplate() || (templateVO.isPublicTemplate() && templateVO.getUrl() == null)) &&
|
||||||
templateVO.getHypervisorType() != Hypervisor.HypervisorType.Simulator) {
|
templateVO.getHypervisorType() != Hypervisor.HypervisorType.Simulator) {
|
||||||
files.add(templateFactory.getTemplate(template.getTemplateId(), srcDataStore));
|
files.add(templateFactory.getTemplate(template.getTemplateId(), srcDataStore));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,3 +19,4 @@
|
|||||||
-- Schema upgrade from 4.15.1.0 to 4.15.2.0
|
-- Schema upgrade from 4.15.1.0 to 4.15.2.0
|
||||||
--;
|
--;
|
||||||
|
|
||||||
|
UPDATE `cloud`.`configuration` SET `value` = 20, `default_value` = 20 WHERE `name` = 'default.ui.page.size';
|
||||||
|
|||||||
@ -122,7 +122,11 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
|
|||||||
activeTmpltSearch.and("store_id", activeTmpltSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ);
|
activeTmpltSearch.and("store_id", activeTmpltSearch.entity().getDataStoreId(), SearchCriteria.Op.EQ);
|
||||||
activeTmpltSearch.and("type", activeTmpltSearch.entity().getTemplateType(), SearchCriteria.Op.EQ);
|
activeTmpltSearch.and("type", activeTmpltSearch.entity().getTemplateType(), SearchCriteria.Op.EQ);
|
||||||
activeTmpltSearch.and("templateState", activeTmpltSearch.entity().getTemplateState(), SearchCriteria.Op.EQ);
|
activeTmpltSearch.and("templateState", activeTmpltSearch.entity().getTemplateState(), SearchCriteria.Op.EQ);
|
||||||
activeTmpltSearch.and("public", activeTmpltSearch.entity().isPublicTemplate(), SearchCriteria.Op.EQ);
|
activeTmpltSearch.and().op("public", activeTmpltSearch.entity().isPublicTemplate(), SearchCriteria.Op.EQ);
|
||||||
|
activeTmpltSearch.or().op("publicNoUrl", activeTmpltSearch.entity().isPublicTemplate(), SearchCriteria.Op.EQ);
|
||||||
|
activeTmpltSearch.and("url", activeTmpltSearch.entity().getUrl(), SearchCriteria.Op.NULL);
|
||||||
|
activeTmpltSearch.cp();
|
||||||
|
activeTmpltSearch.cp();
|
||||||
activeTmpltSearch.done();
|
activeTmpltSearch.done();
|
||||||
|
|
||||||
// select distinct pair (template_id, zone_id)
|
// select distinct pair (template_id, zone_id)
|
||||||
@ -526,6 +530,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBaseWithTagInformation<Templa
|
|||||||
sc.setParameters("type", TemplateType.USER);
|
sc.setParameters("type", TemplateType.USER);
|
||||||
sc.setParameters("templateState", VirtualMachineTemplate.State.Active);
|
sc.setParameters("templateState", VirtualMachineTemplate.State.Active);
|
||||||
sc.setParameters("public", Boolean.FALSE);
|
sc.setParameters("public", Boolean.FALSE);
|
||||||
|
sc.setParameters("publicNoUrl",Boolean.TRUE);
|
||||||
return searchIncludingRemoved(sc, null, null, false);
|
return searchIncludingRemoved(sc, null, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -39,7 +39,8 @@ const getters = {
|
|||||||
server: state => state.app.server,
|
server: state => state.app.server,
|
||||||
domainStore: state => state.user.domainStore,
|
domainStore: state => state.user.domainStore,
|
||||||
darkMode: state => state.user.darkMode,
|
darkMode: state => state.user.darkMode,
|
||||||
themeSetting: state => state.user.themeSetting
|
themeSetting: state => state.user.themeSetting,
|
||||||
|
defaultListViewPageSize: state => state.user.defaultListViewPageSize
|
||||||
}
|
}
|
||||||
|
|
||||||
export default getters
|
export default getters
|
||||||
|
|||||||
@ -55,7 +55,8 @@ const user = {
|
|||||||
usebrowsertimezone: false,
|
usebrowsertimezone: false,
|
||||||
domainStore: {},
|
domainStore: {},
|
||||||
darkMode: false,
|
darkMode: false,
|
||||||
themeSetting: {}
|
themeSetting: {},
|
||||||
|
defaultListViewPageSize: 20
|
||||||
},
|
},
|
||||||
|
|
||||||
mutations: {
|
mutations: {
|
||||||
@ -118,6 +119,9 @@ const user = {
|
|||||||
SET_THEME_SETTING (state, setting) {
|
SET_THEME_SETTING (state, setting) {
|
||||||
state.themeSetting = setting
|
state.themeSetting = setting
|
||||||
Vue.ls.set(THEME_SETTING, setting)
|
Vue.ls.set(THEME_SETTING, setting)
|
||||||
|
},
|
||||||
|
SET_DEFAULT_LISTVIEW_PAGE_SIZE: (state, defaultListViewPageSize) => {
|
||||||
|
state.defaultListViewPageSize = defaultListViewPageSize
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -254,6 +258,13 @@ const user = {
|
|||||||
reject(error)
|
reject(error)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
api('listConfigurations', { name: 'default.ui.page.size' }).then(response => {
|
||||||
|
const defaultListViewPageSize = parseInt(response.listconfigurationsresponse.configuration[0].value)
|
||||||
|
commit('SET_DEFAULT_LISTVIEW_PAGE_SIZE', defaultListViewPageSize)
|
||||||
|
}).catch(error => {
|
||||||
|
reject(error)
|
||||||
|
})
|
||||||
|
|
||||||
api('listLdapConfigurations').then(response => {
|
api('listLdapConfigurations').then(response => {
|
||||||
const ldapEnable = (response.ldapconfigurationresponse.count > 0)
|
const ldapEnable = (response.ldapconfigurationresponse.count > 0)
|
||||||
commit('SET_LDAP', ldapEnable)
|
commit('SET_LDAP', ldapEnable)
|
||||||
|
|||||||
@ -361,7 +361,7 @@
|
|||||||
:pageSize="pageSize"
|
:pageSize="pageSize"
|
||||||
:total="itemCount"
|
:total="itemCount"
|
||||||
:showTotal="total => `${$t('label.showing')} ${Math.min(total, 1+((page-1)*pageSize))}-${Math.min(page*pageSize, total)} ${$t('label.of')} ${total} ${$t('label.items')}`"
|
:showTotal="total => `${$t('label.showing')} ${Math.min(total, 1+((page-1)*pageSize))}-${Math.min(page*pageSize, total)} ${$t('label.of')} ${total} ${$t('label.items')}`"
|
||||||
:pageSizeOptions="device === 'desktop' ? ['20', '50', '100', '200'] : ['10', '20', '50', '100', '200']"
|
:pageSizeOptions="pageSizeOptions"
|
||||||
@change="changePage"
|
@change="changePage"
|
||||||
@showSizeChange="changePageSize"
|
@showSizeChange="changePageSize"
|
||||||
showSizeChanger
|
showSizeChanger
|
||||||
@ -438,7 +438,7 @@ export default {
|
|||||||
modalInfo: {},
|
modalInfo: {},
|
||||||
itemCount: 0,
|
itemCount: 0,
|
||||||
page: 1,
|
page: 1,
|
||||||
pageSize: 10,
|
pageSize: this.$store.getters.defaultListViewPageSize,
|
||||||
resource: {},
|
resource: {},
|
||||||
selectedRowKeys: [],
|
selectedRowKeys: [],
|
||||||
currentAction: {},
|
currentAction: {},
|
||||||
@ -545,9 +545,6 @@ export default {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (this.device === 'desktop') {
|
|
||||||
this.pageSize = 20
|
|
||||||
}
|
|
||||||
this.currentPath = this.$route.fullPath
|
this.currentPath = this.$route.fullPath
|
||||||
this.fetchData()
|
this.fetchData()
|
||||||
if ('projectid' in this.$route.query) {
|
if ('projectid' in this.$route.query) {
|
||||||
@ -570,7 +567,6 @@ export default {
|
|||||||
this.pageSize = Number(to.query.pagesize)
|
this.pageSize = Number(to.query.pagesize)
|
||||||
} else {
|
} else {
|
||||||
this.page = 1
|
this.page = 1
|
||||||
this.pageSize = (this.device === 'desktop' ? 20 : 10)
|
|
||||||
}
|
}
|
||||||
this.itemCount = 0
|
this.itemCount = 0
|
||||||
this.fetchData()
|
this.fetchData()
|
||||||
@ -591,6 +587,15 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
hasSelected () {
|
hasSelected () {
|
||||||
return this.selectedRowKeys.length > 0
|
return this.selectedRowKeys.length > 0
|
||||||
|
},
|
||||||
|
pageSizeOptions () {
|
||||||
|
var sizes = [20, 50, 100, 200, this.$store.getters.defaultListViewPageSize]
|
||||||
|
if (this.device !== 'desktop') {
|
||||||
|
sizes.unshift(10)
|
||||||
|
}
|
||||||
|
return [...new Set(sizes)].sort(function (a, b) {
|
||||||
|
return a - b
|
||||||
|
}).map(String)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@ -17,15 +17,13 @@
|
|||||||
|
|
||||||
package com.cloud.usage.parser;
|
package com.cloud.usage.parser;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.cloudstack.backup.Backup;
|
|
||||||
import org.apache.cloudstack.usage.UsageTypes;
|
import org.apache.cloudstack.usage.UsageTypes;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
@ -68,65 +66,33 @@ public class BackupUsageParser {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Map<Long, BackupInfo> vmUsageMap = new HashMap<>();
|
|
||||||
for (final UsageBackupVO usageBackup : usageBackups) {
|
for (final UsageBackupVO usageBackup : usageBackups) {
|
||||||
final Long vmId = usageBackup.getVmId();
|
final Long vmId = usageBackup.getVmId();
|
||||||
final Long zoneId = usageBackup.getZoneId();
|
final Long zoneId = usageBackup.getZoneId();
|
||||||
final Long offeringId = usageBackup.getBackupOfferingId();
|
final Long offeringId = usageBackup.getBackupOfferingId();
|
||||||
if (vmUsageMap.get(vmId) == null) {
|
Date createdDate = usageBackup.getCreated();
|
||||||
vmUsageMap.put(vmId, new BackupUsageParser.BackupInfo(new Backup.Metric(0L, 0L), zoneId, vmId, offeringId));
|
Date removedDate = usageBackup.getRemoved();
|
||||||
|
if (createdDate.before(startDate)) {
|
||||||
|
createdDate = startDate;
|
||||||
}
|
}
|
||||||
final Backup.Metric metric = vmUsageMap.get(vmId).getMetric();
|
if (removedDate == null || removedDate.after(endDate)) {
|
||||||
metric.setBackupSize(metric.getBackupSize() + usageBackup.getSize());
|
removedDate = endDate;
|
||||||
metric.setDataSize(metric.getDataSize() + usageBackup.getProtectedSize());
|
}
|
||||||
}
|
final long duration = (removedDate.getTime() - createdDate.getTime()) + 1;
|
||||||
|
final float usage = duration / 1000f / 60f / 60f;
|
||||||
|
DecimalFormat dFormat = new DecimalFormat("#.######");
|
||||||
|
String usageDisplay = dFormat.format(usage);
|
||||||
|
|
||||||
for (final BackupInfo backupInfo : vmUsageMap.values()) {
|
final Double rawUsage = (double) usageBackup.getSize();
|
||||||
final Long vmId = backupInfo.getVmId();
|
final String description = String.format("Backup usage VM ID: %d, backup offering: %d", vmId, offeringId);
|
||||||
final Long zoneId = backupInfo.getZoneId();
|
|
||||||
final Long offeringId = backupInfo.getOfferingId();
|
|
||||||
final Double rawUsage = (double) backupInfo.getMetric().getBackupSize();
|
|
||||||
final Double sizeGib = rawUsage / (1024.0 * 1024.0 * 1024.0);
|
|
||||||
final String description = String.format("Backup usage VM ID: %d", vmId);
|
|
||||||
final String usageDisplay = String.format("%.4f GiB", sizeGib);
|
|
||||||
|
|
||||||
final UsageVO usageRecord =
|
final UsageVO usageRecord =
|
||||||
new UsageVO(zoneId, account.getAccountId(), account.getDomainId(), description, usageDisplay,
|
new UsageVO(zoneId, account.getAccountId(), account.getDomainId(), description, usageDisplay + " Hrs",
|
||||||
UsageTypes.BACKUP, rawUsage, vmId, null, offeringId, null, vmId,
|
UsageTypes.BACKUP, new Double(usage), vmId, null, offeringId, null, vmId,
|
||||||
backupInfo.getMetric().getBackupSize(), backupInfo.getMetric().getDataSize(), startDate, endDate);
|
usageBackup.getSize(), usageBackup.getProtectedSize(), startDate, endDate);
|
||||||
s_usageDao.persist(usageRecord);
|
s_usageDao.persist(usageRecord);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static class BackupInfo {
|
|
||||||
Backup.Metric metric;
|
|
||||||
Long zoneId;
|
|
||||||
Long vmId;
|
|
||||||
Long offeringId;
|
|
||||||
|
|
||||||
public BackupInfo(Backup.Metric metric, Long zoneId, Long vmId, Long offeringId) {
|
|
||||||
this.metric = metric;
|
|
||||||
this.zoneId = zoneId;
|
|
||||||
this.vmId = vmId;
|
|
||||||
this.offeringId = offeringId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Backup.Metric getMetric() {
|
|
||||||
return metric;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getZoneId() {
|
|
||||||
return zoneId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getVmId() {
|
|
||||||
return vmId;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Long getOfferingId() {
|
|
||||||
return offeringId;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user