Skip to content

Instantly share code, notes, and snippets.

@ugurengin
Created December 6, 2017 16:00
Show Gist options
  • Save ugurengin/a57ea86016b659e4462580731059ecbb to your computer and use it in GitHub Desktop.
Save ugurengin/a57ea86016b659e4462580731059ecbb to your computer and use it in GitHub Desktop.
Generate SHA1 INCKey
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