Initial updates for grizzly
This commit is contained in:
parent
cd6cc09220
commit
6391c055bc
|
@ -56,6 +56,20 @@ def render_l3_agent_conf():
|
|||
)
|
||||
|
||||
|
||||
def render_metadata_agent_conf():
|
||||
context = get_keystone_conf()
|
||||
if (context and
|
||||
os.path.exists(qutils.METADATA_AGENT_CONF)):
|
||||
context['local_ip'] = utils.get_host_ip()
|
||||
context['shared_secret'] = qutils.get_shared_secret()
|
||||
with open(qutils.METADATA_AGENT_CONF, "w") as conf:
|
||||
conf.write(utils.render_template(
|
||||
os.path.basename(qutils.METADATA_AGENT_CONF),
|
||||
context
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def render_quantum_conf():
|
||||
context = get_rabbit_conf()
|
||||
if (context and
|
||||
|
@ -71,7 +85,7 @@ def render_quantum_conf():
|
|||
|
||||
|
||||
def render_plugin_conf():
|
||||
context = get_db_conf()
|
||||
context = get_quantum_db_conf()
|
||||
if (context and
|
||||
os.path.exists(qutils.PLUGIN_CONF[PLUGIN])):
|
||||
context['local_ip'] = utils.get_host_ip()
|
||||
|
@ -84,6 +98,19 @@ def render_plugin_conf():
|
|||
)
|
||||
|
||||
|
||||
def render_metadata_api_conf():
|
||||
context = get_nova_db_conf()
|
||||
if (context and
|
||||
os.path.exists(qutils.NOVA_CONF)):
|
||||
context['shared_secret'] = qutils.get_shared_secret()
|
||||
with open(qutils.NOVA_CONF, "w") as conf:
|
||||
conf.write(utils.render_template(
|
||||
os.path.basename(qutils.NOVA_CONF),
|
||||
context
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
def get_keystone_conf():
|
||||
for relid in utils.relation_ids('quantum-network-service'):
|
||||
for unit in utils.relation_list(relid):
|
||||
|
@ -106,24 +133,28 @@ def get_keystone_conf():
|
|||
|
||||
|
||||
def db_joined():
|
||||
utils.relation_set(username=qutils.DB_USER,
|
||||
database=qutils.QUANTUM_DB,
|
||||
hostname=utils.unit_get('private-address'))
|
||||
utils.relation_set(quantum_username=qutils.DB_USER,
|
||||
quantum_database=qutils.QUANTUM_DB,
|
||||
quantum_hostname=utils.unit_get('private-address'),
|
||||
nova_username=qutils.NOVA_DB_USER,
|
||||
nova_database=qutils.NOVA_DB,
|
||||
nova_hostname=utils.unit_get('private-address'))
|
||||
|
||||
|
||||
def db_changed():
|
||||
render_plugin_conf()
|
||||
render_metadata_api_conf()
|
||||
utils.restart(*qutils.GATEWAY_AGENTS[PLUGIN])
|
||||
|
||||
|
||||
def get_db_conf():
|
||||
def get_quantum_db_conf():
|
||||
for relid in utils.relation_ids('shared-db'):
|
||||
for unit in utils.relation_list(relid):
|
||||
conf = {
|
||||
"host": utils.relation_get('private-address',
|
||||
unit, relid),
|
||||
"user": qutils.DB_USER,
|
||||
"password": utils.relation_get('password',
|
||||
"password": utils.relation_get('quantum_password',
|
||||
unit, relid),
|
||||
"db": qutils.QUANTUM_DB
|
||||
}
|
||||
|
@ -132,6 +163,22 @@ def get_db_conf():
|
|||
return None
|
||||
|
||||
|
||||
def get_nova_db_conf():
|
||||
for relid in utils.relation_ids('shared-db'):
|
||||
for unit in utils.relation_list(relid):
|
||||
conf = {
|
||||
"host": utils.relation_get('private-address',
|
||||
unit, relid),
|
||||
"user": qutils.NOVA_DB_USER,
|
||||
"password": utils.relation_get('nova_password',
|
||||
unit, relid),
|
||||
"db": qutils.NOVA_DB
|
||||
}
|
||||
if None not in conf.itervalues():
|
||||
return conf
|
||||
return None
|
||||
|
||||
|
||||
def amqp_joined():
|
||||
utils.relation_set(username=qutils.RABBIT_USER,
|
||||
vhost=qutils.RABBIT_VHOST)
|
||||
|
@ -160,6 +207,7 @@ def get_rabbit_conf():
|
|||
|
||||
def nm_changed():
|
||||
render_l3_agent_conf()
|
||||
render_metadata_agent_conf()
|
||||
utils.restart(*qutils.GATEWAY_AGENTS[PLUGIN])
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
import subprocess
|
||||
import os
|
||||
import uuid
|
||||
from utils import juju_log as log
|
||||
from utils import get_os_version
|
||||
|
||||
|
||||
OVS = "ovs"
|
||||
|
@ -28,28 +31,51 @@ GATEWAY_PKGS = {
|
|||
"quantum-plugin-openvswitch-agent",
|
||||
"quantum-l3-agent",
|
||||
"quantum-dhcp-agent",
|
||||
'python-mysqldb'
|
||||
'python-mysqldb',
|
||||
"nova-api-metadata"
|
||||
],
|
||||
NVP: [
|
||||
"quantum-plugin-nicira"
|
||||
"quantum-plugin-nicira",
|
||||
"quantum-l3-agent",
|
||||
"quantum-dhcp-agent",
|
||||
'python-mysqldb',
|
||||
"nova-api-metadata"
|
||||
]
|
||||
}
|
||||
|
||||
# TODO: conditionally add quantum-metadata-agent if
|
||||
# running 2013.1 onwards. OR add some overrides
|
||||
# start on starting quantum-l3-agent
|
||||
# stop on stopping quantum-l3-agent
|
||||
GATEWAY_AGENTS = {
|
||||
OVS: [
|
||||
"quantum-plugin-openvswitch-agent",
|
||||
"quantum-l3-agent",
|
||||
"quantum-dhcp-agent"
|
||||
"quantum-dhcp-agent",
|
||||
"nova-api-metadata"
|
||||
],
|
||||
NVP: [
|
||||
"quantum-l3-agent",
|
||||
"quantum-dhcp-agent",
|
||||
"nova-api-metadata"
|
||||
]
|
||||
}
|
||||
|
||||
if get_os_version('quantum-common') >= "2013.1":
|
||||
for plugin in GATEWAY_AGENTS:
|
||||
GATEWAY_AGENTS[plugin].append("quantum-metadata-agent")
|
||||
|
||||
DB_USER = "quantum"
|
||||
QUANTUM_DB = "quantum"
|
||||
KEYSTONE_SERVICE = "quantum"
|
||||
NOVA_DB_USER = "nova"
|
||||
NOVA_DB = "nova"
|
||||
|
||||
QUANTUM_CONF = "/etc/quantum/quantum.conf"
|
||||
L3_AGENT_CONF = "/etc/quantum/l3_agent.ini"
|
||||
DHCP_AGENT_CONF = "/etc/quantum/dhcp_agent.ini"
|
||||
METADATA_AGENT_CONF = "/etc/quantum/metadata_agent.ini"
|
||||
NOVA_CONF = "/etc/nova/nova.conf"
|
||||
|
||||
RABBIT_USER = "nova"
|
||||
RABBIT_VHOST = "nova"
|
||||
|
@ -90,3 +116,18 @@ def del_bridge_port(name, port):
|
|||
'Deleting port {} from bridge {}'.format(port, name))
|
||||
subprocess.check_call(["ovs-vsctl", "del-port", name, port])
|
||||
subprocess.check_call(["ip", "link", "set", port, "down"])
|
||||
|
||||
|
||||
SHARED_SECRET = "/etc/quantum/secret.txt"
|
||||
|
||||
|
||||
def get_shared_secret():
|
||||
secret = None
|
||||
if not os.path.exists(SHARED_SECRET):
|
||||
secret = str(uuid.uuid4())
|
||||
with open(SHARED_SECRET, 'w') as secret_file:
|
||||
secret_file.write(secret)
|
||||
else:
|
||||
with open(SHARED_SECRET, 'r') as secret_file:
|
||||
secret = secret_file.read().strip()
|
||||
return secret
|
||||
|
|
|
@ -11,6 +11,7 @@ import os
|
|||
import subprocess
|
||||
import socket
|
||||
import sys
|
||||
import apt_pkg as apt
|
||||
|
||||
|
||||
def do_hooks(hooks):
|
||||
|
@ -260,3 +261,13 @@ def stop(*services):
|
|||
def start(*services):
|
||||
for service in services:
|
||||
_service_ctl(service, 'start')
|
||||
|
||||
|
||||
def get_os_version(package=None):
|
||||
apt.init()
|
||||
cache = apt.Cache()
|
||||
pkg = cache[package or 'quantum-common']
|
||||
if pkg.current_ver:
|
||||
return apt.upstream_version(pkg.current_ver.ver_str)
|
||||
else:
|
||||
return None
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
[DEFAULT]
|
||||
debug = True
|
||||
auth_url = http://{{ keystone_host }}:{{ service_port }}/v2.0
|
||||
auth_region = RegionOne
|
||||
admin_tenant_name = {{ service_tenant }}
|
||||
admin_user = {{ service_username }}
|
||||
admin_password = {{ service_password }}
|
||||
root_helper = sudo quantum-rootwrap /etc/quantum/rootwrap.conf
|
||||
state_path = /var/lib/quantum
|
||||
# Gateway runs a metadata API server locally
|
||||
nova_metadata_ip = {{ local_ip }}
|
||||
nova_metadata_port = 8775
|
||||
# When proxying metadata requests, Quantum signs the Instance-ID header with a
|
||||
# shared secret to prevent spoofing. You may select any string for a secret,
|
||||
# but it must match here and in the configuration used by the Nova Metadata
|
||||
# Server. NOTE: Nova uses a different key: quantum_metadata_proxy_shared_secret
|
||||
metadata_proxy_shared_secret = {{ shared_secret }}
|
|
@ -0,0 +1,12 @@
|
|||
[DEFAULT]
|
||||
logdir=/var/log/nova
|
||||
state_path=/var/lib/nova
|
||||
lock_path=/var/lock/nova
|
||||
root_helper=sudo nova-rootwrap /etc/nova/rootwrap.conf
|
||||
verbose=True
|
||||
api_paste_config=/etc/nova/api-paste.ini
|
||||
enabled_apis=metadata
|
||||
multi_host=True
|
||||
sql_connection=mysql://{{ user }}:{{ password }}@{{ host }}/{{ db }}
|
||||
quantum_metadata_proxy_shared_secret={{ shared_secret }}
|
||||
service_quantum_metadata_proxy=True
|
|
@ -12,4 +12,5 @@ api_paste_config = /etc/quantum/api-paste.ini
|
|||
control_exchange = quantum
|
||||
notification_driver = quantum.openstack.common.notifier.list_notifier
|
||||
list_notifier_drivers = quantum.openstack.common.notifier.rabbit_notifier
|
||||
lock_path = /var/run/quantum
|
||||
[QUOTAS]
|
||||
|
|
Loading…
Reference in New Issue