Skip to content
Snippets Groups Projects
Select Git revision
  • ffd9a43c4542407b4e8d55a053af04eeb4f33e3f
  • develop default
  • master protected
  • feature/frontend-tests
  • 0.98
  • 0.97
  • 0.96
  • 0.95
  • 0.94
  • 0.93
  • 0.92
  • 0.91
  • 0.90
  • 0.89
  • 0.88
  • 0.87
  • 0.86
  • 0.85
  • 0.84
  • 0.83
  • 0.82
  • 0.81
  • 0.80
  • 0.79
24 results

dataconversion.tsx

Blame
  • create_challenge.py 1.17 KiB
    #!/usr/bin/env python3
    """ Add Acme challenges to Infoblox """
    import os
    import time
    import configparser
    import requests
    
    
    def create_acme(iblox_domain, acme_token, iblox_user, iblox_pw):
        """ upload txt record """
        post_req = requests.post(
            'https://infoblox.geant.org/wapi/v2.6.1/record:txt',
            auth=(iblox_user, iblox_pw),
            data={
                'name': '_acme-challenge.{}'.format(iblox_domain),
                'text': acme_token,
                'ttl': '60',
                "view": "External"
            }
        )
        return post_req.status_code
    
    
    # Here we Go.
    if __name__ == "__main__":
    
        CONFIG = configparser.RawConfigParser()
        CONFIG.read_file(open('/root/.geant_acme.ini'))
        IBLOX_PASS = CONFIG.get('geant_acme', 'iblox_pass')
        IBLOX_USER = CONFIG.get('geant_acme', 'iblox_user')
    
        ARGS = os.sys.argv
        _ = ARGS.pop(0)
    
        for host in ARGS:
            if ARGS.index(host) % 2 == 0:
                token = ARGS.index(host)+1
                http_code = create_acme(host, ARGS[token], IBLOX_USER, IBLOX_PASS)
                if http_code != 201:
                    print('could not create {} for {}'.format(ARGS[token], host))
                    os.sys.exit(1)
    
        time.sleep(10)