-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Multiple CD-ROM / ISO Support Per VM #13101
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
Draft
Damans227
wants to merge
28
commits into
apache:main
Choose a base branch
from
Damans227:fr283-multi-cdrom
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 20 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
d3668e2
pre-allocate a second empty cdrom slot at boot (hardcoded)
Damans227 90b415f
drive cdrom slot count via vm.cdrom.max.count ConfigKey
Damans227 0516f82
add vm_iso_map table + VO/DAO
Damans227 945f2bd
persist multi-ISO state via vm_iso_map
Damans227 9570369
carry target cdrom slot through AttachCommand to KVM agent
Damans227 5fd487a
enforce per-VM cdrom cap, clamp to hypervisor max
Damans227 3a13ac7
make detachIso accepts an ISO id
Damans227 b05b9f9
expose attached ISOs as isos[] in listVirtualMachines response
Damans227 6d2ae5a
extract CDROM_PRIMARY_DEVICE_SEQ constant
Damans227 a44b4fb
unit tests for cdrom slot allocation logic
Damans227 a6afd26
implement multi-ISO attachment and detachment for VMs with enhanced v…
Damans227 71fe082
implement multi-ISO display in InstanceTab with computed property for…
Damans227 2ff3ce6
add warning alert for max CDROM selections and enhance global capacit…
Damans227 e394f1c
enhance ISO attachment validation to handle multiple ISOs and prevent…
Damans227 e7185ab
refactor ISO attachment logic for detachment and validation
Damans227 1e5bd63
add unit tests for ISO detachment resolution and validation logic
Damans227 79e8edf
add mock for VmIsoMapDao in UserVmJoinDaoImplTest and set lenient beh…
Damans227 bac8122
refactor ISO attachment logic and enhance UI for multi-CDROM management
Damans227 0570cf2
refactor ISO attachment methods to use VM ID and improve parameter ha…
Damans227 61396a1
remove unnecessary mock for VM ISO mapping in TemplateManagerImplTest
Damans227 fdaffb5
add 'since' attribute to ISO detach command parameter description
Damans227 6634da7
scope vm.cdrom.max.count to cluster
Damans227 082896e
add support for configurable CD-ROM count per VM and improve handling…
Damans227 ce530d2
add HostDetailsDao mock to UserVmJoinDaoImplTest
Damans227 7717002
fix: handle null poolId when loading attached ISO slots in prepareIso…
Damans227 2932522
implement listByIsoId method in VmIsoMapDao and update TemplateManage…
Damans227 22fae71
improve logging messages for ISO deletion checks
Damans227 893c6df
add unit tests for CD-ROM handling and enforce limits in TemplateManager
Damans227 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
api/src/main/java/org/apache/cloudstack/api/response/AttachedIsoResponse.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| package org.apache.cloudstack.api.response; | ||
|
|
||
| import org.apache.cloudstack.api.BaseResponse; | ||
|
|
||
| import com.cloud.serializer.Param; | ||
| import com.google.gson.annotations.SerializedName; | ||
|
|
||
| public class AttachedIsoResponse extends BaseResponse { | ||
|
|
||
| @SerializedName("id") | ||
| @Param(description = "The ID of the attached ISO") | ||
| private String id; | ||
|
|
||
| @SerializedName("name") | ||
| @Param(description = "The name of the attached ISO") | ||
| private String name; | ||
|
|
||
| @SerializedName("displaytext") | ||
| @Param(description = "The display text of the attached ISO") | ||
| private String displayText; | ||
|
|
||
| @SerializedName("deviceseq") | ||
| @Param(description = "The cdrom slot that holds this ISO (3=hdc, 4=hdd, ...)") | ||
| private Integer deviceSeq; | ||
|
|
||
| public AttachedIsoResponse() { | ||
| } | ||
|
|
||
| public AttachedIsoResponse(String id, String name, String displayText, Integer deviceSeq) { | ||
| this.id = id; | ||
| this.name = name; | ||
| this.displayText = displayText; | ||
| this.deviceSeq = deviceSeq; | ||
| } | ||
|
|
||
| public String getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public String getDisplayText() { | ||
| return displayText; | ||
| } | ||
|
|
||
| public Integer getDeviceSeq() { | ||
| return deviceSeq; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| package com.cloud.vm; | ||
|
|
||
| import java.util.Date; | ||
|
|
||
| import javax.persistence.Column; | ||
| import javax.persistence.Entity; | ||
| import javax.persistence.GeneratedValue; | ||
| import javax.persistence.GenerationType; | ||
| import javax.persistence.Id; | ||
| import javax.persistence.Table; | ||
| import javax.persistence.Temporal; | ||
| import javax.persistence.TemporalType; | ||
|
|
||
| import org.apache.cloudstack.api.InternalIdentity; | ||
|
|
||
| @Entity | ||
| @Table(name = "vm_iso_map") | ||
| public class VmIsoMapVO implements InternalIdentity { | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "id") | ||
| private Long id; | ||
|
|
||
| @Column(name = "vm_id") | ||
| private long vmId; | ||
|
|
||
| @Column(name = "iso_id") | ||
| private long isoId; | ||
|
|
||
| @Column(name = "device_seq") | ||
| private int deviceSeq; | ||
|
|
||
| @Column(name = "created") | ||
| @Temporal(TemporalType.TIMESTAMP) | ||
| private Date created; | ||
|
|
||
| public VmIsoMapVO() { | ||
| } | ||
|
|
||
| public VmIsoMapVO(long vmId, long isoId, int deviceSeq) { | ||
| this.vmId = vmId; | ||
| this.isoId = isoId; | ||
| this.deviceSeq = deviceSeq; | ||
| this.created = new Date(); | ||
| } | ||
|
|
||
| @Override | ||
| public long getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public long getVmId() { | ||
| return vmId; | ||
| } | ||
|
|
||
| public long getIsoId() { | ||
| return isoId; | ||
| } | ||
|
|
||
| public int getDeviceSeq() { | ||
| return deviceSeq; | ||
| } | ||
|
|
||
| public Date getCreated() { | ||
| return created; | ||
| } | ||
| } |
32 changes: 32 additions & 0 deletions
32
engine/schema/src/main/java/com/cloud/vm/dao/VmIsoMapDao.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| package com.cloud.vm.dao; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import com.cloud.utils.db.GenericDao; | ||
| import com.cloud.vm.VmIsoMapVO; | ||
|
|
||
| public interface VmIsoMapDao extends GenericDao<VmIsoMapVO, Long> { | ||
| List<VmIsoMapVO> listByVmId(long vmId); | ||
|
|
||
| VmIsoMapVO findByVmIdDeviceSeq(long vmId, int deviceSeq); | ||
|
|
||
| VmIsoMapVO findByVmIdIsoId(long vmId, long isoId); | ||
|
|
||
| int removeByVmId(long vmId); | ||
| } |
80 changes: 80 additions & 0 deletions
80
engine/schema/src/main/java/com/cloud/vm/dao/VmIsoMapDaoImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
| package com.cloud.vm.dao; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| import org.springframework.stereotype.Component; | ||
|
|
||
| import com.cloud.utils.db.GenericDaoBase; | ||
| import com.cloud.utils.db.SearchBuilder; | ||
| import com.cloud.utils.db.SearchCriteria; | ||
| import com.cloud.vm.VmIsoMapVO; | ||
|
|
||
| @Component | ||
| public class VmIsoMapDaoImpl extends GenericDaoBase<VmIsoMapVO, Long> implements VmIsoMapDao { | ||
|
|
||
| private SearchBuilder<VmIsoMapVO> ListByVmId; | ||
| private SearchBuilder<VmIsoMapVO> ByVmIdDeviceSeq; | ||
| private SearchBuilder<VmIsoMapVO> ByVmIdIsoId; | ||
|
|
||
| protected VmIsoMapDaoImpl() { | ||
| ListByVmId = createSearchBuilder(); | ||
| ListByVmId.and("vmId", ListByVmId.entity().getVmId(), SearchCriteria.Op.EQ); | ||
| ListByVmId.done(); | ||
|
|
||
| ByVmIdDeviceSeq = createSearchBuilder(); | ||
| ByVmIdDeviceSeq.and("vmId", ByVmIdDeviceSeq.entity().getVmId(), SearchCriteria.Op.EQ); | ||
| ByVmIdDeviceSeq.and("deviceSeq", ByVmIdDeviceSeq.entity().getDeviceSeq(), SearchCriteria.Op.EQ); | ||
| ByVmIdDeviceSeq.done(); | ||
|
|
||
| ByVmIdIsoId = createSearchBuilder(); | ||
| ByVmIdIsoId.and("vmId", ByVmIdIsoId.entity().getVmId(), SearchCriteria.Op.EQ); | ||
| ByVmIdIsoId.and("isoId", ByVmIdIsoId.entity().getIsoId(), SearchCriteria.Op.EQ); | ||
| ByVmIdIsoId.done(); | ||
| } | ||
|
|
||
| @Override | ||
| public List<VmIsoMapVO> listByVmId(long vmId) { | ||
| SearchCriteria<VmIsoMapVO> sc = ListByVmId.create(); | ||
| sc.setParameters("vmId", vmId); | ||
| return listBy(sc); | ||
| } | ||
|
|
||
| @Override | ||
| public VmIsoMapVO findByVmIdDeviceSeq(long vmId, int deviceSeq) { | ||
| SearchCriteria<VmIsoMapVO> sc = ByVmIdDeviceSeq.create(); | ||
| sc.setParameters("vmId", vmId); | ||
| sc.setParameters("deviceSeq", deviceSeq); | ||
| return findOneBy(sc); | ||
| } | ||
|
|
||
| @Override | ||
| public VmIsoMapVO findByVmIdIsoId(long vmId, long isoId) { | ||
| SearchCriteria<VmIsoMapVO> sc = ByVmIdIsoId.create(); | ||
| sc.setParameters("vmId", vmId); | ||
| sc.setParameters("isoId", isoId); | ||
| return findOneBy(sc); | ||
| } | ||
|
|
||
| @Override | ||
| public int removeByVmId(long vmId) { | ||
| SearchCriteria<VmIsoMapVO> sc = ListByVmId.create(); | ||
| sc.setParameters("vmId", vmId); | ||
| return remove(sc); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.