diff --git a/engine/schema/src/main/java/com/cloud/storage/dao/VolumeDao.java b/engine/schema/src/main/java/com/cloud/storage/dao/VolumeDao.java
index 4cd9a8e23bfc..16b8eb975ac4 100644
--- a/engine/schema/src/main/java/com/cloud/storage/dao/VolumeDao.java
+++ b/engine/schema/src/main/java/com/cloud/storage/dao/VolumeDao.java
@@ -182,6 +182,13 @@ public interface VolumeDao extends GenericDao, StateDao implements Vol
protected static final String SELECT_HYPERTYPE_FROM_CLUSTER_VOLUME = "SELECT c.hypervisor_type from volumes v, storage_pool s, cluster c where v.pool_id = s.id and s.cluster_id = c.id and v.id = ?";
protected static final String SELECT_HYPERTYPE_FROM_ZONE_VOLUME = "SELECT s.hypervisor from volumes v, storage_pool s where v.pool_id = s.id and v.id = ?";
protected static final String SELECT_POOLSCOPE = "SELECT s.scope from storage_pool s, volumes v where s.id = v.pool_id and v.id = ?";
+ // Looks for a VM whose Ready root disk is on this pool and whose attached Ready data disk is on another pool.
+ // LIMIT 1 stops after the first match so we do not load all volumes.
+ private static final String HAS_MULTI_PRIMARY_STORAGE_POOL_VM =
+ "SELECT 1 FROM volumes root INNER JOIN volumes data ON data.instance_id = root.instance_id "
+ + "WHERE root.pool_id = ? AND root.volume_type = 'ROOT' AND root.instance_id IS NOT NULL "
+ + "AND root.removed IS NULL AND root.state = 'Ready' "
+ + "AND data.volume_type = 'DATADISK' AND data.pool_id IS NOT NULL AND data.pool_id <> ? "
+ + "AND data.removed IS NULL AND data.state = 'Ready' LIMIT 1";
private static final String ORDER_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT_PART1 = "SELECT pool.id, SUM(IF(vol.state='Ready' AND vol.account_id = ?, 1, 0)) FROM `cloud`.`storage_pool` pool LEFT JOIN `cloud`.`volumes` vol ON pool.id = vol.pool_id WHERE pool.data_center_id = ? ";
private static final String ORDER_POOLS_NUMBER_OF_VOLUMES_FOR_ACCOUNT_PART2 = " GROUP BY pool.id ORDER BY 2 ASC ";
@@ -998,6 +1006,21 @@ public boolean existsWithKmsKey(long kmsKeyId) {
return findOneBy(sc) != null;
}
+ @Override
+ @DB
+ public boolean hasMultiPrimaryStoragePoolVm(long poolId) {
+ TransactionLegacy txn = TransactionLegacy.currentTxn();
+ try (PreparedStatement pstmt = txn.prepareAutoCloseStatement(HAS_MULTI_PRIMARY_STORAGE_POOL_VM)) {
+ pstmt.setLong(1, poolId);
+ pstmt.setLong(2, poolId);
+ try (ResultSet rs = pstmt.executeQuery()) {
+ return rs.next();
+ }
+ } catch (SQLException e) {
+ throw new CloudRuntimeException("DB Exception on: " + HAS_MULTI_PRIMARY_STORAGE_POOL_VM, e);
+ }
+ }
+
public VolumeVO findByExternalUuid(String externalUuid) {
SearchCriteria sc = ExternalUuidSearch.create();
sc.setParameters("externalUuid", externalUuid);
diff --git a/plugins/storage/volume/ontap/pom.xml b/plugins/storage/volume/ontap/pom.xml
index 0ab54c67d343..c18bf559f92a 100644
--- a/plugins/storage/volume/ontap/pom.xml
+++ b/plugins/storage/volume/ontap/pom.xml
@@ -86,6 +86,11 @@
cloud-engine-storage-volume${project.version}
+
+ org.apache.cloudstack
+ cloud-framework-cluster
+ ${project.version}
+ io.swaggerswagger-annotations
diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/asup/OntapAsupManager.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/asup/OntapAsupManager.java
new file mode 100644
index 000000000000..5ab2aa18833e
--- /dev/null
+++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/asup/OntapAsupManager.java
@@ -0,0 +1,673 @@
+/*
+ * 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.storage.asup;
+
+import com.cloud.cluster.ManagementServerHostVO;
+import com.cloud.cluster.dao.ManagementServerHostDao;
+import com.cloud.event.EventTypes;
+import com.cloud.server.ManagementService;
+import com.cloud.storage.Volume;
+import com.cloud.storage.SnapshotVO;
+import com.cloud.storage.VolumeVO;
+import com.cloud.storage.dao.SnapshotDao;
+import com.cloud.storage.dao.VolumeDao;
+import com.cloud.vm.snapshot.VMSnapshot;
+import com.cloud.vm.snapshot.VMSnapshotVO;
+import com.cloud.vm.snapshot.dao.VMSnapshotDao;
+import com.cloud.utils.Ternary;
+import com.cloud.utils.component.ManagerBase;
+import com.cloud.utils.concurrency.NamedThreadFactory;
+import com.cloud.utils.db.GlobalLock;
+import com.cloud.utils.net.NetUtils;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.cloudstack.framework.config.ConfigKey;
+import org.apache.cloudstack.framework.messagebus.MessageBus;
+import org.apache.cloudstack.managed.context.ManagedContextRunnable;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+import org.apache.cloudstack.storage.feign.model.Cluster;
+import org.apache.cloudstack.storage.feign.model.EmsApplicationLog;
+import org.apache.cloudstack.storage.service.StorageStrategy;
+import org.apache.cloudstack.storage.utils.OntapConfigurationManager;
+import org.apache.cloudstack.storage.utils.OntapStorageConstants;
+import org.apache.cloudstack.storage.utils.OntapStorageUtils;
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.inject.Inject;
+import javax.naming.ConfigurationException;
+import java.time.Duration;
+import java.time.Instant;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ScheduledExecutorService;
+import java.util.concurrent.ScheduledFuture;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Periodic ASUP (AutoSupport) telemetry pusher for the NetApp ONTAP plugin.
+ *
+ *
Each run pushes, for every ONTAP-backed primary storage pool, two minimal EMS
+ * application-log messages to the backing ONTAP cluster:
+ *
+ *
+ *
event-id 0 (heartbeat): identifies the CloudStack deployment (CloudStack
+ * version, management host) connected to the ONTAP cluster (ONTAP cluster version).
+ *
event-id 1 (pool): maps the CloudStack storage pool to its backing ONTAP
+ * volume - protocol (NFS/iSCSI), ONTAP FlexVolume UUID, SVM, disk usage, and
+ * snapshot telemetry (counts by state, total provisioned size).
+ *
+ *
+ *
Runs are booked one at a time: after each cycle starts, the next run is scheduled for
+ * {@link OntapConfigurationManager#AsupIntervalHours} after that start, so production
+ * intervals (hours) are start-to-start. REST work sits inside the interval; it is not added
+ * after it. Editing the ONTAP ASUP interval re-books the pending run immediately, with no
+ * management-server restart.
+ */
+public class OntapAsupManager extends ManagerBase {
+ private static final int ASUP_LOCK_TIMEOUT_SECONDS = 5;
+
+ /**
+ * Volume states that guarantee a physical object exists on the ONTAP FlexVolume.
+ * States like {@link Volume.State#Allocated} have a CloudStack DB row pointing to this
+ * pool but ONTAP provisioning has not been called yet — they must be excluded to avoid
+ * inflating disk counts and provisioned-size totals. Upload-family states live on
+ * secondary storage, not on the primary ONTAP volume, so they are also excluded.
+ */
+ private static final Set CS_VOLUME_STATES = EnumSet.of(
+ Volume.State.Ready,
+ Volume.State.Snapshotting,
+ Volume.State.RevertSnapshotting,
+ Volume.State.Attaching,
+ Volume.State.Restoring,
+ Volume.State.Expunging,
+ Volume.State.Destroying
+ );
+
+ /** Serializes the structured event-description payloads to JSON. */
+ private final ObjectMapper objectMapper = new ObjectMapper();
+
+ /**
+ * Timestamp of the last ASUP cycle start (or {@link Instant#EPOCH} if none has run).
+ * The next run is due {@link OntapConfigurationManager#AsupIntervalHours} after this
+ * instant. {@code volatile} so the scheduler thread's write is visible without extra locking.
+ */
+ volatile Instant lastPushTime = Instant.EPOCH;
+
+ /** Single daemon thread that runs the ASUP pushes; owned by this manager. */
+ private ScheduledExecutorService asupScheduler;
+
+ /** The one pending run. Cancelled and re-booked whenever the schedule changes. */
+ private ScheduledFuture> pendingRun;
+
+ @Inject
+ private PrimaryDataStoreDao storagePoolDao;
+ @Inject
+ private StoragePoolDetailsDao storagePoolDetailsDao;
+ @Inject
+ private VolumeDao volumeDao;
+ @Inject
+ private SnapshotDao snapshotDao;
+ @Inject
+ private VMSnapshotDao vmSnapshotDao;
+ @Inject
+ private ManagementService managementService;
+ @Inject
+ private ManagementServerHostDao managementServerHostDao;
+ @Inject
+ private MessageBus messageBus;
+
+ @Override
+ public boolean configure(String name, Map params) throws ConfigurationException {
+ super.configure(name, params);
+ // React to edits of ontap.autosupport.interval so a new value re-books the pending run
+ // instead of waiting for it to fire on the old schedule.
+ messageBus.subscribe(EventTypes.EVENT_CONFIGURATION_VALUE_EDIT, this::onAsupConfigEdited);
+ return true;
+ }
+
+ @Override
+ public boolean start() {
+ asupScheduler = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("OntapAsup"));
+ logger.info("OntapAsupManager started; ASUP telemetry interval={}h",
+ getAsupIntervalHours(OntapConfigurationManager.AsupIntervalHours.value()));
+ scheduleNextRun();
+ return super.start();
+ }
+
+ @Override
+ public boolean stop() {
+ if (asupScheduler != null) {
+ asupScheduler.shutdownNow();
+ }
+ return super.stop();
+ }
+
+ /**
+ * Books the single pending run for the moment the configured interval elapses, cancelling
+ * whatever was booked before. Called at start-up, after every run, and whenever
+ * {@code ontap.autosupport.interval} is edited, so the live config always decides the next run.
+ *
+ *
When the interval is {@link OntapStorageConstants#ASUP_DISABLED_INTERVAL_HOURS}
+ * nothing is booked; setting a non-zero interval publishes a configuration-edit event,
+ * which books a run again.
+ */
+ private synchronized void scheduleNextRun() {
+ if (asupScheduler == null || asupScheduler.isShutdown()) {
+ return;
+ }
+ if (pendingRun != null) {
+ pendingRun.cancel(false);
+ pendingRun = null;
+ }
+ int intervalHours = getAsupIntervalHours(OntapConfigurationManager.AsupIntervalHours.value());
+ if (intervalHours == OntapStorageConstants.ASUP_DISABLED_INTERVAL_HOURS) {
+ logger.debug("ONTAP ASUP: telemetry is disabled ({}={}); no run scheduled.",
+ OntapStorageConstants.ASUP_INTERVAL_CONFIG_KEY,
+ OntapStorageConstants.ASUP_DISABLED_INTERVAL_HOURS);
+ return;
+ }
+ long delayMs = millisUntilNextPush();
+ pendingRun = asupScheduler.schedule(new OntapAsupTask(), delayMs, TimeUnit.MILLISECONDS);
+ logger.debug("ONTAP ASUP: next telemetry push scheduled in {} ms.", delayMs);
+ }
+
+ /**
+ * Milliseconds remaining until {@link #lastPushTime} plus the live configured interval.
+ * Zero when a push is already overdue — for example after the interval is shortened, the
+ * previous cycle ran longer than the interval, or on the very first run when
+ * {@link #lastPushTime} is still {@link Instant#EPOCH}.
+ */
+ long millisUntilNextPush() {
+ Duration configuredInterval = Duration.ofHours(
+ getAsupIntervalHours(OntapConfigurationManager.AsupIntervalHours.value()));
+ Duration remaining = configuredInterval.minus(Duration.between(lastPushTime, Instant.now()));
+ return remaining.isNegative() ? 0L : remaining.toMillis();
+ }
+
+ /**
+ * CloudStack publishes this after invalidating the config cache, so the new value is already
+ * readable. Re-books the pending run: shortening the interval past the due time schedules
+ * with zero delay, which pushes right away on the scheduler thread rather than blocking the
+ * API thread that served {@code updateConfiguration}.
+ */
+ @SuppressWarnings("unchecked")
+ private void onAsupConfigEdited(String senderAddress, String subject, Object args) {
+ if (!(args instanceof Ternary)) {
+ return;
+ }
+ String updatedKey = ((Ternary) args).first();
+ if (!OntapConfigurationManager.AsupIntervalHours.key().equals(updatedKey)) {
+ return;
+ }
+ logger.debug("ONTAP ASUP: [{}] was updated; re-booking the next push.", updatedKey);
+ scheduleNextRun();
+ }
+
+ /**
+ * One ASUP run inside a managed CloudStack context, which the DAO calls made during the push
+ * require.
+ *
+ *
{@link #lastPushTime} is stamped at the start of the cycle so the next wait is the
+ * remainder of the interval (work does not get added on top). The next run is booked again
+ * in {@code finally} so the schedule never stalls.
Guarded by a {@link GlobalLock} so that, in a multi-management-server deployment,
+ * only one node emits per cycle.
+ */
+ protected void pushAsupTelemetry() {
+ List pools = storagePoolDao.findPoolsByProvider(OntapStorageConstants.ONTAP_PLUGIN_NAME);
+ if (CollectionUtils.isEmpty(pools)) {
+ logger.debug("ONTAP ASUP: no ONTAP-backed storage pools found; nothing to push.");
+ return;
+ }
+
+ GlobalLock lock = GlobalLock.getInternLock(OntapStorageConstants.ASUP_GLOBAL_LOCK_NAME);
+ try {
+ if (!lock.lock(ASUP_LOCK_TIMEOUT_SECONDS)) {
+ logger.debug("ONTAP ASUP: another management server holds the ASUP lock; skipping this cycle.");
+ return;
+ }
+ try {
+ logger.debug("ONTAP ASUP: pushing telemetry for {} pool(s) [CloudStack version={}]",
+ pools.size(), getCloudStackVersion());
+ Map clientsByStorageIp = new HashMap<>();
+ for (StoragePoolVO pool : pools) {
+ pushAsupForStoragePool(pool, clientsByStorageIp);
+ }
+ } finally {
+ lock.unlock();
+ }
+ } finally {
+ lock.releaseRef();
+ }
+ }
+
+ /**
+ * Pushes the heartbeat (event-id 0) and pool (event-id 1) ASUP messages for a single pool.
+ *
+ *
{@code clientsByStorageIp} is the per-cycle cache keyed by management {@code storageIP}.
+ * A miss builds the strategy, GETs cluster info and node model, and sends event-0. A hit
+ * reuses that client and skips those calls and event-0. Event-1 is always sent. SVM name
+ * in the payload still comes from this pool's details.
+ *
+ *
Best-effort: any failure is logged and swallowed.
+ */
+ protected void pushAsupForStoragePool(StoragePoolVO pool, Map clientsByStorageIp) {
+ try {
+ Map details = storagePoolDetailsDao.listDetailsKeyPairs(pool.getId());
+ if (details == null || details.isEmpty()) {
+ logger.warn("ONTAP ASUP: storage pool [{}] has no details; skipping.", pool.getId());
+ return;
+ }
+
+ String storageIp = details.get(OntapStorageConstants.STORAGE_IP);
+ AsupClusterClient asupClusterClient = StringUtils.isNotBlank(storageIp)
+ ? clientsByStorageIp.get(storageIp) : null;
+ boolean sendHeartbeat = asupClusterClient == null;
+ if (asupClusterClient == null) {
+ StorageStrategy strategy = OntapStorageUtils.resolveStrategyFromPoolDetails(details);
+ Cluster cluster = strategy.getClusterInfo();
+ asupClusterClient = new AsupClusterClient(strategy, cluster);
+ if (StringUtils.isNotBlank(storageIp)) {
+ clientsByStorageIp.put(storageIp, asupClusterClient);
+ }
+ }
+
+ StorageStrategy strategy = asupClusterClient.strategy;
+ Cluster cluster = asupClusterClient.cluster;
+ String ontapVersion = strategy.getClusterVersion(cluster);
+ String clusterUuid = cluster != null ? cluster.getUuid() : null;
+ String cloudStackVersion = getCloudStackVersion();
+ String computerName = getComputerName();
+
+ if (sendHeartbeat) {
+ EmsApplicationLog heartbeat = buildBaseMessage(computerName, cloudStackVersion);
+ heartbeat.setEventId(OntapStorageConstants.ASUP_EVENT_ID_HEARTBEAT);
+ heartbeat.setEventDescription(buildHeartbeatDescription(
+ cloudStackVersion, ontapVersion, cluster));
+ strategy.sendAsupMessage(heartbeat);
+ } else {
+ logger.debug("ONTAP ASUP: heartbeat already sent this cycle for storage IP [{}]; skipping for pool [{}]",
+ storageIp, pool.getId());
+ }
+
+ // event-id 1: CloudStack storage pool -> backing ONTAP volume mapping, once per pool.
+ // The description also includes disk usage and snapshot telemetry
+ EmsApplicationLog poolMessage = buildBaseMessage(computerName, cloudStackVersion);
+ poolMessage.setEventId(OntapStorageConstants.ASUP_EVENT_ID_STORAGE_POOL);
+ poolMessage.setEventDescription(buildPoolDescription(pool, details, clusterUuid));
+ strategy.sendAsupMessage(poolMessage);
+
+ logger.debug("ONTAP ASUP: pushed telemetry for pool [{}] (ONTAP version={})",
+ pool.getId(), defaultUnknown(ontapVersion));
+ } catch (Exception e) {
+ // Best-effort telemetry; never propagate.
+ logger.warn("ONTAP ASUP: failed to push telemetry for pool [{}]: {}", pool.getId(), e.getMessage());
+ }
+ }
+
+ /**
+ * Builds the heartbeat (event-id 0) description as a JSON object carrying the CloudStack and
+ * ONTAP versions, cluster hardware model, the management-server operating system platform,
+ * and the ONTAP cluster UUID.
+ * Example: {@code {"message":"CloudStack connected to ONTAP cluster","cloudstackVersion":
+ * "4.23.0.0","platform":"Linux 5.15.0-91-generic (amd64)","ontapVersion":"9.17.1",
+ * "ontapClusterModel":"AFF-A400","ontapPlatformType":"performance","clusterUuid":"...",
+ * "managementServerCount":2}}
+ */
+ private String buildHeartbeatDescription(String cloudStackVersion, String ontapVersion, Cluster cluster) {
+ Map payload = new LinkedHashMap<>();
+ payload.put(OntapStorageConstants.ASUP_MESSAGE, OntapStorageConstants.ASUP_HEARTBEAT_MESSAGE);
+ payload.put(OntapStorageConstants.ASUP_CLOUDSTACK_VERSION, defaultUnknown(cloudStackVersion));
+ payload.put(OntapStorageConstants.ASUP_PLATFORM, getOperatingSystem());
+ payload.put(OntapStorageConstants.ASUP_ONTAP_VERSION, defaultUnknown(ontapVersion));
+ payload.put(OntapStorageConstants.ASUP_ONTAP_CLUSTER_MODEL,
+ defaultUnknown(cluster != null ? cluster.getModel() : null));
+ payload.put(OntapStorageConstants.ASUP_ONTAP_PLATFORM_TYPE,
+ defaultUnknown(cluster != null ? cluster.getPlatformType() : null));
+ payload.put(OntapStorageConstants.ASUP_CLUSTER_UUID,
+ defaultUnknown(cluster != null ? cluster.getUuid() : null));
+ payload.put(OntapStorageConstants.ASUP_MANAGEMENT_SERVER_COUNT, getManagementServerCount());
+ return toJson(payload);
+ }
+
+ /**
+ * Builds the pool description (event-id 1) as a JSON object combining the backing-volume
+ * mapping, disk usage, and snapshot telemetry into a single EMS message.
+ *
+ *
+ */
+ private String buildPoolDescription(StoragePoolVO pool, Map details,
+ String clusterUuid) {
+ Map payload = new LinkedHashMap<>();
+ payload.put(OntapStorageConstants.ASUP_MESSAGE, OntapStorageConstants.ASUP_POOL_MESSAGE);
+ payload.put(OntapStorageConstants.ASUP_POOL_NAME, defaultUnknown(pool.getName()));
+ payload.put(OntapStorageConstants.ASUP_POOL_STATUS,
+ pool.getStatus() == null ? OntapStorageConstants.ASUP_UNKNOWN : pool.getStatus().toString());
+ payload.put(OntapStorageConstants.ASUP_PROTOCOL, defaultUnknown(details.get(OntapStorageConstants.PROTOCOL)));
+ payload.put(OntapStorageConstants.ASUP_CLUSTER_UUID, defaultUnknown(clusterUuid));
+ payload.put(OntapStorageConstants.ASUP_SVM, defaultUnknown(details.get(OntapStorageConstants.SVM_NAME)));
+ payload.put(OntapStorageConstants.ASUP_ONTAP_VOLUME_UUID, defaultUnknown(details.get(OntapStorageConstants.VOLUME_UUID)));
+ List volumes = null;
+ try {
+ volumes = loadNonDestroyedVolumes(pool);
+ } catch (Exception e) {
+ logger.error("ONTAP ASUP: failed to load volumes for pool [{}]: {}", pool.getId(), e.getMessage());
+ }
+ if (volumes != null) {
+ addStoragePoolUsage(pool, payload, volumes);
+ addSnapshotMetrics(pool, payload, volumes);
+ }
+ hasMultiPrimaryStoragePoolVm(pool, payload);
+ return toJson(payload);
+ }
+
+ /**
+ * Single CloudStack DB read of non-destroyed volumes on this pool. Shared by usage and
+ * snapshot counts so the list is not queried three times. Never returns null.
+ */
+ private List loadNonDestroyedVolumes(StoragePoolVO pool) {
+ List volumes = volumeDao.findNonDestroyedVolumesByPoolId(pool.getId(), null);
+ return volumes == null ? java.util.Collections.emptyList() : volumes;
+ }
+
+ /**
+ * Computes pool usage from CloudStack's volume records and adds it to the payload:
+ *
+ *
{@code rootDiskCount} - number of ROOT (boot) disks physically on this pool
+ *
{@code dataDiskCount} - number of DATADISK disks physically on this pool
+ *
{@code totalLogicalSizeBytes} - sum of those volumes' provisioned (logical) sizes
+ * in bytes; for thin-provisioned volumes this is the logical size requested at
+ * creation time, not the physical space consumed on ONTAP
+ *
+ * {@code volumes} is the non-destroyed list for this pool (already loaded). Only
+ * {@link #CS_VOLUME_STATES} are counted. Best-effort: any failure leaves the usage
+ * fields out and never breaks telemetry.
+ */
+ private void addStoragePoolUsage(StoragePoolVO pool, Map payload, List volumes) {
+ try {
+ // Only count volumes that definitely have a physical object on the ONTAP FlexVolume.
+ // "Allocated" volumes have a pool_id row in the CS DB but ONTAP provisioning has not
+ // yet been called, so including them would inflate counts and provisioned size.
+ long rootDiskCount = 0L;
+ long dataDiskCount = 0L;
+ long totalLogicalSizeBytes = 0L;
+ for (VolumeVO volume : volumes) {
+ if (!CS_VOLUME_STATES.contains(volume.getState())) {
+ continue;
+ }
+ if (Volume.Type.ROOT.equals(volume.getVolumeType())) {
+ rootDiskCount++;
+ } else if (Volume.Type.DATADISK.equals(volume.getVolumeType())) {
+ dataDiskCount++;
+ }
+ totalLogicalSizeBytes += volume.getSize() != null ? volume.getSize() : 0L;
+ }
+ payload.put(OntapStorageConstants.ASUP_ROOT_DISK_COUNT, rootDiskCount);
+ payload.put(OntapStorageConstants.ASUP_DATA_DISK_COUNT, dataDiskCount);
+ payload.put(OntapStorageConstants.ASUP_TOTAL_LOGICAL_SIZE_BYTES, totalLogicalSizeBytes);
+ } catch (Exception e) {
+ logger.error("ONTAP ASUP: failed to compute usage for pool [{}]: {}", pool.getId(), e.getMessage());
+ }
+ }
+
+ /**
+ * Adds {@code hasMultiPrimaryStoragePoolVm}: true when at least one VM with a Ready ROOT
+ * on this pool also has an attached Ready DATADISK on a different primary storage pool.
+ * Uses a single {@code LIMIT 1} existence query.
+ */
+ private void hasMultiPrimaryStoragePoolVm(StoragePoolVO pool, Map payload) {
+ try {
+ payload.put(OntapStorageConstants.ASUP_MULTI_PRIMARY_STORAGE_POOL_VM,
+ volumeDao.hasMultiPrimaryStoragePoolVm(pool.getId()));
+ } catch (Exception e) {
+ logger.warn("ONTAP ASUP: failed to compute multiPrimaryStoragePoolVm for pool [{}]: {}",
+ pool.getId(), e.getMessage());
+ }
+ }
+
+ /**
+ * Computes and adds two groups of snapshot telemetry to the pool description payload.
+ *
+ *
Volume-snapshot metrics ({@code volumeSnapshotCount}): counts all
+ * non-destroyed CloudStack volume-level snapshots for volumes on this pool.
+ *
+ *
VM-snapshot metrics ({@code vmSnapshotCount}): counts all active
+ * (non-expunging, non-removed) VM snapshots for VMs whose ROOT disk is on this pool.
+ * A data disk on another pool does not duplicate the count.
+ *
+ *
Best-effort: any failure leaves the fields out without breaking telemetry.
+ */
+ private void addSnapshotMetrics(StoragePoolVO pool, Map payload, List volumes) {
+ addVmSnapshotMetrics(pool, payload, volumes);
+ addVolumeSnapshotMetrics(pool, payload, volumes);
+ }
+
+ /**
+ * Adds {@code volumeSnapshotCount} to the payload.
+ * Counts all non-destroyed CloudStack volume-level snapshots for volumes on this pool.
+ */
+ private void addVolumeSnapshotMetrics(StoragePoolVO pool, Map payload, List volumes) {
+ try {
+ if (volumes.isEmpty()) {
+ payload.put(OntapStorageConstants.ASUP_VOLUME_SNAPSHOT_COUNT, 0);
+ return;
+ }
+
+ List volumeIds = volumes.stream()
+ .map(VolumeVO::getId)
+ .collect(java.util.stream.Collectors.toList());
+
+ List snapshots = snapshotDao.searchByVolumes(volumeIds);
+ long snapCount = snapshots == null ? 0L : snapshots.stream()
+ .filter(snap -> !com.cloud.storage.Snapshot.State.Destroyed.equals(snap.getState()))
+ .count();
+
+ payload.put(OntapStorageConstants.ASUP_VOLUME_SNAPSHOT_COUNT, snapCount);
+ } catch (Exception e) {
+ logger.warn("ONTAP ASUP: failed to compute volume-snapshot metrics for pool [{}]: {}",
+ pool.getId(), e.getMessage());
+ }
+ }
+
+ /**
+ * Adds {@code vmSnapshotCount} to the payload.
+ * Counts all active (non-expunging, non-removed) VM snapshots for VMs whose ROOT
+ * disk is on this pool, so a multi-pool VM is counted once (on the root pool).
+ */
+ private void addVmSnapshotMetrics(StoragePoolVO pool, Map payload, List volumes) {
+ try {
+ if (volumes.isEmpty()) {
+ payload.put(OntapStorageConstants.ASUP_VM_SNAPSHOT_COUNT, 0);
+ return;
+ }
+
+ java.util.Set vmIds = volumes.stream()
+ .filter(v -> Volume.Type.ROOT.equals(v.getVolumeType()))
+ .map(VolumeVO::getInstanceId)
+ .filter(java.util.Objects::nonNull)
+ .collect(java.util.stream.Collectors.toSet());
+
+ if (vmIds.isEmpty()) {
+ payload.put(OntapStorageConstants.ASUP_VM_SNAPSHOT_COUNT, 0);
+ return;
+ }
+
+ List vmSnapshots = vmSnapshotDao.searchByVms(new java.util.ArrayList<>(vmIds));
+ long vmSnapCount = vmSnapshots == null ? 0L : vmSnapshots.stream()
+ .filter(vmSnap -> !VMSnapshot.State.Expunging.equals(vmSnap.getState())
+ && vmSnap.getRemoved() == null)
+ .count();
+
+ payload.put(OntapStorageConstants.ASUP_VM_SNAPSHOT_COUNT, vmSnapCount);
+ } catch (Exception e) {
+ logger.warn("ONTAP ASUP: failed to compute VM-snapshot metrics for pool [{}]: {}",
+ pool.getId(), e.getMessage());
+ }
+ }
+
+ /**
+ * Serializes a payload map to a JSON string. Falls back to the map's {@code toString()} if
+ * serialization unexpectedly fails, so telemetry is still emitted (best-effort).
+ */
+ private String toJson(Map payload) {
+ try {
+ return objectMapper.writeValueAsString(payload);
+ } catch (Exception e) {
+ logger.warn("ONTAP ASUP: failed to serialize event description to JSON: {}", e.getMessage());
+ return String.valueOf(payload);
+ }
+ }
+
+ /** Builds the common EMS message envelope shared by all ASUP messages. */
+ private EmsApplicationLog buildBaseMessage(String computerName, String appVersion) {
+ EmsApplicationLog message = new EmsApplicationLog();
+ message.setComputerName(computerName);
+ message.setEventSource(OntapStorageConstants.ASUP_EVENT_SOURCE);
+ message.setAppVersion(appVersion);
+ message.setCategory(OntapStorageConstants.ASUP_CATEGORY);
+ message.setSeverity(OntapStorageConstants.ASUP_SEVERITY);
+ message.setAutosupportRequired(Boolean.FALSE);
+ return message;
+ }
+
+ /**
+ * CloudStack version of this management server, same source as {@link ManagementService#getVersion()}
+ * / {@code listCapabilities}. Falls back to "unknown" when the server JAR has no manifest
+ * (for example running from an IDE).
+ */
+ protected String getCloudStackVersion() {
+ String version = managementService != null ? managementService.getVersion() : null;
+ return StringUtils.isBlank(version) ? OntapStorageConstants.ASUP_UNKNOWN : version;
+ }
+
+ /**
+ * Number of management servers registered in {@code mshost} (not removed), including nodes
+ * that are not currently {@code Up}.
+ */
+ protected int getManagementServerCount() {
+ try {
+ List hosts = managementServerHostDao.listAll();
+ return hosts == null ? 0 : hosts.size();
+ } catch (Exception e) {
+ logger.debug("ONTAP ASUP: unable to count management servers: {}", e.getMessage());
+ return 0;
+ }
+ }
+
+ /** Resolves the management server hostname for the EMS computer-name field. */
+ protected String getComputerName() {
+ String hostName = NetUtils.getCanonicalHostName();
+ return StringUtils.isBlank(hostName) ? OntapStorageConstants.ASUP_UNKNOWN : hostName;
+ }
+
+ /**
+ * Resolves the management server operating system (name, version and architecture) from JVM
+ * system properties, e.g. {@code "Linux 5.15.0-91-generic (amd64)"}. Falls back to "unknown".
+ */
+ protected String getOperatingSystem() {
+ String osName = System.getProperty("os.name");
+ String osVersion = System.getProperty("os.version");
+ String osArch = System.getProperty("os.arch");
+ if (StringUtils.isBlank(osName)) {
+ return OntapStorageConstants.ASUP_UNKNOWN;
+ }
+ StringBuilder sb = new StringBuilder(osName);
+ if (StringUtils.isNotBlank(osVersion)) {
+ sb.append(' ').append(osVersion);
+ }
+ if (StringUtils.isNotBlank(osArch)) {
+ sb.append(" (").append(osArch).append(')');
+ }
+ return sb.toString();
+ }
+
+ private String defaultUnknown(String value) {
+ return StringUtils.isBlank(value) ? OntapStorageConstants.ASUP_UNKNOWN : value;
+ }
+
+ /**
+ * Returns a usable interval in hours. {@link OntapStorageConstants#ASUP_DISABLED_INTERVAL_HOURS}
+ * means telemetry is off. Out-of-range or missing DB values (for example set outside the API)
+ * fall back to the default so ASUP is not sent on an unintended cadence. The scheduler
+ * converts a non-zero value to seconds via {@link Duration#ofHours(long)}.
+ */
+ int getAsupIntervalHours(Integer configured) {
+ if (configured == null) {
+ return OntapStorageConstants.ASUP_DEFAULT_INTERVAL_HOURS;
+ }
+ if (configured == OntapStorageConstants.ASUP_DISABLED_INTERVAL_HOURS) {
+ return OntapStorageConstants.ASUP_DISABLED_INTERVAL_HOURS;
+ }
+ if (configured < OntapStorageConstants.ASUP_MIN_INTERVAL_HOURS
+ || configured > OntapStorageConstants.ASUP_MAX_INTERVAL_HOURS) {
+ logger.warn("ONTAP ASUP: {} value [{}] is outside [{}-{}]; using default [{}]",
+ OntapStorageConstants.ASUP_INTERVAL_CONFIG_KEY, configured,
+ OntapStorageConstants.ASUP_MIN_INTERVAL_HOURS,
+ OntapStorageConstants.ASUP_MAX_INTERVAL_HOURS,
+ OntapStorageConstants.ASUP_DEFAULT_INTERVAL_HOURS);
+ return OntapStorageConstants.ASUP_DEFAULT_INTERVAL_HOURS;
+ }
+ return configured;
+ }
+
+ /**
+ * One ONTAP cluster HTTP client plus the cluster GET and node-model GET for this ASUP cycle,
+ * keyed by {@code storageIP}. Discarded when the cycle ends.
+ */
+ static final class AsupClusterClient {
+ final StorageStrategy strategy;
+ final Cluster cluster;
+
+ AsupClusterClient(StorageStrategy strategy, Cluster cluster) {
+ this.strategy = strategy;
+ this.cluster = cluster;
+ }
+ }
+
+}
diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/ClusterFeignClient.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/ClusterFeignClient.java
index 582fb58e6f3b..476ef2e392fc 100644
--- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/ClusterFeignClient.java
+++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/ClusterFeignClient.java
@@ -19,14 +19,24 @@
package org.apache.cloudstack.storage.feign.client;
+import feign.QueryMap;
import org.apache.cloudstack.storage.feign.model.Cluster;
+import org.apache.cloudstack.storage.feign.model.ClusterNode;
+import org.apache.cloudstack.storage.feign.model.response.OntapResponse;
import feign.Headers;
import feign.Param;
import feign.RequestLine;
+import java.util.Map;
+
public interface ClusterFeignClient {
@RequestLine("GET /api/cluster")
@Headers({"Authorization: {authHeader}", "return_records: {returnRecords}"})
Cluster getCluster(@Param("authHeader") String authHeader, @Param("returnRecords") boolean returnRecords);
+
+ @RequestLine("GET /api/cluster/nodes")
+ @Headers({"Authorization: {authHeader}"})
+ OntapResponse getClusterNodes(@Param("authHeader") String authHeader,
+ @QueryMap Map queryMap);
}
diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/EmsFeignClient.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/EmsFeignClient.java
new file mode 100644
index 000000000000..c3e4c73d6165
--- /dev/null
+++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/client/EmsFeignClient.java
@@ -0,0 +1,32 @@
+/*
+ * 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.storage.feign.client;
+
+import feign.Headers;
+import feign.Param;
+import feign.RequestLine;
+import org.apache.cloudstack.storage.feign.model.EmsApplicationLog;
+
+public interface EmsFeignClient {
+
+ @RequestLine("POST /api/support/ems/application-logs")
+ @Headers({"Authorization: {authHeader}", "Content-Type: application/json"})
+ void sendEmsApplicationLog(@Param("authHeader") String authHeader, EmsApplicationLog emsApplicationLog);
+}
diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Cluster.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Cluster.java
index 061372756175..f0b870f25423 100644
--- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Cluster.java
+++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/Cluster.java
@@ -19,6 +19,7 @@
package org.apache.cloudstack.storage.feign.model;
+import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
@@ -48,6 +49,12 @@ public class Cluster {
@JsonProperty("disaggregated")
private Boolean disaggregated = null;
+ @JsonIgnore
+ private String model;
+
+ @JsonIgnore
+ private String platformType;
+
public String getHealth() {
return health;
@@ -104,6 +111,22 @@ public void setDisaggregated(Boolean disaggregated) {
this.disaggregated = disaggregated;
}
+ public String getModel() {
+ return model;
+ }
+
+ public void setModel(String model) {
+ this.model = model;
+ }
+
+ public String getPlatformType() {
+ return platformType;
+ }
+
+ public void setPlatformType(String platformType) {
+ this.platformType = platformType;
+ }
+
@Override
public int hashCode() {
return Objects.hash(getName(), getUuid());
@@ -129,6 +152,8 @@ public String toString() {
", version=" + version +
", sanOptimized=" + sanOptimized +
", disaggregated=" + disaggregated +
+ ", model='" + model + '\'' +
+ ", platformType='" + platformType + '\'' +
'}';
}
}
diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/ClusterNode.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/ClusterNode.java
new file mode 100644
index 000000000000..8d067c05790c
--- /dev/null
+++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/ClusterNode.java
@@ -0,0 +1,76 @@
+/*
+ * 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.storage.feign.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/**
+ * Subset of {@code GET /api/cluster/nodes} used for ASUP
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class ClusterNode {
+
+ @JsonProperty("model")
+ private String model;
+
+ @JsonProperty("is_all_flash_optimized")
+ private Boolean allFlashOptimized;
+
+ @JsonProperty("is_perf_optimized")
+ private Boolean performanceOptimized;
+
+ @JsonProperty("is_capacity_optimized")
+ private Boolean capacityOptimized;
+
+ public String getModel() {
+ return model;
+ }
+
+ public void setModel(String model) {
+ this.model = model;
+ }
+
+ public Boolean getAllFlashOptimized() {
+ return allFlashOptimized;
+ }
+
+ public void setAllFlashOptimized(Boolean allFlashOptimized) {
+ this.allFlashOptimized = allFlashOptimized;
+ }
+
+ public Boolean getPerformanceOptimized() {
+ return performanceOptimized;
+ }
+
+ public void setPerformanceOptimized(Boolean performanceOptimized) {
+ this.performanceOptimized = performanceOptimized;
+ }
+
+ public Boolean getCapacityOptimized() {
+ return capacityOptimized;
+ }
+
+ public void setCapacityOptimized(Boolean capacityOptimized) {
+ this.capacityOptimized = capacityOptimized;
+ }
+}
diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/EmsApplicationLog.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/EmsApplicationLog.java
new file mode 100644
index 000000000000..24289c8d33b2
--- /dev/null
+++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/feign/model/EmsApplicationLog.java
@@ -0,0 +1,134 @@
+/*
+ * 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.storage.feign.model;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonInclude(JsonInclude.Include.NON_NULL)
+public class EmsApplicationLog {
+
+ @JsonProperty("computer_name")
+ private String computerName;
+
+ @JsonProperty("event_source")
+ private String eventSource;
+
+ @JsonProperty("app_version")
+ private String appVersion;
+
+ @JsonProperty("category")
+ private String category;
+
+ @JsonProperty("severity")
+ private String severity;
+
+ @JsonProperty("autosupport_required")
+ private Boolean autosupportRequired;
+
+ @JsonProperty("event_id")
+ private String eventId;
+
+ @JsonProperty("event_description")
+ private String eventDescription;
+
+ public EmsApplicationLog() {
+ }
+
+ public String getComputerName() {
+ return computerName;
+ }
+
+ public void setComputerName(String computerName) {
+ this.computerName = computerName;
+ }
+
+ public String getEventSource() {
+ return eventSource;
+ }
+
+ public void setEventSource(String eventSource) {
+ this.eventSource = eventSource;
+ }
+
+ public String getAppVersion() {
+ return appVersion;
+ }
+
+ public void setAppVersion(String appVersion) {
+ this.appVersion = appVersion;
+ }
+
+ public String getCategory() {
+ return category;
+ }
+
+ public void setCategory(String category) {
+ this.category = category;
+ }
+
+ public String getSeverity() {
+ return severity;
+ }
+
+ public void setSeverity(String severity) {
+ this.severity = severity;
+ }
+
+ public Boolean getAutosupportRequired() {
+ return autosupportRequired;
+ }
+
+ public void setAutosupportRequired(Boolean autosupportRequired) {
+ this.autosupportRequired = autosupportRequired;
+ }
+
+ public String getEventId() {
+ return eventId;
+ }
+
+ public void setEventId(String eventId) {
+ this.eventId = eventId;
+ }
+
+ public String getEventDescription() {
+ return eventDescription;
+ }
+
+ public void setEventDescription(String eventDescription) {
+ this.eventDescription = eventDescription;
+ }
+
+ @Override
+ public String toString() {
+ return "EmsApplicationLog{" +
+ "computerName='" + computerName + '\'' +
+ ", eventSource='" + eventSource + '\'' +
+ ", appVersion='" + appVersion + '\'' +
+ ", category='" + category + '\'' +
+ ", severity='" + severity + '\'' +
+ ", autosupportRequired=" + autosupportRequired +
+ ", eventId='" + eventId + '\'' +
+ ", eventDescription='" + eventDescription + '\'' +
+ '}';
+ }
+}
diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java
index b385269d5f2a..b060b2312ee9 100644
--- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java
+++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/service/StorageStrategy.java
@@ -21,26 +21,33 @@
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import org.apache.cloudstack.storage.feign.FeignClientFactory;
import org.apache.cloudstack.storage.feign.client.AggregateFeignClient;
+import org.apache.cloudstack.storage.feign.client.ClusterFeignClient;
import org.apache.cloudstack.storage.feign.client.JobFeignClient;
import org.apache.cloudstack.storage.feign.client.NASFeignClient;
import org.apache.cloudstack.storage.feign.client.NetworkFeignClient;
import org.apache.cloudstack.storage.feign.client.SANFeignClient;
import org.apache.cloudstack.storage.feign.client.SnapshotFeignClient;
+import org.apache.cloudstack.storage.feign.client.EmsFeignClient;
import org.apache.cloudstack.storage.feign.client.SvmFeignClient;
import org.apache.cloudstack.storage.feign.client.VolumeFeignClient;
import org.apache.cloudstack.storage.feign.model.Aggregate;
+import org.apache.cloudstack.storage.feign.model.Cluster;
+import org.apache.cloudstack.storage.feign.model.ClusterNode;
+import org.apache.cloudstack.storage.feign.model.EmsApplicationLog;
import org.apache.cloudstack.storage.feign.model.IpInterface;
import org.apache.cloudstack.storage.feign.model.IscsiService;
import org.apache.cloudstack.storage.feign.model.Job;
import org.apache.cloudstack.storage.feign.model.Nas;
import org.apache.cloudstack.storage.feign.model.OntapStorage;
import org.apache.cloudstack.storage.feign.model.Svm;
+import org.apache.cloudstack.storage.feign.model.Version;
import org.apache.cloudstack.storage.feign.model.Volume;
import org.apache.cloudstack.storage.feign.model.response.JobResponse;
import org.apache.cloudstack.storage.feign.model.response.OntapResponse;
@@ -75,6 +82,8 @@ public abstract class StorageStrategy {
protected SANFeignClient sanFeignClient;
protected NASFeignClient nasFeignClient;
protected SnapshotFeignClient snapshotFeignClient;
+ protected ClusterFeignClient clusterFeignClient;
+ protected EmsFeignClient emsFeignClient;
protected OntapStorage storage;
@@ -106,6 +115,147 @@ public StorageStrategy(OntapStorage ontapStorage) {
this.sanFeignClient = feignClientFactory.createClient(SANFeignClient.class, baseURL);
this.nasFeignClient = feignClientFactory.createClient(NASFeignClient.class, baseURL);
this.snapshotFeignClient = feignClientFactory.createClient(SnapshotFeignClient.class, baseURL);
+ this.clusterFeignClient = feignClientFactory.createClient(ClusterFeignClient.class, baseURL);
+ this.emsFeignClient = feignClientFactory.createClient(EmsFeignClient.class, baseURL);
+ }
+
+ /**
+ * Fetches the ONTAP {@link Cluster} (name, uuid, version) and, for ASUP, the rolled-up node
+ * {@code model} and {@code platformType} from {@code GET /api/cluster/nodes}. Best-effort:
+ * returns {@code null} if the cluster GET fails. Node fields are left unset if the nodes GET
+ * fails. Callers must never fail a storage operation because of this.
+ *
+ * @return the ONTAP {@link Cluster}, or {@code null} if it cannot be resolved
+ */
+ public Cluster getClusterInfo() {
+ try {
+ String authHeader = OntapStorageUtils.generateAuthHeader(storage.getUsername(), storage.getPassword());
+ Cluster cluster = clusterFeignClient.getCluster(authHeader, true);
+ if (cluster != null) {
+ populateNodeAsupFields(cluster, authHeader);
+ }
+ return cluster;
+ } catch (Exception e) {
+ logger.warn("getClusterInfo: failed to fetch ONTAP cluster info for storage IP {}: {}",
+ storage.getStorageIP(), e.getMessage());
+ return null;
+ }
+ }
+
+ /**
+ * Sets {@link Cluster#setModel(String)} and {@link Cluster#setPlatformType(String)} from one
+ * {@code GET /api/cluster/nodes}. Distinct models are joined with a comma. Platform type is
+ * {@code performance}, {@code capacity}, {@code fas}, or {@code composite} when personalities mix.
+ * A node that omits {@code is_all_flash_optimized} is left out of the rollup so a partial
+ * response is not reported as {@code fas}.
+ */
+ private void populateNodeAsupFields(Cluster cluster, String authHeader) {
+ try {
+ Map query = new HashMap<>();
+ query.put(OntapStorageConstants.FIELDS, OntapStorageConstants.CLUSTER_NODE_ASUP_FIELDS);
+ OntapResponse response = clusterFeignClient.getClusterNodes(authHeader, query);
+ if (response == null || response.getRecords() == null || response.getRecords().isEmpty()) {
+ return;
+ }
+ LinkedHashSet models = new LinkedHashSet<>();
+ LinkedHashSet platformTypes = new LinkedHashSet<>();
+ for (ClusterNode node : response.getRecords()) {
+ if (node == null) {
+ continue;
+ }
+ if (node.getModel() != null && !node.getModel().isBlank()) {
+ models.add(node.getModel().trim());
+ }
+ String platformType = classifyNodePlatformType(node);
+ if (platformType != null) {
+ platformTypes.add(platformType);
+ }
+ }
+ if (!models.isEmpty()) {
+ cluster.setModel(String.join(OntapStorageConstants.COMMA, models));
+ }
+ cluster.setPlatformType(rollupPlatformType(platformTypes));
+ } catch (Exception e) {
+ logger.warn("getClusterInfo: failed to fetch ONTAP node hardware for storage IP {}: {}",
+ storage.getStorageIP(), e.getMessage());
+ }
+ }
+
+ /**
+ * Extracts a clean, parser-friendly ONTAP version string from a {@link Cluster}.
+ *
+ *
Prefers the compact "generation.major.minor" numeric form (e.g. "9.17.1"), which avoids
+ * the colon/date noise in {@code version.full}. Falls back to the verbose {@code version.full}
+ * banner only when the numeric fields are unavailable.
+ *
+ * @param cluster the cluster (may be {@code null})
+ * @return the ONTAP version string, or {@code null} if it cannot be resolved
+ */
+ public String getClusterVersion(Cluster cluster) {
+ if (cluster == null || cluster.getVersion() == null) {
+ return null;
+ }
+ Version version = cluster.getVersion();
+ if (version.getGeneration() != null && version.getMajor() != null && version.getMinor() != null) {
+ return version.getGeneration() + OntapStorageConstants.DOT + version.getMajor()
+ + OntapStorageConstants.DOT + version.getMinor();
+ }
+ if (version.getFull() != null && !version.getFull().isEmpty()) {
+ return version.getFull();
+ }
+ return null;
+ }
+
+ /**
+ * Classifies one node: not all-flash → {@code fas}; all-flash + capacity → {@code capacity};
+ * otherwise all-flash (including performance-optimized or classic AFF) → {@code performance}.
+ * Returns {@code null} when {@code is_all_flash_optimized} is absent, so unknown hardware is
+ * not reported as {@code fas}.
+ */
+ private static String classifyNodePlatformType(ClusterNode node) {
+ if (node.getAllFlashOptimized() == null) {
+ return null;
+ }
+ if (!node.getAllFlashOptimized()) {
+ return OntapStorageConstants.ASUP_PLATFORM_TYPE_FAS;
+ }
+ if (Boolean.TRUE.equals(node.getCapacityOptimized())) {
+ return OntapStorageConstants.ASUP_PLATFORM_TYPE_CAPACITY;
+ }
+ return OntapStorageConstants.ASUP_PLATFORM_TYPE_PERFORMANCE;
+ }
+
+ private static String rollupPlatformType(LinkedHashSet platformTypes) {
+ if (platformTypes == null || platformTypes.isEmpty()) {
+ return null;
+ }
+ if (platformTypes.size() == 1) {
+ return platformTypes.iterator().next();
+ }
+ return OntapStorageConstants.ASUP_PLATFORM_TYPE_COMPOSITE;
+ }
+
+ /**
+ * Pushes a single ASUP (AutoSupport) EMS application-log message to the ONTAP cluster.
+ *
+ *
This is strictly best-effort telemetry: any failure is logged and swallowed so that
+ * it can never affect a storage operation or the periodic scheduler.
+ *
+ * @param message the EMS message to send
+ */
+ public void sendAsupMessage(EmsApplicationLog message) {
+ if (message == null) {
+ return;
+ }
+ try {
+ String authHeader = OntapStorageUtils.generateAuthHeader(storage.getUsername(), storage.getPassword());
+ emsFeignClient.sendEmsApplicationLog(authHeader, message);
+ logger.debug("sendAsupMessage: ASUP EMS message [event-id={}] sent to ONTAP cluster at {}",
+ message.getEventId(), storage.getStorageIP());
+ } catch (Exception e) {
+ logger.error("sendAsupMessage: failed to send ASUP EMS message [event-id={}] to ONTAP cluster at {}: {}",
+ message.getEventId(), storage.getStorageIP(), e.getMessage());
+ }
}
/**
diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapConfigurationManager.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapConfigurationManager.java
new file mode 100644
index 000000000000..e93a1757de2f
--- /dev/null
+++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapConfigurationManager.java
@@ -0,0 +1,104 @@
+/*
+ * 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.storage.utils;
+
+import com.cloud.exception.InvalidParameterValueException;
+import org.apache.cloudstack.framework.config.ConfigKey;
+import org.apache.cloudstack.framework.config.Configurable;
+import org.apache.cloudstack.framework.config.ValidatedConfigKey;
+import org.apache.commons.lang3.StringUtils;
+
+import java.util.function.Consumer;
+
+/**
+ * Single registration point for ONTAP plugin {@link ConfigKey}s (same pattern as
+ * Linstor/StorPool). Callers read live values via {@code Key.value()}; they must not
+ * construct new {@code ConfigKey} instances.
+ */
+public class OntapConfigurationManager implements Configurable {
+ public static final ValidatedConfigKey AsupIntervalHours = new ValidatedConfigKey<>(
+ OntapStorageConstants.ADVANCED_CONFIG_KEY_CATEGORY, Integer.class,
+ OntapStorageConstants.ASUP_INTERVAL_CONFIG_KEY,
+ String.valueOf(OntapStorageConstants.ASUP_DEFAULT_INTERVAL_HOURS),
+ OntapStorageConstants.ASUP_INTERVAL_DESCRIPTION,
+ true, ConfigKey.Scope.Global, null, asupIntervalValidator());
+
+ public static final ConfigKey>[] CONFIG_KEYS = new ConfigKey>[] {
+ AsupIntervalHours
+ };
+
+ /**
+ * {@link ValidatedConfigKey#validateValue(String)} always passes the raw config string,
+ * even when the key type is {@link Integer}. Adapt that to {@code Consumer}.
+ */
+ @SuppressWarnings("unchecked")
+ private static Consumer asupIntervalValidator() {
+ Consumer
*/
public static final String NETAPP_NAA_PREFIX = NAA_IEEE_REG_EXT + NETAPP_OUI + "0";
+
+ // ASUP (AutoSupport) / EMS telemetry
+ public static final String ADVANCED_CONFIG_KEY_CATEGORY = "Advanced";
+ public static final String ASUP_CATEGORY = "provisioning";
+ public static final String ASUP_SEVERITY = "notice";
+ public static final String ASUP_EVENT_SOURCE = "CloudStack ONTAP plugin";
+ public static final String ASUP_EVENT_ID_HEARTBEAT = "0";
+ public static final String ASUP_EVENT_ID_STORAGE_POOL = "1";
+ public static final String ASUP_UNKNOWN = "unknown";
+ /** Event-id 0/1 JSON field: short human-readable description of the message. */
+ public static final String ASUP_MESSAGE = "message";
+ public static final String ASUP_HEARTBEAT_MESSAGE = "CloudStack connected to Unified ONTAP cluster";
+ public static final String ASUP_POOL_MESSAGE = "CloudStack storage pool backed by Unified ONTAP volume";
+ public static final String ASUP_POOL_NAME = "poolName";
+ public static final String ASUP_POOL_STATUS = "poolStatus";
+ public static final String ASUP_PROTOCOL = "protocol";
+ public static final String ASUP_SVM = "svm";
+ public static final String ASUP_ONTAP_VOLUME_UUID = "ontapVolumeUuid";
+ public static final String ASUP_CLOUDSTACK_VERSION = "cloudstackVersion";
+ public static final String ASUP_PLATFORM = "platform";
+ public static final String ASUP_ONTAP_VERSION = "ontapVersion";
+ public static final String ASUP_ONTAP_CLUSTER_MODEL = "ontapClusterModel";
+ public static final String ASUP_ONTAP_PLATFORM_TYPE = "ontapPlatformType";
+ public static final String ASUP_PLATFORM_TYPE_PERFORMANCE = "performance";
+ public static final String ASUP_PLATFORM_TYPE_CAPACITY = "capacity";
+ public static final String ASUP_PLATFORM_TYPE_FAS = "fas";
+ public static final String ASUP_PLATFORM_TYPE_COMPOSITE = "composite";
+ public static final String ASUP_CLUSTER_UUID = "clusterUuid";
+ public static final String ASUP_MANAGEMENT_SERVER_COUNT = "managementServerCount";
+ /** Event-id 0 field: VM snapshots spanning multiple ONTAP pools (consistency group). */
+ public static final String ASUP_SNAPSHOT_ACROSS_POOL = "snapshot_across_pool";
+ public static final String ASUP_MULTI_PRIMARY_STORAGE_POOL_VM = "multiPrimaryStoragePoolVm";
+ public static final String ASUP_ROOT_DISK_COUNT = "rootDiskCount";
+ public static final String ASUP_DATA_DISK_COUNT = "dataDiskCount";
+ public static final String ASUP_TOTAL_LOGICAL_SIZE_BYTES = "totalLogicalSizeBytes";
+ public static final String ASUP_VOLUME_SNAPSHOT_COUNT = "volumeSnapshotCount";
+ public static final String ASUP_VM_SNAPSHOT_COUNT = "vmSnapshotCount";
+ public static final String ASUP_GLOBAL_LOCK_NAME = "ontap.autosupport.push";
+ public static final String ASUP_INTERVAL_CONFIG_KEY = "ontap.autosupport.interval";
+ /** {@code ontap.autosupport.interval} value that disables telemetry reporting. */
+ public static final int ASUP_DISABLED_INTERVAL_HOURS = 0;
+ public static final int ASUP_MIN_INTERVAL_HOURS = 4;
+ public static final int ASUP_MAX_INTERVAL_HOURS = 168; // once a week
+ public static final int ASUP_DEFAULT_INTERVAL_HOURS = 24; // once a day
+
+ public static final String ASUP_INTERVAL_DESCRIPTION =
+ "Interval in hours between telemetry reports sent to the ONTAP cluster. "
+ + ASUP_DISABLED_INTERVAL_HOURS + " disables reporting. Allowed range is "
+ + ASUP_MIN_INTERVAL_HOURS + " hours to " + ASUP_MAX_INTERVAL_HOURS
+ + " hours (1 week). Default is " + ASUP_DEFAULT_INTERVAL_HOURS
+ + " hours (once a day). Changes take effect immediately and do not require a management server restart.";
}
diff --git a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageUtils.java b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageUtils.java
index 7f09b5584b40..022fbb1d328a 100644
--- a/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageUtils.java
+++ b/plugins/storage/volume/ontap/src/main/java/org/apache/cloudstack/storage/utils/OntapStorageUtils.java
@@ -136,17 +136,24 @@ public static StorageStrategy getStrategyByStoragePoolDetails(Map details,
- boolean validateAggregatesForVolumeCreation) {
+ /**
+ * Same as {@link #getStrategyByStoragePoolDetails(Map)} but does not call
+ * {@link StorageStrategy#connect}. ASUP uses this for cluster GET and EMS POST only.
+ */
+ public static StorageStrategy resolveStrategyFromPoolDetails(Map details) {
if (details == null || details.isEmpty()) {
- logger.error("getStrategyByStoragePoolDetails: Storage pool details are null or empty");
+ logger.error("resolveStrategyFromPoolDetails: Storage pool details are null or empty");
throw new CloudRuntimeException("Storage pool details are null or empty");
}
String protocol = details.get(OntapStorageConstants.PROTOCOL);
OntapStorage ontapStorage = new OntapStorage(details.get(OntapStorageConstants.USERNAME), details.get(OntapStorageConstants.PASSWORD),
details.get(OntapStorageConstants.STORAGE_IP), details.get(OntapStorageConstants.SVM_NAME), Long.parseLong(details.get(OntapStorageConstants.SIZE)),
ProtocolType.valueOf(protocol));
- StorageStrategy storageStrategy = StorageProviderFactory.getStrategy(ontapStorage);
+ return StorageProviderFactory.getStrategy(ontapStorage);
+ }
+
+ public static StorageStrategy getStrategyByStoragePoolDetails(Map details, boolean validateAggregatesForVolumeCreation) {
+ StorageStrategy storageStrategy = resolveStrategyFromPoolDetails(details);
boolean isValid = storageStrategy.connect(validateAggregatesForVolumeCreation);
if (isValid) {
logger.info("Connection to Ontap SVM [{}] successful", details.get(OntapStorageConstants.SVM_NAME));
diff --git a/plugins/storage/volume/ontap/src/main/resources/META-INF/cloudstack/storage-volume-ontap/spring-storage-volume-ontap-context.xml b/plugins/storage/volume/ontap/src/main/resources/META-INF/cloudstack/storage-volume-ontap/spring-storage-volume-ontap-context.xml
index bb907871469c..bfbb430b7c17 100644
--- a/plugins/storage/volume/ontap/src/main/resources/META-INF/cloudstack/storage-volume-ontap/spring-storage-volume-ontap-context.xml
+++ b/plugins/storage/volume/ontap/src/main/resources/META-INF/cloudstack/storage-volume-ontap/spring-storage-volume-ontap-context.xml
@@ -33,4 +33,10 @@
+
+
+
+
diff --git a/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/asup/OntapAsupManagerTest.java b/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/asup/OntapAsupManagerTest.java
new file mode 100644
index 000000000000..700ae8f83e2b
--- /dev/null
+++ b/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/asup/OntapAsupManagerTest.java
@@ -0,0 +1,747 @@
+/*
+ * 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.storage.asup;
+
+import com.cloud.cluster.ManagementServerHostVO;
+import com.cloud.cluster.dao.ManagementServerHostDao;
+import com.cloud.exception.InvalidParameterValueException;
+import com.cloud.server.ManagementService;
+import com.cloud.storage.Snapshot;
+import com.cloud.storage.SnapshotVO;
+import com.cloud.storage.StoragePoolStatus;
+import com.cloud.storage.Volume;
+import com.cloud.storage.VolumeVO;
+import com.cloud.storage.dao.SnapshotDao;
+import com.cloud.storage.dao.VolumeDao;
+import com.cloud.vm.snapshot.VMSnapshot;
+import com.cloud.vm.snapshot.VMSnapshotVO;
+import com.cloud.vm.snapshot.dao.VMSnapshotDao;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
+import org.apache.cloudstack.storage.feign.model.Cluster;
+import org.apache.cloudstack.storage.feign.model.EmsApplicationLog;
+import org.apache.cloudstack.storage.service.StorageStrategy;
+import org.apache.cloudstack.storage.utils.OntapConfigurationManager;
+import org.apache.cloudstack.storage.utils.OntapStorageConstants;
+import org.apache.cloudstack.storage.utils.OntapStorageUtils;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.ArgumentCaptor;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.MockedStatic;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.time.Duration;
+import java.time.Instant;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyList;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.ArgumentMatchers.isNull;
+import static org.mockito.Mockito.lenient;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.mockStatic;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.times;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+@ExtendWith(MockitoExtension.class)
+class OntapAsupManagerTest {
+
+ // ── DAOs ──────────────────────────────────────────────────────────────────
+ @Mock private PrimaryDataStoreDao storagePoolDao;
+ @Mock private StoragePoolDetailsDao storagePoolDetailsDao;
+ @Mock private VolumeDao volumeDao;
+ @Mock private SnapshotDao snapshotDao;
+ @Mock private VMSnapshotDao vmSnapshotDao;
+ @Mock private ManagementService managementService;
+ @Mock private ManagementServerHostDao managementServerHostDao;
+
+ @InjectMocks
+ private OntapAsupManager asupManager;
+
+ // ── Common fixtures ──────────────────────────────────────────────────────
+ private StoragePoolVO pool;
+ private Map poolDetails;
+ private StorageStrategy mockStrategy;
+ private Cluster mockCluster;
+
+ @BeforeEach
+ void setUp() {
+ pool = mock(StoragePoolVO.class);
+ lenient().when(pool.getId()).thenReturn(1L);
+ lenient().when(pool.getName()).thenReturn("ontap-pool-1");
+ lenient().when(pool.getStatus()).thenReturn(StoragePoolStatus.Up);
+
+ poolDetails = new HashMap<>();
+ poolDetails.put(OntapStorageConstants.STORAGE_IP, "192.168.1.10");
+ poolDetails.put(OntapStorageConstants.PROTOCOL, "NFS3");
+ poolDetails.put(OntapStorageConstants.SVM_NAME, "svm1");
+ poolDetails.put(OntapStorageConstants.VOLUME_UUID, "fv-uuid-1");
+ poolDetails.put(OntapStorageConstants.VOLUME_NAME, "fv-name-1");
+
+ mockStrategy = mock(StorageStrategy.class);
+
+ mockCluster = mock(Cluster.class);
+ lenient().when(mockCluster.getUuid()).thenReturn("cluster-uuid-1");
+ lenient().when(mockCluster.getName()).thenReturn("ontap-cluster-1");
+ lenient().when(mockCluster.getModel()).thenReturn("AFF-A400");
+ lenient().when(mockCluster.getPlatformType())
+ .thenReturn(OntapStorageConstants.ASUP_PLATFORM_TYPE_PERFORMANCE);
+ lenient().when(managementService.getVersion()).thenReturn("4.23.0.0-SNAPSHOT");
+ lenient().when(managementServerHostDao.listAll()).thenReturn(Collections.emptyList());
+ }
+
+ // ──────────────────────────────────────────────────────────────────────────
+ // pushAsupTelemetry – no pools
+ // ──────────────────────────────────────────────────────────────────────────
+
+ @Test
+ void pushAsupTelemetry_noOntapPools_sendsNoMessages() {
+ when(storagePoolDao.findPoolsByProvider(OntapStorageConstants.ONTAP_PLUGIN_NAME))
+ .thenReturn(Collections.emptyList());
+
+ asupManager.pushAsupTelemetry();
+
+ verify(mockStrategy, never()).sendAsupMessage(any());
+ }
+
+ // ──────────────────────────────────────────────────────────────────────────
+ // Message count / event-id routing
+ // ──────────────────────────────────────────────────────────────────────────
+
+ @Test
+ void pushAsupForStoragePool_newCluster_sendsHeartbeatThenPoolMessage() {
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(mockStrategy.getClusterInfo()).thenReturn(mockCluster);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+ when(volumeDao.findNonDestroyedVolumesByPoolId(eq(1L), isNull())).thenReturn(Collections.emptyList());
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any())).thenReturn(mockStrategy);
+ asupManager.pushAsupForStoragePool(pool, new HashMap<>());
+ }
+
+ // heartbeat (event-id 0) + pool (event-id 1) = 2 messages
+ ArgumentCaptor cap = ArgumentCaptor.forClass(EmsApplicationLog.class);
+ verify(mockStrategy, times(2)).sendAsupMessage(cap.capture());
+
+ List msgs = cap.getAllValues();
+ assertEquals(OntapStorageConstants.ASUP_EVENT_ID_HEARTBEAT, msgs.get(0).getEventId());
+ assertEquals(OntapStorageConstants.ASUP_EVENT_ID_STORAGE_POOL, msgs.get(1).getEventId());
+ assertTrue(msgs.get(0).getEventDescription().contains("\"managementServerCount\":0"),
+ msgs.get(0).getEventDescription());
+ assertTrue(msgs.get(0).getEventDescription().contains("\"ontapClusterModel\":\"AFF-A400\""),
+ msgs.get(0).getEventDescription());
+ assertTrue(msgs.get(0).getEventDescription().contains("\"ontapPlatformType\":\"performance\""),
+ msgs.get(0).getEventDescription());
+ }
+
+ @Test
+ void pushAsupForStoragePool_cachedStorageIp_sendsOnlyPoolMessage() {
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+ when(volumeDao.findNonDestroyedVolumesByPoolId(eq(1L), isNull())).thenReturn(Collections.emptyList());
+
+ Map clientsByStorageIp = new HashMap<>();
+ clientsByStorageIp.put("192.168.1.10", new OntapAsupManager.AsupClusterClient(mockStrategy, mockCluster));
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ asupManager.pushAsupForStoragePool(pool, clientsByStorageIp);
+ u.verify(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any()), never());
+ }
+
+ ArgumentCaptor cap = ArgumentCaptor.forClass(EmsApplicationLog.class);
+ verify(mockStrategy, times(1)).sendAsupMessage(cap.capture());
+ assertEquals(OntapStorageConstants.ASUP_EVENT_ID_STORAGE_POOL, cap.getValue().getEventId());
+ verify(mockStrategy, never()).getClusterInfo();
+ }
+
+ @Test
+ void heartbeat_clusterModelUnknownWhenNodesGetReturnsNull() {
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(mockStrategy.getClusterInfo()).thenReturn(mockCluster);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+ when(mockCluster.getModel()).thenReturn(null);
+ when(mockCluster.getPlatformType()).thenReturn(null);
+ when(volumeDao.findNonDestroyedVolumesByPoolId(eq(1L), isNull())).thenReturn(Collections.emptyList());
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any())).thenReturn(mockStrategy);
+ asupManager.pushAsupForStoragePool(pool, new HashMap<>());
+ }
+
+ ArgumentCaptor cap = ArgumentCaptor.forClass(EmsApplicationLog.class);
+ verify(mockStrategy, times(2)).sendAsupMessage(cap.capture());
+ String heartbeat = cap.getAllValues().get(0).getEventDescription();
+ assertTrue(heartbeat.contains("\"ontapClusterModel\":\"unknown\""), heartbeat);
+ assertTrue(heartbeat.contains("\"ontapPlatformType\":\"unknown\""), heartbeat);
+ }
+
+ @Test
+ void pushAsupForStoragePool_strategyThrows_doesNotPropagateException() {
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any()))
+ .thenThrow(new RuntimeException("connection refused"));
+ asupManager.pushAsupForStoragePool(pool, new HashMap<>());
+ }
+
+ verify(mockStrategy, never()).sendAsupMessage(any());
+ }
+
+ @Test
+ void pushAsupForStoragePool_poolDetailsEmpty_skipsPool() {
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(Collections.emptyMap());
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any()))
+ .thenThrow(new RuntimeException("no details"));
+ asupManager.pushAsupForStoragePool(pool, new HashMap<>());
+ }
+
+ verify(mockStrategy, never()).sendAsupMessage(any());
+ }
+
+ // ──────────────────────────────────────────────────────────────────────────
+ // Pool message — content verification
+ // ──────────────────────────────────────────────────────────────────────────
+
+ @Test
+ void poolMessage_containsPoolNameClusterUuidAndSnapshotKeys() {
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(mockStrategy.getClusterInfo()).thenReturn(mockCluster);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+ when(volumeDao.findNonDestroyedVolumesByPoolId(eq(1L), isNull())).thenReturn(Collections.emptyList());
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any())).thenReturn(mockStrategy);
+ asupManager.pushAsupForStoragePool(pool, new HashMap<>());
+ }
+
+ String desc = capturePoolMessage();
+ assertTrue(desc.contains("ontap-pool-1"), "should contain pool name");
+ assertTrue(desc.contains("\"poolStatus\":\"Up\""), "should contain pool status");
+ assertTrue(desc.contains("cluster-uuid-1"), "should contain cluster UUID");
+ assertTrue(desc.contains("volumeSnapshotCount"), "should contain volumeSnapshotCount");
+ assertTrue(desc.contains("vmSnapshotCount"), "should contain vmSnapshotCount");
+ assertTrue(desc.contains("\"multiPrimaryStoragePoolVm\":false"), "desc=" + desc);
+ }
+
+ @Test
+ void poolMessage_includesMaintenanceStatus() {
+ when(pool.getStatus()).thenReturn(StoragePoolStatus.Maintenance);
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(mockStrategy.getClusterInfo()).thenReturn(mockCluster);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+ when(volumeDao.findNonDestroyedVolumesByPoolId(eq(1L), isNull())).thenReturn(Collections.emptyList());
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any())).thenReturn(mockStrategy);
+ asupManager.pushAsupForStoragePool(pool, new HashMap<>());
+ }
+
+ String desc = capturePoolMessage();
+ assertTrue(desc.contains("\"poolStatus\":\"Maintenance\""), "desc=" + desc);
+ }
+
+ @Test
+ void poolMessage_volumeSnapshots_zeroWhenNoVolumes() {
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(mockStrategy.getClusterInfo()).thenReturn(mockCluster);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+ when(volumeDao.findNonDestroyedVolumesByPoolId(eq(1L), isNull())).thenReturn(Collections.emptyList());
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any())).thenReturn(mockStrategy);
+ asupManager.pushAsupForStoragePool(pool, new HashMap<>());
+ }
+
+ String desc = capturePoolMessage();
+ assertTrue(desc.contains("\"volumeSnapshotCount\":0"), "desc=" + desc);
+ assertTrue(desc.contains("\"vmSnapshotCount\":0"), "desc=" + desc);
+ }
+
+ @Test
+ void poolMessage_multiPrimaryStoragePoolVm_trueWhenDaoReportsSpan() {
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(mockStrategy.getClusterInfo()).thenReturn(mockCluster);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+ when(volumeDao.findNonDestroyedVolumesByPoolId(eq(1L), isNull())).thenReturn(Collections.emptyList());
+ when(volumeDao.hasMultiPrimaryStoragePoolVm(1L)).thenReturn(true);
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any())).thenReturn(mockStrategy);
+ asupManager.pushAsupForStoragePool(pool, new HashMap<>());
+ }
+
+ String desc = capturePoolMessage();
+ assertTrue(desc.contains("\"multiPrimaryStoragePoolVm\":true"), "desc=" + desc);
+ }
+
+ @Test
+ void poolMessage_volumeSnapshots_countExcludesDestroyed() {
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(mockStrategy.getClusterInfo()).thenReturn(mockCluster);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+
+ // instanceId=null → no VM IDs → vmSnapshotDao never called
+ VolumeVO vol = mockVolume(10L, null, 10_737_418_240L);
+ when(volumeDao.findNonDestroyedVolumesByPoolId(eq(1L), isNull())).thenReturn(Collections.singletonList(vol));
+
+ // 2 active + 1 Destroyed → only 2 counted
+ SnapshotVO s1 = makeSnapshot(1L, 10L, Snapshot.State.BackedUp);
+ SnapshotVO s2 = makeSnapshot(2L, 10L, Snapshot.State.Creating);
+ SnapshotVO s3 = makeSnapshot(3L, 10L, Snapshot.State.Destroyed);
+ when(snapshotDao.searchByVolumes(anyList())).thenReturn(Arrays.asList(s1, s2, s3));
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any())).thenReturn(mockStrategy);
+ asupManager.pushAsupForStoragePool(pool, new HashMap<>());
+ }
+
+ String desc = capturePoolMessage();
+ assertTrue(desc.contains("\"volumeSnapshotCount\":2"), "Destroyed must be excluded; desc=" + desc);
+ verify(volumeDao, times(1)).findNonDestroyedVolumesByPoolId(eq(1L), isNull());
+ }
+
+ // ──────────────────────────────────────────────────────────────────────────
+ // Pool message — VM-snapshot fields (vmSnapshotCount)
+ // ──────────────────────────────────────────────────────────────────────────
+
+ @Test
+ void poolMessage_vmSnapshots_countsActiveSnapshotsAcrossDistinctVMs() {
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(mockStrategy.getClusterInfo()).thenReturn(mockCluster);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+
+ VolumeVO vol1 = mockVolume(10L, 100L, 10_737_418_240L); // vm 100
+ VolumeVO vol2 = mockVolume(20L, 200L, 10_737_418_240L); // vm 200
+ when(volumeDao.findNonDestroyedVolumesByPoolId(eq(1L), isNull()))
+ .thenReturn(Arrays.asList(vol1, vol2));
+ when(snapshotDao.searchByVolumes(anyList())).thenReturn(Collections.emptyList());
+
+ // 2 active VM snapshots; 1 is Expunging (should be excluded)
+ VMSnapshotVO vmSnap1 = makeVmSnapshot(VMSnapshot.State.Ready, null);
+ VMSnapshotVO vmSnap2 = makeVmSnapshot(VMSnapshot.State.Ready, null);
+ VMSnapshotVO vmSnapExp = makeVmSnapshot(VMSnapshot.State.Expunging, null);
+ when(vmSnapshotDao.searchByVms(anyList())).thenReturn(Arrays.asList(vmSnap1, vmSnap2, vmSnapExp));
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any())).thenReturn(mockStrategy);
+ asupManager.pushAsupForStoragePool(pool, new HashMap<>());
+ }
+
+ String desc = capturePoolMessage();
+ assertTrue(desc.contains("\"vmSnapshotCount\":2"), "Expunging must be excluded; desc=" + desc);
+ }
+
+ @Test
+ void poolMessage_vmSnapshots_removedSnapshotsExcluded() {
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(mockStrategy.getClusterInfo()).thenReturn(mockCluster);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+
+ VolumeVO vol = mockVolume(10L, 100L, 1_073_741_824L);
+ when(volumeDao.findNonDestroyedVolumesByPoolId(eq(1L), isNull())).thenReturn(Collections.singletonList(vol));
+ when(snapshotDao.searchByVolumes(anyList())).thenReturn(Collections.emptyList());
+
+ VMSnapshotVO active = makeVmSnapshot(VMSnapshot.State.Ready, null);
+ VMSnapshotVO deleted = makeVmSnapshot(VMSnapshot.State.Ready, new java.util.Date()); // removed
+ when(vmSnapshotDao.searchByVms(anyList())).thenReturn(Arrays.asList(active, deleted));
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any())).thenReturn(mockStrategy);
+ asupManager.pushAsupForStoragePool(pool, new HashMap<>());
+ }
+
+ String desc = capturePoolMessage();
+ assertTrue(desc.contains("\"vmSnapshotCount\":1"), "removed snapshots must be excluded; desc=" + desc);
+ }
+
+ @Test
+ void poolMessage_vmSnapshots_zeroWhenNoVmIdsOnPool() {
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(mockStrategy.getClusterInfo()).thenReturn(mockCluster);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+
+ // instanceId=null → detached data disk → vmSnapshotDao must NOT be called
+ VolumeVO vol = mockVolume(10L, null, 1_073_741_824L);
+ when(volumeDao.findNonDestroyedVolumesByPoolId(eq(1L), isNull())).thenReturn(Collections.singletonList(vol));
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any())).thenReturn(mockStrategy);
+ asupManager.pushAsupForStoragePool(pool, new HashMap<>());
+ }
+
+ String desc = capturePoolMessage();
+ assertTrue(desc.contains("\"vmSnapshotCount\":0"), "desc=" + desc);
+ verify(vmSnapshotDao, never()).searchByVms(anyList());
+ }
+
+ @Test
+ void poolMessage_vmSnapshots_countedOnlyOnRootDiskPool() {
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(mockStrategy.getClusterInfo()).thenReturn(mockCluster);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+
+ // Data disk of a VM whose ROOT lives on another pool — must not count that VM snapshot.
+ VolumeVO dataDisk = mockVolume(20L, 100L, 1_073_741_824L, Volume.Type.DATADISK);
+ when(volumeDao.findNonDestroyedVolumesByPoolId(eq(1L), isNull()))
+ .thenReturn(Collections.singletonList(dataDisk));
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any())).thenReturn(mockStrategy);
+ asupManager.pushAsupForStoragePool(pool, new HashMap<>());
+ }
+
+ String desc = capturePoolMessage();
+ assertTrue(desc.contains("\"vmSnapshotCount\":0"), "desc=" + desc);
+ verify(vmSnapshotDao, never()).searchByVms(anyList());
+ }
+
+ // ──────────────────────────────────────────────────────────────────────────
+ // Best-effort: DAO failures must never suppress the pool message
+ // ──────────────────────────────────────────────────────────────────────────
+
+ @Test
+ void poolMessage_snapshotDaoThrows_poolMessageStillSent() {
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(mockStrategy.getClusterInfo()).thenReturn(mockCluster);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+ when(volumeDao.findNonDestroyedVolumesByPoolId(eq(1L), isNull()))
+ .thenThrow(new RuntimeException("DB error"));
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any())).thenReturn(mockStrategy);
+ asupManager.pushAsupForStoragePool(pool, new HashMap<>());
+ }
+
+ // heartbeat + pool both sent even when DAO fails
+ verify(mockStrategy, times(2)).sendAsupMessage(any());
+ }
+
+ // ──────────────────────────────────────────────────────────────────────────
+ // Multi-pool: same cluster → single heartbeat
+ // ──────────────────────────────────────────────────────────────────────────
+
+ @Test
+ void twoPoolsSameCluster_singleHeartbeat() {
+ StoragePoolVO pool2 = mock(StoragePoolVO.class);
+ when(pool2.getId()).thenReturn(2L);
+ when(pool2.getName()).thenReturn("ontap-pool-2");
+
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(storagePoolDetailsDao.listDetailsKeyPairs(2L)).thenReturn(new HashMap<>(poolDetails));
+ when(mockStrategy.getClusterInfo()).thenReturn(mockCluster);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+ when(volumeDao.findNonDestroyedVolumesByPoolId(anyLong(), isNull())).thenReturn(Collections.emptyList());
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any())).thenReturn(mockStrategy);
+
+ Map clientsByStorageIp = new HashMap<>();
+ asupManager.pushAsupForStoragePool(pool, clientsByStorageIp);
+ asupManager.pushAsupForStoragePool(pool2, clientsByStorageIp);
+
+ u.verify(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any()), times(1));
+ }
+
+ verify(mockStrategy, times(1)).getClusterInfo();
+ // 1 heartbeat + 2 pool messages = 3 total
+ ArgumentCaptor cap = ArgumentCaptor.forClass(EmsApplicationLog.class);
+ verify(mockStrategy, times(3)).sendAsupMessage(cap.capture());
+
+ long heartbeats = cap.getAllValues().stream()
+ .filter(m -> OntapStorageConstants.ASUP_EVENT_ID_HEARTBEAT.equals(m.getEventId()))
+ .count();
+ assertEquals(1, heartbeats, "exactly 1 heartbeat for two pools sharing a cluster");
+ }
+
+ @Test
+ void twoPoolsDifferentStorageIp_resolvesStrategyPerCluster() {
+ StoragePoolVO pool2 = mock(StoragePoolVO.class);
+ when(pool2.getId()).thenReturn(2L);
+ when(pool2.getName()).thenReturn("ontap-pool-2");
+
+ Map otherCluster = new HashMap<>(poolDetails);
+ otherCluster.put(OntapStorageConstants.STORAGE_IP, "192.168.1.20");
+
+ Cluster cluster2 = mock(Cluster.class);
+ when(cluster2.getUuid()).thenReturn("cluster-uuid-2");
+
+ StorageStrategy strategy2 = mock(StorageStrategy.class);
+ when(strategy2.getClusterInfo()).thenReturn(cluster2);
+ when(strategy2.getClusterVersion(cluster2)).thenReturn("9.16.1");
+
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(storagePoolDetailsDao.listDetailsKeyPairs(2L)).thenReturn(otherCluster);
+ when(mockStrategy.getClusterInfo()).thenReturn(mockCluster);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+ when(volumeDao.findNonDestroyedVolumesByPoolId(anyLong(), isNull())).thenReturn(Collections.emptyList());
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(poolDetails)).thenReturn(mockStrategy);
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(otherCluster)).thenReturn(strategy2);
+
+ Map clientsByStorageIp = new HashMap<>();
+ asupManager.pushAsupForStoragePool(pool, clientsByStorageIp);
+ asupManager.pushAsupForStoragePool(pool2, clientsByStorageIp);
+
+ u.verify(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any()), times(2));
+ }
+
+ verify(mockStrategy, times(1)).getClusterInfo();
+ verify(strategy2, times(1)).getClusterInfo();
+ verify(mockStrategy, times(2)).sendAsupMessage(any());
+ verify(strategy2, times(2)).sendAsupMessage(any());
+ }
+
+ // ──────────────────────────────────────────────────────────────────────────
+ // Common EMS envelope fields
+ // ──────────────────────────────────────────────────────────────────────────
+
+ @Test
+ void allMessages_haveCorrectEnvelopeFields() {
+ when(storagePoolDetailsDao.listDetailsKeyPairs(1L)).thenReturn(poolDetails);
+ when(mockStrategy.getClusterInfo()).thenReturn(mockCluster);
+ when(mockStrategy.getClusterVersion(mockCluster)).thenReturn("9.17.1");
+ when(volumeDao.findNonDestroyedVolumesByPoolId(eq(1L), isNull())).thenReturn(Collections.emptyList());
+
+ try (MockedStatic u = mockStatic(OntapStorageUtils.class)) {
+ u.when(() -> OntapStorageUtils.resolveStrategyFromPoolDetails(any())).thenReturn(mockStrategy);
+ asupManager.pushAsupForStoragePool(pool, new HashMap<>());
+ }
+
+ ArgumentCaptor cap = ArgumentCaptor.forClass(EmsApplicationLog.class);
+ verify(mockStrategy, times(2)).sendAsupMessage(cap.capture());
+
+ for (EmsApplicationLog msg : cap.getAllValues()) {
+ assertEquals(OntapStorageConstants.ASUP_EVENT_SOURCE, msg.getEventSource());
+ assertEquals(OntapStorageConstants.ASUP_CATEGORY, msg.getCategory());
+ assertEquals(OntapStorageConstants.ASUP_SEVERITY, msg.getSeverity());
+ assertFalse(msg.getAutosupportRequired(), "autosupport_required should be false");
+ assertEquals(asupManager.getComputerName(), msg.getComputerName());
+ assertEquals(asupManager.getCloudStackVersion(), msg.getAppVersion());
+ }
+ }
+
+ // ──────────────────────────────────────────────────────────────────────────
+ // Config defaults
+ // ──────────────────────────────────────────────────────────────────────────
+
+ @Test
+ void asupIntervalHours_defaultIsProductionValue() {
+ assertEquals(4, OntapStorageConstants.ASUP_MIN_INTERVAL_HOURS);
+ assertEquals(24, OntapStorageConstants.ASUP_DEFAULT_INTERVAL_HOURS);
+ assertEquals(String.valueOf(OntapStorageConstants.ASUP_DEFAULT_INTERVAL_HOURS),
+ OntapConfigurationManager.AsupIntervalHours.defaultValue());
+ }
+
+ @Test
+ void asupIntervalHours_keyIsAutosupportInterval() {
+ assertEquals(OntapStorageConstants.ASUP_INTERVAL_CONFIG_KEY,
+ OntapConfigurationManager.AsupIntervalHours.key());
+ assertEquals("ontap.autosupport.interval", OntapConfigurationManager.AsupIntervalHours.key());
+ }
+
+ @Test
+ void asupIntervalHours_descriptionIncludesAllowedRange() {
+ String description = OntapConfigurationManager.AsupIntervalHours.description();
+ assertTrue(description.contains(String.valueOf(OntapStorageConstants.ASUP_MIN_INTERVAL_HOURS)));
+ assertTrue(description.contains(String.valueOf(OntapStorageConstants.ASUP_MAX_INTERVAL_HOURS)));
+ assertTrue(description.contains(String.valueOf(OntapStorageConstants.ASUP_DISABLED_INTERVAL_HOURS)));
+ assertTrue(description.contains("1 week"), description);
+ }
+
+ @Test
+ void validateAsupInterval_acceptsDisabledMinMaxAndDefault() {
+ OntapConfigurationManager.AsupIntervalHours.validateValue(String.valueOf(OntapStorageConstants.ASUP_DISABLED_INTERVAL_HOURS));
+ OntapConfigurationManager.AsupIntervalHours.validateValue(String.valueOf(OntapStorageConstants.ASUP_MIN_INTERVAL_HOURS));
+ OntapConfigurationManager.AsupIntervalHours.validateValue(String.valueOf(OntapStorageConstants.ASUP_MAX_INTERVAL_HOURS));
+ OntapConfigurationManager.AsupIntervalHours.validateValue(String.valueOf(OntapStorageConstants.ASUP_DEFAULT_INTERVAL_HOURS));
+ }
+
+ @Test
+ void validateAsupInterval_rejectsOutOfRangeAndNonInteger() {
+ assertThrows(InvalidParameterValueException.class, () -> OntapConfigurationManager.AsupIntervalHours.validateValue("-1"));
+ assertThrows(InvalidParameterValueException.class, () -> OntapConfigurationManager.AsupIntervalHours.validateValue("1"));
+ assertThrows(InvalidParameterValueException.class, () -> OntapConfigurationManager.AsupIntervalHours.validateValue("169"));
+ assertThrows(InvalidParameterValueException.class, () -> OntapConfigurationManager.AsupIntervalHours.validateValue("abc"));
+ assertThrows(InvalidParameterValueException.class, () -> OntapConfigurationManager.AsupIntervalHours.validateValue(""));
+ }
+
+ @Test
+ void getAsupIntervalHours_fallsBackOutsideRange() {
+ assertEquals(OntapStorageConstants.ASUP_DEFAULT_INTERVAL_HOURS,
+ asupManager.getAsupIntervalHours(null));
+ assertEquals(OntapStorageConstants.ASUP_DISABLED_INTERVAL_HOURS,
+ asupManager.getAsupIntervalHours(OntapStorageConstants.ASUP_DISABLED_INTERVAL_HOURS));
+ assertEquals(OntapStorageConstants.ASUP_DEFAULT_INTERVAL_HOURS,
+ asupManager.getAsupIntervalHours(1));
+ assertEquals(OntapStorageConstants.ASUP_DEFAULT_INTERVAL_HOURS,
+ asupManager.getAsupIntervalHours(2));
+ assertEquals(OntapStorageConstants.ASUP_DEFAULT_INTERVAL_HOURS,
+ asupManager.getAsupIntervalHours(3));
+ assertEquals(OntapStorageConstants.ASUP_DEFAULT_INTERVAL_HOURS,
+ asupManager.getAsupIntervalHours(-1));
+ assertEquals(OntapStorageConstants.ASUP_DEFAULT_INTERVAL_HOURS,
+ asupManager.getAsupIntervalHours(169));
+ assertEquals(OntapStorageConstants.ASUP_MIN_INTERVAL_HOURS,
+ asupManager.getAsupIntervalHours(OntapStorageConstants.ASUP_MIN_INTERVAL_HOURS));
+ assertEquals(OntapStorageConstants.ASUP_MAX_INTERVAL_HOURS,
+ asupManager.getAsupIntervalHours(OntapStorageConstants.ASUP_MAX_INTERVAL_HOURS));
+ assertEquals(25, asupManager.getAsupIntervalHours(25));
+ }
+
+ // ──────────────────────────────────────────────────────────────────────────
+ // OntapAsupTask / schedule
+ // ──────────────────────────────────────────────────────────────────────────
+
+ @Test
+ void millisUntilNextPush_zeroWhenOverdue() {
+ asupManager.lastPushTime = Instant.EPOCH; // never pushed
+ assertEquals(0L, asupManager.millisUntilNextPush());
+ }
+
+ @Test
+ void millisUntilNextPush_remainderOfConfiguredInterval() {
+ asupManager.lastPushTime = Instant.now();
+ long remaining = asupManager.millisUntilNextPush();
+ long configured = Duration.ofHours(OntapStorageConstants.ASUP_DEFAULT_INTERVAL_HOURS).toMillis();
+ assertTrue(remaining > configured - 5000L && remaining <= configured,
+ "remaining=" + remaining);
+ }
+
+ @Test
+ void asupTask_stampsLastPushTimeAndPushes() {
+ asupManager.lastPushTime = Instant.EPOCH; // never pushed
+ when(storagePoolDao.findPoolsByProvider(OntapStorageConstants.ONTAP_PLUGIN_NAME))
+ .thenReturn(Collections.emptyList());
+ Instant before = Instant.now();
+ OntapAsupManager.OntapAsupTask task = asupManager.new OntapAsupTask();
+ task.run();
+ verify(storagePoolDao).findPoolsByProvider(OntapStorageConstants.ONTAP_PLUGIN_NAME);
+ assertFalse(asupManager.lastPushTime.equals(Instant.EPOCH));
+ assertFalse(asupManager.lastPushTime.isBefore(before));
+ }
+
+ // ──────────────────────────────────────────────────────────────────────────
+ // Utility helpers
+ // ──────────────────────────────────────────────────────────────────────────
+
+ @Test
+ void getCloudStackVersion_returnsManagementServiceVersion() {
+ assertEquals("4.23.0.0-SNAPSHOT", asupManager.getCloudStackVersion());
+ }
+
+ @Test
+ void getCloudStackVersion_blank_returnsUnknown() {
+ when(managementService.getVersion()).thenReturn(" ");
+ assertEquals(OntapStorageConstants.ASUP_UNKNOWN, asupManager.getCloudStackVersion());
+ }
+
+ @Test
+ void getManagementServerCount_returnsRegisteredHostCount() {
+ when(managementServerHostDao.listAll()).thenReturn(Arrays.asList(
+ mock(ManagementServerHostVO.class), mock(ManagementServerHostVO.class)));
+ assertEquals(2, asupManager.getManagementServerCount());
+ }
+
+ @Test
+ void getComputerName_returnsNonEmpty() {
+ String host = asupManager.getComputerName();
+ assertNotNull(host);
+ assertFalse(host.isEmpty());
+ }
+
+ @Test
+ void getOperatingSystem_returnsNonEmpty() {
+ String os = asupManager.getOperatingSystem();
+ assertNotNull(os);
+ assertFalse(os.isEmpty());
+ }
+
+ // ──────────────────────────────────────────────────────────────────────────
+ // Helpers
+ // ──────────────────────────────────────────────────────────────────────────
+
+ /**
+ * Captures and returns the event-id 1 (pool) message description.
+ * Expects exactly 2 messages to have been sent (heartbeat + pool).
+ */
+ private String capturePoolMessage() {
+ ArgumentCaptor cap = ArgumentCaptor.forClass(EmsApplicationLog.class);
+ verify(mockStrategy, times(2)).sendAsupMessage(cap.capture());
+ EmsApplicationLog poolMsg = cap.getAllValues().get(1);
+ assertEquals(OntapStorageConstants.ASUP_EVENT_ID_STORAGE_POOL, poolMsg.getEventId());
+ String desc = poolMsg.getEventDescription();
+ assertNotNull(desc);
+ return desc;
+ }
+
+ /**
+ * Creates a mock VolumeVO with state=Ready so that CS_VOLUME_STATES filter includes it
+ * and getSize() is exercised (avoiding UnnecessaryStubbingException in strict mode).
+ */
+ private VolumeVO mockVolume(long id, Long instanceId, long size) {
+ return mockVolume(id, instanceId, size, Volume.Type.ROOT);
+ }
+
+ private VolumeVO mockVolume(long id, Long instanceId, long size, Volume.Type type) {
+ VolumeVO vol = mock(VolumeVO.class);
+ when(vol.getId()).thenReturn(id);
+ lenient().when(vol.getInstanceId()).thenReturn(instanceId);
+ when(vol.getSize()).thenReturn(size);
+ when(vol.getState()).thenReturn(Volume.State.Ready);
+ when(vol.getVolumeType()).thenReturn(type);
+ return vol;
+ }
+
+ /** Creates a mock SnapshotVO with the given id, volumeId and state. */
+ private SnapshotVO makeSnapshot(long id, long volumeId, Snapshot.State state) {
+ SnapshotVO snap = mock(SnapshotVO.class);
+ when(snap.getState()).thenReturn(state);
+ return snap;
+ }
+
+ /** Creates a mock VMSnapshotVO with the given state and removed timestamp. */
+ private VMSnapshotVO makeVmSnapshot(VMSnapshot.State state, java.util.Date removed) {
+ VMSnapshotVO vmSnap = mock(VMSnapshotVO.class);
+ when(vmSnap.getState()).thenReturn(state);
+ lenient().when(vmSnap.getRemoved()).thenReturn(removed);
+ return vmSnap;
+ }
+}
diff --git a/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java b/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java
index 3518d7fe1bc8..ba4d88fede84 100644
--- a/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java
+++ b/plugins/storage/volume/ontap/src/test/java/org/apache/cloudstack/storage/service/StorageStrategyTest.java
@@ -27,6 +27,7 @@
import java.util.Map;
import org.apache.cloudstack.storage.feign.client.AggregateFeignClient;
+import org.apache.cloudstack.storage.feign.client.ClusterFeignClient;
import org.apache.cloudstack.storage.feign.client.JobFeignClient;
import org.apache.cloudstack.storage.feign.client.NetworkFeignClient;
import org.apache.cloudstack.storage.feign.client.SANFeignClient;
@@ -34,6 +35,8 @@
import org.apache.cloudstack.storage.feign.client.SvmFeignClient;
import org.apache.cloudstack.storage.feign.client.VolumeFeignClient;
import org.apache.cloudstack.storage.feign.model.Aggregate;
+import org.apache.cloudstack.storage.feign.model.Cluster;
+import org.apache.cloudstack.storage.feign.model.ClusterNode;
import org.apache.cloudstack.storage.feign.model.IpInterface;
import org.apache.cloudstack.storage.feign.model.IscsiService;
import org.apache.cloudstack.storage.feign.model.Job;
@@ -48,6 +51,7 @@
import org.apache.cloudstack.storage.utils.OntapStorageConstants;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import org.junit.jupiter.api.BeforeEach;
@@ -99,6 +103,9 @@ public class StorageStrategyTest {
@Mock
private SnapshotFeignClient snapshotFeignClient;
+ @Mock
+ private ClusterFeignClient clusterFeignClient;
+
private TestableStorageStrategy storageStrategy;
// Concrete implementation for testing abstract class
@@ -110,7 +117,8 @@ public TestableStorageStrategy(OntapStorage ontapStorage,
JobFeignClient jobFeignClient,
NetworkFeignClient networkFeignClient,
SANFeignClient sanFeignClient,
- SnapshotFeignClient snapshotFeignClient) {
+ SnapshotFeignClient snapshotFeignClient,
+ ClusterFeignClient clusterFeignClient) {
super(ontapStorage);
// Use reflection to replace the private Feign client fields with mocked ones
injectMockedClient("aggregateFeignClient", aggregateFeignClient);
@@ -120,6 +128,7 @@ public TestableStorageStrategy(OntapStorage ontapStorage,
injectMockedClient("networkFeignClient", networkFeignClient);
injectMockedClient("sanFeignClient", sanFeignClient);
injectMockedClient("snapshotFeignClient", snapshotFeignClient);
+ injectMockedClient("clusterFeignClient", clusterFeignClient);
}
private void injectMockedClient(String fieldName, Object mockedClient) {
@@ -205,7 +214,7 @@ void setUp() {
// For testing, we'll need to mock the FeignClientFactory behavior
storageStrategy = new TestableStorageStrategy(ontapStorage,
aggregateFeignClient, volumeFeignClient, svmFeignClient,
- jobFeignClient, networkFeignClient, sanFeignClient, snapshotFeignClient);
+ jobFeignClient, networkFeignClient, sanFeignClient, snapshotFeignClient, clusterFeignClient);
}
// ========== connect() Tests ==========
@@ -264,6 +273,140 @@ public void testConnect_operationsOnly_skipsAggregateValidation() {
assertTrue(result, "connect() should succeed for an online aggregate even when its free space is below the pool capacity");
}
+ @Test
+ public void testGetClusterInfo_dedupesIdenticalNodeModels() {
+ Cluster cluster = stubClusterGet();
+ ClusterNode node1 = new ClusterNode();
+ node1.setModel("AFF-A400");
+ ClusterNode node2 = new ClusterNode();
+ node2.setModel("AFF-A400");
+ when(clusterFeignClient.getClusterNodes(anyString(), anyMap()))
+ .thenReturn(new OntapResponse<>(List.of(node1, node2)));
+
+ Cluster result = storageStrategy.getClusterInfo();
+ assertEquals(cluster, result);
+ assertEquals("AFF-A400", result.getModel());
+ }
+
+ @Test
+ public void testGetClusterInfo_joinsDistinctModels() {
+ stubClusterGet();
+ ClusterNode node1 = new ClusterNode();
+ node1.setModel("AFF-A400");
+ ClusterNode node2 = new ClusterNode();
+ node2.setModel("FAS8300");
+ when(clusterFeignClient.getClusterNodes(anyString(), anyMap()))
+ .thenReturn(new OntapResponse<>(List.of(node1, node2)));
+
+ assertEquals("AFF-A400,FAS8300", storageStrategy.getClusterInfo().getModel());
+ }
+
+ @Test
+ public void testGetClusterInfo_allFlashPerformance() {
+ stubClusterGet();
+ when(clusterFeignClient.getClusterNodes(anyString(), anyMap()))
+ .thenReturn(new OntapResponse<>(List.of(
+ clusterNode("AFF-A400", true, true, false),
+ clusterNode("AFF-A400", true, true, false))));
+
+ Cluster result = storageStrategy.getClusterInfo();
+ assertEquals("AFF-A400", result.getModel());
+ assertEquals(OntapStorageConstants.ASUP_PLATFORM_TYPE_PERFORMANCE, result.getPlatformType());
+ }
+
+ @Test
+ public void testGetClusterInfo_allFlashCapacity() {
+ stubClusterGet();
+ when(clusterFeignClient.getClusterNodes(anyString(), anyMap()))
+ .thenReturn(new OntapResponse<>(List.of(
+ clusterNode("AFF-C800", true, false, true),
+ clusterNode("AFF-C800", true, false, true))));
+
+ Cluster result = storageStrategy.getClusterInfo();
+ assertEquals("AFF-C800", result.getModel());
+ assertEquals(OntapStorageConstants.ASUP_PLATFORM_TYPE_CAPACITY, result.getPlatformType());
+ }
+
+ @Test
+ public void testGetClusterInfo_notAllFlashIsFas() {
+ stubClusterGet();
+ when(clusterFeignClient.getClusterNodes(anyString(), anyMap()))
+ .thenReturn(new OntapResponse<>(List.of(
+ clusterNode("FAS8300", false, false, false),
+ clusterNode("FAS8300", false, false, false))));
+
+ Cluster result = storageStrategy.getClusterInfo();
+ assertEquals("FAS8300", result.getModel());
+ assertEquals(OntapStorageConstants.ASUP_PLATFORM_TYPE_FAS, result.getPlatformType());
+ }
+
+ @Test
+ public void testGetClusterInfo_mixedPersonalitiesIsComposite() {
+ stubClusterGet();
+ when(clusterFeignClient.getClusterNodes(anyString(), anyMap()))
+ .thenReturn(new OntapResponse<>(List.of(
+ clusterNode("AFF-A400", true, true, false),
+ clusterNode("AFF-A400", true, true, false),
+ clusterNode("FAS8300", false, false, false),
+ clusterNode("FAS8300", false, false, false))));
+
+ Cluster result = storageStrategy.getClusterInfo();
+ assertEquals("AFF-A400,FAS8300", result.getModel());
+ assertEquals(OntapStorageConstants.ASUP_PLATFORM_TYPE_COMPOSITE, result.getPlatformType());
+ }
+
+ @Test
+ public void testGetClusterInfo_missingAllFlashFlagLeavesPlatformUnset() {
+ stubClusterGet();
+ when(clusterFeignClient.getClusterNodes(anyString(), anyMap()))
+ .thenReturn(new OntapResponse<>(List.of(
+ clusterNode("AFF-A400", null, null, null))));
+
+ Cluster result = storageStrategy.getClusterInfo();
+ assertEquals("AFF-A400", result.getModel());
+ assertNull(result.getPlatformType());
+ }
+
+ @Test
+ public void testGetClusterInfo_missingFlagDoesNotChangeKnownPlatform() {
+ stubClusterGet();
+ when(clusterFeignClient.getClusterNodes(anyString(), anyMap()))
+ .thenReturn(new OntapResponse<>(List.of(
+ clusterNode("AFF-A400", true, true, false),
+ clusterNode("AFF-A400", null, null, null))));
+
+ Cluster result = storageStrategy.getClusterInfo();
+ assertEquals("AFF-A400", result.getModel());
+ assertEquals(OntapStorageConstants.ASUP_PLATFORM_TYPE_PERFORMANCE, result.getPlatformType());
+ }
+
+ @Test
+ public void testGetClusterInfo_nodesGetFailureLeavesModelUnset() {
+ stubClusterGet();
+ when(clusterFeignClient.getClusterNodes(anyString(), anyMap()))
+ .thenThrow(new RuntimeException("connection refused"));
+
+ Cluster result = storageStrategy.getClusterInfo();
+ assertNotNull(result);
+ assertNull(result.getModel());
+ assertNull(result.getPlatformType());
+ }
+
+ private Cluster stubClusterGet() {
+ Cluster cluster = new Cluster();
+ when(clusterFeignClient.getCluster(anyString(), eq(true))).thenReturn(cluster);
+ return cluster;
+ }
+
+ private static ClusterNode clusterNode(String model, Boolean allFlash, Boolean performance, Boolean capacity) {
+ ClusterNode node = new ClusterNode();
+ node.setModel(model);
+ node.setAllFlashOptimized(allFlash);
+ node.setPerformanceOptimized(performance);
+ node.setCapacityOptimized(capacity);
+ return node;
+ }
+
@Test
public void testConnect_noOnlineAggregates() {
// Setup - aggregate assigned to the SVM exists but is not ONLINE
@@ -359,7 +502,7 @@ public void testConnect_iscsiNotEnabled() {
"svm1", 5000000000L, ProtocolType.ISCSI);
storageStrategy = new TestableStorageStrategy(iscsiStorage,
aggregateFeignClient, volumeFeignClient, svmFeignClient,
- jobFeignClient, networkFeignClient, sanFeignClient, snapshotFeignClient);
+ jobFeignClient, networkFeignClient, sanFeignClient, snapshotFeignClient, clusterFeignClient);
Svm svm = new Svm();
svm.setName("svm1");
@@ -703,7 +846,7 @@ public void testGetStoragePath_iscsi() {
"svm1", null, ProtocolType.ISCSI);
storageStrategy = new TestableStorageStrategy(iscsiStorage,
aggregateFeignClient, volumeFeignClient, svmFeignClient,
- jobFeignClient, networkFeignClient, sanFeignClient, snapshotFeignClient);
+ jobFeignClient, networkFeignClient, sanFeignClient, snapshotFeignClient, clusterFeignClient);
IscsiService.IscsiServiceTarget target = new IscsiService.IscsiServiceTarget();
target.setName("iqn.1992-08.com.netapp:sn.123456:vs.1");
@@ -733,7 +876,7 @@ public void testGetStoragePath_iscsi_noService() {
"svm1", null, ProtocolType.ISCSI);
storageStrategy = new TestableStorageStrategy(iscsiStorage,
aggregateFeignClient, volumeFeignClient, svmFeignClient,
- jobFeignClient, networkFeignClient, sanFeignClient, snapshotFeignClient);
+ jobFeignClient, networkFeignClient, sanFeignClient, snapshotFeignClient, clusterFeignClient);
OntapResponse emptyResponse = new OntapResponse<>();
emptyResponse.setRecords(new ArrayList<>());
@@ -754,7 +897,7 @@ public void testGetStoragePath_iscsi_noTargetIqn() {
"svm1", null, ProtocolType.ISCSI);
storageStrategy = new TestableStorageStrategy(iscsiStorage,
aggregateFeignClient, volumeFeignClient, svmFeignClient,
- jobFeignClient, networkFeignClient, sanFeignClient, snapshotFeignClient);
+ jobFeignClient, networkFeignClient, sanFeignClient, snapshotFeignClient, clusterFeignClient);
IscsiService iscsiService = new IscsiService();
iscsiService.setTarget(null);
@@ -807,7 +950,7 @@ public void testGetNetworkInterface_iscsi() {
"svm1", null, ProtocolType.ISCSI);
storageStrategy = new TestableStorageStrategy(iscsiStorage,
aggregateFeignClient, volumeFeignClient, svmFeignClient,
- jobFeignClient, networkFeignClient, sanFeignClient, snapshotFeignClient);
+ jobFeignClient, networkFeignClient, sanFeignClient, snapshotFeignClient, clusterFeignClient);
IpInterface.IpInfo ipInfo = new IpInterface.IpInfo();
ipInfo.setAddress("192.168.1.51");
@@ -883,7 +1026,7 @@ public void testGetNetworkInterface_iscsi_lifDown() {
"svm1", null, ProtocolType.ISCSI);
storageStrategy = new TestableStorageStrategy(iscsiStorage,
aggregateFeignClient, volumeFeignClient, svmFeignClient,
- jobFeignClient, networkFeignClient, sanFeignClient, snapshotFeignClient);
+ jobFeignClient, networkFeignClient, sanFeignClient, snapshotFeignClient, clusterFeignClient);
IpInterface.IpInfo ipInfo = new IpInterface.IpInfo();
ipInfo.setAddress("192.168.1.51");