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"
|
echo "Done"
|
||||||
fi
|
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"
|
run_process etcd-server "$DEST/etcd/etcd-$ETCD_VERSION-linux-amd64/etcd"
|
||||||
|
|
||||||
wget http://get.docker.com -O install_docker.sh
|
wget http://get.docker.com -O install_docker.sh
|
||||||
@ -56,7 +77,7 @@ if is_service_enabled kuryr; then
|
|||||||
|
|
||||||
sudo killall docker
|
sudo killall docker
|
||||||
run_process docker-engine "sudo /usr/bin/docker daemon --cluster-store etcd://localhost:4001"
|
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
|
fi
|
||||||
|
|
||||||
if [[ "$1" == "unstack" ]]; then
|
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
|
# 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_DIR=${KURYR_JSON_DIR:-/usr/lib/docker/plugins/kuryr}
|
||||||
KURYR_JSON=${KURYR_JSON_DIR}/${KURYR_JSON_FILENAME}
|
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 = utils.make_json_app(__name__)
|
||||||
app.logger.addHandler(logging.StreamHandler(sys.stdout))
|
app.logger.addHandler(logging.StreamHandler(sys.stdout))
|
||||||
app.logger.setLevel(logging.INFO)
|
app.logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
from kuryr.controllers import app # noqa
|
|
||||||
|
@ -64,17 +64,21 @@ keystone_opts = [
|
|||||||
default=os.environ.get('SERVICE_TOKEN'),
|
default=os.environ.get('SERVICE_TOKEN'),
|
||||||
help=_('The admin 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 = [
|
binding_opts = [
|
||||||
cfg.StrOpt('veth_dst_prefix',
|
cfg.StrOpt('veth_dst_prefix',
|
||||||
default='eth',
|
default='eth',
|
||||||
help=('The name prefix of the veth endpoint put inside the '
|
help=('The name prefix of the veth endpoint put inside the '
|
||||||
'container.'))
|
'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')
|
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 schemata
|
||||||
from kuryr import utils
|
from kuryr import utils
|
||||||
|
|
||||||
|
|
||||||
MANDATORY_NEUTRON_EXTENSION = "subnet_allocation"
|
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
|
def neutron_client():
|
||||||
username = keystone_conf.admin_user
|
"""Creates the Neutron client for communicating with Neutron."""
|
||||||
tenant_name = keystone_conf.admin_tenant_name
|
if not hasattr(app, 'neutron'):
|
||||||
password = keystone_conf.admin_password
|
cfg.CONF.import_group('neutron_client', 'kuryr.common.config')
|
||||||
auth_token = keystone_conf.admin_token
|
cfg.CONF.import_group('keystone_client', 'kuryr.common.config')
|
||||||
auth_uri = keystone_conf.auth_uri.rstrip('/')
|
|
||||||
|
|
||||||
neutron_uri = cfg.CONF.neutron_client.neutron_uri
|
keystone_conf = cfg.CONF.keystone_client
|
||||||
enable_dhcp = cfg.CONF.neutron_client.enable_dhcp
|
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:
|
neutron_uri = cfg.CONF.neutron_client.neutron_uri
|
||||||
|
if username and password:
|
||||||
# Authenticate with password crentials
|
# Authenticate with password crentials
|
||||||
app.neutron = utils.get_neutron_client(
|
app.neutron = utils.get_neutron_client(
|
||||||
url=neutron_uri, username=username, tenant_name=tenant_name,
|
url=neutron_uri, username=username, tenant_name=tenant_name,
|
||||||
password=password, auth_url=auth_uri)
|
password=password, auth_url=auth_uri)
|
||||||
else:
|
else:
|
||||||
app.neutron = utils.get_neutron_client_simple(
|
app.neutron = utils.get_neutron_client_simple(
|
||||||
url=neutron_uri, token=auth_token)
|
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():
|
def check_for_neutron_ext_support():
|
||||||
"""Validates for mandatory extension support availability in neutron.
|
"""Validates for mandatory extension support availability in neutron."""
|
||||||
"""
|
|
||||||
try:
|
try:
|
||||||
app.neutron.show_extension(MANDATORY_NEUTRON_EXTENSION)
|
app.neutron.show_extension(MANDATORY_NEUTRON_EXTENSION)
|
||||||
except n_exceptions.NeutronClientException as e:
|
except n_exceptions.NeutronClientException as e:
|
||||||
@ -71,8 +76,6 @@ SUBNET_POOLS_V4 = [
|
|||||||
SUBNET_POOLS_V6 = [
|
SUBNET_POOLS_V6 = [
|
||||||
p.strip() for p in os.environ.get('SUBNET_POOLS_V6', 'kuryr6').split(',')]
|
p.strip() for p in os.environ.get('SUBNET_POOLS_V6', 'kuryr6').split(',')]
|
||||||
|
|
||||||
app.neutron.format = 'json'
|
|
||||||
|
|
||||||
|
|
||||||
def _cache_default_subnetpool_ids(app):
|
def _cache_default_subnetpool_ids(app):
|
||||||
"""Caches IDs of the default subnetpools as app.DEFAULT_POOL_IDS."""
|
"""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,
|
'network_id': neutron_network_id,
|
||||||
'ip_version': cidr.version,
|
'ip_version': cidr.version,
|
||||||
'cidr': subnet_cidr,
|
'cidr': subnet_cidr,
|
||||||
'enable_dhcp': enable_dhcp,
|
'enable_dhcp': app.enable_dhcp,
|
||||||
}
|
}
|
||||||
if pool_id:
|
if pool_id:
|
||||||
del new_subnet['cidr']
|
del new_subnet['cidr']
|
||||||
@ -747,3 +750,6 @@ def network_driver_leave():
|
|||||||
app.logger.error('Cleaning the veth pair up was failed.')
|
app.logger.error('Cleaning the veth pair up was failed.')
|
||||||
|
|
||||||
return flask.jsonify(constants.SCHEMA['SUCCESS'])
|
return flask.jsonify(constants.SCHEMA['SUCCESS'])
|
||||||
|
|
||||||
|
|
||||||
|
neutron_client()
|
||||||
|
@ -10,9 +10,15 @@
|
|||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from kuryr import app
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def start():
|
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.debug = True
|
||||||
app.run("0.0.0.0", port=2377)
|
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_DIR=${KURYR_JSON_DIR:-/usr/lib/docker/plugins/kuryr}
|
||||||
KURYR_JSON=${KURYR_JSON_DIR}/${KURYR_JSON_FILENAME}
|
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
|
if [[ ! -d "${KURYR_JSON_DIR}" ]]; then
|
||||||
echo -n "${KURYR_JSON_DIR} directory is missing. Creating it... "
|
echo -n "${KURYR_JSON_DIR} directory is missing. Creating it... "
|
||||||
sudo mkdir -p ${KURYR_JSON_DIR}
|
sudo mkdir -p ${KURYR_JSON_DIR}
|
||||||
@ -32,4 +38,24 @@ if [[ ! -f "${KURYR_JSON}" ]]; then
|
|||||||
echo "Done"
|
echo "Done"
|
||||||
fi
|
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
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from kuryr import controllers
|
|
||||||
from kuryr import server
|
from kuryr import server
|
||||||
|
|
||||||
controllers.check_for_neutron_ext_support()
|
|
||||||
server.start()
|
server.start()
|
||||||
|
Loading…
Reference in New Issue
Block a user