Commit 08b53cb3 authored by Łukasz Nowak's avatar Łukasz Nowak

Use slapos.cfg file instead of other arguments.

parent bc328ce0
......@@ -17,6 +17,7 @@ import argparse
import os
import subprocess
import sys
import ConfigParser
def generateCertificate(certificate_file, key_file, common_name):
......@@ -27,6 +28,8 @@ def generateCertificate(certificate_file, key_file, common_name):
raise ValueError("Key %r exists, will not overwrite." %
key_file)
print 'Generating certificate for %r (key: %r, certficate: %r)' % (
common_name, key_file, certificate_file)
subj = '/CN=%s' % common_name
subprocess.check_call(["openssl", "req", "-x509", "-nodes", "-days", "365",
"-subj", subj, "-newkey", "rsa:1024", "-keyout", key_file, "-out",
......@@ -35,13 +38,12 @@ def generateCertificate(certificate_file, key_file, common_name):
def run(*args):
parser = argparse.ArgumentParser()
parser.add_argument('certificate_file', type=str,
help='Certificate file to generate.')
parser.add_argument('key_file', type=str,
help='Key file to generate.')
parser.add_argument('common_name', type=str, help="Common Name")
parser.add_argument('slapos_config', type=argparse.FileType('r'),
help='SlapOS configuration file.')
config = ConfigParser.SafeConfigParser()
option = parser.parse_args(list(args) or sys.argv[1:])
generateCertificate(option.certificate_file,
option.key_file, option.common_name)
config.readfp(option.slapos_config)
generateCertificate(config.get('networkcache', 'signature_certificate_file'),
config.get('networkcache', 'signature_private_key_file'),
config.get('slapos', 'computer_id'))
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment