Created
October 12, 2016 04:01
-
-
Save negz/da64b67448d78ca7d06f963731a030c9 to your computer and use it in GitHub Desktop.
secret-volume creation snippet
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
#!/usr/bin/env python | |
import logging | |
import sys | |
import requests | |
def main(): | |
logging.basicConfig(level=logging.DEBUG) | |
vol = { | |
"ID": "awesomevolume", | |
"Source": "talos", | |
"Tags": {"awesome": ["very", "lots"]}, | |
"KeyPair": {} | |
} | |
with open("fixtures/cert.pem") as c: | |
vol["KeyPair"]["Certificate"] = c.read() | |
with open("fixtures/key.pem") as k: | |
vol["KeyPair"]["PrivateKey"] = k.read() | |
try: | |
rsp = requests.post("http://192.168.99.100:32779", json=vol) | |
rsp.raise_for_status() | |
except (IOError, requests.exceptions.RequestException) as e: | |
if hasattr(e, 'response'): | |
logging.fatal("%s: %s", e, e.response.text) | |
sys.exit(1) | |
logging.fatal(e) | |
sys.exit(1) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment