Merge "refactor: Drop unsupported configurations and code"

This commit is contained in:
Jenkins 2016-03-03 17:13:05 +00:00 committed by Gerrit Code Review
commit 3e994ce425
36 changed files with 83 additions and 645 deletions

1
.gitignore vendored
View File

@ -3,5 +3,6 @@ bin
tags tags
.tox .tox
.testrepository .testrepository
*.pyc
*.sw[nop] *.sw[nop]
*.pyc *.pyc

View File

@ -9,7 +9,7 @@ from charmhelpers.contrib.openstack.utils import (
from neutron_utils import ( from neutron_utils import (
do_openstack_upgrade, do_openstack_upgrade,
get_common_package, NEUTRON_COMMON,
) )
from neutron_hooks import ( from neutron_hooks import (
@ -26,7 +26,7 @@ def openstack_upgrade():
code to run, otherwise a full service level upgrade will fire code to run, otherwise a full service level upgrade will fire
on config-changed.""" on config-changed."""
if do_action_openstack_upgrade(get_common_package(), if do_action_openstack_upgrade(NEUTRON_COMMON,
do_openstack_upgrade, do_openstack_upgrade,
CONFIGS): CONFIGS):
config_changed() config_changed()

View File

@ -33,7 +33,8 @@ options:
For series=Trusty we support cloud archives for openstack-release: For series=Trusty we support cloud archives for openstack-release:
* juno * juno
* kilo * kilo
* ... * liberty
* mitaka
NOTE: updating this setting to a source that is known to provide NOTE: updating this setting to a source that is known to provide
a later version of OpenStack will trigger a software upgrade. a later version of OpenStack will trigger a software upgrade.
@ -60,10 +61,10 @@ options:
Network configuration plugin to use for quantum. Network configuration plugin to use for quantum.
Supported values include: Supported values include:
ovs - Open vSwitch ovs - ML2 + Open vSwitch
nvp|nsx - Nicira NVP/VMware NSX nsx - VMware NSX
n1kv - Cisco N1kv n1kv - Cisco N1kv
ovs-odl - Open vSwitch with OpenDayLight Controller ovs-odl - ML2 + Open vSwitch with OpenDayLight Controller
ext-port: ext-port:
type: string type: string
default: default:
@ -140,14 +141,6 @@ options:
description: | description: |
Optional configuration to support use of linux router Optional configuration to support use of linux router
Note that this is used only for Cisco n1kv plugin. Note that this is used only for Cisco n1kv plugin.
database-user:
default: nova
type: string
description: Username for database access
database:
default: nova
type: string
description: Database name
nagios_context: nagios_context:
default: "juju" default: "juju"
type: string type: string

View File

@ -15,9 +15,6 @@ from charmhelpers.contrib.openstack.context import (
NeutronAPIContext, NeutronAPIContext,
config_flags_parser config_flags_parser
) )
from charmhelpers.contrib.openstack.utils import (
get_os_codename_install_source
)
from charmhelpers.contrib.hahelpers.cluster import( from charmhelpers.contrib.hahelpers.cluster import(
eligible_leader eligible_leader
) )
@ -25,75 +22,29 @@ from charmhelpers.contrib.network.ip import (
get_address_in_network, get_address_in_network,
) )
DB_USER = "quantum" NEUTRON_ML2_PLUGIN = "ml2"
QUANTUM_DB = "quantum"
NOVA_DB_USER = "nova"
NOVA_DB = "nova"
QUANTUM_OVS_PLUGIN = \
"quantum.plugins.openvswitch.ovs_quantum_plugin.OVSQuantumPluginV2"
QUANTUM_NVP_PLUGIN = \
"quantum.plugins.nicira.nicira_nvp_plugin.QuantumPlugin.NvpPluginV2"
NEUTRON_OVS_PLUGIN = \
"neutron.plugins.openvswitch.ovs_neutron_plugin.OVSNeutronPluginV2"
NEUTRON_ML2_PLUGIN = \
"neutron.plugins.ml2.plugin.Ml2Plugin"
NEUTRON_NVP_PLUGIN = \
"neutron.plugins.nicira.nicira_nvp_plugin.NeutronPlugin.NvpPluginV2"
NEUTRON_N1KV_PLUGIN = \ NEUTRON_N1KV_PLUGIN = \
"neutron.plugins.cisco.n1kv.n1kv_neutron_plugin.N1kvNeutronPluginV2" "neutron.plugins.cisco.n1kv.n1kv_neutron_plugin.N1kvNeutronPluginV2"
NEUTRON_NSX_PLUGIN = "vmware" NEUTRON_NSX_PLUGIN = "vmware"
NEUTRON_OVS_ODL_PLUGIN = "ml2" NEUTRON_OVS_ODL_PLUGIN = "ml2"
NEUTRON = 'neutron'
QUANTUM = 'quantum'
def networking_name():
''' Determine whether neutron or quantum should be used for name '''
if get_os_codename_install_source(config('openstack-origin')) >= 'havana':
return NEUTRON
else:
return QUANTUM
OVS = 'ovs' OVS = 'ovs'
NVP = 'nvp'
N1KV = 'n1kv' N1KV = 'n1kv'
NSX = 'nsx' NSX = 'nsx'
OVS_ODL = 'ovs-odl' OVS_ODL = 'ovs-odl'
NEUTRON = 'neutron'
CORE_PLUGIN = { CORE_PLUGIN = {
QUANTUM: { OVS: NEUTRON_ML2_PLUGIN,
OVS: QUANTUM_OVS_PLUGIN, N1KV: NEUTRON_N1KV_PLUGIN,
NVP: QUANTUM_NVP_PLUGIN, NSX: NEUTRON_NSX_PLUGIN,
}, OVS_ODL: NEUTRON_OVS_ODL_PLUGIN,
NEUTRON: {
OVS: NEUTRON_OVS_PLUGIN,
NVP: NEUTRON_NVP_PLUGIN,
N1KV: NEUTRON_N1KV_PLUGIN,
NSX: NEUTRON_NSX_PLUGIN,
OVS_ODL: NEUTRON_OVS_ODL_PLUGIN,
},
} }
def remap_plugin(plugin):
''' Remaps plugin name for renames/switches in packaging '''
release = get_os_codename_install_source(config('openstack-origin'))
if plugin == 'nvp' and release >= 'icehouse':
plugin = 'nsx'
elif plugin == 'nsx' and release < 'icehouse':
plugin = 'nvp'
return plugin
def core_plugin(): def core_plugin():
plugin = remap_plugin(config('plugin')) return CORE_PLUGIN[config('plugin')]
if (get_os_codename_install_source(config('openstack-origin')) >=
'icehouse' and plugin == OVS):
return NEUTRON_ML2_PLUGIN
else:
return CORE_PLUGIN[networking_name()][plugin]
class L3AgentContext(OSContextGenerator): class L3AgentContext(OSContextGenerator):
@ -189,7 +140,7 @@ SHARED_SECRET = "/etc/{}/secret.txt"
def get_shared_secret(): def get_shared_secret():
secret = None secret = None
_path = SHARED_SECRET.format(networking_name()) _path = SHARED_SECRET.format(NEUTRON)
if not os.path.exists(_path): if not os.path.exists(_path):
secret = str(uuid.uuid4()) secret = str(uuid.uuid4())
with open(_path, 'w') as secret_file: with open(_path, 'w') as secret_file:

View File

@ -5,11 +5,9 @@ from base64 import b64decode
from charmhelpers.core.hookenv import ( from charmhelpers.core.hookenv import (
log, ERROR, WARNING, log, ERROR, WARNING,
config, config,
is_relation_made,
relation_get, relation_get,
relation_set, relation_set,
relation_ids, relation_ids,
unit_get,
Hooks, Hooks,
UnregisteredHookError, UnregisteredHookError,
status_set, status_set,
@ -52,7 +50,6 @@ from neutron_utils import (
do_openstack_upgrade, do_openstack_upgrade,
get_packages, get_packages,
get_early_packages, get_early_packages,
get_common_package,
get_topics, get_topics,
git_install, git_install,
git_install_requested, git_install_requested,
@ -69,6 +66,7 @@ from neutron_utils import (
use_l3ha, use_l3ha,
REQUIRED_INTERFACES, REQUIRED_INTERFACES,
check_optional_relations, check_optional_relations,
NEUTRON_COMMON,
) )
hooks = Hooks() hooks = Hooks()
@ -82,7 +80,7 @@ def install():
src = config('openstack-origin') src = config('openstack-origin')
if (lsb_release()['DISTRIB_CODENAME'] == 'precise' and if (lsb_release()['DISTRIB_CODENAME'] == 'precise' and
src == 'distro'): src == 'distro'):
src = 'cloud:precise-folsom' src = 'cloud:precise-icehouse'
configure_installation_source(src) configure_installation_source(src)
status_set('maintenance', 'Installing apt packages') status_set('maintenance', 'Installing apt packages')
apt_update(fatal=True) apt_update(fatal=True)
@ -115,7 +113,7 @@ def config_changed():
CONFIGS.write_all() CONFIGS.write_all()
elif not config('action-managed-upgrade'): elif not config('action-managed-upgrade'):
if openstack_upgrade_available(get_common_package()): if openstack_upgrade_available(NEUTRON_COMMON):
status_set('maintenance', 'Running openstack upgrade') status_set('maintenance', 'Running openstack upgrade')
do_openstack_upgrade(CONFIGS) do_openstack_upgrade(CONFIGS)
@ -126,10 +124,6 @@ def config_changed():
create_sysctl(sysctl_dict, '/etc/sysctl.d/50-quantum-gateway.conf') create_sysctl(sysctl_dict, '/etc/sysctl.d/50-quantum-gateway.conf')
# Re-run joined hooks as config might have changed # Re-run joined hooks as config might have changed
for r_id in relation_ids('shared-db'):
db_joined(relation_id=r_id)
for r_id in relation_ids('pgsql-db'):
pgsql_db_joined(relation_id=r_id)
for r_id in relation_ids('amqp'): for r_id in relation_ids('amqp'):
amqp_joined(relation_id=r_id) amqp_joined(relation_id=r_id)
for r_id in relation_ids('amqp-nova'): for r_id in relation_ids('amqp-nova'):
@ -163,32 +157,6 @@ def upgrade_charm():
update_legacy_ha_files(force=True) update_legacy_ha_files(force=True)
@hooks.hook('shared-db-relation-joined')
def db_joined(relation_id=None):
if is_relation_made('pgsql-db'):
# raise error
e = ('Attempting to associate a mysql database when there is already '
'associated a postgresql one')
log(e, level=ERROR)
raise Exception(e)
relation_set(username=config('database-user'),
database=config('database'),
hostname=unit_get('private-address'),
relation_id=relation_id)
@hooks.hook('pgsql-db-relation-joined')
def pgsql_db_joined(relation_id=None):
if is_relation_made('shared-db'):
# raise error
e = ('Attempting to associate a postgresql database when there'
' is already associated a mysql one')
log(e, level=ERROR)
raise Exception(e)
relation_set(database=config('database'),
relation_id=relation_id)
@hooks.hook('amqp-nova-relation-joined') @hooks.hook('amqp-nova-relation-joined')
def amqp_nova_joined(relation_id=None): def amqp_nova_joined(relation_id=None):
relation_set(relation_id=relation_id, relation_set(relation_id=relation_id,
@ -222,13 +190,11 @@ def amqp_departed():
CONFIGS.write_all() CONFIGS.write_all()
@hooks.hook('shared-db-relation-changed', @hooks.hook('amqp-relation-changed',
'pgsql-db-relation-changed',
'amqp-relation-changed',
'cluster-relation-changed', 'cluster-relation-changed',
'cluster-relation-joined') 'cluster-relation-joined')
@restart_on_change(restart_map()) @restart_on_change(restart_map())
def db_amqp_changed(): def amqp_changed():
CONFIGS.write_all() CONFIGS.write_all()
@ -280,7 +246,7 @@ def stop():
@hooks.hook('zeromq-configuration-relation-joined') @hooks.hook('zeromq-configuration-relation-joined')
@os_requires_version('kilo', 'neutron-common') @os_requires_version('kilo', NEUTRON_COMMON)
def zeromq_configuration_relation_joined(relid=None): def zeromq_configuration_relation_joined(relid=None):
relation_set(relation_id=relid, relation_set(relation_id=relid,
topics=" ".join(get_topics()), topics=" ".join(get_topics()),

View File

@ -43,7 +43,6 @@ from charmhelpers.contrib.hahelpers.cluster import (
from charmhelpers.contrib.openstack.utils import ( from charmhelpers.contrib.openstack.utils import (
configure_installation_source, configure_installation_source,
get_os_codename_install_source, get_os_codename_install_source,
get_os_codename_package,
git_install_requested, git_install_requested,
git_clone_and_install, git_clone_and_install,
git_src_dir, git_src_dir,
@ -68,12 +67,9 @@ from charmhelpers.contrib.openstack.context import (
import charmhelpers.contrib.openstack.templating as templating import charmhelpers.contrib.openstack.templating as templating
from charmhelpers.contrib.openstack.neutron import headers_package from charmhelpers.contrib.openstack.neutron import headers_package
from neutron_contexts import ( from neutron_contexts import (
CORE_PLUGIN, OVS, NVP, NSX, N1KV, OVS_ODL, CORE_PLUGIN, OVS, NSX, N1KV, OVS_ODL,
NEUTRON, QUANTUM,
networking_name,
NeutronGatewayContext, NeutronGatewayContext,
L3AgentContext, L3AgentContext,
remap_plugin,
) )
from charmhelpers.contrib.openstack.neutron import ( from charmhelpers.contrib.openstack.neutron import (
parse_bridge_mappings, parse_bridge_mappings,
@ -83,23 +79,12 @@ from copy import deepcopy
def valid_plugin(): def valid_plugin():
return config('plugin') in CORE_PLUGIN[networking_name()] return config('plugin') in CORE_PLUGIN
QUANTUM_CONF_DIR = '/etc/quantum' NEUTRON_COMMON = 'neutron-common'
QUANTUM_OVS_PLUGIN_CONF = \
"/etc/quantum/plugins/openvswitch/ovs_quantum_plugin.ini"
QUANTUM_NVP_PLUGIN_CONF = \
"/etc/quantum/plugins/nicira/nvp.ini"
QUANTUM_PLUGIN_CONF = {
OVS: QUANTUM_OVS_PLUGIN_CONF,
NVP: QUANTUM_NVP_PLUGIN_CONF,
}
NEUTRON_CONF_DIR = '/etc/neutron' NEUTRON_CONF_DIR = '/etc/neutron'
NEUTRON_OVS_PLUGIN_CONF = \
"/etc/neutron/plugins/openvswitch/ovs_neutron_plugin.ini"
NEUTRON_ML2_PLUGIN_CONF = \ NEUTRON_ML2_PLUGIN_CONF = \
"/etc/neutron/plugins/ml2/ml2_conf.ini" "/etc/neutron/plugins/ml2/ml2_conf.ini"
NEUTRON_OVS_AGENT_CONF = \ NEUTRON_OVS_AGENT_CONF = \
@ -110,30 +95,11 @@ NEUTRON_NSX_PLUGIN_CONF = \
"/etc/neutron/plugins/vmware/nsx.ini" "/etc/neutron/plugins/vmware/nsx.ini"
NEUTRON_PLUGIN_CONF = { NEUTRON_PLUGIN_CONF = {
OVS: NEUTRON_OVS_PLUGIN_CONF, OVS: NEUTRON_ML2_PLUGIN_CONF,
NVP: NEUTRON_NVP_PLUGIN_CONF,
NSX: NEUTRON_NSX_PLUGIN_CONF, NSX: NEUTRON_NSX_PLUGIN_CONF,
} }
QUANTUM_GATEWAY_PKGS = { GATEWAY_PKGS = {
OVS: [
"quantum-plugin-openvswitch-agent",
"quantum-l3-agent",
"quantum-dhcp-agent",
'python-mysqldb',
'python-psycopg2',
"nova-api-metadata"
],
NVP: [
"openvswitch-switch",
"quantum-dhcp-agent",
'python-mysqldb',
'python-psycopg2',
"nova-api-metadata"
]
}
NEUTRON_GATEWAY_PKGS = {
OVS: [ OVS: [
"neutron-plugin-openvswitch-agent", "neutron-plugin-openvswitch-agent",
"openvswitch-switch", "openvswitch-switch",
@ -146,7 +112,7 @@ NEUTRON_GATEWAY_PKGS = {
"neutron-plugin-metering-agent", "neutron-plugin-metering-agent",
"neutron-lbaas-agent", "neutron-lbaas-agent",
], ],
NVP: [ NSX: [
"neutron-dhcp-agent", "neutron-dhcp-agent",
'python-mysqldb', 'python-mysqldb',
'python-psycopg2', 'python-psycopg2',
@ -171,16 +137,10 @@ NEUTRON_GATEWAY_PKGS = {
"neutron-lbaas-agent", "neutron-lbaas-agent",
], ],
} }
NEUTRON_GATEWAY_PKGS[NSX] = NEUTRON_GATEWAY_PKGS[NVP]
GATEWAY_PKGS = {
QUANTUM: QUANTUM_GATEWAY_PKGS,
NEUTRON: NEUTRON_GATEWAY_PKGS,
}
EARLY_PACKAGES = { EARLY_PACKAGES = {
OVS: ['openvswitch-datapath-dkms'], OVS: ['openvswitch-datapath-dkms'],
NVP: [], NSX: [],
N1KV: [], N1KV: [],
OVS_ODL: [], OVS_ODL: [],
} }
@ -261,8 +221,8 @@ def get_early_packages():
def get_packages(): def get_packages():
'''Return a list of packages for install based on the configured plugin''' '''Return a list of packages for install based on the configured plugin'''
plugin = remap_plugin(config('plugin')) plugin = config('plugin')
packages = deepcopy(GATEWAY_PKGS[networking_name()][plugin]) packages = deepcopy(GATEWAY_PKGS[plugin])
source = get_os_codename_install_source(config('openstack-origin')) source = get_os_codename_install_source(config('openstack-origin'))
if plugin == 'ovs': if plugin == 'ovs':
if (source >= 'icehouse' and if (source >= 'icehouse' and
@ -304,13 +264,6 @@ def determine_l3ha_packages():
return [] return []
def get_common_package():
if get_os_codename_package('quantum-common', fatal=False) is not None:
return 'quantum-common'
else:
return 'neutron-common'
def use_l3ha(): def use_l3ha():
return NeutronAPIContext()()['enable_l3ha'] return NeutronAPIContext()()['enable_l3ha']
@ -347,19 +300,6 @@ NOVA_CONFIG_FILES = {
}, },
} }
QUANTUM_SHARED_CONFIG_FILES = {
QUANTUM_DHCP_AGENT_CONF: {
'hook_contexts': [NeutronGatewayContext()],
'services': ['quantum-dhcp-agent']
},
QUANTUM_METADATA_AGENT_CONF: {
'hook_contexts': [NetworkServiceContext(),
NeutronGatewayContext()],
'services': ['quantum-metadata-agent']
},
}
QUANTUM_SHARED_CONFIG_FILES.update(NOVA_CONFIG_FILES)
NEUTRON_SHARED_CONFIG_FILES = { NEUTRON_SHARED_CONFIG_FILES = {
NEUTRON_DHCP_AGENT_CONF: { NEUTRON_DHCP_AGENT_CONF: {
'hook_contexts': [NeutronGatewayContext()], 'hook_contexts': [NeutronGatewayContext()],
@ -377,38 +317,6 @@ NEUTRON_SHARED_CONFIG_FILES = {
} }
NEUTRON_SHARED_CONFIG_FILES.update(NOVA_CONFIG_FILES) NEUTRON_SHARED_CONFIG_FILES.update(NOVA_CONFIG_FILES)
QUANTUM_OVS_CONFIG_FILES = {
QUANTUM_CONF: {
'hook_contexts': [context.AMQPContext(ssl_dir=QUANTUM_CONF_DIR),
NeutronGatewayContext(),
SyslogContext(),
context.ZeroMQContext(),
context.NotificationDriverContext()],
'services': ['quantum-l3-agent',
'quantum-dhcp-agent',
'quantum-metadata-agent',
'quantum-plugin-openvswitch-agent']
},
QUANTUM_L3_AGENT_CONF: {
'hook_contexts': [NetworkServiceContext(),
NeutronGatewayContext()],
'services': ['quantum-l3-agent']
},
QUANTUM_OVS_PLUGIN_CONF: {
'hook_contexts': [NeutronGatewayContext()],
'services': ['quantum-plugin-openvswitch-agent']
},
EXT_PORT_CONF: {
'hook_contexts': [ExternalPortContext()],
'services': ['ext-port']
},
PHY_NIC_MTU_CONF: {
'hook_contexts': [PhyNICMTUContext()],
'services': ['os-charm-phy-nic-mtu']
}
}
QUANTUM_OVS_CONFIG_FILES.update(QUANTUM_SHARED_CONFIG_FILES)
NEUTRON_OVS_CONFIG_FILES = { NEUTRON_OVS_CONFIG_FILES = {
NEUTRON_CONF: { NEUTRON_CONF: {
'hook_contexts': [context.AMQPContext(ssl_dir=NEUTRON_CONF_DIR), 'hook_contexts': [context.AMQPContext(ssl_dir=NEUTRON_CONF_DIR),
@ -450,7 +358,7 @@ NEUTRON_OVS_CONFIG_FILES = {
'hook_contexts': [NeutronGatewayContext()], 'hook_contexts': [NeutronGatewayContext()],
'services': ['neutron-l3-agent', 'neutron-vpn-agent'] 'services': ['neutron-l3-agent', 'neutron-vpn-agent']
}, },
NEUTRON_OVS_PLUGIN_CONF: { NEUTRON_ML2_PLUGIN_CONF: {
'hook_contexts': [NeutronGatewayContext()], 'hook_contexts': [NeutronGatewayContext()],
'services': ['neutron-plugin-openvswitch-agent'] 'services': ['neutron-plugin-openvswitch-agent']
}, },
@ -524,18 +432,7 @@ NEUTRON_OVS_ODL_CONFIG_FILES = {
} }
NEUTRON_OVS_ODL_CONFIG_FILES.update(NEUTRON_SHARED_CONFIG_FILES) NEUTRON_OVS_ODL_CONFIG_FILES.update(NEUTRON_SHARED_CONFIG_FILES)
NEUTRON_NSX_CONFIG_FILES = {
QUANTUM_NVP_CONFIG_FILES = {
QUANTUM_CONF: {
'hook_contexts': [context.AMQPContext(ssl_dir=QUANTUM_CONF_DIR),
NeutronGatewayContext(),
SyslogContext()],
'services': ['quantum-dhcp-agent', 'quantum-metadata-agent']
},
}
QUANTUM_NVP_CONFIG_FILES.update(QUANTUM_SHARED_CONFIG_FILES)
NEUTRON_NVP_CONFIG_FILES = {
NEUTRON_CONF: { NEUTRON_CONF: {
'hook_contexts': [context.AMQPContext(ssl_dir=NEUTRON_CONF_DIR), 'hook_contexts': [context.AMQPContext(ssl_dir=NEUTRON_CONF_DIR),
NeutronGatewayContext(), NeutronGatewayContext(),
@ -543,7 +440,7 @@ NEUTRON_NVP_CONFIG_FILES = {
'services': ['neutron-dhcp-agent', 'neutron-metadata-agent'] 'services': ['neutron-dhcp-agent', 'neutron-metadata-agent']
}, },
} }
NEUTRON_NVP_CONFIG_FILES.update(NEUTRON_SHARED_CONFIG_FILES) NEUTRON_NSX_CONFIG_FILES.update(NEUTRON_SHARED_CONFIG_FILES)
NEUTRON_N1KV_CONFIG_FILES = { NEUTRON_N1KV_CONFIG_FILES = {
NEUTRON_CONF: { NEUTRON_CONF: {
@ -564,17 +461,10 @@ NEUTRON_N1KV_CONFIG_FILES = {
NEUTRON_N1KV_CONFIG_FILES.update(NEUTRON_SHARED_CONFIG_FILES) NEUTRON_N1KV_CONFIG_FILES.update(NEUTRON_SHARED_CONFIG_FILES)
CONFIG_FILES = { CONFIG_FILES = {
QUANTUM: { NSX: NEUTRON_NSX_CONFIG_FILES,
NVP: QUANTUM_NVP_CONFIG_FILES, OVS: NEUTRON_OVS_CONFIG_FILES,
OVS: QUANTUM_OVS_CONFIG_FILES, N1KV: NEUTRON_N1KV_CONFIG_FILES,
}, OVS_ODL: NEUTRON_OVS_ODL_CONFIG_FILES
NEUTRON: {
NSX: NEUTRON_NVP_CONFIG_FILES,
NVP: NEUTRON_NVP_CONFIG_FILES,
OVS: NEUTRON_OVS_CONFIG_FILES,
N1KV: NEUTRON_N1KV_CONFIG_FILES,
OVS_ODL: NEUTRON_OVS_ODL_CONFIG_FILES
},
} }
SERVICE_RENAMES = { SERVICE_RENAMES = {
@ -601,33 +491,26 @@ def remap_service(service_name):
return service_name return service_name
def resolve_config_files(name, plugin, release): def resolve_config_files(plugin, release):
''' '''
Resolve configuration files and contexts Resolve configuration files and contexts
:param name: neutron or quantum
:param plugin: shortname of plugin e.g. ovs :param plugin: shortname of plugin e.g. ovs
:param release: openstack release codename :param release: openstack release codename
:returns: dict of configuration files, contexts :returns: dict of configuration files, contexts
and associated services and associated services
''' '''
config_files = deepcopy(CONFIG_FILES) config_files = deepcopy(CONFIG_FILES)
if plugin == 'ovs': if plugin == OVS:
# NOTE: deal with switch to ML2 plugin for >= icehouse # NOTE: deal with switch to ML2 plugin for >= icehouse
drop_config = [NEUTRON_ML2_PLUGIN_CONF, drop_config = [NEUTRON_OVS_AGENT_CONF]
NEUTRON_OVS_AGENT_CONF]
if release >= 'icehouse':
# ovs -> ml2
drop_config = [NEUTRON_OVS_PLUGIN_CONF,
NEUTRON_OVS_AGENT_CONF]
if release >= 'mitaka': if release >= 'mitaka':
# ml2 -> ovs_agent # ml2 -> ovs_agent
drop_config = [NEUTRON_OVS_PLUGIN_CONF, drop_config = [NEUTRON_ML2_PLUGIN_CONF]
NEUTRON_ML2_PLUGIN_CONF]
for _config in drop_config: for _config in drop_config:
if _config in config_files[name][plugin]: if _config in config_files[plugin]:
config_files[name][plugin].pop(_config) config_files[plugin].pop(_config)
if is_relation_made('amqp-nova'): if is_relation_made('amqp-nova'):
amqp_nova_ctxt = context.AMQPContext( amqp_nova_ctxt = context.AMQPContext(
@ -638,7 +521,7 @@ def resolve_config_files(name, plugin, release):
amqp_nova_ctxt = context.AMQPContext( amqp_nova_ctxt = context.AMQPContext(
ssl_dir=NOVA_CONF_DIR, ssl_dir=NOVA_CONF_DIR,
rel_name='amqp') rel_name='amqp')
config_files[name][plugin][NOVA_CONF][ config_files[plugin][NOVA_CONF][
'hook_contexts'].append(amqp_nova_ctxt) 'hook_contexts'].append(amqp_nova_ctxt)
return config_files return config_files
@ -646,24 +529,22 @@ def resolve_config_files(name, plugin, release):
def register_configs(): def register_configs():
''' Register config files with their respective contexts. ''' ''' Register config files with their respective contexts. '''
release = get_os_codename_install_source(config('openstack-origin')) release = get_os_codename_install_source(config('openstack-origin'))
plugin = remap_plugin(config('plugin')) plugin = config('plugin')
name = networking_name() config_files = resolve_config_files(plugin, release)
config_files = resolve_config_files(name, plugin, release)
configs = templating.OSConfigRenderer(templates_dir=TEMPLATES, configs = templating.OSConfigRenderer(templates_dir=TEMPLATES,
openstack_release=release) openstack_release=release)
for conf in config_files[name][plugin]: for conf in config_files[plugin]:
configs.register(conf, configs.register(conf,
config_files[name][plugin][conf]['hook_contexts']) config_files[plugin][conf]['hook_contexts'])
return configs return configs
def stop_services(): def stop_services():
release = get_os_codename_install_source(config('openstack-origin')) release = get_os_codename_install_source(config('openstack-origin'))
plugin = remap_plugin(config('plugin')) plugin = config('plugin')
name = networking_name() config_files = resolve_config_files(plugin, release)
config_files = resolve_config_files(name, plugin, release)
svcs = set() svcs = set()
for ctxt in config_files[name][config('plugin')].itervalues(): for ctxt in config_files[config('plugin')].itervalues():
for svc in ctxt['services']: for svc in ctxt['services']:
svcs.add(remap_service(svc)) svcs.add(remap_service(svc))
for svc in svcs: for svc in svcs:
@ -679,11 +560,10 @@ def restart_map():
that should be restarted when file changes. that should be restarted when file changes.
''' '''
release = get_os_codename_install_source(config('openstack-origin')) release = get_os_codename_install_source(config('openstack-origin'))
plugin = remap_plugin(config('plugin')) plugin = config('plugin')
name = networking_name() config_files = resolve_config_files(plugin, release)
config_files = resolve_config_files(name, plugin, release)
_map = {} _map = {}
for f, ctxt in config_files[name][plugin].iteritems(): for f, ctxt in config_files[plugin].iteritems():
svcs = set() svcs = set()
for svc in ctxt['services']: for svc in ctxt['services']:
svcs.add(remap_service(svc)) svcs.add(remap_service(svc))

View File

@ -1 +0,0 @@
neutron_hooks.py

View File

@ -1 +0,0 @@
neutron_hooks.py

View File

@ -1 +0,0 @@
neutron_hooks.py

View File

@ -1 +0,0 @@
neutron_hooks.py

View File

@ -22,10 +22,6 @@ provides:
quantum-network-service: quantum-network-service:
interface: quantum interface: quantum
requires: requires:
shared-db:
interface: mysql-shared
pgsql-db:
interface: pgsql
amqp: amqp:
interface: rabbitmq interface: rabbitmq
amqp-nova: amqp-nova:

View File

@ -1,10 +0,0 @@
[DEFAULT]
state_path = /var/lib/quantum
interface_driver = quantum.agent.linux.interface.OVSInterfaceDriver
dhcp_driver = quantum.agent.linux.dhcp.Dnsmasq
root_helper = sudo /usr/bin/quantum-rootwrap /etc/quantum/rootwrap.conf
{% if plugin == 'nvp' -%}
ovs_use_veth = True
enable_metadata_network = True
enable_isolated_metadata = True
{% endif -%}

View File

@ -1,8 +0,0 @@
[DEFAULT]
interface_driver = quantum.agent.linux.interface.OVSInterfaceDriver
auth_url = {{ service_protocol }}://{{ keystone_host }}:{{ service_port }}/v2.0
auth_region = {{ region }}
admin_tenant_name = {{ service_tenant }}
admin_user = {{ service_username }}
admin_password = {{ service_password }}
root_helper = sudo /usr/bin/quantum-rootwrap /etc/quantum/rootwrap.conf

View File

@ -1,12 +0,0 @@
[DEFAULT]
auth_url = {{ service_protocol }}://{{ keystone_host }}:{{ service_port }}/v2.0
auth_region = {{ region }}
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
metadata_proxy_shared_secret = {{ shared_secret }}

View File

@ -1,26 +0,0 @@
[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
use_syslog = {{ use_syslog }}
api_paste_config=/etc/nova/api-paste.ini
enabled_apis=metadata
multi_host=True
{% include "parts/database" %}
quantum_metadata_proxy_shared_secret={{ shared_secret }}
service_quantum_metadata_proxy=True
# Access to message bus
rabbit_userid={{ rabbitmq_user }}
rabbit_virtual_host={{ rabbitmq_virtual_host }}
rabbit_host={{ rabbitmq_host }}
rabbit_password={{ rabbitmq_password }}
# Access to quantum API services
network_api_class=nova.network.quantumv2.api.API
quantum_auth_strategy=keystone
quantum_url={{ quantum_url }}
quantum_admin_tenant_name={{ service_tenant }}
quantum_admin_username={{ service_username }}
quantum_admin_password={{ service_password }}
quantum_admin_auth_url={{ service_protocol }}://{{ keystone_host }}:{{ service_port }}/v2.0

View File

@ -1,8 +0,0 @@
[OVS]
local_ip = {{ local_ip }}
tenant_network_type = gre
enable_tunneling = True
tunnel_id_ranges = 1:1000
[AGENT]
polling_interval = 10
root_helper = sudo /usr/bin/quantum-rootwrap /etc/quantum/rootwrap.conf

View File

@ -1,15 +0,0 @@
[DEFAULT]
verbose = {{ verbose }}
debug = {{ debug }}
use_syslog = {{ use_syslog }}
lock_path = /var/lock/quantum
core_plugin = {{ core_plugin }}
rabbit_userid = {{ rabbitmq_user }}
rabbit_virtual_host = {{ rabbitmq_virtual_host }}
rabbit_host = {{ rabbitmq_host }}
rabbit_password = {{ rabbitmq_password }}
control_exchange = quantum
notification_driver = quantum.openstack.common.notifier.list_notifier
list_notifier_drivers = quantum.openstack.common.notifier.rabbit_notifier
[AGENT]
root_helper = sudo /usr/bin/quantum-rootwrap /etc/quantum/rootwrap.conf

View File

@ -1,22 +0,0 @@
[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
{% include "parts/database" %}
quantum_metadata_proxy_shared_secret={{ shared_secret }}
service_quantum_metadata_proxy=True
# Access to message bus
{% include "parts/rabbitmq" %}
# Access to quantum API services
network_api_class=nova.network.quantumv2.api.API
quantum_auth_strategy=keystone
quantum_url={{ quantum_url }}
quantum_admin_tenant_name={{ service_tenant }}
quantum_admin_username={{ service_username }}
quantum_admin_password={{ service_password }}
quantum_admin_auth_url={{ service_protocol }}://{{ keystone_host }}:{{ service_port }}/v2.0

View File

@ -1,11 +0,0 @@
[DEFAULT]
verbose = {{ verbose }}
debug = {{ debug }}
lock_path = /var/lock/quantum
core_plugin = {{ core_plugin }}
{% include "parts/rabbitmq" %}
control_exchange = quantum
notification_driver = quantum.openstack.common.notifier.list_notifier
list_notifier_drivers = quantum.openstack.common.notifier.rabbit_notifier
[AGENT]
root_helper = sudo /usr/bin/quantum-rootwrap /etc/quantum/rootwrap.conf

View File

@ -1,18 +0,0 @@
###############################################################################
# [ WARNING ]
# Configuration file maintained by Juju. Local changes may be overwritten.
###############################################################################
# Metadata service seems to cache neutron api url from keystone so trigger
# restart if it changes: {{ quantum_url }}
[DEFAULT]
auth_url = {{ service_protocol }}://{{ keystone_host }}:{{ service_port }}/v2.0
auth_region = {{ region }}
admin_tenant_name = {{ service_tenant }}
admin_user = {{ service_username }}
admin_password = {{ service_password }}
root_helper = sudo neutron-rootwrap /etc/neutron/rootwrap.conf
state_path = /var/lib/neutron
# Gateway runs a metadata API server locally
nova_metadata_ip = {{ local_ip }}
nova_metadata_port = 8775
metadata_proxy_shared_secret = {{ shared_secret }}

View File

@ -1,16 +0,0 @@
###############################################################################
# [ WARNING ]
# Configuration file maintained by Juju. Local changes may be overwritten.
###############################################################################
[DEFAULT]
verbose = {{ verbose }}
debug = {{ debug }}
use_syslog = {{ use_syslog }}
lock_path = /var/lock/neutron
core_plugin = {{ core_plugin }}
{% include "parts/rabbitmq" %}
control_exchange = neutron
notification_driver = neutron.openstack.common.notifier.list_notifier
list_notifier_drivers = neutron.openstack.common.notifier.rabbit_notifier
[agent]
root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf

View File

@ -1,14 +0,0 @@
###############################################################################
# [ WARNING ]
# Configuration file maintained by Juju. Local changes may be overwritten.
###############################################################################
[ovs]
local_ip = {{ local_ip }}
tenant_network_type = gre
enable_tunneling = True
tunnel_id_ranges = 1:1000
[agent]
{% if veth_mtu -%}
veth_mtu = {{ veth_mtu }}
{% endif %}

View File

@ -61,7 +61,6 @@ class NeutronGatewayBasicDeployment(OpenStackAmuletDeployment):
"""Add all of the relations for the services.""" """Add all of the relations for the services."""
relations = { relations = {
'keystone:shared-db': 'mysql:shared-db', 'keystone:shared-db': 'mysql:shared-db',
'neutron-gateway:shared-db': 'mysql:shared-db',
'neutron-gateway:amqp': 'rabbitmq-server:amqp', 'neutron-gateway:amqp': 'rabbitmq-server:amqp',
'nova-cloud-controller:quantum-network-service': 'nova-cloud-controller:quantum-network-service':
'neutron-gateway:quantum-network-service', 'neutron-gateway:quantum-network-service',
@ -173,6 +172,12 @@ class NeutronGatewayBasicDeployment(OpenStackAmuletDeployment):
tenant_name='admin', tenant_name='admin',
region_name='RegionOne') region_name='RegionOne')
def get_private_address(self, unit):
"""Return the private address of the given sentry unit."""
address, retcode = unit.run('unit-get private-address')
assert retcode == 0, 'error retrieving unit private address'
return address.strip()
def test_100_services(self): def test_100_services(self):
"""Verify the expected services are running on the corresponding """Verify the expected services are running on the corresponding
service units.""" service units."""
@ -293,39 +298,6 @@ class NeutronGatewayBasicDeployment(OpenStackAmuletDeployment):
if ret: if ret:
amulet.raise_status(amulet.FAIL, msg=ret) amulet.raise_status(amulet.FAIL, msg=ret)
def test_200_neutron_gateway_mysql_shared_db_relation(self):
"""Verify the neutron-gateway to mysql shared-db relation data"""
u.log.debug('Checking neutron-gateway:mysql db relation data...')
unit = self.neutron_gateway_sentry
relation = ['shared-db', 'mysql:shared-db']
expected = {
'private-address': u.valid_ip,
'database': 'nova',
'username': 'nova',
'hostname': u.valid_ip
}
ret = u.validate_relation_data(unit, relation, expected)
if ret:
message = u.relation_error('neutron-gateway shared-db', ret)
amulet.raise_status(amulet.FAIL, msg=message)
def test_201_mysql_neutron_gateway_shared_db_relation(self):
"""Verify the mysql to neutron-gateway shared-db relation data"""
u.log.debug('Checking mysql:neutron-gateway db relation data...')
unit = self.mysql_sentry
relation = ['shared-db', 'neutron-gateway:shared-db']
expected = {
'private-address': u.valid_ip,
'password': u.not_null,
'db_host': u.valid_ip
}
ret = u.validate_relation_data(unit, relation, expected)
if ret:
message = u.relation_error('mysql shared-db', ret)
amulet.raise_status(amulet.FAIL, msg=message)
def test_202_neutron_gateway_rabbitmq_amqp_relation(self): def test_202_neutron_gateway_rabbitmq_amqp_relation(self):
"""Verify the neutron-gateway to rabbitmq-server amqp relation data""" """Verify the neutron-gateway to rabbitmq-server amqp relation data"""
u.log.debug('Checking neutron-gateway:rmq amqp relation data...') u.log.debug('Checking neutron-gateway:rmq amqp relation data...')
@ -575,7 +547,7 @@ class NeutronGatewayBasicDeployment(OpenStackAmuletDeployment):
'DEFAULT': { 'DEFAULT': {
'verbose': 'False', 'verbose': 'False',
'debug': 'False', 'debug': 'False',
'core_plugin': 'neutron.plugins.ml2.plugin.Ml2Plugin', 'core_plugin': 'ml2',
'control_exchange': 'neutron', 'control_exchange': 'neutron',
'notification_driver': 'neutron.openstack.common.notifier.' 'notification_driver': 'neutron.openstack.common.notifier.'
'list_notifier', 'list_notifier',
@ -624,7 +596,6 @@ class NeutronGatewayBasicDeployment(OpenStackAmuletDeployment):
unit = self.neutron_gateway_sentry unit = self.neutron_gateway_sentry
conf = '/etc/neutron/plugins/ml2/ml2_conf.ini' conf = '/etc/neutron/plugins/ml2/ml2_conf.ini'
ng_db_rel = unit.relation('shared-db', 'mysql:shared-db')
expected = { expected = {
'ml2': { 'ml2': {
@ -640,7 +611,7 @@ class NeutronGatewayBasicDeployment(OpenStackAmuletDeployment):
}, },
'ovs': { 'ovs': {
'enable_tunneling': 'True', 'enable_tunneling': 'True',
'local_ip': ng_db_rel['private-address'] 'local_ip': self.get_private_address(unit)
}, },
'agent': { 'agent': {
'tunnel_types': 'gre', 'tunnel_types': 'gre',
@ -787,8 +758,6 @@ class NeutronGatewayBasicDeployment(OpenStackAmuletDeployment):
unit = self.neutron_gateway_sentry unit = self.neutron_gateway_sentry
ep = self.keystone.service_catalog.url_for(service_type='identity', ep = self.keystone.service_catalog.url_for(service_type='identity',
endpoint_type='publicURL') endpoint_type='publicURL')
ng_db_rel = unit.relation('shared-db',
'mysql:shared-db')
nova_cc_relation = self.nova_cc_sentry.relation( nova_cc_relation = self.nova_cc_sentry.relation(
'quantum-network-service', 'quantum-network-service',
'neutron-gateway:quantum-network-service') 'neutron-gateway:quantum-network-service')
@ -802,7 +771,7 @@ class NeutronGatewayBasicDeployment(OpenStackAmuletDeployment):
'root_helper': 'sudo neutron-rootwrap ' 'root_helper': 'sudo neutron-rootwrap '
'/etc/neutron/rootwrap.conf', '/etc/neutron/rootwrap.conf',
'state_path': '/var/lib/neutron', 'state_path': '/var/lib/neutron',
'nova_metadata_ip': ng_db_rel['private-address'], 'nova_metadata_ip': self.get_private_address(unit),
'nova_metadata_port': '8775', 'nova_metadata_port': '8775',
'cache_url': 'memory://?default_ttl=5' 'cache_url': 'memory://?default_ttl=5'
} }

View File

@ -8,6 +8,7 @@ setenv = VIRTUAL_ENV={envdir}
install_command = install_command =
pip install --allow-unverified python-apt {opts} {packages} pip install --allow-unverified python-apt {opts} {packages}
commands = ostestr {posargs} commands = ostestr {posargs}
sitepackages = True
[testenv:py27] [testenv:py27]
basepython = python2.7 basepython = python2.7

View File

@ -14,7 +14,6 @@ with patch('charmhelpers.core.hookenv.status_set'):
TO_PATCH = [ TO_PATCH = [
'do_openstack_upgrade', 'do_openstack_upgrade',
'config_changed', 'config_changed',
'get_common_package',
] ]

View File

@ -15,7 +15,6 @@ TO_PATCH = [
'apt_install', 'apt_install',
'config', 'config',
'eligible_leader', 'eligible_leader',
'get_os_codename_install_source',
'unit_get', 'unit_get',
] ]
@ -132,7 +131,6 @@ class TestNeutronGatewayContext(CharmTestCase):
_rids.return_value = ['neutron-plugin-api:0'] _rids.return_value = ['neutron-plugin-api:0']
_runits.return_value = ['neutron-api/0'] _runits.return_value = ['neutron-api/0']
_rget.side_effect = lambda *args, **kwargs: rdata _rget.side_effect = lambda *args, **kwargs: rdata
self.get_os_codename_install_source.return_value = 'folsom'
_host_ip.return_value = '10.5.0.1' _host_ip.return_value = '10.5.0.1'
_secret.return_value = 'testsecret' _secret.return_value = 'testsecret'
ctxt = neutron_contexts.NeutronGatewayContext()() ctxt = neutron_contexts.NeutronGatewayContext()()
@ -142,8 +140,7 @@ class TestNeutronGatewayContext(CharmTestCase):
'enable_l3ha': True, 'enable_l3ha': True,
'local_ip': '10.5.0.1', 'local_ip': '10.5.0.1',
'instance_mtu': 1420, 'instance_mtu': 1420,
'core_plugin': "quantum.plugins.openvswitch.ovs_quantum_plugin." 'core_plugin': "ml2",
"OVSQuantumPluginV2",
'plugin': 'ovs', 'plugin': 'ovs',
'debug': False, 'debug': False,
'verbose': True, 'verbose': True,
@ -177,7 +174,7 @@ class TestSharedSecret(CharmTestCase):
self.assertEquals(neutron_contexts.get_shared_secret(), self.assertEquals(neutron_contexts.get_shared_secret(),
'secret_thing') 'secret_thing')
_open.assert_called_with( _open.assert_called_with(
neutron_contexts.SHARED_SECRET.format('quantum'), 'w') neutron_contexts.SHARED_SECRET.format('neutron'), 'w')
_file.write.assert_called_with('secret_thing') _file.write.assert_called_with('secret_thing')
@patch('os.path') @patch('os.path')
@ -188,7 +185,7 @@ class TestSharedSecret(CharmTestCase):
self.assertEquals(neutron_contexts.get_shared_secret(), self.assertEquals(neutron_contexts.get_shared_secret(),
'secret_thing') 'secret_thing')
_open.assert_called_with( _open.assert_called_with(
neutron_contexts.SHARED_SECRET.format('quantum'), 'r') neutron_contexts.SHARED_SECRET.format('neutron'), 'r')
class TestHostIP(CharmTestCase): class TestHostIP(CharmTestCase):
@ -245,36 +242,7 @@ class TestMisc(CharmTestCase):
self).setUp(neutron_contexts, self).setUp(neutron_contexts,
TO_PATCH) TO_PATCH)
def test_lt_havana(self):
self.get_os_codename_install_source.return_value = 'folsom'
self.assertEquals(neutron_contexts.networking_name(), 'quantum')
def test_ge_havana(self):
self.get_os_codename_install_source.return_value = 'havana'
self.assertEquals(neutron_contexts.networking_name(), 'neutron')
def test_remap_plugin(self):
self.get_os_codename_install_source.return_value = 'havana'
self.assertEquals(neutron_contexts.remap_plugin('nvp'), 'nvp')
self.assertEquals(neutron_contexts.remap_plugin('nsx'), 'nvp')
def test_remap_plugin_icehouse(self):
self.get_os_codename_install_source.return_value = 'icehouse'
self.assertEquals(neutron_contexts.remap_plugin('nvp'), 'nsx')
self.assertEquals(neutron_contexts.remap_plugin('nsx'), 'nsx')
def test_remap_plugin_noop(self):
self.get_os_codename_install_source.return_value = 'icehouse'
self.assertEquals(neutron_contexts.remap_plugin('ovs'), 'ovs')
def test_core_plugin(self):
self.get_os_codename_install_source.return_value = 'havana'
self.config.return_value = 'ovs'
self.assertEquals(neutron_contexts.core_plugin(),
neutron_contexts.NEUTRON_OVS_PLUGIN)
def test_core_plugin_ml2(self): def test_core_plugin_ml2(self):
self.get_os_codename_install_source.return_value = 'icehouse'
self.config.return_value = 'ovs' self.config.return_value = 'ovs'
self.assertEquals(neutron_contexts.core_plugin(), self.assertEquals(neutron_contexts.core_plugin(),
neutron_contexts.NEUTRON_ML2_PLUGIN) neutron_contexts.NEUTRON_ML2_PLUGIN)

View File

@ -35,15 +35,12 @@ TO_PATCH = [
'configure_ovs', 'configure_ovs',
'relation_set', 'relation_set',
'relation_ids', 'relation_ids',
'unit_get',
'relation_get', 'relation_get',
'install_ca_cert', 'install_ca_cert',
'get_common_package',
'execd_preinstall', 'execd_preinstall',
'lsb_release', 'lsb_release',
'stop_services', 'stop_services',
'b64decode', 'b64decode',
'is_relation_made',
'create_sysctl', 'create_sysctl',
'update_nrpe_config', 'update_nrpe_config',
'update_legacy_ha_files', 'update_legacy_ha_files',
@ -98,7 +95,7 @@ class TestQuantumHooks(CharmTestCase):
self.test_config.set('openstack-origin', 'distro') self.test_config.set('openstack-origin', 'distro')
self._call_hook('install') self._call_hook('install')
self.configure_installation_source.assert_called_with( self.configure_installation_source.assert_called_with(
'cloud:precise-folsom' 'cloud:precise-icehouse'
) )
@patch('sys.exit') @patch('sys.exit')
@ -152,16 +149,12 @@ class TestQuantumHooks(CharmTestCase):
self.openstack_upgrade_available.return_value = True self.openstack_upgrade_available.return_value = True
self.valid_plugin.return_value = True self.valid_plugin.return_value = True
self.relation_ids.side_effect = mock_relids self.relation_ids.side_effect = mock_relids
_db_joined = self.patch('db_joined')
_pgsql_db_joined = self.patch('pgsql_db_joined')
_amqp_joined = self.patch('amqp_joined') _amqp_joined = self.patch('amqp_joined')
_amqp_nova_joined = self.patch('amqp_nova_joined') _amqp_nova_joined = self.patch('amqp_nova_joined')
_zmq_joined = self.patch('zeromq_configuration_relation_joined') _zmq_joined = self.patch('zeromq_configuration_relation_joined')
self._call_hook('config-changed') self._call_hook('config-changed')
self.assertTrue(self.do_openstack_upgrade.called) self.assertTrue(self.do_openstack_upgrade.called)
self.assertTrue(self.configure_ovs.called) self.assertTrue(self.configure_ovs.called)
self.assertTrue(_db_joined.called)
self.assertTrue(_pgsql_db_joined.called)
self.assertTrue(_amqp_joined.called) self.assertTrue(_amqp_joined.called)
self.assertTrue(_amqp_nova_joined.called) self.assertTrue(_amqp_nova_joined.called)
self.assertTrue(_zmq_joined.called) self.assertTrue(_zmq_joined.called)
@ -208,8 +201,6 @@ class TestQuantumHooks(CharmTestCase):
self.openstack_upgrade_available.return_value = True self.openstack_upgrade_available.return_value = True
self.valid_plugin.return_value = True self.valid_plugin.return_value = True
self.relation_ids.side_effect = mock_relids self.relation_ids.side_effect = mock_relids
_db_joined = self.patch('db_joined')
_pgsql_db_joined = self.patch('pgsql_db_joined')
_amqp_joined = self.patch('amqp_joined') _amqp_joined = self.patch('amqp_joined')
_amqp_nova_joined = self.patch('amqp_nova_joined') _amqp_nova_joined = self.patch('amqp_nova_joined')
_zmq_joined = self.patch('zeromq_configuration_relation_joined') _zmq_joined = self.patch('zeromq_configuration_relation_joined')
@ -233,8 +224,6 @@ class TestQuantumHooks(CharmTestCase):
self.git_install.assert_called_with(projects_yaml) self.git_install.assert_called_with(projects_yaml)
self.assertFalse(self.do_openstack_upgrade.called) self.assertFalse(self.do_openstack_upgrade.called)
self.assertTrue(self.configure_ovs.called) self.assertTrue(self.configure_ovs.called)
self.assertTrue(_db_joined.called)
self.assertTrue(_pgsql_db_joined.called)
self.assertTrue(_amqp_joined.called) self.assertTrue(_amqp_joined.called)
self.assertTrue(_amqp_nova_joined.called) self.assertTrue(_amqp_nova_joined.called)
self.assertTrue(_zmq_joined.called) self.assertTrue(_zmq_joined.called)
@ -247,44 +236,6 @@ class TestQuantumHooks(CharmTestCase):
self.assertTrue(_install.called) self.assertTrue(_install.called)
self.assertTrue(_config_changed.called) self.assertTrue(_config_changed.called)
def test_db_joined(self):
self.is_relation_made.return_value = False
self.unit_get.return_value = 'myhostname'
self._call_hook('shared-db-relation-joined')
self.relation_set.assert_called_with(
username='nova',
database='nova',
hostname='myhostname',
relation_id=None
)
def test_db_joined_with_postgresql(self):
self.is_relation_made.return_value = True
with self.assertRaises(Exception) as context:
hooks.db_joined()
self.assertEqual(context.exception.message,
'Attempting to associate a mysql database when there '
'is already associated a postgresql one')
def test_postgresql_db_joined(self):
self.unit_get.return_value = 'myhostname'
self.is_relation_made.return_value = False
self._call_hook('pgsql-db-relation-joined')
self.relation_set.assert_called_with(
database='nova',
relation_id=None
)
def test_postgresql_joined_with_db(self):
self.is_relation_made.return_value = True
with self.assertRaises(Exception) as context:
hooks.pgsql_db_joined()
self.assertEqual(context.exception.message,
'Attempting to associate a postgresql database when'
' there is already associated a mysql one')
def test_amqp_joined(self): def test_amqp_joined(self):
self._call_hook('amqp-relation-joined') self._call_hook('amqp-relation-joined')
self.relation_set.assert_called_with( self.relation_set.assert_called_with(
@ -325,14 +276,6 @@ class TestQuantumHooks(CharmTestCase):
self._call_hook('amqp-nova-relation-changed') self._call_hook('amqp-nova-relation-changed')
self.assertTrue(self.CONFIGS.write_all.called) self.assertTrue(self.CONFIGS.write_all.called)
def test_shared_db_changed(self):
self._call_hook('shared-db-relation-changed')
self.assertTrue(self.CONFIGS.write_all.called)
def test_pgsql_db_changed(self):
self._call_hook('pgsql-db-relation-changed')
self.assertTrue(self.CONFIGS.write_all.called)
def test_nm_changed(self): def test_nm_changed(self):
self.relation_get.return_value = "cert" self.relation_get.return_value = "cert"
self._call_hook('quantum-network-service-relation-changed') self._call_hook('quantum-network-service-relation-changed')

View File

@ -22,7 +22,6 @@ import charmhelpers.core.hookenv as hookenv
TO_PATCH = [ TO_PATCH = [
'config', 'config',
'get_os_codename_install_source', 'get_os_codename_install_source',
'get_os_codename_package',
'apt_update', 'apt_update',
'apt_upgrade', 'apt_upgrade',
'apt_install', 'apt_install',
@ -30,7 +29,6 @@ TO_PATCH = [
'log', 'log',
'add_bridge', 'add_bridge',
'add_bridge_port', 'add_bridge_port',
'networking_name',
'headers_package', 'headers_package',
'full_restart', 'full_restart',
'service_running', 'service_running',
@ -41,7 +39,6 @@ TO_PATCH = [
'service_stop', 'service_stop',
'determine_dkms_package', 'determine_dkms_package',
'service_restart', 'service_restart',
'remap_plugin',
'is_relation_made', 'is_relation_made',
'lsb_release', 'lsb_release',
'mkdir', 'mkdir',
@ -59,7 +56,7 @@ openstack_origin_git = \
branch: stable/juno}""" branch: stable/juno}"""
class TestQuantumUtils(CharmTestCase): class TestNeutronUtils(CharmTestCase):
def assertDictEqual(self, d1, d2, msg=None): # assertEqual uses for dicts def assertDictEqual(self, d1, d2, msg=None): # assertEqual uses for dicts
for k, v1 in d1.iteritems(): for k, v1 in d1.iteritems():
@ -72,15 +69,10 @@ class TestQuantumUtils(CharmTestCase):
self.assertEqual(v1, v2, msg) self.assertEqual(v1, v2, msg)
def setUp(self): def setUp(self):
super(TestQuantumUtils, self).setUp(neutron_utils, TO_PATCH) super(TestNeutronUtils, self).setUp(neutron_utils, TO_PATCH)
self.networking_name.return_value = 'neutron'
self.headers_package.return_value = 'linux-headers-2.6.18' self.headers_package.return_value = 'linux-headers-2.6.18'
self._set_distrib_codename('trusty') self._set_distrib_codename('trusty')
def noop(value):
return value
self.remap_plugin.side_effect = noop
def tearDown(self): def tearDown(self):
# Reset cached cache # Reset cached cache
hookenv.cache = {} hookenv.cache = {}
@ -91,8 +83,6 @@ class TestQuantumUtils(CharmTestCase):
def test_valid_plugin(self): def test_valid_plugin(self):
self.config.return_value = 'ovs' self.config.return_value = 'ovs'
self.assertTrue(neutron_utils.valid_plugin()) self.assertTrue(neutron_utils.valid_plugin())
self.config.return_value = 'nvp'
self.assertTrue(neutron_utils.valid_plugin())
self.config.return_value = 'nsx' self.config.return_value = 'nsx'
self.assertTrue(neutron_utils.valid_plugin()) self.assertTrue(neutron_utils.valid_plugin())
@ -108,8 +98,8 @@ class TestQuantumUtils(CharmTestCase):
neutron_utils.get_early_packages(), neutron_utils.get_early_packages(),
['openvswitch-datapath-dkms', 'linux-headers-2.6.18']) ['openvswitch-datapath-dkms', 'linux-headers-2.6.18'])
def test_get_early_packages_nvp(self): def test_get_early_packages_nsx(self):
self.config.return_value = 'nvp' self.config.return_value = 'nsx'
self.assertEquals( self.assertEquals(
neutron_utils.get_early_packages(), neutron_utils.get_early_packages(),
[]) [])
@ -119,13 +109,6 @@ class TestQuantumUtils(CharmTestCase):
self.assertEquals(neutron_utils.get_early_packages(), self.assertEquals(neutron_utils.get_early_packages(),
[]) [])
@patch.object(neutron_utils, 'git_install_requested')
def test_get_packages_ovs(self, git_requested):
git_requested.return_value = False
self.config.return_value = 'ovs'
self.get_os_codename_install_source.return_value = 'havana'
self.assertNotEqual(neutron_utils.get_packages(), [])
@patch.object(neutron_utils, 'git_install_requested') @patch.object(neutron_utils, 'git_install_requested')
def test_get_packages_ovs_icehouse(self, git_requested): def test_get_packages_ovs_icehouse(self, git_requested):
git_requested.return_value = False git_requested.return_value = False
@ -297,7 +280,7 @@ class TestQuantumUtils(CharmTestCase):
neutron_utils.NOVA_CONF, neutron_utils.NOVA_CONF,
neutron_utils.NEUTRON_CONF, neutron_utils.NEUTRON_CONF,
neutron_utils.NEUTRON_L3_AGENT_CONF, neutron_utils.NEUTRON_L3_AGENT_CONF,
neutron_utils.NEUTRON_OVS_PLUGIN_CONF, neutron_utils.NEUTRON_ML2_PLUGIN_CONF,
neutron_utils.EXT_PORT_CONF] neutron_utils.EXT_PORT_CONF]
for conf in confs: for conf in confs:
configs.register.assert_any_call(conf, ANY) configs.register.assert_any_call(conf, ANY)
@ -326,7 +309,7 @@ class TestQuantumUtils(CharmTestCase):
neutron_utils.NOVA_CONF, neutron_utils.NOVA_CONF,
neutron_utils.NEUTRON_CONF, neutron_utils.NEUTRON_CONF,
neutron_utils.NEUTRON_L3_AGENT_CONF, neutron_utils.NEUTRON_L3_AGENT_CONF,
neutron_utils.NEUTRON_OVS_PLUGIN_CONF, neutron_utils.NEUTRON_ML2_PLUGIN_CONF,
neutron_utils.EXT_PORT_CONF] neutron_utils.EXT_PORT_CONF]
for conf in confs: for conf in confs:
configs.register.assert_any_call(conf, ANY) configs.register.assert_any_call(conf, ANY)
@ -347,7 +330,7 @@ class TestQuantumUtils(CharmTestCase):
neutron_utils.NEUTRON_DNSMASQ_CONF: ['neutron-dhcp-agent'], neutron_utils.NEUTRON_DNSMASQ_CONF: ['neutron-dhcp-agent'],
neutron_utils.NEUTRON_LBAAS_AGENT_CONF: neutron_utils.NEUTRON_LBAAS_AGENT_CONF:
['neutron-lbaas-agent'], ['neutron-lbaas-agent'],
neutron_utils.NEUTRON_OVS_PLUGIN_CONF: neutron_utils.NEUTRON_ML2_PLUGIN_CONF:
['neutron-plugin-openvswitch-agent'], ['neutron-plugin-openvswitch-agent'],
neutron_utils.NEUTRON_METADATA_AGENT_CONF: neutron_utils.NEUTRON_METADATA_AGENT_CONF:
['neutron-metadata-agent'], ['neutron-metadata-agent'],
@ -437,17 +420,6 @@ class TestQuantumUtils(CharmTestCase):
self.assertDictEqual(neutron_utils.restart_map(), ex_map) self.assertDictEqual(neutron_utils.restart_map(), ex_map)
def test_register_configs_nvp(self):
self.config.return_value = 'nvp'
self.is_relation_made.return_value = False
configs = neutron_utils.register_configs()
confs = [neutron_utils.NEUTRON_DHCP_AGENT_CONF,
neutron_utils.NEUTRON_METADATA_AGENT_CONF,
neutron_utils.NOVA_CONF,
neutron_utils.NEUTRON_CONF]
for conf in confs:
configs.register.assert_any_call(conf, ANY)
def test_register_configs_nsx(self): def test_register_configs_nsx(self):
self.config.return_value = 'nsx' self.config.return_value = 'nsx'
configs = neutron_utils.register_configs() configs = neutron_utils.register_configs()
@ -458,19 +430,6 @@ class TestQuantumUtils(CharmTestCase):
for conf in confs: for conf in confs:
configs.register.assert_any_call(conf, ANY) configs.register.assert_any_call(conf, ANY)
def test_stop_services_nvp(self):
self.config.return_value = 'nvp'
neutron_utils.stop_services()
calls = [
call('neutron-dhcp-agent'),
call('nova-api-metadata'),
call('neutron-metadata-agent')
]
self.service_stop.assert_has_calls(
calls,
any_order=True,
)
def test_stop_services_ovs(self): def test_stop_services_ovs(self):
self.config.return_value = 'ovs' self.config.return_value = 'ovs'
neutron_utils.stop_services() neutron_utils.stop_services()
@ -484,42 +443,18 @@ class TestQuantumUtils(CharmTestCase):
any_order=True, any_order=True,
) )
def test_restart_map_nvp(self):
self.config.return_value = 'nvp'
ex_map = {
neutron_utils.NEUTRON_DHCP_AGENT_CONF: ['neutron-dhcp-agent'],
neutron_utils.NEUTRON_DNSMASQ_CONF: ['neutron-dhcp-agent'],
neutron_utils.NOVA_CONF: ['nova-api-metadata'],
neutron_utils.NEUTRON_CONF: ['neutron-dhcp-agent',
'neutron-metadata-agent'],
neutron_utils.NEUTRON_METADATA_AGENT_CONF:
['neutron-metadata-agent'],
}
self.assertEquals(neutron_utils.restart_map(), ex_map)
def test_register_configs_pre_install(self): def test_register_configs_pre_install(self):
self.config.return_value = 'ovs' self.config.return_value = 'ovs'
self.is_relation_made.return_value = False self.is_relation_made.return_value = False
self.networking_name.return_value = 'quantum'
configs = neutron_utils.register_configs() configs = neutron_utils.register_configs()
confs = [neutron_utils.QUANTUM_DHCP_AGENT_CONF, confs = [neutron_utils.NOVA_CONF,
neutron_utils.QUANTUM_METADATA_AGENT_CONF, neutron_utils.NEUTRON_CONF,
neutron_utils.NOVA_CONF, neutron_utils.NEUTRON_L3_AGENT_CONF,
neutron_utils.QUANTUM_CONF, neutron_utils.NEUTRON_ML2_PLUGIN_CONF,
neutron_utils.QUANTUM_L3_AGENT_CONF,
neutron_utils.QUANTUM_OVS_PLUGIN_CONF,
neutron_utils.EXT_PORT_CONF] neutron_utils.EXT_PORT_CONF]
for conf in confs: for conf in confs:
configs.register.assert_any_call(conf, ANY) configs.register.assert_any_call(conf, ANY)
def test_get_common_package_quantum(self):
self.get_os_codename_package.return_value = 'folsom'
self.assertEquals(neutron_utils.get_common_package(), 'quantum-common')
def test_get_common_package_neutron(self):
self.get_os_codename_package.return_value = None
self.assertEquals(neutron_utils.get_common_package(), 'neutron-common')
def test_copy_file_without_update(self): def test_copy_file_without_update(self):
src = 'dummy_source_dir/dummy_file' src = 'dummy_source_dir/dummy_file'
dst = 'dummy_des_dir' dst = 'dummy_des_dir'
@ -707,12 +642,12 @@ cluster2 = ['cluster2-machine1.internal', 'cluster2-machine2.internal'
'cluster2-machine3.internal'] 'cluster2-machine3.internal']
class TestQuantumAgentReallocation(CharmTestCase): class TestNeutronAgentReallocation(CharmTestCase):
def setUp(self): def setUp(self):
if not neutronclient: if not neutronclient:
raise self.skipTest('Skipping, no neutronclient installed') raise self.skipTest('Skipping, no neutronclient installed')
super(TestQuantumAgentReallocation, self).setUp(neutron_utils, super(TestNeutronAgentReallocation, self).setUp(neutron_utils,
TO_PATCH) TO_PATCH)
def tearDown(self): def tearDown(self):