Skip to content
Snippets Groups Projects
Select Git revision
  • f0075ef55b562208077fb969979fac3f9e4d9a63
  • develop default
  • master protected
  • async-provision
  • DBOARD3-1252/inventory-api
  • 0.86
  • 0.85
  • 0.84
  • 0.83
  • 0.82
  • 0.81
  • 0.80
  • 0.79
  • 0.78
  • 0.77
  • 0.76
  • 0.75
  • 0.74
  • 0.73
  • 0.72
  • 0.71
  • 0.70
  • 0.69
  • 0.68
  • 0.67
25 results

test_grafana_datasource.py

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)