1- import requests
2- from requests .packages .urllib3 .exceptions import InsecureRequestWarning
3- requests .packages .urllib3 .disable_warnings (InsecureRequestWarning )
1+ import urllib3
2+ urllib3 .disable_warnings ()
43from base64 import b64encode
54import os
65import sys
1413from purity_fb import PurityFb , FileSystem , FileSystemSnapshot , SnapshotSuffix , rest
1514
1615# Global Variables
17- VERSION = '1 .0.0'
16+ VERSION = '2 .0.0'
1817HEADER = 'Pure Storage Take FlashBlade Snapshot (' + VERSION + ')'
1918BANNER = ('=' * 132 )
2019DEBUG_FLAG = False
2423def parsecl ():
2524 usage = 'usage: %prog [options]'
2625 version = '%prog ' + VERSION
27- description = "This application has been developed using Pure Storage v1.8 RESTful Web Service interfaces. Developed and tested using Python 3.6.8. Please contact ron@purestorage.com for assistance."
26+ description = "This application has been developed using Pure Storage v1.12 RESTful Web Service interfaces. Developed and tested using Python 3.9.5 Please contact ron@purestorage.com for assistance."
2827
2928 parser = OptionParser (usage = usage , version = version , description = description )
3029
@@ -41,12 +40,18 @@ def parsecl():
4140 dest = 'fs' ,
4241 help = 'FlashBlade File System' )
4342
43+ parser .add_option ('-r' , '--replicant' ,
44+ action = 'store' ,
45+ type = 'string' ,
46+ dest = 'flashBladeRep' ,
47+ help = 'FlashBlade Replicant array' )
48+
4449 parser .add_option ('-s' , '--server' ,
4550 action = 'store' ,
4651 type = 'string' ,
4752 dest = 'flashBlade' ,
4853 help = 'FlashBlade array' )
49-
54+
5055 parser .add_option ('-t' , '--token' ,
5156 action = 'store' ,
5257 type = 'string' ,
@@ -83,6 +88,7 @@ def main():
8388 options = parsecl ()
8489 API_TOKEN = options .API_TOKEN
8590 flashBlade = options .flashBlade
91+ flashBladeRep = options .flashBladeRep
8692 fs = options .fs
8793 suffix = options .suffix
8894 DEBUG_FLAG = options .DEBUG_FLAG
@@ -91,14 +97,15 @@ def main():
9197 if DEBUG_FLAG :
9298 print ('API Token:' , API_TOKEN )
9399 print ('FlashBlade:' , flashBlade )
100+ print ('Relplicant:' , flashBladeRep )
94101 print ('File System:' , fs )
95102 print ('Suffix:' , suffix )
96103 print ('Debug Flag:' , DEBUG_FLAG )
97104 print ('Verbose Flag:' , VERBOSE_FLAG )
98105
99106 if flashBlade == None :
100107 sys .exit ('Exiting: You must provide FlashBlade details' )
101-
108+
102109 if API_TOKEN == None :
103110 sys .exit ('Exiting: You must provide FlashBlade API Token details' )
104111
@@ -123,14 +130,27 @@ def main():
123130
124131 if res :
125132 try :
126- if suffix :
127- # create a snapshot with suffix for flashblade file system
128- res = fb .file_system_snapshots .create_file_system_snapshots (sources = [fs ],
129- suffix = SnapshotSuffix (suffix ))
133+ if flashBladeRep :
134+ if suffix :
135+ # create a snapshot with suffix and replicate to target array
136+ res = fb .file_system_snapshots .create_file_system_snapshots (sources = [fs ],
137+ suffix = SnapshotSuffix (suffix ),
138+ send = True ,
139+ targets = [flashBladeRep ])
140+ else :
141+ # create a snapshot without suffix and replicate to target array
142+ res = fb .file_system_snapshots .create_file_system_snapshots (sources = [fs ],
143+ send = True ,
144+ targets = [flashBladeRep ])
130145 else :
131- # create a snapshot for the file system
132- res = fb .file_system_snapshots .create_file_system_snapshots (sources = [fs ])
133-
146+ if suffix :
147+ # create a snapshot with suffix for the file system
148+ res = fb .file_system_snapshots .create_file_system_snapshots (sources = [fs ],
149+ suffix = SnapshotSuffix (suffix ))
150+ else :
151+ # create a snapshot without suffix for the file system
152+ res = fb .file_system_snapshots .create_file_system_snapshots (sources = [fs ])
153+
134154 if VERBOSE_FLAG :
135155 print (res )
136156
0 commit comments