-
Notifications
You must be signed in to change notification settings - Fork 8
/
cert.py
31 lines (23 loc) · 874 Bytes
/
cert.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from __future__ import absolute_import, print_function
import logging
import os
import re
import subprocess
def path(name):
return os.path.join(os.environ.get("EASYRSA_PKI", ""),
"private/{0}.key".format(name))
def generate(name):
subprocess.check_call(
"/dcos/bin/easyrsa build-client-full {0} nopass".format(
name), shell=True)
def upload(name):
subprocess.check_call(
'$ZKCLI --run-once "cp file://{0} $ZKPATH/{1}" $ZKURL'.format(
path(name), os.path.relpath(path(name),
os.environ.get("CONFIG_LOCATION"))), shell=True)
def output(name):
loc = subprocess.check_output("/dcos/bin/run.bash get_location", shell=True)
return re.sub("remote .*", loc, subprocess.check_output(
"ovpn_getclient {0}".format(name), shell=True))
def remove(name):
return os.remove(path(name))