|
32 | 32 | import javax.net.ssl.HostnameVerifier; |
33 | 33 | import javax.net.ssl.SSLContext; |
34 | 34 |
|
| 35 | +import org.apache.commons.collections4.CollectionUtils; |
35 | 36 | import org.apache.http.Header; |
36 | 37 | import org.apache.http.NameValuePair; |
37 | 38 | import org.apache.cloudstack.storage.datastore.adapter.ProviderAdapter; |
@@ -491,18 +492,49 @@ public void disconnect() { |
491 | 492 | @Override |
492 | 493 | public ProviderVolumeStorageStats getManagedStorageStats() { |
493 | 494 | FlashArrayPod pod = getVolumeNamespace(this.pod); |
494 | | - // just in case |
495 | | - if (pod == null || pod.getFootprint() == 0) { |
| 495 | + if (pod == null) { |
496 | 496 | return null; |
497 | 497 | } |
498 | 498 | Long capacityBytes = pod.getQuotaLimit(); |
499 | | - Long usedBytes = pod.getQuotaLimit() - (pod.getQuotaLimit() - pod.getFootprint()); |
| 499 | + if (capacityBytes == null || capacityBytes == 0) { |
| 500 | + // Pod has no explicit quota set; report the array total physical |
| 501 | + // capacity so the CloudStack allocator has a real ceiling to plan |
| 502 | + // against rather than bailing out with a zero-capacity pool. |
| 503 | + capacityBytes = getArrayTotalCapacity(); |
| 504 | + } |
| 505 | + if (capacityBytes == null || capacityBytes == 0) { |
| 506 | + return null; |
| 507 | + } |
| 508 | + Long usedBytes = pod.getFootprint(); |
| 509 | + if (usedBytes == null) { |
| 510 | + usedBytes = 0L; |
| 511 | + } |
500 | 512 | ProviderVolumeStorageStats stats = new ProviderVolumeStorageStats(); |
501 | 513 | stats.setCapacityInBytes(capacityBytes); |
502 | 514 | stats.setActualUsedInBytes(usedBytes); |
503 | 515 | return stats; |
504 | 516 | } |
505 | 517 |
|
| 518 | + private Long getArrayTotalCapacity() { |
| 519 | + try { |
| 520 | + FlashArrayList<Map<String, Object>> list = GET("/arrays?space=true", |
| 521 | + new TypeReference<FlashArrayList<Map<String, Object>>>() { |
| 522 | + }); |
| 523 | + if (list != null && CollectionUtils.isNotEmpty(list.getItems())) { |
| 524 | + Object cap = list.getItems().get(0).get("capacity"); |
| 525 | + if (cap instanceof Number) { |
| 526 | + return ((Number) cap).longValue(); |
| 527 | + } |
| 528 | + } |
| 529 | + } catch (Exception e) { |
| 530 | + logger.warn("Could not retrieve total capacity for FlashArray [{}] (pod [{}]): {}", |
| 531 | + this.url, this.pod, e.getMessage()); |
| 532 | + logger.debug("Stack trace for array total capacity lookup failure on FlashArray [{}] (pod [{}])", |
| 533 | + this.url, this.pod, e); |
| 534 | + } |
| 535 | + return null; |
| 536 | + } |
| 537 | + |
506 | 538 | @Override |
507 | 539 | public ProviderVolumeStats getVolumeStats(ProviderAdapterContext context, ProviderAdapterDataObject dataObject) { |
508 | 540 | ProviderVolume vol = getVolume(dataObject.getExternalName()); |
|
0 commit comments