Skip to content

Commit 3a4bbe8

Browse files
Merge pull request #53 from PureStorage-OpenConnect/user/aorlov/metric-availabilities
Fix for issue 52: better handling of metrics with multiple availabilities by the Get-PureOneMetric command
2 parents fc4112f + d89a73e commit 3a4bbe8

File tree

3 files changed

+52
-15
lines changed

3 files changed

+52
-15
lines changed

PureStorage.Pure1.psd1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Created by: Cody Hosterman
55
Organization: Pure Storage, Inc.
66
Filename: Cody.PureStorage.Pure1.psd1
7-
Version: 1.4.4.2
7+
Version: 1.4.4.3
88
Copyright: 2022 Pure Storage, Inc.
99
-------------------------------------------------------------------------
1010
Module Name: PureStoragePure1PowerShell
@@ -30,7 +30,7 @@
3030
RootModule = 'PureStorage.Pure1.psm1'
3131

3232
# Version number of this module; major.minor[.build[.revision]]
33-
ModuleVersion = '1.4.4.2'
33+
ModuleVersion = '1.4.4.3'
3434

3535
# ID used to uniquely identify this module
3636
GUID = '65867a33-8c09-4651-8043-96c2f7ca2893'

PureStorage.Pure1.psm1

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1946,9 +1946,36 @@ function Get-PureOneMetric {
19461946
#set granularity if not set
19471947
if ($granularity -eq 0)
19481948
{
1949-
$granularity = $metricDetails.availabilities.resolution
1949+
if ($metricDetails.availabilities.Count -gt 1) {
1950+
#some of the metrics have multiple availabilities defined
1951+
#caller needs to specify metric granularity explicitly through the input parameters in this case
1952+
throw "Multiple granularities are available for the metric $($metricDetails.name). Specify the desired granularity explicitly, and re-run the command."
1953+
}
1954+
else {
1955+
$granularity = $metricDetails.availabilities.resolution
1956+
}
1957+
}
1958+
1959+
[datetime]$epoch = '1970-01-01 00:00:00'
1960+
#set start time to current time (if not entered) and convert to epoch time
1961+
if ($null -eq $startTime)
1962+
{
1963+
if ($metricDetails.availabilities.Count -gt 1) {
1964+
#some of the metrics have multiple availabilities defined
1965+
#caller needs to specify metric history start time explicitly through the input parameters in this case
1966+
throw "Multiple granularities and history time ranges are available for the metric $($metricDetails.name). Specify the desired start time explicitly, and re-run the command."
1967+
}
1968+
else {
1969+
$startTime = $epoch.AddMilliseconds($metricDetails._as_of - $metricDetails.availabilities[0].retention)
1970+
}
1971+
}
1972+
else {
1973+
$startTime = $startTime.ToUniversalTime()
19501974
}
19511975

1976+
$startEpoch = (New-TimeSpan -Start $epoch -End $startTime).TotalMilliSeconds
1977+
$startEpoch = [math]::Round($startEpoch)
1978+
19521979
#set end time to start time minus retention for that stat (if not entered) and convert to epoch time
19531980
if ($null -eq $endTime)
19541981
{
@@ -1958,21 +1985,9 @@ function Get-PureOneMetric {
19581985
else {
19591986
$endTime = $endTime.ToUniversalTime()
19601987
}
1961-
[datetime]$epoch = '1970-01-01 00:00:00'
19621988
$endEpoch = (New-TimeSpan -Start $epoch -End $endTime).TotalMilliSeconds
19631989
$endEpoch = [math]::Round($endEpoch)
19641990

1965-
#set start time to current time (if not entered) and convert to epoch time
1966-
if ($null -eq $startTime)
1967-
{
1968-
$startTime = $epoch.AddMilliseconds($metricDetails._as_of - $metricDetails.availabilities.retention)
1969-
}
1970-
else {
1971-
$startTime = $startTime.ToUniversalTime()
1972-
}
1973-
$startEpoch = (New-TimeSpan -Start $epoch -End $startTime).TotalMilliSeconds
1974-
$startEpoch = [math]::Round($startEpoch)
1975-
19761991
#building query
19771992
if ($average -eq $true)
19781993
{
@@ -2651,6 +2666,7 @@ function Get-PureOneArrayLoadMeter {
26512666
#set granularity if not set
26522667
if ($granularity -eq 0)
26532668
{
2669+
#only one availability is defined for the array_total_load metric at the moment
26542670
$granularity = $metricDetails.availabilities.resolution
26552671
}
26562672

@@ -2670,6 +2686,7 @@ function Get-PureOneArrayLoadMeter {
26702686
#set start time to current time (if not entered) and convert to epoch time
26712687
if ($startTime -eq $null)
26722688
{
2689+
#only one availability is defined for the array_total_load metric at the moment
26732690
$startTime = $epoch.AddMilliseconds($metricDetails._as_of - $metricDetails.availabilities.retention)
26742691
}
26752692
else {

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,26 @@
6868
<ul><li>W is iterated for large updates</li><li>X is iterated for new cmdlets/significant enhancements</li><li>Y is iterated for new functions to existing cmdlets</li><li>Z is iterated for bug fixes</li></ul>
6969
<!-- /wp:list -->
7070

71+
<!-- wp:heading -->
72+
<h2>Latest version 1.4.4.3 (July 21st, 2022)</h2>
73+
<!-- /wp:heading -->
74+
75+
<!-- wp:paragraph -->
76+
<p>See version details:<a href="https://github.com/PureStorage-OpenConnect/PureStorage.Pure1/issues/52"> https://github.com/PureStorage-OpenConnect/PureStorage.Pure1/issues/52</a></p>
77+
<!-- /wp:paragraph -->
78+
79+
<!-- wp:paragraph -->
80+
<p><strong>New features:</strong></p>
81+
<!-- /wp:paragraph -->
82+
83+
<!-- wp:paragraph -->
84+
<p><strong>Bug Fixes:</strong></p>
85+
<!-- /wp:paragraph -->
86+
87+
<!-- wp:list -->
88+
<ul><li>Enhanced handling of metrics with multiple availabilities by the Get-PureOneMetric command</li></ul>
89+
<!-- /wp:list -->
90+
7191
<!-- wp:heading -->
7292
<h2>Latest version 1.4.4.1 (June 2nd, 2021)</h2>
7393
<!-- /wp:heading -->

0 commit comments

Comments
 (0)