Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ public Map getDetails() {
return (Map) (paramsCollection.toArray())[0];
}

public boolean isCleanupDetails(){
return cleanupDetails == null ? false : cleanupDetails.booleanValue();
public boolean isCleanupDetails() {
return cleanupDetails != null && cleanupDetails;
}

public CPU.CPUArch getCPUArch() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ public void saveDetails(VMTemplateVO tmpl) {
if (detailsStr == null) {
return;
}
List<VMTemplateDetailVO> details = new ArrayList<VMTemplateDetailVO>();
List<VMTemplateDetailVO> details = new ArrayList<>();
for (String key : detailsStr.keySet()) {
VMTemplateDetailVO detail = new VMTemplateDetailVO(tmpl.getId(), key, detailsStr.get(key), true);
details.add(detail);
Expand All @@ -481,7 +481,7 @@ public long addTemplateToZone(VMTemplateVO tmplt, long zoneId) {
}

if (tmplt.getDetails() != null) {
List<VMTemplateDetailVO> details = new ArrayList<VMTemplateDetailVO>();
List<VMTemplateDetailVO> details = new ArrayList<>();
for (String key : tmplt.getDetails().keySet()) {
details.add(new VMTemplateDetailVO(tmplt.getId(), key, tmplt.getDetails().get(key), true));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2210,7 +2210,7 @@ private VMTemplateVO updateTemplateOrIso(BaseUpdateTemplateOrIsoCmd cmd) {
templateType == null &&
templateTag == null &&
arch == null &&
(! cleanupDetails && details == null) //update details in every case except this one
(!cleanupDetails && details == null) //update details in every case except this one
);
if (!updateNeeded) {
return template;
Expand Down Expand Up @@ -2308,8 +2308,7 @@ private VMTemplateVO updateTemplateOrIso(BaseUpdateTemplateOrIsoCmd cmd) {
if (cleanupDetails) {
template.setDetails(null);
_tmpltDetailsDao.removeDetails(id);
}
else if (details != null && !details.isEmpty()) {
} else if (details != null && !details.isEmpty()) {
template.setDetails(details);
_tmpltDao.saveDetails(template);
}
Expand Down
15 changes: 13 additions & 2 deletions ui/src/views/image/UpdateTemplate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ export default {
userdataid: null,
userdatapolicy: null,
userdatapolicylist: {},
architectureTypes: {}
architectureTypes: {},
details: {}
}
},
beforeCreate () {
Expand Down Expand Up @@ -295,6 +296,11 @@ export default {
}
}
}
if (this.resource.details) {
this.details = Object.keys(this.resource.details).map(k => {
return { name: k, value: this.resource.details[k] }
})
}
const resourceDetailsFields = []
if (this.resource.hypervisor === 'KVM') {
resourceDetailsFields.push('rootDiskController')
Expand All @@ -304,7 +310,7 @@ export default {
for (var detailsField of resourceDetailsFields) {
var detailValue = this.resource?.details?.[detailsField] || null
if (detailValue) {
this.form[detailValue] = fieldValue
this.form[detailsField] = detailValue
}
}
},
Expand Down Expand Up @@ -495,6 +501,11 @@ export default {
const params = {
id: this.resource.id
}
if (this.resource.details) {
Object.keys(this.resource.details).forEach((detail, index) => {
params['details[0].' + detail] = this.resource.details[detail]
})
}
const detailsField = ['rootDiskController', 'nicAdapter', 'keyboard']
for (const key in values) {
if (!this.isValidValueForKey(values, key)) continue
Expand Down
Loading