Made horizon, rabbit and mysql ports configurable
Addresses requests to make it easier to avoid conflicts between the Horizon dashboard and http services that might already be running on the machine. Configurable via snap config. Exposing via arguments to .init and testing post init configuration is left for a separate PR. Eventually, these may move to non standard ports by default. This PR sets the stage for that, but further discussion is needed before we decide whether to implement. (This commit also contains a sneaky fix for the username display at the end of the launch script.) Closes-Bug: 1814829 Change-Id: If728d6ec8024bca4d3e809637fbdcc03ed4e6934
This commit is contained in:
parent
d34a98ad15
commit
1a25e50a17
@ -20,6 +20,9 @@ snapctl set \
|
||||
config.network.ext-cidr=10.20.20.1/24 \
|
||||
config.network.security-rules=true \
|
||||
config.network.dashboard-allowed-hosts="*" \
|
||||
config.network.ports.dashboard=80 \
|
||||
config.network.ports.mysql=3306 \
|
||||
config.network.ports.rabbit=5672 \
|
||||
;
|
||||
|
||||
# Passwords, certs, etc.
|
||||
|
@ -17,6 +17,7 @@ setup:
|
||||
- "{snap_common}/etc/cinder/uwsgi/snap"
|
||||
- "{snap_common}/etc/nova/uwsgi/snap"
|
||||
- "{snap_common}/etc/horizon/uwsgi/snap"
|
||||
- "{snap_common}/etc/rabbitmq"
|
||||
- "{snap_common}/fernet-keys"
|
||||
- "{snap_common}/lib"
|
||||
- "{snap_common}/lib/images"
|
||||
@ -53,6 +54,7 @@ setup:
|
||||
neutron.nova.conf.j2: "{snap_common}/etc/neutron/neutron.conf.d/nova.conf"
|
||||
neutron.database.conf.j2: "{snap_common}/etc/neutron/neutron.conf.d/database.conf"
|
||||
neutron.conf.d.rabbitmq.conf.j2: "{snap_common}/etc/neutron/neutron.conf.d/rabbitmq.conf"
|
||||
rabbitmq.conf.j2: "{snap_common}/etc/rabbitmq/rabbitmq.config"
|
||||
|
||||
chmod:
|
||||
"{snap_common}/instances": 0755
|
||||
@ -69,6 +71,9 @@ setup:
|
||||
extcidr: 'config.network.ext-cidr'
|
||||
dns: 'config.network.dns'
|
||||
dashboard_allowed_hosts: 'config.network.dashboard-allowed-hosts'
|
||||
dashboard_port: 'config.network.ports.dashboard'
|
||||
mysql_port: 'config.network.ports.mysql'
|
||||
rabbit_port: 'config.network.ports.rabbit'
|
||||
entry_points:
|
||||
keystone-manage:
|
||||
binary: "{snap}/bin/keystone-manage"
|
||||
|
@ -1,2 +1,2 @@
|
||||
[database]
|
||||
connection = mysql+pymysql://glance:glance@{{ control_ip }}/glance
|
||||
connection = mysql+pymysql://glance:glance@{{ control_ip }}:{{ mysql_port }}/glance
|
||||
|
@ -2,7 +2,7 @@
|
||||
# to define this template. Be sure to update "listen" with the port number and
|
||||
# also update "api-name" for the socket.
|
||||
server {
|
||||
listen 80;
|
||||
listen {{ dashboard_port }};
|
||||
error_log syslog:server=unix:/dev/log;
|
||||
access_log syslog:server=unix:/dev/log;
|
||||
location / {
|
||||
|
@ -1,2 +1,2 @@
|
||||
[database]
|
||||
connection = mysql+pymysql://keystone:keystone@{{ control_ip }}/keystone
|
||||
connection = mysql+pymysql://keystone:keystone@{{ control_ip }}:{{ mysql_port }}/keystone
|
||||
|
@ -1,2 +1,2 @@
|
||||
[DEFAULT]
|
||||
transport_url = rabbit://openstack:rabbitmq@{{ control_ip }}
|
||||
transport_url = rabbit://openstack:rabbitmq@{{ control_ip }}:{{ rabbit_port }}
|
||||
|
@ -1,2 +1,2 @@
|
||||
[database]
|
||||
connection = mysql+pymysql://neutron:neutron@{{ control_ip }}/neutron
|
||||
connection = mysql+pymysql://neutron:neutron@{{ control_ip }}:{{ mysql_port }}/neutron
|
||||
|
@ -1,5 +1,5 @@
|
||||
[database]
|
||||
connection = mysql+pymysql://nova:nova@{{ control_ip }}/nova
|
||||
connection = mysql+pymysql://nova:nova@{{ control_ip }}:{{ mysql_port }}/nova
|
||||
|
||||
[api_database]
|
||||
connection = mysql+pymysql://nova_api:nova_api@{{ control_ip }}/nova_api
|
||||
connection = mysql+pymysql://nova_api:nova_api@{{ control_ip }}:{{ mysql_port }}/nova_api
|
||||
|
@ -1,2 +1,2 @@
|
||||
[DEFAULT]
|
||||
transport_url = rabbit://openstack:rabbitmq@{{ control_ip }}
|
||||
transport_url = rabbit://openstack:rabbitmq@{{ control_ip }}:{{ rabbit_port }}
|
||||
|
6
snap-overlay/templates/rabbitmq.conf.j2
Normal file
6
snap-overlay/templates/rabbitmq.conf.j2
Normal file
@ -0,0 +1,6 @@
|
||||
[
|
||||
{rabbit, [
|
||||
{tcp_listeners, [{{ rabbit_port}}]}
|
||||
]
|
||||
}
|
||||
].
|
@ -17,12 +17,16 @@
|
||||
set -e
|
||||
|
||||
init_config() {
|
||||
# Write out config.
|
||||
# Include 'client' section for pymysql client.
|
||||
# TODO: is [mysql] section necessary?
|
||||
mkdir -p "${CONFDIR}"
|
||||
echo "Generating config file in ${CONFFILE}..."
|
||||
cat > ${CONFFILE} <<EOF
|
||||
[mysqld]
|
||||
pid-file=${RUNDIR}/mysqld.pid
|
||||
socket=${RUNDIR}/mysqld.sock
|
||||
port=${PORT}
|
||||
datadir=${DATADIR}
|
||||
log-error=${LOGDIR}/error.log
|
||||
secure-file-priv=${FILESDIR}
|
||||
@ -30,9 +34,15 @@ basedir=${BASEDIR}
|
||||
|
||||
[mysql]
|
||||
socket=${RUNDIR}/mysqld.sock
|
||||
port=${PORT}
|
||||
|
||||
[client]
|
||||
socket=${RUNDIR}/mysqld.sock
|
||||
port=${PORT}
|
||||
|
||||
[mysql_upgrade]
|
||||
socket=${RUNDIR}/mysqld.sock
|
||||
port=${PORT}
|
||||
EOF
|
||||
}
|
||||
|
||||
@ -57,6 +67,7 @@ CONFDIR="${MYSQL_SNAPDIR}/etc/mysql"
|
||||
CONFFILE="${CONFDIR}/my.cnf"
|
||||
FILESDIR="${MYSQL_SNAPDIR}/lib/mysql-files"
|
||||
BASEDIR="${SNAP}/usr"
|
||||
PORT=$(snapctl get config.network.ports.mysql)
|
||||
|
||||
[ -d "${LOGDIR}" ] || mkdir -p ${LOGDIR}
|
||||
[ -f "${LOGDIR}/error.log" ] || touch ${LOGDIR}/error.log
|
||||
|
@ -16,4 +16,18 @@ if [ -z "$(snapctl get config)" ]; then
|
||||
mkdir -p ${SNAP_COMMON}/etc/horizon/local_settings.d
|
||||
fi
|
||||
|
||||
# Add default ports for mysql, rabbit and dashboard services.
|
||||
# [2019-11-21] build 171 (beta) -> master
|
||||
if [ -z "$(snapctl get config.network.ports.dashboard)" ]; then
|
||||
snapctl set config.network.ports.dashboard=80
|
||||
fi
|
||||
|
||||
if [ -z "$(snapctl get config.network.ports.mysql)" ]; then
|
||||
snapctl set config.network.ports.mysql=3306
|
||||
fi
|
||||
|
||||
if [ -z "$(snapctl get config.network.ports.rabbit)" ]; then
|
||||
snapctl set config.network.ports.rabbit=5672
|
||||
fi
|
||||
|
||||
snap-openstack setup # Write any template changes.
|
||||
|
@ -778,11 +778,11 @@ parts:
|
||||
rm -f $SNAPCRAFT_PART_INSTALL/usr/bin/erl
|
||||
rm -f $SNAPCRAFT_PART_INSTALL/usr/lib/rabbitmq/bin/rabbitmq-script-wrapper
|
||||
# NOTE(jamespage): The versioned path below is brittle.
|
||||
rm -f $SNAPCRAFT_PART_INSTALL/usr/lib/rabbitmq/lib/rabbitmq_server-3.5.7/sbin/rabbitmq-defaults
|
||||
rm -f $SNAPCRAFT_PART_INSTALL/usr/lib/rabbitmq/lib/rabbitmq_server-3.6.10/sbin/rabbitmq-defaults
|
||||
snapcraftctl build
|
||||
organize:
|
||||
rabbitmq-script-wrapper: usr/lib/rabbitmq/bin/rabbitmq-script-wrapper
|
||||
rabbitmq-defaults: usr/lib/rabbitmq/lib/rabbitmq_server-3.5.7/sbin/rabbitmq-defaults
|
||||
rabbitmq-defaults: usr/lib/rabbitmq/lib/rabbitmq_server-3.6.10/sbin/rabbitmq-defaults
|
||||
erl: usr/bin/erl
|
||||
|
||||
# Memcached Token Caching
|
||||
|
@ -224,7 +224,13 @@ class Framework(unittest.TestCase):
|
||||
# Test
|
||||
print('Verifying GUI for (IP: {})'.format(host.horizon_ip))
|
||||
# Verify that our GUI is working properly
|
||||
self.driver.get("http://{}/".format(host.horizon_ip))
|
||||
dashboard_port = check_output(*host.prefix, 'sudo', 'snap', 'get',
|
||||
'microstack',
|
||||
'config.network.ports.dashboard')
|
||||
self.driver.get("http://{}:{}/".format(
|
||||
host.horizon_ip,
|
||||
dashboard_port
|
||||
))
|
||||
# Login to horizon!
|
||||
self.driver.find_element(By.ID, "id_username").click()
|
||||
self.driver.find_element(By.ID, "id_username").send_keys("admin")
|
||||
|
@ -267,7 +267,9 @@ class RabbitMq(Question):
|
||||
config_key = 'config.services.control-plane'
|
||||
|
||||
def _wait(self) -> None:
|
||||
nc_wait(_env['control_ip'], '5672')
|
||||
rabbit_port = check_output(
|
||||
'snapctl', 'get', 'config.network.ports.rabbit')
|
||||
nc_wait(_env['control_ip'], rabbit_port)
|
||||
log_file = '{SNAP_COMMON}/log/rabbitmq/startup_log'.format(**_env)
|
||||
log_wait(log_file, 'completed')
|
||||
|
||||
@ -301,7 +303,9 @@ class DatabaseSetup(Question):
|
||||
config_key = 'config.services.control-plane'
|
||||
|
||||
def _wait(self) -> None:
|
||||
nc_wait(_env['control_ip'], '3306')
|
||||
mysql_port = check_output(
|
||||
'snapctl', 'get', 'config.network.ports.mysql')
|
||||
nc_wait(_env['control_ip'], mysql_port)
|
||||
log_wait('{SNAP_COMMON}/log/mysql/error.log'.format(**_env),
|
||||
'mysqld: ready for connections.')
|
||||
|
||||
|
@ -127,9 +127,8 @@ def sql(cmd: str) -> None:
|
||||
:param cmd: sql to execute.
|
||||
|
||||
"""
|
||||
mysql_conf = '${SNAP_USER_COMMON}/etc/mysql/my.cnf'.format(**_env)
|
||||
connection = pymysql.connect(host='localhost', user='root',
|
||||
read_default_file=mysql_conf)
|
||||
mysql_conf = '{SNAP_COMMON}/etc/mysql/my.cnf'.format(**_env)
|
||||
connection = pymysql.connect(read_default_file=mysql_conf)
|
||||
|
||||
with connection.cursor() as cursor:
|
||||
cursor.execute(cmd)
|
||||
|
@ -146,15 +146,29 @@ def launch(name, args):
|
||||
'-c', 'floating_ip_address', 'external')
|
||||
check('openstack', 'server', 'add', 'floating', 'ip', server_id, ip)
|
||||
|
||||
username = '<username>'
|
||||
if args.flavor:
|
||||
# Try to guess at a username.
|
||||
# TODO: make this more sophisticated.
|
||||
if 'fedora' in args.flavor.lower():
|
||||
username = 'fedora'
|
||||
if 'ubuntu' in args.flavor.lower():
|
||||
username = 'ubuntu'
|
||||
if 'cirros' in args.flavor.lower():
|
||||
username = 'cirros'
|
||||
|
||||
print("""\
|
||||
Server {} launched! (status is {})
|
||||
Server {name} launched! (status is {status})
|
||||
|
||||
Access it with `ssh -i \
|
||||
$HOME/.ssh/id_microstack` <username>@{}""".format(name, status, ip))
|
||||
$HOME/.ssh/id_microstack` {username}@{ip}""".format(name=name, status=status,
|
||||
username=username, ip=ip))
|
||||
|
||||
gate = check_output('snapctl', 'get', 'config.network.ext-gateway')
|
||||
print('You can also visit the OpenStack dashboard at http://{}'.format(
|
||||
gate))
|
||||
port = check_output('snapctl', 'get', 'config.network.ports.dashboard')
|
||||
|
||||
print('You can also visit the OpenStack dashboard at http://{}:{}'.format(
|
||||
gate, port))
|
||||
|
||||
|
||||
def main():
|
||||
|
Loading…
Reference in New Issue
Block a user