Created
December 6, 2017 16:00
-
-
Save ugurengin/a57ea86016b659e4462580731059ecbb to your computer and use it in GitHub Desktop.
Generate SHA1 INCKey
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 hashlib | |
from optparse import OptionParser | |
# Generate unique incident key for Openduty | |
def get_opt(): | |
parser = OptionParser() | |
parser.add_option("-H", dest="host_name") | |
parser.add_option("-D", dest="service_desc") | |
(options, args) = parser.parse_args() | |
return options, args | |
def gen_inckey(host_name, service_desc): | |
hash_object = hashlib.sha1(host_name+service_desc) | |
hex_dig = hash_object.hexdigest() | |
print hex_dig | |
def check_main(): | |
options, args = get_opt() | |
gen_inckey(options.host_name, options.service_desc) | |
if __name__ == "__main__": | |
check_main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment