Various fixes.
This commit is contained in:
parent
d651b3904b
commit
5c010b878e
@ -22,11 +22,11 @@ options:
|
||||
default: nova
|
||||
type: string
|
||||
decsription: Rabbitmq vhost
|
||||
db-user:
|
||||
database-user:
|
||||
default: nova
|
||||
type: string
|
||||
description: Username for database access
|
||||
nova-db:
|
||||
database:
|
||||
default: nova
|
||||
type: string
|
||||
description: Database name
|
||||
|
@ -229,7 +229,14 @@ class OSConfigRenderer(object):
|
||||
# using a munged full path, eg:
|
||||
# /etc/apache2/apache2.conf -> etc_apache2_apache2.conf
|
||||
_tmpl = '_'.join(config_file.split('/')[1:])
|
||||
template = self._get_template(_tmpl)
|
||||
try:
|
||||
template = self._get_template(_tmpl)
|
||||
except exceptions.TemplateNotFound as e:
|
||||
log('Could not load template from %s by %s or %s.' %
|
||||
(self.templates_dir, os.path.basename(config_file), _tmpl),
|
||||
level=ERROR)
|
||||
raise e
|
||||
|
||||
log('Rendering from template: %s' % _tmpl, level=INFO)
|
||||
return template.render(ctxt)
|
||||
|
||||
|
@ -163,6 +163,25 @@ def get_os_version_package(pkg, fatal=True):
|
||||
#error_out(e)
|
||||
|
||||
|
||||
os_rel = None
|
||||
|
||||
|
||||
def os_release(package, base='essex'):
|
||||
'''
|
||||
Returns OpenStack release codename from a cached global.
|
||||
If the codename can not be determined from either an installed package or
|
||||
the installation source, the earliest release supported by the charm should
|
||||
be returned.
|
||||
'''
|
||||
global os_rel
|
||||
if os_rel:
|
||||
return os_rel
|
||||
os_rel = (get_os_codename_package(package, fatal=False) or
|
||||
get_os_codename_install_source(config('openstack-origin')) or
|
||||
base)
|
||||
return os_rel
|
||||
|
||||
|
||||
def import_key(keyid):
|
||||
cmd = "apt-key adv --keyserver keyserver.ubuntu.com " \
|
||||
"--recv-keys %s" % keyid
|
||||
|
@ -12,10 +12,7 @@ from charmhelpers.contrib.openstack import context
|
||||
|
||||
from charmhelpers.core.host import apt_install, filter_installed_packages
|
||||
|
||||
from charmhelpers.contrib.openstack.utils import (
|
||||
get_os_codename_package,
|
||||
get_os_codename_install_source,
|
||||
)
|
||||
from charmhelpers.contrib.openstack.utils import os_release
|
||||
|
||||
|
||||
def _save_flag_file(path, data):
|
||||
@ -120,7 +117,7 @@ class NeutronComputeContext(NeutronContext):
|
||||
|
||||
def ovs_ctxt(self):
|
||||
ctxt = super(NeutronComputeContext, self).ovs_ctxt()
|
||||
if get_os_codename_package('nova-common') == 'folsom':
|
||||
if os_release('nova-common') == 'folsom':
|
||||
n_driver = 'nova.virt.libvirt.vif.LibvirtHybridOVSBridgeDriver'
|
||||
else:
|
||||
n_driver = 'nova.virt.libvirt.vif.LibvirtGenericVIFDriver'
|
||||
@ -135,7 +132,11 @@ class NeutronCCContext(NeutronContext):
|
||||
|
||||
@property
|
||||
def plugin(self):
|
||||
return network_plugin()
|
||||
return neutron_plugin()
|
||||
|
||||
@property
|
||||
def network_manager(self):
|
||||
return network_manager()
|
||||
|
||||
@property
|
||||
def neutron_security_groups(self):
|
||||
@ -196,7 +197,7 @@ def neutron_plugins():
|
||||
}
|
||||
|
||||
|
||||
def network_plugin():
|
||||
def neutron_plugin():
|
||||
# quantum-plugin config setting can be safely overriden
|
||||
# as we only supported OVS in G/neutron
|
||||
return config('neutron-plugin') or config('quantum-plugin')
|
||||
@ -229,26 +230,13 @@ def network_plugin_attribute(plugin, attr):
|
||||
return None
|
||||
|
||||
|
||||
os_rel = None
|
||||
|
||||
|
||||
def os_release():
|
||||
global os_rel
|
||||
if os_rel:
|
||||
return os_rel
|
||||
os_rel = (get_os_codename_package('nova-common', fatal=False) or
|
||||
get_os_codename_install_source(config('openstack-origin')) or
|
||||
'essex')
|
||||
return os_rel
|
||||
|
||||
|
||||
def network_manager():
|
||||
'''
|
||||
Deals with the renaming of Quantum to Neutron in H and any situations
|
||||
that require compatability (eg, deploying H with network-manager=quantum,
|
||||
upgrading from G).
|
||||
'''
|
||||
release = os_release()
|
||||
release = os_release('nova-common')
|
||||
manager = config('network-manager').lower()
|
||||
|
||||
if manager not in ['quantum', 'neutron']:
|
||||
|
@ -1,8 +1,7 @@
|
||||
|
||||
from misc_utils import network_manager
|
||||
from charmhelpers.core.hookenv import relation_ids, relation_set
|
||||
from charmhelpers.core.hookenv import config, relation_ids, relation_set
|
||||
from charmhelpers.core.host import apt_install, filter_installed_packages
|
||||
from charmhelpers.contrib.openstack import context, utils
|
||||
from charmhelpers.contrib.openstack import context, neutron, utils
|
||||
|
||||
from charmhelpers.contrib.hahelpers.cluster import (
|
||||
determine_api_port, determine_haproxy_port)
|
||||
@ -87,7 +86,7 @@ class HAProxyContext(context.HAProxyContext):
|
||||
})
|
||||
ctxt['osapi_volume_listen_port'] = api_port('nova-api-os-volume')
|
||||
|
||||
if network_manager() in ['neutron', 'quantum']:
|
||||
if neutron.network_manager() in ['neutron', 'quantum']:
|
||||
port_mapping.update({
|
||||
'neutron-server': [
|
||||
determine_haproxy_port(api_port('neutron-server')),
|
||||
@ -95,3 +94,21 @@ class HAProxyContext(context.HAProxyContext):
|
||||
})
|
||||
ctxt['bind_port'] = api_port('neutron-server')
|
||||
ctxt['service_ports'] = port_mapping
|
||||
|
||||
|
||||
class NeutronCCContext(context.NeutronContext):
|
||||
interfaces = []
|
||||
|
||||
@property
|
||||
def plugin(self):
|
||||
return neutron.neutron_plugin()
|
||||
|
||||
@property
|
||||
def network_manager(self):
|
||||
return neutron.network_manager()
|
||||
|
||||
@property
|
||||
def neutron_security_groups(self):
|
||||
sec_groups = (config('neutron-security-groups') or
|
||||
config('quantum-security-groups'))
|
||||
return sec_groups.lower() == 'yes'
|
||||
|
@ -154,6 +154,7 @@ def identity_changed():
|
||||
CONFIGS.write('/etc/nova/api-paste.ini')
|
||||
if network_manager() == 'quantum':
|
||||
CONFIGS.write('/etc/quantum/api-paste.ini')
|
||||
CONFIGS.write('/etc/quantum/quantum.conf')
|
||||
if network_manager() == 'neutron':
|
||||
CONFIGS.write('/etc/neutron/neutron.conf')
|
||||
# XXX configure quantum networking
|
||||
@ -217,7 +218,7 @@ def compute_joined(rid=None):
|
||||
relation_set(rid=rid, **rel_settings)
|
||||
|
||||
|
||||
@hooks.hook('cloud-compute-relation-joined')
|
||||
@hooks.hook('cloud-compute-relation-changed')
|
||||
def compute_changed():
|
||||
migration_auth = relation_get('migration_auth_type')
|
||||
if migration_auth == 'ssh':
|
||||
|
@ -6,9 +6,11 @@ from base64 import b64encode
|
||||
from collections import OrderedDict
|
||||
from copy import deepcopy
|
||||
|
||||
from charmhelpers.contrib.openstack import templating, context
|
||||
from charmhelpers.contrib.openstack import context, templating
|
||||
from charmhelpers.contrib.openstack.neutron import network_manager
|
||||
|
||||
from charmhelpers.contrib.openstack.utils import (
|
||||
os_release,
|
||||
save_script_rc as _save_script_rc)
|
||||
|
||||
|
||||
@ -17,14 +19,13 @@ from charmhelpers.core.hookenv import (
|
||||
log,
|
||||
relation_ids,
|
||||
remote_unit,
|
||||
INFO,
|
||||
ERROR,
|
||||
)
|
||||
|
||||
|
||||
import nova_cc_context
|
||||
|
||||
from misc_utils import network_manager, NeutronCCContext, os_release
|
||||
|
||||
TEMPLATES = 'templates/'
|
||||
|
||||
CLUSTER_RES = 'res_nova_vip'
|
||||
@ -57,9 +58,9 @@ BASE_RESOURCE_MAP = OrderedDict([
|
||||
('/etc/nova/nova.conf', {
|
||||
'services': BASE_SERVICES,
|
||||
'contexts': [context.AMQPContext(),
|
||||
context.SharedDBContext(),
|
||||
context.SharedDBContext(relation_prefix='nova'),
|
||||
context.ImageServiceContext(),
|
||||
NeutronCCContext(),
|
||||
nova_cc_context.NeutronCCContext(),
|
||||
nova_cc_context.VolumeServiceContext()],
|
||||
}),
|
||||
('/etc/nova/api-paste.ini', {
|
||||
@ -70,7 +71,8 @@ BASE_RESOURCE_MAP = OrderedDict([
|
||||
'services': ['quantum-server'],
|
||||
'contexts': [context.AMQPContext(),
|
||||
nova_cc_context.HAProxyContext(),
|
||||
NeutronCCContext()],
|
||||
context.IdentityServiceContext(),
|
||||
nova_cc_context.NeutronCCContext()],
|
||||
}),
|
||||
('/etc/quantum/api-paste.ini', {
|
||||
'services': ['quantum-server'],
|
||||
@ -80,7 +82,7 @@ BASE_RESOURCE_MAP = OrderedDict([
|
||||
'services': ['neutron-server'],
|
||||
'contexts': [context.AMQPContext(),
|
||||
context.IdentityServiceContext(),
|
||||
NeutronCCContext(),
|
||||
nova_cc_context.NeutronCCContext(),
|
||||
nova_cc_context.HAProxyContext()],
|
||||
}),
|
||||
('/etc/haproxy/haproxy.cfg', {
|
||||
@ -124,7 +126,7 @@ def resource_map():
|
||||
|
||||
|
||||
def register_configs():
|
||||
release = os_release()
|
||||
release = os_release('nova-common')
|
||||
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
|
||||
openstack_release=release)
|
||||
for cfg, rscs in resource_map().iteritems():
|
||||
@ -186,7 +188,7 @@ def do_openstack_upgrade():
|
||||
|
||||
def volume_service():
|
||||
'''Specifies correct volume API for specific OS release'''
|
||||
os_vers = os_release()
|
||||
os_vers = os_release('nova-common')
|
||||
if os_vers == 'essex':
|
||||
return 'nova-volume'
|
||||
elif os_vers == 'folsom': # support both drivers in folsom.
|
||||
@ -197,6 +199,7 @@ def volume_service():
|
||||
|
||||
def migrate_database():
|
||||
'''Runs nova-manage to initialize a new database or migrate existing'''
|
||||
log('Migrating the nova database', level=INFO)
|
||||
cmd = ['nova-manage', 'db', 'sync']
|
||||
subprocess.check_call(cmd)
|
||||
|
||||
@ -227,10 +230,15 @@ def keystone_ca_cert_b64():
|
||||
|
||||
def ssh_directory_for_unit():
|
||||
remote_service = remote_unit().split('/')[0]
|
||||
d = os.path.join(NOVA_SSH_DIR, remote_service)
|
||||
if not os.path.isdir(d):
|
||||
os.mkdir(d)
|
||||
return d
|
||||
_dir = os.path.join(NOVA_SSH_DIR, remote_service)
|
||||
for d in [NOVA_SSH_DIR, _dir]:
|
||||
if not os.path.isdir(d):
|
||||
os.mkdir(d)
|
||||
for f in ['authorized_keys', 'known_hosts']:
|
||||
f = os.path.join(_dir, f)
|
||||
if not os.path.isfile(f):
|
||||
open(f, 'w').close()
|
||||
return _dir
|
||||
|
||||
|
||||
def known_hosts():
|
||||
@ -289,7 +297,7 @@ def ssh_compute_add(public_key, host):
|
||||
add_known_host(host)
|
||||
if not ssh_authorized_key_exists(public_key):
|
||||
log('Saving SSH authorized key for compute host at %s.' % host)
|
||||
add_authorized_key(host)
|
||||
add_authorized_key(public_key)
|
||||
|
||||
|
||||
def ssh_known_hosts_b64():
|
||||
|
Loading…
Reference in New Issue
Block a user