-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add volume group handling #6012
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
Closed
Closed
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
da5c6cd
add volume group handling
7ab0530
add VolumeGroup
8c8df11
add since parameter to AttachVolumeCmd
9fa59ec
adapt marvin for volumegroups
7541179
adapt/add test volumegroup handling
77232e9
add condition for volumes in group null in case of device count durin…
ee39c93
add groups for import/unmanage vm's
2ff2fac
adapt java test case
d55e26c
adapt marvin to import vms
f98e08d
add test group handling for import/unmanage vm's
fe51bd5
adapt code for special controller unit 7
40d0d1e
add test for special controller unit 7(attach volume and start vm)
29172ac
Add useConntrollerConfiguration to allow user to use the current cont…
3d73823
extend test call importUnmanagedVM
adb7462
Adapt test for useControllerConfiguration
541f4ac
Update api/src/main/java/org/apache/cloudstack/api/command/admin/vm/I…
DK101010 5d9e10f
Update vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/Virtu…
c7f1605
change license header to ASF
e792836
Merge branch 'main' of https://github.com/apache/cloudstack into feat…
677e34b
adapt test
3a84ea1
adapt test
c64aa68
Merge branch 'main' into feat/add_volume_groups
7f0de61
refactoring
323b69e
adapt importVolume
0785a99
Update vmware-base/src/main/java/com/cloud/hypervisor/vmware/mo/Virtu…
DK101010 699adbd
Apply suggestions from code review
DK101010 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
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
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
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
86 changes: 86 additions & 0 deletions
86
engine/schema/src/main/java/com/cloud/storage/VolumeGroupVO.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,86 @@ | ||
| /* | ||
| * 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.storage; | ||
|
|
||
| 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 org.apache.cloudstack.api.InternalIdentity; | ||
|
|
||
| @Entity | ||
| @Table(name = "volume_group") | ||
| public class VolumeGroupVO implements InternalIdentity{ | ||
| @Id | ||
| @GeneratedValue(strategy = GenerationType.IDENTITY) | ||
| @Column(name = "id") | ||
| private long id; | ||
|
|
||
| @Column(name = "vm_id") | ||
| private long vmId; | ||
|
|
||
| @Column(name = "volume_id") | ||
| private long volumeId; | ||
|
|
||
| @Column(name = "group_number") | ||
| private int groupNumber; | ||
|
|
||
|
|
||
| public VolumeGroupVO() {} | ||
|
|
||
| public VolumeGroupVO(long vmId, long volumeId, int groupNumber) { | ||
| this.vmId = vmId; | ||
| this.volumeId = volumeId; | ||
| this.groupNumber = groupNumber; | ||
| } | ||
|
|
||
| public long getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public void setId(long id) { | ||
| this.id = id; | ||
| } | ||
|
|
||
| public long getVmId() { | ||
| return vmId; | ||
| } | ||
|
|
||
| public void setVmId(long vmId) { | ||
| this.vmId = vmId; | ||
| } | ||
|
|
||
| public int getGroupNumber() { | ||
| return groupNumber; | ||
| } | ||
|
|
||
| public void setGroupNumber(int groupNumber) { | ||
| this.groupNumber = groupNumber; | ||
| } | ||
|
|
||
| public long getVolumeId() { | ||
| return volumeId; | ||
| } | ||
|
|
||
| public void setVolumeId(long volumeId) { | ||
| this.volumeId = volumeId; | ||
| } | ||
| } |
29 changes: 29 additions & 0 deletions
29
engine/schema/src/main/java/com/cloud/storage/dao/VolumeGroupDao.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,29 @@ | ||
| /* | ||
| * 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.storage.dao; | ||
|
|
||
| import com.cloud.utils.db.GenericDao; | ||
| import com.cloud.storage.VolumeGroupVO; | ||
|
|
||
|
|
||
| public interface VolumeGroupDao extends GenericDao<VolumeGroupVO, Long> { | ||
| public void addVolumeToGroup(long vmId, long volumeId, long deviceId, int groupNumber); | ||
| public void deleteVolumeFromGroup(long volumeId); | ||
| public VolumeGroupVO findByVmAndVolume(long vmId, long volumeId); | ||
| } |
69 changes: 69 additions & 0 deletions
69
engine/schema/src/main/java/com/cloud/storage/dao/VolumeGroupDaoImpl.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,69 @@ | ||
| /* | ||
| * 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.storage.dao; | ||
|
|
||
| import com.cloud.utils.db.GenericDaoBase; | ||
| import com.cloud.storage.VolumeGroupVO; | ||
| import com.cloud.utils.db.SearchBuilder; | ||
| import com.cloud.utils.db.SearchCriteria; | ||
|
|
||
|
|
||
| public class VolumeGroupDaoImpl extends GenericDaoBase<VolumeGroupVO, Long> implements VolumeGroupDao { | ||
| protected final SearchBuilder<VolumeGroupVO> allFieldsSearch; | ||
| private static final String VOLUME_ID = "volumeId"; | ||
| private static final String VM_ID = "vmId"; | ||
| private static final String GROUP_NUMBER = "groupNumber"; | ||
|
|
||
| public VolumeGroupDaoImpl(){ | ||
| allFieldsSearch = createSearchBuilder(); | ||
| allFieldsSearch.and(VM_ID, allFieldsSearch.entity().getVmId(), SearchCriteria.Op.EQ); | ||
| allFieldsSearch.and(VOLUME_ID, allFieldsSearch.entity().getVolumeId(), SearchCriteria.Op.EQ); | ||
| allFieldsSearch.and(GROUP_NUMBER, allFieldsSearch.entity().getGroupNumber(), SearchCriteria.Op.EQ); | ||
| allFieldsSearch.done(); | ||
| } | ||
|
|
||
| @Override | ||
| public void addVolumeToGroup(long vmId, long volumeId, long deviceId, int groupNumber) { | ||
| if (groupNumber != -1) { | ||
| if (deviceId == 0L) { | ||
| groupNumber = 0; | ||
| } | ||
| VolumeGroupVO group = new VolumeGroupVO(); | ||
| group.setVmId(vmId); | ||
| group.setVolumeId(volumeId); | ||
| group.setGroupNumber(groupNumber); | ||
| persist(group); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public void deleteVolumeFromGroup(long volumeId) { | ||
| SearchCriteria<VolumeGroupVO> sc = allFieldsSearch.create(); | ||
| sc.setParameters(VOLUME_ID, volumeId); | ||
| expunge(sc); | ||
| } | ||
|
|
||
| @Override | ||
| public VolumeGroupVO findByVmAndVolume(long vmId, long volumeId){ | ||
| SearchCriteria<VolumeGroupVO> sc = allFieldsSearch.create(); | ||
| sc.setParameters(VM_ID, vmId); | ||
| sc.setParameters(VOLUME_ID, volumeId); | ||
| return findOneBy(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
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.