Created
February 25, 2016 15:40
-
-
Save leenagupte/34881b405d1d397a7b9f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import getopt | |
import os | |
def main(argv): | |
""" | |
Bulk unpublish dashboards. | |
Pass in a file containing a list of dashboard slugs to unpublish. | |
Usage: unpublish_dashboards_from_file.py -f <filename> -e <environment> | |
filename: File containing a list of dashboard slugs | |
environment: Environment to run against. Defaults to integration. | |
""" | |
""" | |
:param argv: | |
:return: | |
""" | |
filename = None | |
env = None | |
try: | |
opts, args = getopt.getopt(argv, "hf:e:") | |
except getopt.GetoptError: | |
print 'Usage: unpublish_dashboards_from_file.py -f <filename> -e <environment>' | |
sys.exit(2) | |
for opt, arg in opts: | |
if opt == '-h': | |
print 'Usage: unpublish_dashboards_from_file.py -f <filename> -e <environment>' | |
sys.exit() | |
elif opt == "-f": | |
filename = arg | |
elif opt == "-e": | |
env = arg | |
if not env: | |
env = "integration" | |
if not filename: | |
print "You must specify a filename" | |
print "Usage: unpublish_dashboards_from_file.py -f <filename> -e <environment>" | |
sys.exit(2) | |
print 'File is {}'.format(filename) | |
print 'Environment file is {}'.format(env) | |
with open(filename) as f: | |
dashboards = f.read().splitlines() | |
for dashboard in dashboards: | |
os.system("fab {} performanceplatform.unpublish_dashboard:{}".format(env, dashboard)) | |
if __name__ == "__main__": | |
main(sys.argv[1:]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment