Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Fix template details deletion while updating template from UI #12559

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
sureshanaparti wants to merge 2 commits into apache:4.20
base: 4.20
Choose a base branch
Loading
from shapeblue:fix-details-in-update-template
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
View file Open in desktop
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
View file Open in desktop
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
View file Open in desktop
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
47 changes: 35 additions & 12 deletions ui/src/views/image/UpdateTemplate.vue
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,9 @@ export default {
userdataid: null,
userdatapolicy: null,
userdatapolicylist: {},
architectureTypes: {}
architectureTypes: {},
detailsFields: [],
details: {}
}
},
beforeCreate () {
Expand Down Expand Up @@ -295,17 +297,10 @@ export default {
}
}
}
const resourceDetailsFields = []
if (this.resource.hypervisor === 'KVM') {
resourceDetailsFields.push('rootDiskController')
this.detailsFields.push('rootDiskController')
} else if (this.resource.hypervisor === 'VMware' && !this.resource.deployasis) {
resourceDetailsFields.push(...['rootDiskController', 'nicAdapter', 'keyboard'])
}
for (var detailsField of resourceDetailsFields) {
var detailValue = this.resource?.details?.[detailsField] || null
if (detailValue) {
this.form[detailValue] = fieldValue
}
this.detailsFields.push(...['rootDiskController', 'nicAdapter', 'keyboard'])
}
},
fetchData () {
Expand All @@ -316,6 +311,7 @@ export default {
this.fetchKeyboardTypes()
this.fetchUserdata()
this.fetchUserdataPolicy()
this.fetchDetails()
},
isValidValueForKey (obj, key) {
if (this.emptyAllowedFields.includes(key) && obj[key] === '') {
Expand Down Expand Up @@ -360,6 +356,10 @@ export default {
id: 'virtio',
description: 'virtio'
})
controller.push({
id: 'virtio-blk',
description: 'virtio-blk'
})
} else if (hyperVisor === 'VMware') {
controller.push({
id: '',
Expand Down Expand Up @@ -486,6 +486,25 @@ export default {
this.userdata.loading = false
})
},
fetchDetails () {
const params = {}
params.id = this.resource.id
params.templatefilter = 'all'

api('listTemplates', params).then(response => {
if (response?.listtemplatesresponse?.template?.length > 0) {
this.details = response.listtemplatesresponse.template[0].details
if (this.details) {
for (var detailsField of this.detailsFields) {
var detailValue = this.details?.[detailsField] || null
if (detailValue) {
this.form[detailsField] = detailValue
}
}
}
}
})
},
handleSubmit (e) {
e.preventDefault()
if (this.loading) return
Expand All @@ -495,10 +514,14 @@ export default {
const params = {
id: this.resource.id
}
const detailsField = ['rootDiskController', 'nicAdapter', 'keyboard']
if (this.details) {
Object.keys(this.details).forEach((detail, index) => {
params['details[0].' + detail] = this.details[detail]
})
}
for (const key in values) {
if (!this.isValidValueForKey(values, key)) continue
if (detailsField.includes(key)) {
if (this.detailsFields.includes(key)) {
params['details[0].' + key] = values[key]
continue
}
Expand Down
Loading

AltStyle によって変換されたページ (->オリジナル) /