Skip to content

Commit b17808b

Browse files
Introducing Storage Access Groups for better management for host and storage connections (#10381)
* Introducing Storage Access Groups to define the host and storage pool connections In CloudStack, when a primary storage is added at the Zone or Cluster scope, it is by default connected to all hosts within that scope. This default behavior can be refined using storage access groups, which allow operators to control and limit which hosts can access specific storage pools. Storage access groups can be assigned to hosts, clusters, pods, zones, and primary storage pools. When a storage access group is set on a cluster/pod/zone, all hosts within that scope inherit the group. Connectivity between a host and a storage pool is then governed by whether they share the same storage access group. A storage pool with a storage access group will connect only to hosts that have the same storage access group. A storage pool without a storage access group will connect to all hosts, including those with or without a storage access group.
1 parent d5ba23c commit b17808b

File tree

127 files changed

+5703
-357
lines changed

Some content is hidden

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

127 files changed

+5703
-357
lines changed

api/src/main/java/com/cloud/configuration/ConfigurationService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,12 @@ public interface ConfigurationService {
201201
* TODO
202202
* @param allocationState
203203
* TODO
204+
* @param storageAccessGroups
204205
* @return the new pod if successful, null otherwise
205206
* @throws
206207
* @throws
207208
*/
208-
Pod createPod(long zoneId, String name, String startIp, String endIp, String gateway, String netmask, String allocationState);
209+
Pod createPod(long zoneId, String name, String startIp, String endIp, String gateway, String netmask, String allocationState, List<String> storageAccessGroups);
209210

210211
/**
211212
* Creates a mutual exclusive IP range in the pod with same gateway, netmask.

api/src/main/java/com/cloud/dc/Pod.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,6 @@ public interface Pod extends InfrastructureEntity, Grouping, Identity, InternalI
4343
AllocationState getAllocationState();
4444

4545
boolean getExternalDhcp();
46+
47+
String getStorageAccessGroups();
4648
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ public class EventTypes {
465465
public static final String EVENT_ENABLE_PRIMARY_STORAGE = "ENABLE.PS";
466466
public static final String EVENT_DISABLE_PRIMARY_STORAGE = "DISABLE.PS";
467467
public static final String EVENT_SYNC_STORAGE_POOL = "SYNC.STORAGE.POOL";
468+
public static final String EVENT_CONFIGURE_STORAGE_ACCESS = "CONFIGURE.STORAGE.ACCESS";
468469
public static final String EVENT_CHANGE_STORAGE_POOL_SCOPE = "CHANGE.STORAGE.POOL.SCOPE";
469470

470471
// VPN

api/src/main/java/com/cloud/host/Host.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,4 +213,6 @@ public static String[] toStrings(Host.Type... types) {
213213
ResourceState getResourceState();
214214

215215
CPU.CPUArch getArch();
216+
217+
String getStorageAccessGroups();
216218
}

api/src/main/java/com/cloud/org/Cluster.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,6 @@ public static enum ClusterType {
4141
ManagedState getManagedState();
4242

4343
CPU.CPUArch getArch();
44+
45+
String getStorageAccessGroups();
4446
}

api/src/main/java/com/cloud/resource/ResourceService.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,11 @@ public interface ResourceService {
9595

9696
boolean releaseHostReservation(Long hostId);
9797

98+
void updatePodStorageAccessGroups(long podId, List<String> newStorageAccessGroups);
99+
100+
void updateZoneStorageAccessGroups(long zoneId, List<String> newStorageAccessGroups);
101+
102+
void updateClusterStorageAccessGroups(Long clusterId, List<String> newStorageAccessGroups);
103+
104+
void updateHostStorageAccessGroups(Long hostId, List<String> newStorageAccessGroups);
98105
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd;
2424
import org.apache.cloudstack.api.command.admin.storage.ChangeStoragePoolScopeCmd;
25+
import org.apache.cloudstack.api.command.admin.storage.ConfigureStorageAccessCmd;
2526
import org.apache.cloudstack.api.command.admin.storage.CreateSecondaryStagingStoreCmd;
2627
import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
2728
import org.apache.cloudstack.api.command.admin.storage.DeleteImageStoreCmd;
@@ -99,6 +100,8 @@ public interface StorageService {
99100

100101
StoragePool disablePrimaryStoragePool(Long id);
101102

103+
boolean configureStorageAccess(ConfigureStorageAccessCmd cmd);
104+
102105
StoragePool getStoragePool(long id);
103106

104107
boolean deleteImageStore(DeleteImageStoreCmd cmd);

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,11 @@ public class ApiConstants {
496496
public static final String SYSTEM_VM_TYPE = "systemvmtype";
497497
public static final String TAGS = "tags";
498498
public static final String STORAGE_TAGS = "storagetags";
499+
public static final String STORAGE_ACCESS_GROUPS = "storageaccessgroups";
500+
public static final String STORAGE_ACCESS_GROUP = "storageaccessgroup";
501+
public static final String CLUSTER_STORAGE_ACCESS_GROUPS = "clusterstorageaccessgroups";
502+
public static final String POD_STORAGE_ACCESS_GROUPS = "podstorageaccessgroups";
503+
public static final String ZONE_STORAGE_ACCESS_GROUPS = "zonestorageaccessgroups";
499504
public static final String SUCCESS = "success";
500505
public static final String SUITABLE_FOR_VM = "suitableforvirtualmachine";
501506
public static final String SUPPORTS_STORAGE_SNAPSHOT = "supportsstoragesnapshot";

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ public interface ResponseGenerator {
310310

311311
PodResponse createPodResponse(Pod pod, Boolean showCapacities);
312312

313+
PodResponse createMinimalPodResponse(Pod pod);
314+
313315
ZoneResponse createZoneResponse(ResponseView view, DataCenter dataCenter, Boolean showCapacities, Boolean showResourceIcon);
314316

315317
DataCenterGuestIpv6PrefixResponse createDataCenterGuestIpv6PrefixResponse(DataCenterGuestIpv6Prefix prefix);
@@ -324,6 +326,8 @@ public interface ResponseGenerator {
324326

325327
ClusterResponse createClusterResponse(Cluster cluster, Boolean showCapacities);
326328

329+
ClusterResponse createMinimalClusterResponse(Cluster cluster);
330+
327331
FirewallRuleResponse createPortForwardingRuleResponse(PortForwardingRule fwRule);
328332

329333
IpForwardingRuleResponse createIpForwardingRuleResponse(StaticNatRule fwRule);

api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,12 @@ public class AddClusterCmd extends BaseCmd {
118118
private String ovm3cluster;
119119
@Parameter(name = ApiConstants.OVM3_VIP, type = CommandType.STRING, required = false, description = "Ovm3 vip to use for pool (and cluster)")
120120
private String ovm3vip;
121+
@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUPS,
122+
type = CommandType.LIST, collectionType = CommandType.STRING,
123+
description = "comma separated list of storage access groups for the hosts in the cluster",
124+
since = "4.21.0")
125+
private List<String> storageAccessGroups;
126+
121127
public String getOvm3Pool() {
122128
return ovm3pool;
123129
}
@@ -192,6 +198,10 @@ public void setClusterType(String type) {
192198
this.clusterType = type;
193199
}
194200

201+
public List<String> getStorageAccessGroups() {
202+
return storageAccessGroups;
203+
}
204+
195205
@Override
196206
public long getEntityOwnerId() {
197207
return Account.ACCOUNT_ID_SYSTEM;

api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ public class ListClustersCmd extends BaseListCmd {
7474
since = "4.20.1")
7575
private String arch;
7676

77+
@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUP, type = CommandType.STRING,
78+
description = "the name of the storage access group",
79+
since = "4.21.0")
80+
private String storageAccessGroup;
81+
7782
/////////////////////////////////////////////////////
7883
/////////////////// Accessors ///////////////////////
7984
/////////////////////////////////////////////////////
@@ -122,6 +127,18 @@ public CPU.CPUArch getArch() {
122127
return StringUtils.isBlank(arch) ? null : CPU.CPUArch.fromType(arch);
123128
}
124129

130+
public String getStorageAccessGroup() {
131+
return storageAccessGroup;
132+
}
133+
134+
public ListClustersCmd() {
135+
136+
}
137+
138+
public ListClustersCmd(String storageAccessGroup) {
139+
this.storageAccessGroup = storageAccessGroup;
140+
}
141+
125142
/////////////////////////////////////////////////////
126143
/////////////// API Implementation///////////////////
127144
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public void execute() {
130130
}
131131
Cluster result = _resourceService.updateCluster(this);
132132
if (result != null) {
133-
ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(cluster, false);
133+
ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(result, false);
134134
clusterResponse.setResponseName(getCommandName());
135135
this.setResponseObject(clusterResponse);
136136
} else {

api/src/main/java/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ public class AddHostCmd extends BaseCmd {
7575
@Parameter(name = ApiConstants.HOST_TAGS, type = CommandType.LIST, collectionType = CommandType.STRING, description = "list of tags to be added to the host")
7676
private List<String> hostTags;
7777

78+
@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUPS,
79+
type = CommandType.LIST, collectionType = CommandType.STRING,
80+
description = "comma separated list of storage access groups for the host",
81+
since = "4.21.0")
82+
private List<String> storageAccessGroups;
83+
7884
/////////////////////////////////////////////////////
7985
/////////////////// Accessors ///////////////////////
8086
/////////////////////////////////////////////////////
@@ -115,6 +121,10 @@ public List<String> getHostTags() {
115121
return hostTags;
116122
}
117123

124+
public List<String> getStorageAccessGroups() {
125+
return storageAccessGroups;
126+
}
127+
118128
public String getAllocationState() {
119129
return allocationState;
120130
}

api/src/main/java/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,11 @@ public class ListHostsCmd extends BaseListCmd {
113113
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING, description = "CPU Arch of the host", since = "4.20.1")
114114
private String arch;
115115

116+
@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUP, type = CommandType.STRING,
117+
description = "the name of the storage access group",
118+
since = "4.21.0")
119+
private String storageAccessGroup;
120+
116121
/////////////////////////////////////////////////////
117122
/////////////////// Accessors ///////////////////////
118123
/////////////////////////////////////////////////////
@@ -205,6 +210,18 @@ public CPU.CPUArch getArch() {
205210
return StringUtils.isBlank(arch) ? null : CPU.CPUArch.fromType(arch);
206211
}
207212

213+
public String getStorageAccessGroup() {
214+
return storageAccessGroup;
215+
}
216+
217+
public ListHostsCmd() {
218+
219+
}
220+
221+
public ListHostsCmd(String storageAccessGroup) {
222+
this.storageAccessGroup = storageAccessGroup;
223+
}
224+
208225
/////////////////////////////////////////////////////
209226
/////////////// API Implementation///////////////////
210227
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/admin/pod/CreatePodCmd.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
import com.cloud.dc.Pod;
3131
import com.cloud.user.Account;
3232

33+
import java.util.List;
34+
3335
@APICommand(name = "createPod", description = "Creates a new Pod.", responseObject = PodResponse.class,
3436
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
3537
public class CreatePodCmd extends BaseCmd {
@@ -63,6 +65,12 @@ public class CreatePodCmd extends BaseCmd {
6365
@Parameter(name = ApiConstants.ALLOCATION_STATE, type = CommandType.STRING, description = "Allocation state of this Pod for allocation of new resources")
6466
private String allocationState;
6567

68+
@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUPS,
69+
type = CommandType.LIST, collectionType = CommandType.STRING,
70+
description = "comma separated list of storage access groups for the hosts in the pod",
71+
since = "4.21.0")
72+
private List<String> storageAccessGroups;
73+
6674
/////////////////////////////////////////////////////
6775
/////////////////// Accessors ///////////////////////
6876
/////////////////////////////////////////////////////
@@ -95,6 +103,10 @@ public String getAllocationState() {
95103
return allocationState;
96104
}
97105

106+
public List<String> getStorageAccessGroups() {
107+
return storageAccessGroups;
108+
}
109+
98110
/////////////////////////////////////////////////////
99111
/////////////// API Implementation///////////////////
100112
/////////////////////////////////////////////////////
@@ -111,7 +123,7 @@ public ApiCommandResourceType getApiResourceType() {
111123

112124
@Override
113125
public void execute() {
114-
Pod result = _configService.createPod(getZoneId(), getPodName(), getStartIp(), getEndIp(), getGateway(), getNetmask(), getAllocationState());
126+
Pod result = _configService.createPod(getZoneId(), getPodName(), getStartIp(), getEndIp(), getGateway(), getNetmask(), getAllocationState(), getStorageAccessGroups());
115127
if (result != null) {
116128
PodResponse response = _responseGenerator.createPodResponse(result, false);
117129
response.setResponseName(getCommandName());

api/src/main/java/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ public class ListPodsByCmd extends BaseListCmd {
5555
@Parameter(name = ApiConstants.SHOW_CAPACITIES, type = CommandType.BOOLEAN, description = "flag to display the capacity of the pods")
5656
private Boolean showCapacities;
5757

58+
@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUP, type = CommandType.STRING,
59+
description = "the name of the storage access group",
60+
since = "4.21.0")
61+
private String storageAccessGroup;
62+
5863
/////////////////////////////////////////////////////
5964
/////////////////// Accessors ///////////////////////
6065
/////////////////////////////////////////////////////
@@ -79,6 +84,18 @@ public Boolean getShowCapacities() {
7984
return showCapacities;
8085
}
8186

87+
public String getStorageAccessGroup() {
88+
return storageAccessGroup;
89+
}
90+
91+
public ListPodsByCmd() {
92+
93+
}
94+
95+
public ListPodsByCmd(String storageAccessGroup) {
96+
this.storageAccessGroup = storageAccessGroup;
97+
}
98+
8299
/////////////////////////////////////////////////////
83100
/////////////// API Implementation///////////////////
84101
/////////////////////////////////////////////////////

0 commit comments

Comments
 (0)