summaryrefslogtreecommitdiff
path: root/openstack_dashboard/management
diff options
context:
space:
mode:
authorIvan Udovichenko <iudovichenko@mirantis.com>2016-07-22 15:05:05 +0300
committerIvan Udovichenko <iudovichenko@mirantis.com>2016-08-09 09:00:21 +0300
commit374e60307dd3aead57d2bfbadd6f332695f96d34 (patch)
tree21cc40f534e7032fbea30758da65d12c89f3b3e1 /openstack_dashboard/management
parent528358cbbd8c894a166a2c906903f2de8dcbf0bd (diff)
downloadhorizon-374e60307dd3aead57d2bfbadd6f332695f96d34.tar.gz
Use argparse instead of optparse
Use of optparse module is deprecated [1] in Django 1.8 and 1.9 versions and its support has been removed in currently developed version 1.10 [2] [1] https://docs.djangoproject.com/en/1.9/howto/custom-management-commands/#django.core.management.BaseCommand.option_list [2] https://github.com/django/django/commit/6a70cb53971a19f2d9e71d5ee24bfb0e844b4d9d#diff-dfc45ab8548a0777543d12d6e77c9173 Change-Id: I0c7622fce0d5fabce45366d002b5e72e4c170344
Diffstat (limited to 'openstack_dashboard/management')
-rw-r--r--openstack_dashboard/management/commands/make_web_conf.py163
-rw-r--r--openstack_dashboard/management/commands/migrate_settings.py12
2 files changed, 98 insertions, 77 deletions
diff --git a/openstack_dashboard/management/commands/make_web_conf.py b/openstack_dashboard/management/commands/make_web_conf.py
index 9cbfe61d4..57478bca7 100644
--- a/openstack_dashboard/management/commands/make_web_conf.py
+++ b/openstack_dashboard/management/commands/make_web_conf.py
@@ -13,7 +13,6 @@
from __future__ import print_function
-from optparse import make_option # noqa
import os
import re
import socket
@@ -165,76 +164,100 @@ location you desire, e.g.::
'admin': context['ADMIN'],
'hostname': context['VHOSTNAME'], }
- option_list = BaseCommand.option_list + (
+ def add_arguments(self, parser):
# TODO(ygbo): Add an --nginx option.
- make_option("-a", "--apache",
- default=False, action="store_true", dest="apache",
- help="generate an apache vhost configuration"),
- make_option("--cacert",
- dest="cacert",
- help=("Use with the --apache and --ssl option to define "
- "the path to the SSLCACertificateFile"
- ),
- metavar="CACERT"),
- make_option("-f", "--force",
- default=False, action="store_true", dest="force",
- help="force overwriting of an existing %s file" %
- context['WSGI_FILE']),
- make_option("-H", "--hostname",
- dest="hostname",
- help=("Use with the --apache option to define the server's"
- " hostname (default : %s)") % context['VHOSTNAME'],
- metavar="HOSTNAME"),
- make_option("--logdir",
- dest="logdir",
- help=("Use with the --apache option to define the path to "
- "the apache log directory(default : %s)"
- % context['LOGDIR']),
- metavar="CACERT"),
- make_option("-m", "--mail",
- dest="mail",
- help=("Use with the --apache option to define the web site"
- " administrator's email (default : %s)") %
- context['ADMIN'],
- metavar="MAIL"),
- make_option("-n", "--namedhost",
- default=False, action="store_true", dest="namedhost",
- help=("Use with the --apache option. The apache vhost "
- "configuration will work only when accessed with "
- "the proper hostname (see --hostname).")),
- make_option("-p", "--project",
- dest="project",
- help=("Use with the --apache option to define the project "
- "name (default : %s)") % context['PROJECT_NAME'],
- metavar="PROJECT"),
- make_option("-s", "--ssl",
- default=False, action="store_true", dest="ssl",
- help=("Use with the --apache option. The apache vhost "
- "configuration will use an SSL configuration")),
- make_option("--sslcert",
- dest="sslcert",
- help=("Use with the --apache and --ssl option to define "
- "the path to the SSLCertificateFile (default : %s)"
- ) % context['SSLCERT'],
- metavar="SSLCERT"),
- make_option("--sslkey",
- dest="sslkey",
- help=("Use with the --apache and --ssl option to define "
- "the path to the SSLCertificateKeyFile "
- "(default : %s)") % context['SSLKEY'],
- metavar="SSLKEY"),
- make_option("--apache-version",
- dest="apache_version",
- type="float",
- help=("Use with the --apache option to define the apache "
- "major (as a floating point number) version "
- "(default : %s)."
- % context['APACHE2_VERSION']),
- metavar="APACHE_VERSION"),
- make_option("-w", "--wsgi",
- default=False, action="store_true", dest="wsgi",
- help="generate the horizon.wsgi file"),
- )
+ parser.add_argument(
+ "-a", "--apache",
+ default=False, action="store_true", dest="apache",
+ help="generate an apache vhost configuration"
+ )
+ parser.add_argument(
+ "--cacert",
+ dest="cacert",
+ help=("Use with the --apache and --ssl option to define the path"
+ " to the SSLCACertificateFile"),
+ metavar="CACERT"
+ )
+ parser.add_argument(
+ "-f", "--force",
+ default=False, action="store_true", dest="force",
+ help="force overwriting of an existing %s file" %
+ context['WSGI_FILE']
+ )
+ parser.add_argument(
+ "-H", "--hostname",
+ dest="hostname",
+ help=("Use with the --apache option to define the server's"
+ " hostname (default : %s)") % context['VHOSTNAME'],
+ metavar="HOSTNAME"
+ )
+ parser.add_argument(
+ "--logdir",
+ dest="logdir",
+ help=("Use with the --apache option to define the path to "
+ "the apache log directory(default : %s)"
+ % context['LOGDIR']),
+ metavar="CACERT"
+ )
+ parser.add_argument(
+ "-m", "--mail",
+ dest="mail",
+ help=("Use with the --apache option to define the web site"
+ " administrator's email (default : %s)") %
+ context['ADMIN'],
+ metavar="MAIL"
+ )
+ parser.add_argument(
+ "-n", "--namedhost",
+ default=False, action="store_true", dest="namedhost",
+ help=("Use with the --apache option. The apache vhost "
+ "configuration will work only when accessed with "
+ "the proper hostname (see --hostname).")
+ )
+ parser.add_argument(
+ "-p", "--project",
+ dest="project",
+ help=("Use with the --apache option to define the project "
+ "name (default : %s)") % context['PROJECT_NAME'],
+ metavar="PROJECT"
+ )
+ parser.add_argument(
+ "-s", "--ssl",
+ default=False, action="store_true", dest="ssl",
+ help=("Use with the --apache option. The apache vhost "
+ "configuration will use an SSL configuration")
+ )
+ parser.add_argument(
+ "--sslcert",
+ dest="sslcert",
+ help=("Use with the --apache and --ssl option to define "
+ "the path to the SSLCertificateFile (default : %s)"
+ ) % context['SSLCERT'],
+ metavar="SSLCERT"
+ )
+ parser.add_argument(
+ "--sslkey",
+ dest="sslkey",
+ help=("Use with the --apache and --ssl option to define "
+ "the path to the SSLCertificateKeyFile "
+ "(default : %s)") % context['SSLKEY'],
+ metavar="SSLKEY"
+ )
+ parser.add_argument(
+ "--apache-version",
+ dest="apache_version",
+ type=float,
+ help=("Use with the --apache option to define the apache "
+ "major (as a floating point number) version "
+ "(default : %s)."
+ % context['APACHE2_VERSION']),
+ metavar="APACHE_VERSION"
+ )
+ parser.add_argument(
+ "-w", "--wsgi",
+ default=False, action="store_true", dest="wsgi",
+ help="generate the horizon.wsgi file"
+ )
def handle(self, *args, **options):
force = options.get('force')
diff --git a/openstack_dashboard/management/commands/migrate_settings.py b/openstack_dashboard/management/commands/migrate_settings.py
index ce4f7b9f1..8a9b420b1 100644
--- a/openstack_dashboard/management/commands/migrate_settings.py
+++ b/openstack_dashboard/management/commands/migrate_settings.py
@@ -14,7 +14,6 @@ from __future__ import print_function
import difflib
import imp
-import optparse
import os
import shlex
import subprocess
@@ -75,24 +74,23 @@ class DirContext(object):
class Command(BaseCommand):
- option_list = BaseCommand.option_list + (
- optparse.make_option(
+ def add_arguments(self, parser):
+ parser.add_argument(
'--gendiff',
action='store_true',
dest='gendiff',
default=False,
help=('Generate a diff file between local_settings.py and '
'local_settings.py.example'),
- ),
- optparse.make_option(
+ )
+ parser.add_argument(
'-f', '--force',
action='store_true',
dest='force',
default=False,
help=('Force destination rewriting without warning if the '
'destination file already exists.'),
- ),
- )
+ )
help = ("Creates a local_settings.py file from the "
"local_settings.py.example template.")