Commit 73562467 authored by Alain Takoudjou's avatar Alain Takoudjou

configure client: login is not needed

parent ffaf4491
...@@ -33,13 +33,12 @@ import sys ...@@ -33,13 +33,12 @@ import sys
import uuid import uuid
import requests import requests
from caucase.cli_flask import CertificateAuthorityRequest
from slapos.cli.config import ClientConfigCommand from slapos.cli.config import ClientConfigCommand
from slapos.util import mkdir_p from slapos.util import mkdir_p
from slapos.certificate import (parse_certificate_from_html, from slapos.certificate import (parse_certificate_from_html,
generateCertificateRequest, generateCertificateRequest,
generatePkey) generatePrivatekey)
class ConfigureClientCommand(ClientConfigCommand): class ConfigureClientCommand(ClientConfigCommand):
...@@ -67,16 +66,11 @@ class ConfigureClientCommand(ClientConfigCommand): ...@@ -67,16 +66,11 @@ class ConfigureClientCommand(ClientConfigCommand):
return ap return ap
def take_action(self, args): def take_action(self, args):
if not args.login:
parser.error('Please enter your username on SlapOS Master Web. Use --login LOGIN')
parser.print_help()
return
do_configure_client(logger=self.app.log, do_configure_client(logger=self.app.log,
master_url_web=args.master_url_web, master_url_web=args.master_url_web,
token=args.token, token=args.token,
config_path=self.config_path(args), config_path=self.config_path(args),
master_url=args.master_url, master_url=args.master_url)
login=args.login)
def sign_certificate(logger, master_url_web, csr, token): def sign_certificate(logger, master_url_web, csr, token):
...@@ -120,26 +114,17 @@ def do_configure_client(logger, master_url_web, token, config_path, master_url): ...@@ -120,26 +114,17 @@ def do_configure_client(logger, master_url_web, token, config_path, master_url):
mkdir_p(basedir, mode=0o700) mkdir_p(basedir, mode=0o700)
cert_path = os.path.join(basedir, 'client.crt') cert_path = os.path.join(basedir, 'client.crt')
key_path = os.path.join(basedir, 'client.key')
if os.path.exists(cert_path):
if os.path.exists(cert_path): if os.path.exists(cert_path):
logger.critical('There is a certificate in %s. ' logger.critical('There is a certificate in %s. '
'Please remove it before creating a new certificate.', cert_path) 'Please remove it before creating a new certificate.', cert_path)
sys.exit(1)
key_path = os.path.join(basedir, 'client.key')
if os.path.exists(key_path):
logger.critical('There is a key in %s. ' logger.critical('There is a key in %s. '
'Please remove it before creating a new key.', key_path) 'Please remove it before creating a new key.', key_path)
sys.exit(1) sys.exit(1)
ca_cert_path = os.path.join(basedir, 'ca.crt') ca_cert_path = os.path.join(basedir, 'ca.crt')
# create certificate authority client
ca_client = CertificateAuthorityRequest(
key_path,
cert_path,
ca_cert_path,
ca_url='')
logger.debug('Generating key to %s', key_path) logger.debug('Generating key to %s', key_path)
key_string =generatePrivatekey(key_path, size=2048) key_string =generatePrivatekey(key_path, size=2048)
csr_string = generateCertificateRequest( csr_string = generateCertificateRequest(
...@@ -147,7 +132,6 @@ def do_configure_client(logger, master_url_web, token, config_path, master_url): ...@@ -147,7 +132,6 @@ def do_configure_client(logger, master_url_web, token, config_path, master_url):
cn=str(uuid.uuid4())) cn=str(uuid.uuid4()))
# retrieve a template for the configuration file # retrieve a template for the configuration file
cfg = fetch_configuration_template() cfg = fetch_configuration_template()
cfg = re.sub('master_url = .*', 'master_url = %s' % master_url, cfg) cfg = re.sub('master_url = .*', 'master_url = %s' % master_url, cfg)
......
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