Skip to content

Commit

Permalink
refactor: Drop unsupported configurations and code
Browse files Browse the repository at this point in the history
Includes dropping support for quantum, nvp plugin (renamed
nsx long ago) and generally refactoring the unit tests
around no longer having to deal with neutron and quantum in
the same codebase.

Drop support for database connections - these are no longer
required as all DB access is now via RPC to nova-conductor
or neutron-server.

Roll-up configuration file templates < icehouse, remove any
that are no longer required.

Refactor basic_deployment a bit as it was using the shared-db
relation to retrieve the n-gateway units private-address.

Change-Id: I22957c0e21c4dd49e5aa74795173b4fc8f043f55
  • Loading branch information
javacruft committed Mar 3, 2016
1 parent fce66ca commit 00f0edc
Show file tree
Hide file tree
Showing 36 changed files with 83 additions and 645 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,4 +3,5 @@ bin
tags
.tox
.testrepository
*.pyc
*.sw[nop]
4 changes: 2 additions & 2 deletions actions/openstack_upgrade.py
Expand Up @@ -9,7 +9,7 @@

from neutron_utils import (
do_openstack_upgrade,
get_common_package,
NEUTRON_COMMON,
)

from neutron_hooks import (
Expand All @@ -26,7 +26,7 @@ def openstack_upgrade():
code to run, otherwise a full service level upgrade will fire
on config-changed."""

if do_action_openstack_upgrade(get_common_package(),
if do_action_openstack_upgrade(NEUTRON_COMMON,
do_openstack_upgrade,
CONFIGS):
config_changed()
Expand Down
17 changes: 5 additions & 12 deletions config.yaml
Expand Up @@ -33,7 +33,8 @@ options:
For series=Trusty we support cloud archives for openstack-release:
* juno
* kilo
* ...
* liberty
* mitaka
NOTE: updating this setting to a source that is known to provide
a later version of OpenStack will trigger a software upgrade.
Expand All @@ -60,10 +61,10 @@ options:
Network configuration plugin to use for quantum.
Supported values include:
ovs - Open vSwitch
nvp|nsx - Nicira NVP/VMware NSX
ovs - ML2 + Open vSwitch
nsx - VMware NSX
n1kv - Cisco N1kv
ovs-odl - Open vSwitch with OpenDayLight Controller
ovs-odl - ML2 + Open vSwitch with OpenDayLight Controller
ext-port:
type: string
default:
Expand Down Expand Up @@ -140,14 +141,6 @@ options:
description: |
Optional configuration to support use of linux router
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:
default: "juju"
type: string
Expand Down
67 changes: 9 additions & 58 deletions hooks/neutron_contexts.py
Expand Up @@ -15,85 +15,36 @@
NeutronAPIContext,
config_flags_parser
)
from charmhelpers.contrib.openstack.utils import (
get_os_codename_install_source
)
from charmhelpers.contrib.hahelpers.cluster import(
eligible_leader
)
from charmhelpers.contrib.network.ip import (
get_address_in_network,
)

DB_USER = "quantum"
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_ML2_PLUGIN = "ml2"
NEUTRON_N1KV_PLUGIN = \
"neutron.plugins.cisco.n1kv.n1kv_neutron_plugin.N1kvNeutronPluginV2"
NEUTRON_NSX_PLUGIN = "vmware"
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'
NVP = 'nvp'
N1KV = 'n1kv'
NSX = 'nsx'
OVS_ODL = 'ovs-odl'

NEUTRON = 'neutron'

CORE_PLUGIN = {
QUANTUM: {
OVS: QUANTUM_OVS_PLUGIN,
NVP: QUANTUM_NVP_PLUGIN,
},
NEUTRON: {
OVS: NEUTRON_OVS_PLUGIN,
NVP: NEUTRON_NVP_PLUGIN,
N1KV: NEUTRON_N1KV_PLUGIN,
NSX: NEUTRON_NSX_PLUGIN,
OVS_ODL: NEUTRON_OVS_ODL_PLUGIN,
},
OVS: NEUTRON_ML2_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():
plugin = remap_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]
return CORE_PLUGIN[config('plugin')]


class L3AgentContext(OSContextGenerator):
Expand Down Expand Up @@ -189,7 +140,7 @@ def get_host_ip(hostname=None):

def get_shared_secret():
secret = None
_path = SHARED_SECRET.format(networking_name())
_path = SHARED_SECRET.format(NEUTRON)
if not os.path.exists(_path):
secret = str(uuid.uuid4())
with open(_path, 'w') as secret_file:
Expand Down
46 changes: 6 additions & 40 deletions hooks/neutron_hooks.py
Expand Up @@ -5,11 +5,9 @@
from charmhelpers.core.hookenv import (
log, ERROR, WARNING,
config,
is_relation_made,
relation_get,
relation_set,
relation_ids,
unit_get,
Hooks,
UnregisteredHookError,
status_set,
Expand Down Expand Up @@ -52,7 +50,6 @@
do_openstack_upgrade,
get_packages,
get_early_packages,
get_common_package,
get_topics,
git_install,
git_install_requested,
Expand All @@ -69,6 +66,7 @@
use_l3ha,
REQUIRED_INTERFACES,
check_optional_relations,
NEUTRON_COMMON,
)

hooks = Hooks()
Expand All @@ -82,7 +80,7 @@ def install():
src = config('openstack-origin')
if (lsb_release()['DISTRIB_CODENAME'] == 'precise' and
src == 'distro'):
src = 'cloud:precise-folsom'
src = 'cloud:precise-icehouse'
configure_installation_source(src)
status_set('maintenance', 'Installing apt packages')
apt_update(fatal=True)
Expand Down Expand Up @@ -115,7 +113,7 @@ def config_changed():
CONFIGS.write_all()

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')
do_openstack_upgrade(CONFIGS)

Expand All @@ -126,10 +124,6 @@ def config_changed():
create_sysctl(sysctl_dict, '/etc/sysctl.d/50-quantum-gateway.conf')

# 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'):
amqp_joined(relation_id=r_id)
for r_id in relation_ids('amqp-nova'):
Expand Down Expand Up @@ -163,32 +157,6 @@ def upgrade_charm():
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')
def amqp_nova_joined(relation_id=None):
relation_set(relation_id=relation_id,
Expand Down Expand Up @@ -222,13 +190,11 @@ def amqp_departed():
CONFIGS.write_all()


@hooks.hook('shared-db-relation-changed',
'pgsql-db-relation-changed',
'amqp-relation-changed',
@hooks.hook('amqp-relation-changed',
'cluster-relation-changed',
'cluster-relation-joined')
@restart_on_change(restart_map())
def db_amqp_changed():
def amqp_changed():
CONFIGS.write_all()


Expand Down Expand Up @@ -280,7 +246,7 @@ def stop():


@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):
relation_set(relation_id=relid,
topics=" ".join(get_topics()),
Expand Down

0 comments on commit 00f0edc

Please sign in to comment.