Completing the basic configuration for Kuryr
Adds support for providing a configuration file for specifying Kuryr configuration options. Updates the Kuryr scripts to use and if needed, generate the configuration file. Implements: blueprint kuryr-config Change-Id: I6909ef21da13a7137ffff019383be19306f35152
This commit is contained in:
parent
4bd27cce7d
commit
2f4686393a
@ -47,6 +47,27 @@ if is_service_enabled kuryr; then
|
||||
echo "Done"
|
||||
fi
|
||||
|
||||
if [[ ! -d "${KURYR_CONFIG_DIR}" ]]; then
|
||||
echo -n "${KURYR_CONFIG_DIR} directory is missing. Creating it... "
|
||||
sudo mkdir -p ${KURYR_CONFIG_DIR}
|
||||
echo "Done"
|
||||
fi
|
||||
|
||||
if [[ ! -f "${KURYR_CONFIG}" ]]; then
|
||||
if [[ -f "${KURYR_DEFAULT_CONFIG}" ]]; then
|
||||
echo -n "${KURYR_CONFIG} is missing. Copying the default one... "
|
||||
sudo cp ${KURYR_DEFAULT_CONFIG} ${KURYR_CONFIG}
|
||||
echo "Done"
|
||||
else
|
||||
echo -n "${KURYR_CONFIG} and the default config missing. Auto generating and copying one... "
|
||||
cd ${KURYR_HOME}
|
||||
tox -egenconfig
|
||||
sudo cp ${KURYR_DEFAULT_CONFIG}.sample ${KURYR_DEFAULT_CONFIG}
|
||||
sudo cp ${KURYR_DEFAULT_CONFIG} ${KURYR_CONFIG}
|
||||
cd -
|
||||
fi
|
||||
fi
|
||||
|
||||
run_process etcd-server "$DEST/etcd/etcd-$ETCD_VERSION-linux-amd64/etcd"
|
||||
|
||||
wget http://get.docker.com -O install_docker.sh
|
||||
@ -56,7 +77,7 @@ if is_service_enabled kuryr; then
|
||||
|
||||
sudo killall docker
|
||||
run_process docker-engine "sudo /usr/bin/docker daemon --cluster-store etcd://localhost:4001"
|
||||
run_process kuryr "sudo PYTHONPATH=$PYTHONPATH:$DEST/kuryr SERVICE_USER=admin SERVICE_PASSWORD=$SERVICE_PASSWORD SERVICE_TENANT_NAME=admin SERVICE_TOKEN=$SERVICE_TOKEN IDENTITY_URL=http://127.0.0.1:5000/v2.0 python $DEST/kuryr/scripts/run_server.py"
|
||||
run_process kuryr "sudo PYTHONPATH=$PYTHONPATH:$DEST/kuryr SERVICE_USER=admin SERVICE_PASSWORD=$SERVICE_PASSWORD SERVICE_TENANT_NAME=admin SERVICE_TOKEN=$SERVICE_TOKEN IDENTITY_URL=http://127.0.0.1:5000/v2.0 python $DEST/kuryr/scripts/run_server.py --config-file /etc/kuryr/kuryr.conf"
|
||||
fi
|
||||
|
||||
if [[ "$1" == "unstack" ]]; then
|
||||
|
@ -7,3 +7,8 @@ KURYR_DEFAULT_JSON=${KURYR_HOME}/etc/${KURYR_JSON_FILENAME}
|
||||
# https://github.com/docker/docker/blob/c4d45b6a29a91f2fb5d7a51ac36572f2a9b295c6/docs/extend/plugin_api.md#plugin-discovery
|
||||
KURYR_JSON_DIR=${KURYR_JSON_DIR:-/usr/lib/docker/plugins/kuryr}
|
||||
KURYR_JSON=${KURYR_JSON_DIR}/${KURYR_JSON_FILENAME}
|
||||
|
||||
KURYR_CONFIG_FILENAME=kuryr.conf
|
||||
KURYR_DEFAULT_CONFIG=${KURYR_HOME}/etc/${KURYR_CONFIG_FILENAME}
|
||||
KURYR_CONFIG_DIR=${KURYR_CONFIG_DIR:-/etc/kuryr}
|
||||
KURYR_CONFIG=${KURYR_CONFIG_DIR}/${KURYR_CONFIG_FILENAME}
|
||||
|
@ -18,5 +18,3 @@ from kuryr import utils
|
||||
app = utils.make_json_app(__name__)
|
||||
app.logger.addHandler(logging.StreamHandler(sys.stdout))
|
||||
app.logger.setLevel(logging.INFO)
|
||||
|
||||
from kuryr.controllers import app # noqa
|
||||
|
@ -64,17 +64,21 @@ keystone_opts = [
|
||||
default=os.environ.get('SERVICE_TOKEN'),
|
||||
help=_('The admin token.')),
|
||||
]
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(core_opts)
|
||||
CONF.register_opts(neutron_opts, group='neutron_client')
|
||||
CONF.register_opts(keystone_opts, group='keystone_client')
|
||||
|
||||
binding_opts = [
|
||||
cfg.StrOpt('veth_dst_prefix',
|
||||
default='eth',
|
||||
help=('The name prefix of the veth endpoint put inside the '
|
||||
'container.'))
|
||||
]
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(core_opts)
|
||||
CONF.register_opts(neutron_opts, group='neutron_client')
|
||||
CONF.register_opts(keystone_opts, group='keystone_client')
|
||||
CONF.register_opts(binding_opts, 'binding')
|
||||
|
||||
|
||||
def init(args, **kwargs):
|
||||
cfg.CONF(args=args, project='kuryr',
|
||||
version='0.1', **kwargs)
|
||||
|
@ -28,34 +28,39 @@ from kuryr.common import exceptions
|
||||
from kuryr import schemata
|
||||
from kuryr import utils
|
||||
|
||||
|
||||
MANDATORY_NEUTRON_EXTENSION = "subnet_allocation"
|
||||
|
||||
cfg.CONF.import_group('neutron_client', 'kuryr.common.config')
|
||||
cfg.CONF.import_group('keystone_client', 'kuryr.common.config')
|
||||
|
||||
keystone_conf = cfg.CONF.keystone_client
|
||||
username = keystone_conf.admin_user
|
||||
tenant_name = keystone_conf.admin_tenant_name
|
||||
password = keystone_conf.admin_password
|
||||
auth_token = keystone_conf.admin_token
|
||||
auth_uri = keystone_conf.auth_uri.rstrip('/')
|
||||
def neutron_client():
|
||||
"""Creates the Neutron client for communicating with Neutron."""
|
||||
if not hasattr(app, 'neutron'):
|
||||
cfg.CONF.import_group('neutron_client', 'kuryr.common.config')
|
||||
cfg.CONF.import_group('keystone_client', 'kuryr.common.config')
|
||||
|
||||
neutron_uri = cfg.CONF.neutron_client.neutron_uri
|
||||
enable_dhcp = cfg.CONF.neutron_client.enable_dhcp
|
||||
keystone_conf = cfg.CONF.keystone_client
|
||||
username = keystone_conf.admin_user
|
||||
tenant_name = keystone_conf.admin_tenant_name
|
||||
password = keystone_conf.admin_password
|
||||
auth_token = keystone_conf.admin_token
|
||||
auth_uri = keystone_conf.auth_uri.rstrip('/')
|
||||
|
||||
if username and password:
|
||||
# Authenticate with password crentials
|
||||
app.neutron = utils.get_neutron_client(
|
||||
url=neutron_uri, username=username, tenant_name=tenant_name,
|
||||
password=password, auth_url=auth_uri)
|
||||
else:
|
||||
app.neutron = utils.get_neutron_client_simple(
|
||||
url=neutron_uri, token=auth_token)
|
||||
neutron_uri = cfg.CONF.neutron_client.neutron_uri
|
||||
if username and password:
|
||||
# Authenticate with password crentials
|
||||
app.neutron = utils.get_neutron_client(
|
||||
url=neutron_uri, username=username, tenant_name=tenant_name,
|
||||
password=password, auth_url=auth_uri)
|
||||
else:
|
||||
app.neutron = utils.get_neutron_client_simple(
|
||||
url=neutron_uri, token=auth_token)
|
||||
|
||||
app.enable_dhcp = cfg.CONF.neutron_client.enable_dhcp
|
||||
app.neutron.format = 'json'
|
||||
|
||||
|
||||
def check_for_neutron_ext_support():
|
||||
"""Validates for mandatory extension support availability in neutron.
|
||||
"""
|
||||
"""Validates for mandatory extension support availability in neutron."""
|
||||
try:
|
||||
app.neutron.show_extension(MANDATORY_NEUTRON_EXTENSION)
|
||||
except n_exceptions.NeutronClientException as e:
|
||||
@ -71,8 +76,6 @@ SUBNET_POOLS_V4 = [
|
||||
SUBNET_POOLS_V6 = [
|
||||
p.strip() for p in os.environ.get('SUBNET_POOLS_V6', 'kuryr6').split(',')]
|
||||
|
||||
app.neutron.format = 'json'
|
||||
|
||||
|
||||
def _cache_default_subnetpool_ids(app):
|
||||
"""Caches IDs of the default subnetpools as app.DEFAULT_POOL_IDS."""
|
||||
@ -147,7 +150,7 @@ def _process_subnet(neutron_network_id, endpoint_id, interface_cidr,
|
||||
'network_id': neutron_network_id,
|
||||
'ip_version': cidr.version,
|
||||
'cidr': subnet_cidr,
|
||||
'enable_dhcp': enable_dhcp,
|
||||
'enable_dhcp': app.enable_dhcp,
|
||||
}
|
||||
if pool_id:
|
||||
del new_subnet['cidr']
|
||||
@ -747,3 +750,6 @@ def network_driver_leave():
|
||||
app.logger.error('Cleaning the veth pair up was failed.')
|
||||
|
||||
return flask.jsonify(constants.SCHEMA['SUCCESS'])
|
||||
|
||||
|
||||
neutron_client()
|
||||
|
@ -10,9 +10,15 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from kuryr import app
|
||||
import sys
|
||||
|
||||
|
||||
def start():
|
||||
from kuryr.common import config
|
||||
config.init(sys.argv[1:])
|
||||
|
||||
from kuryr import app
|
||||
from kuryr import controllers
|
||||
controllers.check_for_neutron_ext_support()
|
||||
app.debug = True
|
||||
app.run("0.0.0.0", port=2377)
|
||||
|
@ -20,6 +20,12 @@ KURYR_DEFAULT_JSON=${KURYR_HOME}/etc/${KURYR_JSON_FILENAME}
|
||||
KURYR_JSON_DIR=${KURYR_JSON_DIR:-/usr/lib/docker/plugins/kuryr}
|
||||
KURYR_JSON=${KURYR_JSON_DIR}/${KURYR_JSON_FILENAME}
|
||||
|
||||
KURYR_CONFIG_FILENAME=kuryr.conf
|
||||
KURYR_DEFAULT_CONFIG=${KURYR_HOME}/etc/${KURYR_CONFIG_FILENAME}
|
||||
KURYR_CONFIG_DIR=${KURYR_CONFIG_DIR:-/etc/kuryr}
|
||||
KURYR_CONFIG=${KURYR_CONFIG_DIR}/${KURYR_CONFIG_FILENAME}
|
||||
|
||||
|
||||
if [[ ! -d "${KURYR_JSON_DIR}" ]]; then
|
||||
echo -n "${KURYR_JSON_DIR} directory is missing. Creating it... "
|
||||
sudo mkdir -p ${KURYR_JSON_DIR}
|
||||
@ -32,4 +38,24 @@ if [[ ! -f "${KURYR_JSON}" ]]; then
|
||||
echo "Done"
|
||||
fi
|
||||
|
||||
PYTHONPATH=${KURYR_HOME} python ${KURYR_HOME}/scripts/run_server.py
|
||||
if [[ ! -d "${KURYR_CONFIG_DIR}" ]]; then
|
||||
echo -n "${KURYR_CONFIG_DIR} directory is missing. Creating it... "
|
||||
sudo mkdir -p ${KURYR_CONFIG_DIR}
|
||||
echo "Done"
|
||||
fi
|
||||
|
||||
if [[ ! -f "${KURYR_CONFIG}" ]]; then
|
||||
if [[ -f "${KURYR_DEFAULT_CONFIG}" ]]; then
|
||||
echo -n "${KURYR_CONFIG} is missing. Copying the default one... "
|
||||
sudo cp ${KURYR_DEFAULT_CONFIG} ${KURYR_CONFIG}
|
||||
echo "Done"
|
||||
else
|
||||
echo -n "${KURYR_CONFIG} and the default config missing. Auto generating and copying one... "
|
||||
cd ${KURYR_HOME}
|
||||
tox -egenconfig
|
||||
sudo cp ${KURYR_DEFAULT_CONFIG}.sample ${KURYR_DEFAULT_CONFIG}
|
||||
sudo cp ${KURYR_DEFAULT_CONFIG} ${KURYR_CONFIG}
|
||||
fi
|
||||
fi
|
||||
|
||||
PYTHONPATH=${KURYR_HOME} python ${KURYR_HOME}/scripts/run_server.py --config-file /etc/kuryr/kuryr.conf
|
||||
|
@ -12,8 +12,6 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from kuryr import controllers
|
||||
from kuryr import server
|
||||
|
||||
controllers.check_for_neutron_ext_support()
|
||||
server.start()
|
||||
|
Loading…
Reference in New Issue
Block a user