fixing commands we need

This commit is contained in:
Cayo Puigdefabregas 2021-01-30 14:17:18 +01:00
parent 78db4fb8d5
commit 8da89ae22a
2 changed files with 117 additions and 55 deletions

View file

@ -11,54 +11,117 @@ from orchestra.utils.sys import run, check_root, confirm
class Command(BaseCommand): class Command(BaseCommand):
help = 'Configures nginx + uwsgi to run with your Orchestra instance.'
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(Command, self).__init__(*args, **kwargs) super(Command, self).__init__(*args, **kwargs)
self.option_list = BaseCommand.option_list + (
make_option('--cert', dest='cert', default='',
help='Nginx SSL certificate, one will be created by default.'),
make_option('--cert-key', dest='cert_key', default='',
help='Nginx SSL certificate key.'),
make_option('--cert-path', dest='cert_path', def add_arguments(self, parser):
default=os.path.join(paths.get_site_dir(), 'ssl', 'orchestra.crt'), parser.add_argument(
help='Nginx SSL certificate, one will be created by default.'), '--cert',
make_option('--cert-key-path', dest='cert_key_path', dest='cert',
default=os.path.join(paths.get_site_dir(), 'ssl', 'orchestra.key'), default='',
help='Nginx SSL certificate key.'), help='Nginx SSL certificate, one will be created by default.',
# Cert options )
make_option('--cert-override', dest='cert_override', action='store_true', parser.add_argument(
default=False, help='Force override cert and keys if exists.'), '--cert-key',
make_option('--cert-country', dest='cert_country', default='ES', dest='cert_key',
help='Certificate Distinguished Name Country.'), default='',
make_option('--cert-state', dest='cert_state', default='Spain', help='Nginx SSL certificate key.'
help='Certificate Distinguished Name STATE.'), )
make_option('--cert-locality', dest='cert_locality', default='Barcelona', parser.add_argument(
help='Certificate Distinguished Name Country.'), '--cert-path',
make_option('--cert-org_name', dest='cert_org_name', default='Orchestra', dest='cert_path',
help='Certificate Distinguished Name Organization Name.'), default=os.path.join(paths.get_site_dir(), 'ssl', 'orchestra.crt'),
make_option('--cert-org_unit', dest='cert_org_unit', default='DevOps', help='Nginx SSL certificate, one will be created by default.'
help='Certificate Distinguished Name Organization Unity.'), )
make_option('--cert-email', dest='cert_email', default='orchestra@orchestra.lan', parser.add_argument(
help='Certificate Distinguished Name Email Address.'), '--cert-key-path',
make_option('--cert-common_name', dest='cert_common_name', default=None, dest='cert_key_path',
help='Certificate Distinguished Name Common Name.'), default=os.path.join(paths.get_site_dir(), 'ssl', 'orchestra.key'),
help='Nginx SSL certificate key.'
make_option('--server-name', dest='server_name', default='', )
help='Nginx SSL certificate key.'), parser.add_argument(
make_option('--user', dest='user', default='', '--cert-override',
help='uWSGI daemon user.'), dest='cert_override',
make_option('--group', dest='group', default='', action='store_true',
help='uWSGI daemon group.'), default=False, help='Force override cert and keys if exists.'
make_option('--processes', dest='processes', default=4, )
help='uWSGI number of processes.'), parser.add_argument(
make_option('--noinput', action='store_false', dest='interactive', default=True, '--cert-country',
help='Tells Django to NOT prompt the user for input of any kind. ' dest='cert_country',
'You must use --username with --noinput, and must contain the ' default='ES',
'cleeryd process owner, which is the user how will perform tincd updates'), help='Certificate Distinguished Name Country.'
)
parser.add_argument(
'--cert-state',
dest='cert_state',
default='Spain',
help='Certificate Distinguished Name STATE.'
)
parser.add_argument(
'--cert-locality',
dest='cert_locality',
default='Barcelona',
help='Certificate Distinguished Name Country.'
)
parser.add_argument(
'--cert-org_name',
dest='cert_org_name',
default='Orchestra',
help='Certificate Distinguished Name Organization Name.'
)
parser.add_argument(
'--cert-org_unit',
dest='cert_org_unit',
default='DevOps',
help='Certificate Distinguished Name Organization Unity.'
)
parser.add_argument(
'--cert-email',
dest='cert_email',
default='orchestra@orchestra.lan',
help='Certificate Distinguished Name Email Address.'
)
parser.add_argument(
'--cert-common_name',
dest='cert_common_name',
default=None,
help='Certificate Distinguished Name Common Name.'
)
parser.add_argument(
'--server-name',
dest='server_name',
default='',
help='Nginx SSL certificate key.'
)
parser.add_argument(
'--user',
dest='user',
default='',
help='uWSGI daemon user.'
)
parser.add_argument(
'--group',
dest='group',
default='',
help='uWSGI daemon group.'
)
parser.add_argument(
'--processes',
dest='processes',
default=4,
help='uWSGI number of processes.'
)
parser.add_argument(
'--noinput',
action='store_false',
dest='interactive',
default=True,
help='''Tells Django to NOT prompt the user for input of any kind.
You must use --username with --noinput, and must contain the
cleeryd process owner, which is the user how will perform tincd updates'''
) )
option_list = BaseCommand.option_list
help = 'Configures nginx + uwsgi to run with your Orchestra instance.'
def generate_certificate(self, **options): def generate_certificate(self, **options):
override = options.get('cert_override') override = options.get('cert_override')

View file

@ -49,7 +49,7 @@ class Command(BaseCommand):
parser.add_argument( parser.add_argument(
'--db_host', '--db_host',
dest='db_host', dest='db_host',
default=slef.defaults.get('HOST', 'localhost'), default=self.defaults.get('HOST', 'localhost'),
help='Specifies the database to create.', help='Specifies the database to create.',
type=str type=str
) )
@ -65,10 +65,9 @@ class Command(BaseCommand):
action='store_false', action='store_false',
dest='interactive', dest='interactive',
default=True, default=True,
help='Tells Django to NOT prompt the user for input of any kind. ' help='''Tells Django to NOT prompt the user for input of any kind.
'You must use --username with --noinput, and must contain the ' You must use --username with --noinput, and must contain the
'cleeryd process owner, which is the user how will perform tincd updates', cleeryd process owner, which is the user how will perform tincd updates'''
type=str
) )
def run_postgres(self, cmd, *args, **kwargs): def run_postgres(self, cmd, *args, **kwargs):
@ -79,11 +78,11 @@ class Command(BaseCommand):
interactive = options.get('interactive') interactive = options.get('interactive')
db_password = options.get('db_password') db_password = options.get('db_password')
context = { context = {
'db_name': options.get('db_name', 'orchestra'), 'db_name': options.get('db_name'),
'db_user': options.get('db_user', 'orchestra'), 'db_user': options.get('db_user'),
'db_password': db_password, 'db_password': db_password,
'db_host': options.get('db_host', '127.0.0.1'), 'db_host': options.get('db_host'),
'db_port': options.get('db_port', '5432'), 'db_port': options.get('db_port'),
'default_db_password': db_password or random_ascii(10), 'default_db_password': db_password or random_ascii(10),
} }