-
Notifications
You must be signed in to change notification settings - Fork 0
NFS Cloudstack volume and file and export policy utils #18
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
Changes from 1 commit
5f71168
c88483a
e3c44ae
09caf90
aa14ab5
f89bb1b
fe19c55
e27fad2
e8062fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,10 +40,13 @@ | |
| import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope; | ||
| import org.apache.cloudstack.storage.datastore.lifecycle.BasePrimaryDataStoreLifeCycleImpl; | ||
| import org.apache.cloudstack.storage.feign.model.OntapStorage; | ||
| import org.apache.cloudstack.storage.feign.model.Volume; | ||
| import org.apache.cloudstack.storage.provider.StorageProviderFactory; | ||
| import org.apache.cloudstack.storage.service.StorageStrategy; | ||
| import org.apache.cloudstack.storage.service.model.AccessGroup; | ||
| import org.apache.cloudstack.storage.service.model.ProtocolType; | ||
| import org.apache.cloudstack.storage.utils.Constants; | ||
| import org.apache.cloudstack.storage.utils.Utility; | ||
| import org.apache.cloudstack.storage.volume.datastore.PrimaryDataStoreHelper; | ||
| import org.apache.logging.log4j.LogManager; | ||
| import org.apache.logging.log4j.Logger; | ||
|
|
@@ -184,7 +187,7 @@ public DataStore initialize(Map<String, Object> dsInfos) { | |
| String path; | ||
| ProtocolType protocol = ProtocolType.valueOf(details.get(Constants.PROTOCOL)); | ||
| switch (protocol) { | ||
| case NFS3: | ||
| case NFS: | ||
| parameters.setType(Storage.StoragePoolType.NetworkFilesystem); | ||
| path = details.get(Constants.MANAGEMENT_LIF) + ":/" + storagePoolName; | ||
| s_logger.info("Setting NFS path for storage pool: " + path); | ||
|
|
@@ -213,7 +216,9 @@ public DataStore initialize(Map<String, Object> dsInfos) { | |
| long volumeSize = Long.parseLong(details.get(Constants.SIZE)); | ||
| s_logger.info("Creating ONTAP volume '" + storagePoolName + "' with size: " + volumeSize + " bytes (" + | ||
| (volumeSize / (1024 * 1024 * 1024)) + " GB)"); | ||
| storageStrategy.createStorageVolume(storagePoolName, volumeSize); | ||
| Volume volume = storageStrategy.createStorageVolume(storagePoolName, volumeSize); | ||
| details.put(Constants.VOLUME_UUID, volume.getUuid()); | ||
| details.put(Constants.VOLUME_NAME, volume.getName()); | ||
| } else { | ||
| throw new CloudRuntimeException("ONTAP details validation failed, cannot create primary storage"); | ||
| } | ||
|
|
@@ -241,10 +246,20 @@ public DataStore initialize(Map<String, Object> dsInfos) { | |
| @Override | ||
| public boolean attachCluster(DataStore dataStore, ClusterScope scope) { | ||
| logger.debug("In attachCluster for ONTAP primary storage"); | ||
| PrimaryDataStoreInfo primarystore = (PrimaryDataStoreInfo)dataStore; | ||
| List<HostVO> hostsToConnect = _resourceMgr.getEligibleUpAndEnabledHostsInClusterForStorageConnection(primarystore); | ||
| PrimaryDataStoreInfo primaryStore = (PrimaryDataStoreInfo)dataStore; | ||
| List<HostVO> hostsToConnect = _resourceMgr.getEligibleUpAndEnabledHostsInClusterForStorageConnection(primaryStore); | ||
|
|
||
| logger.debug(String.format("Attaching the pool to each of the hosts %s in the cluster: %s", hostsToConnect, primarystore.getClusterId())); | ||
| logger.debug(String.format("Attaching the pool to each of the hosts %s in the cluster: %s", hostsToConnect, primaryStore.getClusterId())); | ||
|
|
||
| Map<String, String> details = primaryStore.getDetails(); // TODO check while testing , if it is populated we can remove below db call | ||
| StorageStrategy strategy = Utility.getStrategyByStoragePoolDetails(details); | ||
| AccessGroup accessGroupRequest = new AccessGroup(); | ||
| accessGroupRequest.setHostsToConnect(hostsToConnect); | ||
| accessGroupRequest.setScope(scope); | ||
| accessGroupRequest.setPrimaryDataStoreInfo(primaryStore); | ||
| strategy.createAccessGroup(accessGroupRequest); | ||
|
|
||
| logger.debug("attachCluster: Attaching the pool to each of the host in the cluster: {}", primaryStore.getClusterId()); | ||
|
||
| for (HostVO host : hostsToConnect) { | ||
| // TODO: Fetch the host IQN and add to the initiator group on ONTAP cluster | ||
| try { | ||
|
|
@@ -265,9 +280,18 @@ public boolean attachHost(DataStore store, HostScope scope, StoragePoolInfo exis | |
| @Override | ||
| public boolean attachZone(DataStore dataStore, ZoneScope scope, Hypervisor.HypervisorType hypervisorType) { | ||
| logger.debug("In attachZone for ONTAP primary storage"); | ||
| List<HostVO> hostsToConnect = _resourceMgr.getEligibleUpAndEnabledHostsInZoneForStorageConnection(dataStore, scope.getScopeId(), Hypervisor.HypervisorType.KVM); | ||
|
|
||
| PrimaryDataStoreInfo primaryStore = (PrimaryDataStoreInfo)dataStore; | ||
| List<HostVO> hostsToConnect = _resourceMgr.getEligibleUpAndEnabledHostsInZoneForStorageConnection(dataStore, scope.getScopeId(), Hypervisor.HypervisorType.KVM); | ||
| logger.debug(String.format("In createPool. Attaching the pool to each of the hosts in %s.", hostsToConnect)); | ||
|
|
||
| Map<String, String> details = primaryStore.getDetails(); // TODO check while testing , if it is populated we can remove below db call | ||
| StorageStrategy strategy = Utility.getStrategyByStoragePoolDetails(details); | ||
| AccessGroup accessGroupRequest = new AccessGroup(); | ||
| accessGroupRequest.setHostsToConnect(hostsToConnect); | ||
| accessGroupRequest.setScope(scope); | ||
| accessGroupRequest.setPrimaryDataStoreInfo(primaryStore); | ||
| strategy.createAccessGroup(accessGroupRequest); | ||
| for (HostVO host : hostsToConnect) { | ||
| // TODO: Fetch the host IQN and add to the initiator group on ONTAP cluster | ||
| try { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package org.apache.cloudstack.storage.provider; | ||
|
|
||
| import com.cloud.exception.StorageConflictException; | ||
| import org.apache.cloudstack.engine.subsystem.api.storage.HypervisorHostListener; | ||
|
|
||
| class OntapHostListener implements HypervisorHostListener { | ||
|
|
||
| @Override | ||
| public boolean hostAdded(long hostId) { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean hostConnect(long hostId, long poolId) throws StorageConflictException { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean hostDisconnected(long hostId, long poolId) { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean hostAboutToBeRemoved(long hostId) { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean hostRemoved(long hostId, long clusterId) { | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean hostEnabled(long hostId) { | ||
| return false; | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -156,8 +156,11 @@ public Volume createStorageVolume(String volumeName, Long size) { | |||||
| volumeRequest.setSize(size); | ||||||
| // Make the POST API call to create the volume | ||||||
| try { | ||||||
| // Create URI for POST CreateVolume API | ||||||
| // Call the VolumeFeignClient to create the volume | ||||||
| /* | ||||||
| ONTAP created a default rule of 0.0.0.0 if no export rule are defined while creating volume | ||||||
| and since in storage pool creation, cloudstack is not aware of the host , we can either create default or | ||||||
| permissive rule and later update it as part of attachCluster or attachZone implementation | ||||||
| */ | ||||||
| JobResponse jobResponse = volumeFeignClient.createVolumeWithJob(authHeader, volumeRequest); | ||||||
| if (jobResponse == null || jobResponse.getJob() == null) { | ||||||
| throw new CloudRuntimeException("Failed to initiate volume creation for " + volumeName); | ||||||
|
|
@@ -192,8 +195,20 @@ public Volume createStorageVolume(String volumeName, Long size) { | |||||
| throw new CloudRuntimeException("Failed to create volume: " + e.getMessage()); | ||||||
| } | ||||||
| s_logger.info("Volume created successfully: " + volumeName); | ||||||
| //TODO | ||||||
| return null; | ||||||
| // Below code is to update volume uuid to storage pool mapping once and used for all other workflow saving get volume call | ||||||
| OntapResponse<Volume> ontapVolume = new OntapResponse<>(); | ||||||
| try { | ||||||
| Map<String, Object> queryParams = Map.of(Constants.NAME, volumeName); | ||||||
| ontapVolume = volumeFeignClient.getVolume(authHeader, queryParams); | ||||||
| if ((ontapVolume == null || ontapVolume.getRecords().isEmpty())) { | ||||||
| s_logger.error("Exception while getting volume volume not found:"); | ||||||
| throw new CloudRuntimeException("Failed to fetch volume " + volumeName); | ||||||
| } | ||||||
| }catch (Exception e) { | ||||||
| s_logger.error("Exception while getting volume: " + e.getMessage()); | ||||||
| throw new CloudRuntimeException("Failed to fetch volume: " + e.getMessage()); | ||||||
| } | ||||||
| return ontapVolume.getRecords().get(0); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
|
|
@@ -287,7 +302,7 @@ public Volume getStorageVolume(Volume volume) | |||||
| * @param accessGroup the access group to create | ||||||
| * @return the created AccessGroup object | ||||||
| */ | ||||||
| abstract AccessGroup createAccessGroup(AccessGroup accessGroup); | ||||||
| abstract public AccessGroup createAccessGroup(AccessGroup accessGroup); | ||||||
|
||||||
| abstract public AccessGroup createAccessGroup(AccessGroup accessGroup); | |
| public abstract AccessGroup createAccessGroup(AccessGroup accessGroup); |
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.
Removed 'acceptHeader' parameter from method signature. This is a breaking change that could affect existing callers of this method.