Skip to content

Commit 03e149d

Browse files
committed
Added FA API Version parameter in List_Volumes.py
Allows the user to dynamically set the FA API Version as the -V or --apiversion parameter
1 parent 592a2a9 commit 03e149d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

List_Volumes.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
# Global Variables
1616
VERSION = '1.1.0'
17+
API_VERSION = '1.12'
1718
HEADER = 'Pure Storage List Volumes (' + VERSION + ')'
1819
BANNER = ('=' * 102)
1920
DEBUG_LEVEL = 0
@@ -35,7 +36,7 @@ def create_session(flashArray, user, password, api_token):
3536
'username': password
3637
}
3738
params = json.dumps(data)
38-
path = '/api/1.12/auth/apitoken'
39+
path = '/api' + API_VERSION + '/auth/apitoken'
3940
url = 'https://%s%s'%(flashArray,path)
4041

4142
# Perform action
@@ -66,7 +67,7 @@ def create_session(flashArray, user, password, api_token):
6667
}
6768

6869
params = json.dumps(data)
69-
path = '/api/1.12/auth/session'
70+
path = '/api/'+ API_VERSION + '/auth/session'
7071
url = 'https://%s%s'%(flashArray,path)
7172

7273
# Perform action
@@ -150,7 +151,7 @@ def list_volumes(flashArray):
150151
data = ''
151152
params = json.dumps(data)
152153

153-
path = '/api/1.12/volume?space=true'
154+
path = '/api/' + API_VERSION + '/volume?space=true'
154155

155156
# Perform action
156157
jsonData = get_url(flashArray,path,params)
@@ -218,6 +219,12 @@ def parsecl():
218219
dest = 'api_token',
219220
help = 'Pure Api Token')
220221

222+
parser.add_option('-V', '--apiversion',
223+
action = 'store',
224+
type = 'string',
225+
dest = 'API_VERSION',
226+
help = 'Pure FlashArray API Version')
227+
221228
parser.add_option('-u', '--user',
222229
action = 'store',
223230
type = 'string',
@@ -246,6 +253,7 @@ def main():
246253
# Setup variables
247254
global DEBUG_LEVEL
248255
global VERBOSE_FLAG
256+
global API_VERSION
249257
exit_code = 0
250258

251259
# Check for command line parameters
@@ -256,6 +264,7 @@ def main():
256264
api_token = options.api_token
257265
DEBUG_LEVEL = options.DEBUG_LEVEL
258266
VERBOSE_FLAG = options.VERBOSE_FLAG
267+
API_VERSION = options.API_VERSION
259268

260269
if DEBUG_LEVEL != 0:
261270
print('Password', password)

0 commit comments

Comments
 (0)