-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Change storage pool scope from Cluster to Zone and vise versa #8875
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
Merged
Merged
Changes from 53 commits
Commits
Show all changes
57 commits
Select commit
Hold shift + click to select a range
f7ea076
New feature: Change storage pool scope
abh1sar d6aa362
Added checks for Ceph/RBD
abh1sar 5a1e7bd
Update op_host_capacity table on primary storage scope change
abh1sar 5bd6995
Storage pool scope change integration test
abh1sar c5cbd5d
pull 8875 : Addressed review comments
abh1sar 0fab7a3
Pull 8875: remove storage checks, AbstractPrimayStorageLifeCycleImpl …
abh1sar 283db1f
Pull 8875: Fixed integration test failure
abh1sar fb976d9
Pull 8875: Review comments
abh1sar 042aef7
Pull 8875: review comments + broke changeStoragePoolScope into smalle…
abh1sar 72160ea
Added UT for changeStoragePoolScope
abh1sar abf7082
Rename AbstractPrimaryDataStoreLifeCycleImpl to BasePrimaryDataStoreL…
abh1sar 5ba040d
Pull 8875: Dao review comments
abh1sar ca36119
Pull 8875: Rename changeStoragePoolScope.vue to ChangeStoragePoolScop…
abh1sar 962d0f3
Pull 8875: Created a new smokes test file + A single warning msg in ui
abh1sar f98b754
Merge with latest 4.19
abh1sar 3753be3
Merge remote-tracking branch 'upstream/4.19' into changescope419
abh1sar 30d628d
Merge branch '4.19' into 419-changescope
abh1sar aa83ec0
Pull 8875: Added cleanup in test_primary_storage_scope.py
abh1sar dcb9449
Pull 8875: Type in en.json
abh1sar 8ce579a
Merge remote-tracking branch 'upstream/4.19' into changescope419
abh1sar bc4e700
Merge branch '4.19' into 419-changescope
abh1sar d714b8c
Merge remote-tracking branch 'upstream/4.19' into 419
abh1sar 8de7aa6
Pull 8875: cleanup array in test_primary_storage_scope.py
abh1sar 4b07a6c
Merge branch '4.19' into 419-changescope
abh1sar b3245cd
Pull:8875 Removing extra whitespace at eof of StorageManagerImplTest
abh1sar f3bdae8
Merge branch '419-changescope' of http://github.com/abh1sar/cloudstac…
abh1sar 9657a10
Pull 8875: Added UT for PrimaryDataStoreHelper and BasePrimaryDataSto…
abh1sar 8d36db0
Pull 8875: Added license header
abh1sar 5ef41e1
Merge remote-tracking branch 'upstream/4.19' into changescope419
abh1sar aad87f2
Pull 8875: Fixed sql query for vmstates
abh1sar 85a6340
Pull 8875: Changed icon plus info on disabled mode in apidoc
abh1sar 49341db
Merge remote-tracking branch 'upstream/4.19' into changescope419
abh1sar 419e5a4
Pull 8875: Change scope should not work for local storage
abh1sar d611198
Pull 8875: Change scope completion event
abh1sar 9da8382
Pull 8875: Added api findAffectedVmsForStorageScopeChange
abh1sar 8646c80
Merge remote-tracking branch 'upstream/4.19' into changescope419
abh1sar 35c8b00
Pull 8875: Added UT for findAffectedVmsForStorageScopeChange and remo…
abh1sar ba397d7
Pull 8875: Review comments + Vm name in response
abh1sar 81a2c67
Pull 8875: listByVmsNotInClusterUsingPool was returning duplicate VM …
abh1sar c502838
Pull 8875: fixed listAffectedVmsForStorageScopeChange UT
abh1sar edea352
Merge remote-tracking branch 'upstream/4.19' into changescope419
abh1sar 3af24b4
Merge remote-tracking branch 'upstream/4.19' into scope
abh1sar cc08595
listAffectedVmsForStorageScopeChange should work if the pool is not d…
abh1sar 0b75de1
Fix listAffectedVmsForStorageScopeChangeTest UT
abh1sar eedb361
Merge branch '4.19' into 419-changescope
abh1sar e62551b
Merge remote-tracking branch 'upstream/4.19' into cs
abh1sar 57c4a2f
Pull 8875: add volume.removed not null check in VmsNotInClusterUsingP…
abh1sar 271d526
Pull 8875: minor refactoring in changeStoragePoolScopeToCluster
abh1sar 0821cc7
Update server/src/main/java/com/cloud/storage/StorageManagerImpl.java
sureshanaparti 0507508
Merge remote-tracking branch 'upstream/4.19' into cs
abh1sar afd107b
fix eof
abh1sar 2bdd974
Merge branch '4.19' into 419-changescope
abh1sar e40c14a
Merge branch '4.19' into 419-changescope
abh1sar e0cec9e
changeStoragePoolScopeToZone should connect pool to all Up hosts
abh1sar 11b43b2
Merge branch '4.19' into 419-changescope
abh1sar 25c4a01
Merge branch '4.19' into 419-changescope
abh1sar 1b698c1
Merge branch '4.19' into 419-changescope
abh1sar 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
98 changes: 98 additions & 0 deletions
98
.../main/java/org/apache/cloudstack/api/command/admin/storage/ChangeStoragePoolScopeCmd.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,98 @@ | ||
| // 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.command.admin.storage; | ||
|
|
||
| import org.apache.cloudstack.api.APICommand; | ||
| import org.apache.cloudstack.api.ApiCommandResourceType; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import org.apache.cloudstack.api.BaseAsyncCmd; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.response.ClusterResponse; | ||
| import org.apache.cloudstack.api.response.StoragePoolResponse; | ||
| import org.apache.cloudstack.api.response.SuccessResponse; | ||
| import org.apache.cloudstack.context.CallContext; | ||
|
|
||
| import com.cloud.event.EventTypes; | ||
| import com.cloud.storage.StoragePool; | ||
|
|
||
| @APICommand(name = "changeStoragePoolScope", description = "Changes the scope of a storage pool when the pool is in Disabled state." + | ||
| "This feature is officially tested and supported for Hypervisors: KVM and VMware, Protocols: NFS and Ceph, and Storage Provider: DefaultPrimary. " + | ||
| "There might be extra steps involved to make this work for other hypervisors and storage options.", | ||
| responseObject = SuccessResponse.class, since= "4.19.1", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) | ||
| public class ChangeStoragePoolScopeCmd extends BaseAsyncCmd { | ||
|
|
||
| @Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = StoragePoolResponse.class, required = true, description = "the Id of the storage pool") | ||
| private Long id; | ||
|
|
||
| @Parameter(name = ApiConstants.SCOPE, type = CommandType.STRING, required = true, description = "the scope of the storage: cluster or zone") | ||
| private String scope; | ||
|
|
||
| @Parameter(name = ApiConstants.CLUSTER_ID, type = CommandType.UUID, entityType = ClusterResponse.class, description = "the Id of the cluster to use if scope is being set to Cluster") | ||
| private Long clusterId; | ||
|
|
||
| @Override | ||
| public ApiCommandResourceType getApiResourceType() { | ||
| return ApiCommandResourceType.StoragePool; | ||
| } | ||
|
|
||
| @Override | ||
| public Long getApiResourceId() { | ||
| return getId(); | ||
| } | ||
|
|
||
| public String getEventType() { | ||
| return EventTypes.EVENT_CHANGE_STORAGE_POOL_SCOPE; | ||
| } | ||
|
|
||
| @Override | ||
| public String getEventDescription() { | ||
| String description = "Change storage pool scope. Storage pool Id: "; | ||
| StoragePool pool = _entityMgr.findById(StoragePool.class, getId()); | ||
| if (pool != null) { | ||
| description += pool.getUuid(); | ||
| } else { | ||
| description += getId(); | ||
| } | ||
| description += " to " + getScope(); | ||
| return description; | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| _storageService.changeStoragePoolScope(this); | ||
| SuccessResponse response = new SuccessResponse(getCommandName()); | ||
| this.setResponseObject(response); | ||
| } | ||
|
|
||
| @Override | ||
| public long getEntityOwnerId() { | ||
| return CallContext.current().getCallingAccountId(); | ||
| } | ||
|
|
||
| public Long getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public String getScope() { | ||
| return scope; | ||
| } | ||
|
|
||
| public Long getClusterId() { | ||
| return clusterId; | ||
| } | ||
| } |
77 changes: 77 additions & 0 deletions
77
...a/org/apache/cloudstack/api/command/admin/vm/ListAffectedVmsForStorageScopeChangeCmd.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,77 @@ | ||
| /* | ||
| * 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.command.admin.vm; | ||
|
|
||
| import org.apache.cloudstack.acl.RoleType; | ||
| import org.apache.cloudstack.api.APICommand; | ||
| import org.apache.cloudstack.api.ApiConstants; | ||
| import org.apache.cloudstack.api.BaseListCmd; | ||
| import org.apache.cloudstack.api.Parameter; | ||
| import org.apache.cloudstack.api.response.ClusterResponse; | ||
| import org.apache.cloudstack.api.response.ListResponse; | ||
| import org.apache.cloudstack.api.response.StoragePoolResponse; | ||
| import org.apache.cloudstack.api.response.VirtualMachineResponse; | ||
|
|
||
| import com.cloud.vm.VirtualMachine; | ||
|
|
||
| @APICommand(name = "listAffectedVmsForStorageScopeChange", | ||
| description = "List user and system VMs that need to be stopped and destroyed respectively for changing the scope of the storage pool from Zone to Cluster.", | ||
| responseObject = VirtualMachineResponse.class, | ||
| requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, since = "4.19.1", | ||
| authorized = {RoleType.Admin}) | ||
| public class ListAffectedVmsForStorageScopeChangeCmd extends BaseListCmd { | ||
|
|
||
| @Parameter(name = ApiConstants.CLUSTER_ID, | ||
| type = CommandType.UUID, | ||
| entityType = ClusterResponse.class, | ||
| required = true, | ||
| description = "the Id of the cluster the scope of the storage pool is being changed to") | ||
| private Long clusterIdForScopeChange; | ||
|
|
||
| @Parameter(name = ApiConstants.STORAGE_ID, | ||
| type = CommandType.UUID, | ||
| entityType = StoragePoolResponse.class, | ||
| required = true, | ||
| description = "the Id of the storage pool on which change scope operation is being done") | ||
| private Long storageId; | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| /////////////////// Accessors /////////////////////// | ||
| ///////////////////////////////////////////////////// | ||
|
|
||
| public Long getClusterIdForScopeChange() { | ||
| return clusterIdForScopeChange; | ||
| } | ||
|
|
||
| public Long getStorageId() { | ||
| return storageId; | ||
| } | ||
|
|
||
| ///////////////////////////////////////////////////// | ||
| /////////////// API Implementation/////////////////// | ||
| ///////////////////////////////////////////////////// | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| ListResponse<VirtualMachineResponse> response = _queryService.listAffectedVmsForStorageScopeChange(this); | ||
| response.setResponseName(getCommandName()); | ||
| response.setObjectName(VirtualMachine.class.getSimpleName().toLowerCase()); | ||
| setResponseObject(response); | ||
| } | ||
| } |
124 changes: 124 additions & 0 deletions
124
api/src/main/java/org/apache/cloudstack/api/response/VirtualMachineResponse.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,124 @@ | ||
| // 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 org.apache.cloudstack.api.EntityReference; | ||
|
|
||
| import com.cloud.serializer.Param; | ||
| import com.cloud.vm.VirtualMachine; | ||
| import com.google.gson.annotations.SerializedName; | ||
|
|
||
| @EntityReference(value = VirtualMachine.class) | ||
| public class VirtualMachineResponse extends BaseResponse { | ||
| @SerializedName("id") | ||
| @Param(description = "the ID of the VM") | ||
| private String id; | ||
|
|
||
| @SerializedName("type") | ||
| @Param(description = "the type of VM") | ||
| private String type; | ||
|
|
||
| @SerializedName("name") | ||
| @Param(description = "the name of the VM") | ||
| private String name; | ||
|
|
||
| @SerializedName("clusterid") | ||
| @Param(description = "the cluster ID for the VM") | ||
| private String clusterId; | ||
|
|
||
| @SerializedName("clustername") | ||
| @Param(description = "the cluster name for the VM") | ||
| private String clusterName; | ||
|
|
||
| @SerializedName("hostid") | ||
| @Param(description = "the host ID for the VM") | ||
| private String hostId; | ||
|
|
||
| @SerializedName("hostname") | ||
| @Param(description = "the hostname for the VM") | ||
| private String hostName; | ||
|
|
||
weizhouapache marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @Override | ||
| public String getObjectId() { | ||
| return this.getId(); | ||
| } | ||
|
|
||
| public String getId() { | ||
| return id; | ||
| } | ||
|
|
||
| public void setId(String id) { | ||
| this.id = id; | ||
| } | ||
|
|
||
| public String getVmType() { | ||
| return type; | ||
| } | ||
|
|
||
| public void setVmType(String type) { | ||
| this.type = type; | ||
| } | ||
|
|
||
| public String getVmName() { | ||
| return name; | ||
| } | ||
|
|
||
| public void setVmName(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getClusterId() { | ||
| return clusterId; | ||
| } | ||
|
|
||
| public void setClusterId(String clusterId) { | ||
| this.clusterId = clusterId; | ||
| } | ||
|
|
||
| public String getClusterName() { | ||
| return clusterName; | ||
| } | ||
|
|
||
| public void setClusterName(String clusterName) { | ||
| this.clusterName = clusterName; | ||
| } | ||
|
|
||
| public String getName() { | ||
| return name; | ||
| } | ||
|
|
||
| public void setName(String name) { | ||
| this.name = name; | ||
| } | ||
|
|
||
| public String getHostId() { | ||
| return hostId; | ||
| } | ||
|
|
||
| public void setHostId(String hostId) { | ||
| this.hostId = hostId; | ||
| } | ||
|
|
||
| public String getHostName() { | ||
| return hostName; | ||
| } | ||
|
|
||
| public void setHostName(String hostName) { | ||
| this.hostName = hostName; | ||
| } | ||
| } | ||
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need this class? Is it possible to use UserVmResponse or do we also have affected VR and system VMs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if storage scope is changed from Zone to Cluster, the hosts in other cluster will disconnect from the storage.
the running VMs (user vms, vr, system vms) on the hosts will be affected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the response can return system VMs as well.