Skip to content

Commit 0ec7c72

Browse files
committed
Merge branch '4.19'
2 parents e010c9b + d797356 commit 0ec7c72

File tree

81 files changed

+3405
-494
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+3405
-494
lines changed

api/src/main/java/com/cloud/event/EventTypes.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ public class EventTypes {
451451
public static final String EVENT_ENABLE_PRIMARY_STORAGE = "ENABLE.PS";
452452
public static final String EVENT_DISABLE_PRIMARY_STORAGE = "DISABLE.PS";
453453
public static final String EVENT_SYNC_STORAGE_POOL = "SYNC.STORAGE.POOL";
454+
public static final String EVENT_CHANGE_STORAGE_POOL_SCOPE = "CHANGE.STORAGE.POOL.SCOPE";
454455

455456
// VPN
456457
public static final String EVENT_REMOTE_ACCESS_VPN_CREATE = "VPN.REMOTE.ACCESS.CREATE";
@@ -1002,6 +1003,7 @@ public class EventTypes {
10021003
// Primary storage pool
10031004
entityEventDetails.put(EVENT_ENABLE_PRIMARY_STORAGE, StoragePool.class);
10041005
entityEventDetails.put(EVENT_DISABLE_PRIMARY_STORAGE, StoragePool.class);
1006+
entityEventDetails.put(EVENT_CHANGE_STORAGE_POOL_SCOPE, StoragePool.class);
10051007

10061008
// VPN
10071009
entityEventDetails.put(EVENT_REMOTE_ACCESS_VPN_CREATE, RemoteAccessVpn.class);

api/src/main/java/com/cloud/storage/StorageService.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Map;
2222

2323
import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd;
24+
import org.apache.cloudstack.api.command.admin.storage.ChangeStoragePoolScopeCmd;
2425
import org.apache.cloudstack.api.command.admin.storage.CreateSecondaryStagingStoreCmd;
2526
import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
2627
import org.apache.cloudstack.api.command.admin.storage.DeleteImageStoreCmd;
@@ -35,6 +36,7 @@
3536
import com.cloud.exception.DiscoveryException;
3637
import com.cloud.exception.InsufficientCapacityException;
3738
import com.cloud.exception.InvalidParameterValueException;
39+
import com.cloud.exception.PermissionDeniedException;
3840
import com.cloud.exception.ResourceInUseException;
3941
import com.cloud.exception.ResourceUnavailableException;
4042
import org.apache.cloudstack.api.command.admin.storage.heuristics.CreateSecondaryStorageSelectorCmd;
@@ -130,4 +132,6 @@ public interface StorageService {
130132
boolean deleteObjectStore(DeleteObjectStoragePoolCmd cmd);
131133

132134
ObjectStore updateObjectStore(Long id, UpdateObjectStoragePoolCmd cmd);
135+
136+
void changeStoragePoolScope(ChangeStoragePoolScopeCmd cmd) throws IllegalArgumentException, InvalidParameterValueException, PermissionDeniedException;
133137
}

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,7 @@ public class ApiConstants {
450450
public static final String STORAGE_POLICY = "storagepolicy";
451451
public static final String STORAGE_MOTION_ENABLED = "storagemotionenabled";
452452
public static final String STORAGE_CAPABILITIES = "storagecapabilities";
453+
public static final String STORAGE_CUSTOM_STATS = "storagecustomstats";
453454
public static final String SUBNET = "subnet";
454455
public static final String OWNER = "owner";
455456
public static final String SWAP_OWNER = "swapowner";
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
18+
package org.apache.cloudstack.api.command.admin.storage;
19+
20+
import org.apache.cloudstack.api.APICommand;
21+
import org.apache.cloudstack.api.ApiCommandResourceType;
22+
import org.apache.cloudstack.api.ApiConstants;
23+
import org.apache.cloudstack.api.BaseAsyncCmd;
24+
import org.apache.cloudstack.api.Parameter;
25+
import org.apache.cloudstack.api.response.ClusterResponse;
26+
import org.apache.cloudstack.api.response.StoragePoolResponse;
27+
import org.apache.cloudstack.api.response.SuccessResponse;
28+
import org.apache.cloudstack.context.CallContext;
29+
30+
import com.cloud.event.EventTypes;
31+
import com.cloud.storage.StoragePool;
32+
33+
@APICommand(name = "changeStoragePoolScope", description = "Changes the scope of a storage pool when the pool is in Disabled state." +
34+
"This feature is officially tested and supported for Hypervisors: KVM and VMware, Protocols: NFS and Ceph, and Storage Provider: DefaultPrimary. " +
35+
"There might be extra steps involved to make this work for other hypervisors and storage options.",
36+
responseObject = SuccessResponse.class, since= "4.19.1", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
37+
public class ChangeStoragePoolScopeCmd extends BaseAsyncCmd {
38+
39+
@Parameter(name = ApiConstants.ID, type = CommandType.UUID, entityType = StoragePoolResponse.class, required = true, description = "the Id of the storage pool")
40+
private Long id;
41+
42+
@Parameter(name = ApiConstants.SCOPE, type = CommandType.STRING, required = true, description = "the scope of the storage: cluster or zone")
43+
private String scope;
44+
45+
@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")
46+
private Long clusterId;
47+
48+
@Override
49+
public ApiCommandResourceType getApiResourceType() {
50+
return ApiCommandResourceType.StoragePool;
51+
}
52+
53+
@Override
54+
public Long getApiResourceId() {
55+
return getId();
56+
}
57+
58+
public String getEventType() {
59+
return EventTypes.EVENT_CHANGE_STORAGE_POOL_SCOPE;
60+
}
61+
62+
@Override
63+
public String getEventDescription() {
64+
String description = "Change storage pool scope. Storage pool Id: ";
65+
StoragePool pool = _entityMgr.findById(StoragePool.class, getId());
66+
if (pool != null) {
67+
description += pool.getUuid();
68+
} else {
69+
description += getId();
70+
}
71+
description += " to " + getScope();
72+
return description;
73+
}
74+
75+
@Override
76+
public void execute() {
77+
_storageService.changeStoragePoolScope(this);
78+
SuccessResponse response = new SuccessResponse(getCommandName());
79+
this.setResponseObject(response);
80+
}
81+
82+
@Override
83+
public long getEntityOwnerId() {
84+
return CallContext.current().getCallingAccountId();
85+
}
86+
87+
public Long getId() {
88+
return id;
89+
}
90+
91+
public String getScope() {
92+
return scope;
93+
}
94+
95+
public Long getClusterId() {
96+
return clusterId;
97+
}
98+
}

api/src/main/java/org/apache/cloudstack/api/command/admin/storage/ListStoragePoolsCmd.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public class ListStoragePoolsCmd extends BaseListCmd {
7272
@Parameter(name = ApiConstants.HOST_ID, type = CommandType.UUID, entityType = HostResponse.class, description = "host ID of the storage pools")
7373
private Long hostId;
7474

75-
75+
@Parameter(name = ApiConstants.STORAGE_CUSTOM_STATS, type = CommandType.BOOLEAN, description = "If true, lists the custom stats of the storage pool", since = "4.18.1")
76+
private Boolean customStats;
7677
/////////////////////////////////////////////////////
7778
/////////////////// Accessors ///////////////////////
7879
/////////////////////////////////////////////////////
@@ -129,6 +130,10 @@ public void setScope(String scope) {
129130
this.scope = scope;
130131
}
131132

133+
public Boolean getCustomStats() {
134+
return customStats != null && customStats;
135+
}
136+
132137
/////////////////////////////////////////////////////
133138
/////////////// API Implementation///////////////////
134139
/////////////////////////////////////////////////////
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.cloudstack.api.command.admin.vm;
20+
21+
import org.apache.cloudstack.acl.RoleType;
22+
import org.apache.cloudstack.api.APICommand;
23+
import org.apache.cloudstack.api.ApiConstants;
24+
import org.apache.cloudstack.api.BaseListCmd;
25+
import org.apache.cloudstack.api.Parameter;
26+
import org.apache.cloudstack.api.response.ClusterResponse;
27+
import org.apache.cloudstack.api.response.ListResponse;
28+
import org.apache.cloudstack.api.response.StoragePoolResponse;
29+
import org.apache.cloudstack.api.response.VirtualMachineResponse;
30+
31+
import com.cloud.vm.VirtualMachine;
32+
33+
@APICommand(name = "listAffectedVmsForStorageScopeChange",
34+
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.",
35+
responseObject = VirtualMachineResponse.class,
36+
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, since = "4.19.1",
37+
authorized = {RoleType.Admin})
38+
public class ListAffectedVmsForStorageScopeChangeCmd extends BaseListCmd {
39+
40+
@Parameter(name = ApiConstants.CLUSTER_ID,
41+
type = CommandType.UUID,
42+
entityType = ClusterResponse.class,
43+
required = true,
44+
description = "the Id of the cluster the scope of the storage pool is being changed to")
45+
private Long clusterIdForScopeChange;
46+
47+
@Parameter(name = ApiConstants.STORAGE_ID,
48+
type = CommandType.UUID,
49+
entityType = StoragePoolResponse.class,
50+
required = true,
51+
description = "the Id of the storage pool on which change scope operation is being done")
52+
private Long storageId;
53+
54+
/////////////////////////////////////////////////////
55+
/////////////////// Accessors ///////////////////////
56+
/////////////////////////////////////////////////////
57+
58+
public Long getClusterIdForScopeChange() {
59+
return clusterIdForScopeChange;
60+
}
61+
62+
public Long getStorageId() {
63+
return storageId;
64+
}
65+
66+
/////////////////////////////////////////////////////
67+
/////////////// API Implementation///////////////////
68+
/////////////////////////////////////////////////////
69+
70+
@Override
71+
public void execute() {
72+
ListResponse<VirtualMachineResponse> response = _queryService.listAffectedVmsForStorageScopeChange(this);
73+
response.setResponseName(getCommandName());
74+
response.setObjectName(VirtualMachine.class.getSimpleName().toLowerCase());
75+
setResponseObject(response);
76+
}
77+
}

api/src/main/java/org/apache/cloudstack/api/response/StoragePoolResponse.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,10 @@ public class StoragePoolResponse extends BaseResponseWithAnnotations {
9797
@Param(description = "total min IOPS currently in use by volumes")
9898
private Long allocatedIops;
9999

100+
@SerializedName(ApiConstants.STORAGE_CUSTOM_STATS)
101+
@Param(description = "the storage pool custom stats", since = "4.18.1")
102+
private Map<String, String> customStats;
103+
100104
@SerializedName("tags")
101105
@Param(description = "the tags for the storage pool")
102106
private String tags;
@@ -304,6 +308,14 @@ public void setAllocatedIops(Long allocatedIops) {
304308
this.allocatedIops = allocatedIops;
305309
}
306310

311+
public Map<String, String> getCustomStats() {
312+
return customStats;
313+
}
314+
315+
public void setCustomStats(Map<String, String> customStats) {
316+
this.customStats = customStats;
317+
}
318+
307319
public String getTags() {
308320
return tags;
309321
}
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.api.response;
18+
19+
import org.apache.cloudstack.api.BaseResponse;
20+
import org.apache.cloudstack.api.EntityReference;
21+
22+
import com.cloud.serializer.Param;
23+
import com.cloud.vm.VirtualMachine;
24+
import com.google.gson.annotations.SerializedName;
25+
26+
@EntityReference(value = VirtualMachine.class)
27+
public class VirtualMachineResponse extends BaseResponse {
28+
@SerializedName("id")
29+
@Param(description = "the ID of the VM")
30+
private String id;
31+
32+
@SerializedName("type")
33+
@Param(description = "the type of VM")
34+
private String type;
35+
36+
@SerializedName("name")
37+
@Param(description = "the name of the VM")
38+
private String name;
39+
40+
@SerializedName("clusterid")
41+
@Param(description = "the cluster ID for the VM")
42+
private String clusterId;
43+
44+
@SerializedName("clustername")
45+
@Param(description = "the cluster name for the VM")
46+
private String clusterName;
47+
48+
@SerializedName("hostid")
49+
@Param(description = "the host ID for the VM")
50+
private String hostId;
51+
52+
@SerializedName("hostname")
53+
@Param(description = "the hostname for the VM")
54+
private String hostName;
55+
56+
@Override
57+
public String getObjectId() {
58+
return this.getId();
59+
}
60+
61+
public String getId() {
62+
return id;
63+
}
64+
65+
public void setId(String id) {
66+
this.id = id;
67+
}
68+
69+
public String getVmType() {
70+
return type;
71+
}
72+
73+
public void setVmType(String type) {
74+
this.type = type;
75+
}
76+
77+
public String getVmName() {
78+
return name;
79+
}
80+
81+
public void setVmName(String name) {
82+
this.name = name;
83+
}
84+
85+
public String getClusterId() {
86+
return clusterId;
87+
}
88+
89+
public void setClusterId(String clusterId) {
90+
this.clusterId = clusterId;
91+
}
92+
93+
public String getClusterName() {
94+
return clusterName;
95+
}
96+
97+
public void setClusterName(String clusterName) {
98+
this.clusterName = clusterName;
99+
}
100+
101+
public String getName() {
102+
return name;
103+
}
104+
105+
public void setName(String name) {
106+
this.name = name;
107+
}
108+
109+
public String getHostId() {
110+
return hostId;
111+
}
112+
113+
public void setHostId(String hostId) {
114+
this.hostId = hostId;
115+
}
116+
117+
public String getHostName() {
118+
return hostName;
119+
}
120+
121+
public void setHostName(String hostName) {
122+
this.hostName = hostName;
123+
}
124+
}

0 commit comments

Comments
 (0)