Skip to content

Commit bc18854

Browse files
committed
Update pureTakeFBsnapshot.py
Update to support FlashBlade File system snapshot replication
1 parent 04487d3 commit bc18854

File tree

1 file changed

+34
-14
lines changed

1 file changed

+34
-14
lines changed

pureTakeFBsnapshot.py

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
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()
43
from base64 import b64encode
54
import os
65
import sys
@@ -14,7 +13,7 @@
1413
from purity_fb import PurityFb, FileSystem, FileSystemSnapshot, SnapshotSuffix, rest
1514

1615
# Global Variables
17-
VERSION = '1.0.0'
16+
VERSION = '2.0.0'
1817
HEADER = 'Pure Storage Take FlashBlade Snapshot (' + VERSION + ')'
1918
BANNER = ('=' * 132)
2019
DEBUG_FLAG = False
@@ -24,7 +23,7 @@
2423
def 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

Comments
 (0)