Skip to content

Introducing Storage Access Groups for better management for host and storage connections #10381

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

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -201,11 +201,12 @@ public interface ConfigurationService {
* TODO
* @param allocationState
* TODO
* @param storageAccessGroups
* @return the new pod if successful, null otherwise
* @throws
* @throws
*/
Pod createPod(long zoneId, String name, String startIp, String endIp, String gateway, String netmask, String allocationState);
Pod createPod(long zoneId, String name, String startIp, String endIp, String gateway, String netmask, String allocationState, List<String> storageAccessGroups);

/**
* Creates a mutual exclusive IP range in the pod with same gateway, netmask.
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/java/com/cloud/dc/Pod.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,6 @@ public interface Pod extends InfrastructureEntity, Grouping, Identity, InternalI
AllocationState getAllocationState();

boolean getExternalDhcp();

String getStorageAccessGroups();
}
1 change: 1 addition & 0 deletions api/src/main/java/com/cloud/event/EventTypes.java
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ public class EventTypes {
public static final String EVENT_ENABLE_PRIMARY_STORAGE = "ENABLE.PS";
public static final String EVENT_DISABLE_PRIMARY_STORAGE = "DISABLE.PS";
public static final String EVENT_SYNC_STORAGE_POOL = "SYNC.STORAGE.POOL";
public static final String EVENT_CONFIGURE_STORAGE_ACCESS = "CONFIGURE.STORAGE.ACCESS";
public static final String EVENT_CHANGE_STORAGE_POOL_SCOPE = "CHANGE.STORAGE.POOL.SCOPE";

// VPN
Expand Down
2 changes: 2 additions & 0 deletions api/src/main/java/com/cloud/host/Host.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,6 @@ public static String[] toStrings(Host.Type... types) {
ResourceState getResourceState();

CPU.CPUArch getArch();

String getStorageAccessGroups();
}
2 changes: 2 additions & 0 deletions api/src/main/java/com/cloud/org/Cluster.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,6 @@ public static enum ClusterType {
ManagedState getManagedState();

CPU.CPUArch getArch();

String getStorageAccessGroups();
}
7 changes: 7 additions & 0 deletions api/src/main/java/com/cloud/resource/ResourceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,11 @@ public interface ResourceService {

boolean releaseHostReservation(Long hostId);

void updatePodStorageAccessGroups(long podId, List<String> newStorageAccessGroups);

void updateZoneStorageAccessGroups(long zoneId, List<String> newStorageAccessGroups);

void updateClusterStorageAccessGroups(Long clusterId, List<String> newStorageAccessGroups);

void updateHostStorageAccessGroups(Long hostId, List<String> newStorageAccessGroups);
}
3 changes: 3 additions & 0 deletions api/src/main/java/com/cloud/storage/StorageService.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import org.apache.cloudstack.api.command.admin.storage.CancelPrimaryStorageMaintenanceCmd;
import org.apache.cloudstack.api.command.admin.storage.ChangeStoragePoolScopeCmd;
import org.apache.cloudstack.api.command.admin.storage.ConfigureStorageAccessCmd;
import org.apache.cloudstack.api.command.admin.storage.CreateSecondaryStagingStoreCmd;
import org.apache.cloudstack.api.command.admin.storage.CreateStoragePoolCmd;
import org.apache.cloudstack.api.command.admin.storage.DeleteImageStoreCmd;
Expand Down Expand Up @@ -99,6 +100,8 @@ public interface StorageService {

StoragePool disablePrimaryStoragePool(Long id);

boolean configureStorageAccess(ConfigureStorageAccessCmd cmd);

StoragePool getStoragePool(long id);

boolean deleteImageStore(DeleteImageStoreCmd cmd);
Expand Down
5 changes: 5 additions & 0 deletions api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,11 @@ public class ApiConstants {
public static final String SYSTEM_VM_TYPE = "systemvmtype";
public static final String TAGS = "tags";
public static final String STORAGE_TAGS = "storagetags";
public static final String STORAGE_ACCESS_GROUPS = "storageaccessgroups";
public static final String STORAGE_ACCESS_GROUP = "storageaccessgroup";
public static final String CLUSTER_STORAGE_ACCESS_GROUPS = "clusterstorageaccessgroups";
public static final String POD_STORAGE_ACCESS_GROUPS = "podstorageaccessgroups";
public static final String ZONE_STORAGE_ACCESS_GROUPS = "zonestorageaccessgroups";
public static final String SUCCESS = "success";
public static final String SUITABLE_FOR_VM = "suitableforvirtualmachine";
public static final String SUPPORTS_STORAGE_SNAPSHOT = "supportsstoragesnapshot";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,8 @@ public interface ResponseGenerator {

PodResponse createPodResponse(Pod pod, Boolean showCapacities);

PodResponse createMinimalPodResponse(Pod pod);

ZoneResponse createZoneResponse(ResponseView view, DataCenter dataCenter, Boolean showCapacities, Boolean showResourceIcon);

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

ClusterResponse createClusterResponse(Cluster cluster, Boolean showCapacities);

ClusterResponse createMinimalClusterResponse(Cluster cluster);

FirewallRuleResponse createPortForwardingRuleResponse(PortForwardingRule fwRule);

IpForwardingRuleResponse createIpForwardingRuleResponse(StaticNatRule fwRule);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,12 @@
private String ovm3cluster;
@Parameter(name = ApiConstants.OVM3_VIP, type = CommandType.STRING, required = false, description = "Ovm3 vip to use for pool (and cluster)")
private String ovm3vip;
@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUPS,
type = CommandType.LIST, collectionType = CommandType.STRING,
description = "comma separated list of storage access groups for the hosts in the cluster",
since = "4.21.0")
private List<String> storageAccessGroups;

public String getOvm3Pool() {
return ovm3pool;
}
Expand Down Expand Up @@ -192,6 +198,10 @@
this.clusterType = type;
}

public List<String> getStorageAccessGroups() {
return storageAccessGroups;
}

Check warning on line 203 in api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/AddClusterCmd.java#L201-L203

Added lines #L201 - L203 were not covered by tests

@Override
public long getEntityOwnerId() {
return Account.ACCOUNT_ID_SYSTEM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@
since = "4.20.1")
private String arch;

@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUP, type = CommandType.STRING,
description = "the name of the storage access group",
since = "4.21.0")
private String storageAccessGroup;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -122,6 +127,18 @@
return StringUtils.isBlank(arch) ? null : CPU.CPUArch.fromType(arch);
}

public String getStorageAccessGroup() {
return storageAccessGroup;
}

Check warning on line 132 in api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java#L130-L132

Added lines #L130 - L132 were not covered by tests

public ListClustersCmd() {

Check warning on line 134 in api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L134 was not covered by tests

}

Check warning on line 136 in api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L136 was not covered by tests

public ListClustersCmd(String storageAccessGroup) {
this.storageAccessGroup = storageAccessGroup;
}

Check warning on line 140 in api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java#L138-L140

Added lines #L138 - L140 were not covered by tests

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
}
Cluster result = _resourceService.updateCluster(this);
if (result != null) {
ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(cluster, false);
ClusterResponse clusterResponse = _responseGenerator.createClusterResponse(result, false);

Check warning on line 133 in api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/UpdateClusterCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L133 was not covered by tests
clusterResponse.setResponseName(getCommandName());
this.setResponseObject(clusterResponse);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,12 @@
@Parameter(name = ApiConstants.HOST_TAGS, type = CommandType.LIST, collectionType = CommandType.STRING, description = "list of tags to be added to the host")
private List<String> hostTags;

@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUPS,
type = CommandType.LIST, collectionType = CommandType.STRING,
description = "comma separated list of storage access groups for the host",
since = "4.21.0")
private List<String> storageAccessGroups;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -115,6 +121,10 @@
return hostTags;
}

public List<String> getStorageAccessGroups() {
return storageAccessGroups;
}

Check warning on line 126 in api/src/main/java/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/host/AddHostCmd.java#L124-L126

Added lines #L124 - L126 were not covered by tests

public String getAllocationState() {
return allocationState;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@
@Parameter(name = ApiConstants.ARCH, type = CommandType.STRING, description = "CPU Arch of the host", since = "4.20.1")
private String arch;

@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUP, type = CommandType.STRING,
description = "the name of the storage access group",
since = "4.21.0")
private String storageAccessGroup;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -205,6 +210,18 @@
return StringUtils.isBlank(arch) ? null : CPU.CPUArch.fromType(arch);
}

public String getStorageAccessGroup() {
return storageAccessGroup;
}

Check warning on line 215 in api/src/main/java/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java#L213-L215

Added lines #L213 - L215 were not covered by tests

public ListHostsCmd() {

Check warning on line 217 in api/src/main/java/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L217 was not covered by tests

}

Check warning on line 219 in api/src/main/java/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L219 was not covered by tests

public ListHostsCmd(String storageAccessGroup) {
this.storageAccessGroup = storageAccessGroup;
}

Check warning on line 223 in api/src/main/java/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java#L221-L223

Added lines #L221 - L223 were not covered by tests

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import com.cloud.dc.Pod;
import com.cloud.user.Account;

import java.util.List;

@APICommand(name = "createPod", description = "Creates a new Pod.", responseObject = PodResponse.class,
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
public class CreatePodCmd extends BaseCmd {
Expand Down Expand Up @@ -63,6 +65,12 @@
@Parameter(name = ApiConstants.ALLOCATION_STATE, type = CommandType.STRING, description = "Allocation state of this Pod for allocation of new resources")
private String allocationState;

@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUPS,
type = CommandType.LIST, collectionType = CommandType.STRING,
description = "comma separated list of storage access groups for the hosts in the pod",
since = "4.21.0")
private List<String> storageAccessGroups;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand Down Expand Up @@ -95,6 +103,10 @@
return allocationState;
}

public List<String> getStorageAccessGroups() {
return storageAccessGroups;
}

Check warning on line 108 in api/src/main/java/org/apache/cloudstack/api/command/admin/pod/CreatePodCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/pod/CreatePodCmd.java#L106-L108

Added lines #L106 - L108 were not covered by tests

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand All @@ -111,7 +123,7 @@

@Override
public void execute() {
Pod result = _configService.createPod(getZoneId(), getPodName(), getStartIp(), getEndIp(), getGateway(), getNetmask(), getAllocationState());
Pod result = _configService.createPod(getZoneId(), getPodName(), getStartIp(), getEndIp(), getGateway(), getNetmask(), getAllocationState(), getStorageAccessGroups());

Check warning on line 126 in api/src/main/java/org/apache/cloudstack/api/command/admin/pod/CreatePodCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L126 was not covered by tests
if (result != null) {
PodResponse response = _responseGenerator.createPodResponse(result, false);
response.setResponseName(getCommandName());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@
@Parameter(name = ApiConstants.SHOW_CAPACITIES, type = CommandType.BOOLEAN, description = "flag to display the capacity of the pods")
private Boolean showCapacities;

@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUP, type = CommandType.STRING,
description = "the name of the storage access group",
since = "4.21.0")
private String storageAccessGroup;

/////////////////////////////////////////////////////
/////////////////// Accessors ///////////////////////
/////////////////////////////////////////////////////
Expand All @@ -79,6 +84,18 @@
return showCapacities;
}

public String getStorageAccessGroup() {
return storageAccessGroup;
}

Check warning on line 89 in api/src/main/java/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java#L87-L89

Added lines #L87 - L89 were not covered by tests

public ListPodsByCmd() {

Check warning on line 91 in api/src/main/java/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L91 was not covered by tests

}

Check warning on line 93 in api/src/main/java/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L93 was not covered by tests

public ListPodsByCmd(String storageAccessGroup) {
this.storageAccessGroup = storageAccessGroup;
}

Check warning on line 97 in api/src/main/java/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java

View check run for this annotation

Codecov / codecov/patch

api/src/main/java/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java#L95-L97

Added lines #L95 - L97 were not covered by tests

/////////////////////////////////////////////////////
/////////////// API Implementation///////////////////
/////////////////////////////////////////////////////
Expand Down
Loading
Loading