Drop support for Neutron functionality

Neutron functionality was deprecated last release; remove
direct support for managing the neutron-server process and
associated plugin support from this charm.

All neutron-server support is now provided by the neutron-api
charm.

Change-Id: Iec7bd5ec6d835b573a15f8163fa5f78842bd672b
This commit is contained in:
James Page 2016-04-08 10:42:07 +01:00
parent 6e2715c83e
commit c2bc02e3ab
15 changed files with 32 additions and 809 deletions

View File

@ -2,11 +2,6 @@
Cloud controller node for OpenStack nova. Contains nova-schedule, nova-api, nova-network and nova-objectstore.
The neutron-api interface can be used join this charm with an external neutron-api server. If this is done
then this charm will shutdown its neutron-api service and the external charm will be registered as the
neutron-api endpoint in keystone. It will also use the quantum-security-groups setting which is passed to
it by the api service rather than its own quantum-security-groups setting.
If console access is required then console-proxy-ip should be set to a client accessible IP that resolves
to the nova-cloud-controller. If running in HA mode then the public vip is used if console-proxy-ip is set
to local. Note: The console access protocol is baked into a guest when it is created, if you change it then

View File

@ -75,20 +75,6 @@ options:
description: |
Comma-separated list of key=value sqlalchemy related config flags to be
set in nova.conf [database] section.
neutron-database-user:
default: neutron
type: string
description: Username for Neutron database access (if enabled)
neutron-database:
default: neutron
type: string
description: Database name for Neutron (if enabled)
neutron-alchemy-flags:
type: string
default:
description: |
Comma-separated list of key=value sqlalchemy related config flags to be
set in neutron.conf [database] section.
network-manager:
default: FlatDHCPManager
type: string
@ -113,27 +99,6 @@ options:
default: 255.255.255.0
type: string
description: Netmask to be assigned to bridge interface
quantum-plugin:
default: ovs
type: string
description: |
Quantum plugin to use for network management; supports:
ovs - OpenvSwitch Plugin
nvp|nsx - Nicira Network Virtualization Platform/
VMware NSX Network Virtualization Platform
(renamed for Icehouse)
vsp - Nuage Networks VSP
This configuration only has context when used with network-manager
Quantum|Neutron.
quantum-security-groups:
type: string
default: "no"
description: |
Use quantum for security group management.
.
Only supported for >= grizzly.
neutron-external-network:
type: string
default: ext_net
@ -232,36 +197,6 @@ options:
description: |
SSL CA to use with the certificate and key provided - this is only
required if you are providing a privately signed ssl_cert and ssl_key.
# Neutron NVP and VMware NSX plugin configuration
nvp-controllers:
type: string
default:
description: Space delimited addresses of NVP/NSX controllers
nvp-username:
type: string
default: admin
description: Username to connect to NVP/NSX controllers with
nvp-password:
type: string
default: admin
description: Password to connect to NVP/NSX controllers with
nvp-cluster-name:
type: string
default: example
description: Name of the NVP cluster configuration to create (grizzly only)
nvp-tz-uuid:
type: string
default:
description: |
This is uuid of the default NVP/NSX Transport zone that will be used for
creating tunneled isolated Quantum networks. It needs to be created
in NVP before starting Quantum with the nvp plugin.
nvp-l3-uuid:
type: string
default:
description: |
This is uuid of the default NVP/NSX L3 Gateway Service.
# end of NVP/NSX configuration
# Network configuration options
# by default all access is over 'private-address'
os-admin-network:

View File

@ -10,7 +10,6 @@ from charmhelpers.core.hookenv import (
related_units,
relations_for_id,
relation_get,
is_relation_made,
unit_get,
)
from charmhelpers.contrib.openstack import (
@ -141,9 +140,6 @@ class HAProxyContext(context.HAProxyContext):
singlenode_mode=True)
s3_api = determine_api_port(api_port('nova-objectstore'),
singlenode_mode=True)
neutron_api = determine_api_port(api_port('neutron-server'),
singlenode_mode=True)
# Apache ports
a_compute_api = determine_apache_port(api_port('nova-api-os-compute'),
singlenode_mode=True)
@ -151,9 +147,6 @@ class HAProxyContext(context.HAProxyContext):
singlenode_mode=True)
a_s3_api = determine_apache_port(api_port('nova-objectstore'),
singlenode_mode=True)
a_neutron_api = determine_apache_port(api_port('neutron-server'),
singlenode_mode=True)
# to be set in nova.conf accordingly.
listen_ports = {
'osapi_compute_listen_port': compute_api,
@ -170,15 +163,6 @@ class HAProxyContext(context.HAProxyContext):
api_port('nova-objectstore'), a_s3_api],
}
if not is_relation_made('neutron-api'):
if neutron.network_manager() == 'neutron':
port_mapping.update({
'neutron-server': [
api_port('neutron-server'), a_neutron_api]
})
# neutron.conf listening port, set separte from nova's.
ctxt['neutron_bind_port'] = neutron_api
# for haproxy.conf
ctxt['service_ports'] = port_mapping
# for nova.conf
@ -198,38 +182,13 @@ def canonical_url():
return '%s://%s' % (scheme, format_ipv6_addr(addr) or addr)
def use_local_neutron_api():
"""If no neutron-api relation exists returns True.
If no neutron-api relation exists we assume that we are going to use
legacy-mode i.e. local neutron server.
"""
for rid in relation_ids('neutron-api'):
for unit in related_units(rid):
return False
return True
class NeutronCCContext(context.NeutronContext):
interfaces = ['quantum-network-service', 'neutron-network-service']
@property
def plugin(self):
from nova_cc_utils import neutron_plugin
return neutron_plugin()
@property
def network_manager(self):
return neutron.network_manager()
@property
def neutron_security_groups(self):
# TODO: review use of this flag
sec_groups = (config('neutron-security-groups') or
config('quantum-security-groups'))
return sec_groups.lower() == 'yes'
def _ensure_packages(self):
# Only compute nodes need to ensure packages here, to install
# required agents.
@ -238,21 +197,7 @@ class NeutronCCContext(context.NeutronContext):
def __call__(self):
ctxt = super(NeutronCCContext, self).__call__()
ctxt['external_network'] = config('neutron-external-network')
if config('quantum-plugin') in ['nvp', 'nsx']:
_config = config()
for k, v in _config.iteritems():
if k.startswith('nvp'):
ctxt[k.replace('-', '_')] = v
if 'nvp-controllers' in _config:
ctxt['nvp_controllers'] = \
','.join(_config['nvp-controllers'].split())
ctxt['nvp_controllers_list'] = \
_config['nvp-controllers'].split()
ctxt['nova_url'] = "{}:8774/v2".format(canonical_url())
if use_local_neutron_api():
ctxt['neutron_url'] = "{}:9696".format(canonical_url())
return ctxt

View File

@ -31,10 +31,7 @@ from charmhelpers.core.hookenv import (
)
from charmhelpers.core.host import (
service_running,
service_stop,
service_reload,
service_restart,
)
from charmhelpers.fetch import (
@ -58,7 +55,6 @@ from charmhelpers.contrib.openstack.utils import (
from charmhelpers.contrib.openstack.neutron import (
network_manager,
neutron_plugin_attribute,
)
from nova_cc_context import (
@ -72,7 +68,6 @@ from charmhelpers.contrib.peerstorage import (
)
from nova_cc_utils import (
api_port,
auth_token_config,
cmd_all_services,
determine_endpoints,
@ -84,9 +79,7 @@ from nova_cc_utils import (
git_install,
is_api_ready,
keystone_ca_cert_b64,
migrate_neutron_database,
migrate_nova_database,
neutron_plugin,
save_script_rc,
services,
ssh_compute_add,
@ -97,7 +90,6 @@ from nova_cc_utils import (
restart_map,
CLUSTER_RES,
NOVA_CONF,
NEUTRON_CONF,
console_attributes,
service_guard,
guard_map,
@ -180,8 +172,6 @@ def leader_init_db_if_ready(skip_acl_check=False, skip_cells_restarts=False,
log('Triggering remote cell restarts.')
[nova_cell_relation_joined(rid=rid, remote_restart=True)
for rid in relation_ids('cell')]
conditional_neutron_migration()
else:
log('allowed_units either not presented, or local unit '
'not in acl list: %s' % repr(allowed_units))
@ -298,9 +288,6 @@ def amqp_changed():
log('amqp relation incomplete. Peer not ready?')
return
CONFIGS.write(NOVA_CONF)
if not is_relation_made('neutron-api'):
if network_manager() == 'neutron':
CONFIGS.write(NEUTRON_CONF)
[nova_cell_relation_joined(rid=rid)
for rid in relation_ids('cell')]
@ -308,29 +295,6 @@ def amqp_changed():
nova_api_relation_joined(rid=r_id)
def conditional_neutron_migration():
if os_release('nova-common') <= 'icehouse':
log('Not running neutron database migration as migrations are handled '
'by the neutron-server process.')
elif os_release('nova-common') >= 'kilo':
log('Not running neutron database migration as migrations are by '
'the neutron-api charm.')
else:
if not config('quantum-plugin') == 'vsp':
status_set('maintenance', 'Running neutron db migration')
migrate_neutron_database()
else:
log('Not running neutron database migration as migrations are '
'handled by the neutron-api charm in case of VSP(juno).')
# neutron-api service may have appeared while the migration was
# running so prod it just in case
[neutron_api_relation_joined(rid=rid, remote_restart=True)
for rid in relation_ids('neutron-api')]
if 'neutron-server' in services() and not is_unit_paused_set():
service_restart('neutron-server')
@hooks.hook('shared-db-relation-joined')
def db_joined(relation_id=None):
if is_relation_made('pgsql-nova-db') or \
@ -341,11 +305,6 @@ def db_joined(relation_id=None):
log(e, level=ERROR)
raise Exception(e)
if network_manager() == 'neutron':
config_neutron = True
else:
config_neutron = False
if config('prefer-ipv6'):
sync_db_with_multi_ipv6_addresses(config('database'),
config('database-user'),
@ -357,10 +316,6 @@ def db_joined(relation_id=None):
config('database-user'),
relation_prefix='novaapi')
if config_neutron:
sync_db_with_multi_ipv6_addresses(config('neutron-database'),
config('neutron-database-user'),
relation_prefix='neutron')
else:
host = unit_get('private-address')
relation_set(nova_database=config('database'),
@ -375,12 +330,6 @@ def db_joined(relation_id=None):
novaapi_hostname=host,
relation_id=relation_id)
if config_neutron:
relation_set(neutron_database=config('neutron-database'),
neutron_username=config('neutron-database-user'),
neutron_hostname=host,
relation_id=relation_id)
@hooks.hook('pgsql-nova-db-relation-joined')
def pgsql_nova_db_joined():
@ -394,18 +343,6 @@ def pgsql_nova_db_joined():
relation_set(database=config('database'))
@hooks.hook('pgsql-neutron-db-relation-joined')
def pgsql_neutron_db_joined():
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('neutron-database'))
@hooks.hook('shared-db-relation-changed')
@service_guard(guard_map(), CONFIGS,
active=config('service-guard'))
@ -435,17 +372,6 @@ def postgresql_nova_db_changed():
nova_api_relation_joined(rid=r_id)
@hooks.hook('pgsql-neutron-db-relation-changed')
@service_guard(guard_map(), CONFIGS,
active=config('service-guard'))
@restart_on_change(restart_map())
def postgresql_neutron_db_changed():
if network_manager() == 'neutron':
plugin = neutron_plugin()
# DB config might have been moved to main neutron.conf in H?
CONFIGS.write(neutron_plugin_attribute(plugin, 'config'))
@hooks.hook('image-service-relation-changed')
@service_guard(guard_map(), CONFIGS,
active=config('service-guard'))
@ -481,9 +407,6 @@ def identity_changed():
return
CONFIGS.write('/etc/nova/api-paste.ini')
CONFIGS.write(NOVA_CONF)
if not is_relation_made('neutron-api'):
if network_manager() == 'neutron':
CONFIGS.write(NEUTRON_CONF)
[compute_joined(rid) for rid in relation_ids('cloud-compute')]
[quantum_joined(rid) for rid in relation_ids('quantum-network-service')]
[nova_vmware_relation_joined(rid) for rid in relation_ids('nova-vmware')]
@ -558,18 +481,9 @@ def neutron_settings():
neutron_api_info['neutron_security_groups'],
'quantum_url': neutron_api_info['neutron_url'],
})
else:
neutron_settings.update({
# XXX: Rename these relations settings?
'quantum_plugin': neutron_plugin(),
'region': config('region'),
'quantum_security_groups': config('quantum-security-groups'),
'quantum_url': "{}:{}".format(canonical_url(CONFIGS, INTERNAL),
str(api_port('neutron-server'))),
})
neutron_url = urlparse(neutron_settings['quantum_url'])
neutron_settings['quantum_host'] = neutron_url.hostname
neutron_settings['quantum_port'] = neutron_url.port
neutron_url = urlparse(neutron_settings['quantum_url'])
neutron_settings['quantum_host'] = neutron_url.hostname
neutron_settings['quantum_port'] = neutron_url.port
return neutron_settings
@ -847,9 +761,6 @@ def ha_changed():
return
CONFIGS.write(NOVA_CONF)
if not is_relation_made('neutron-api'):
if network_manager() == 'neutron':
CONFIGS.write(NEUTRON_CONF)
log('Cluster configured, notifying other services and updating '
'keystone endpoint configuration')
@ -917,11 +828,7 @@ def nova_vmware_relation_joined(rid=None):
ks_auth = _auth_config()
if ks_auth:
rel_settings.update(ks_auth)
rel_settings.update({
'quantum_plugin': neutron_plugin(),
'quantum_security_groups': config('quantum-security-groups'),
'quantum_url': "{}:{}".format(canonical_url(CONFIGS, INTERNAL),
str(api_port('neutron-server')))})
rel_settings.update(neutron_settings())
relation_set(relation_id=rid, **rel_settings)
@ -992,12 +899,6 @@ def get_cell_type():
@hooks.hook('neutron-api-relation-joined')
def neutron_api_relation_joined(rid=None, remote_restart=False):
with open('/etc/init/neutron-server.override', 'wb') as out:
out.write('manual\n')
if os.path.isfile(NEUTRON_CONF):
os.rename(NEUTRON_CONF, NEUTRON_CONF + '_unused')
if service_running('neutron-server'):
service_stop('neutron-server')
for id_rid in relation_ids('identity-service'):
identity_joined(rid=id_rid)
rel_settings = {
@ -1027,8 +928,6 @@ def neutron_api_relation_changed():
active=config('service-guard'))
@restart_on_change(restart_map())
def neutron_api_relation_broken():
if os.path.isfile('/etc/init/neutron-server.override'):
os.remove('/etc/init/neutron-server.override')
CONFIGS.write_all()
for rid in relation_ids('cloud-compute'):
compute_joined(rid=rid)

View File

@ -8,8 +8,6 @@ from collections import OrderedDict
from copy import deepcopy
from charmhelpers.contrib.openstack import context, templating
from charmhelpers.contrib.openstack.neutron import (
network_manager, neutron_plugin_attribute)
from charmhelpers.contrib.hahelpers.cluster import (
is_elected_leader,
@ -60,7 +58,6 @@ from charmhelpers.core.hookenv import (
relation_get,
relation_ids,
remote_unit,
is_relation_made,
DEBUG,
INFO,
ERROR,
@ -179,7 +176,6 @@ API_PORTS = {
'nova-api-os-compute': 8774,
'nova-api-os-volume': 8776,
'nova-objectstore': 3333,
'neutron-server': 9696,
}
NOVA_CONF_DIR = "/etc/nova"
@ -187,11 +183,9 @@ NEUTRON_CONF_DIR = "/etc/neutron"
NOVA_CONF = '%s/nova.conf' % NOVA_CONF_DIR
NOVA_API_PASTE = '%s/api-paste.ini' % NOVA_CONF_DIR
NEUTRON_CONF = '%s/neutron.conf' % NEUTRON_CONF_DIR
HAPROXY_CONF = '/etc/haproxy/haproxy.cfg'
APACHE_CONF = '/etc/apache2/sites-available/openstack_https_frontend'
APACHE_24_CONF = '/etc/apache2/sites-available/openstack_https_frontend.conf'
NEUTRON_DEFAULT = '/etc/default/neutron-server'
def resolve_services():
@ -243,28 +237,6 @@ BASE_RESOURCE_MAP = OrderedDict([
'contexts': [nova_cc_context.IdentityServiceContext(),
nova_cc_context.APIRateLimitingContext()],
}),
(NEUTRON_CONF, {
'services': ['neutron-server'],
'contexts': [context.AMQPContext(ssl_dir=NEUTRON_CONF_DIR),
context.SharedDBContext(
user=config('neutron-database-user'),
database=config('neutron-database'),
relation_prefix='neutron',
ssl_dir=NEUTRON_CONF_DIR),
nova_cc_context.NeutronPostgresqlDBContext(),
nova_cc_context.IdentityServiceContext(
service='neutron',
service_user='neutron'),
nova_cc_context.NeutronCCContext(),
nova_cc_context.HAProxyContext(),
context.SyslogContext(),
nova_cc_context.NovaConfigContext(),
context.BindHostContext()],
}),
(NEUTRON_DEFAULT, {
'services': ['neutron-server'],
'contexts': [nova_cc_context.NeutronCCContext()],
}),
(HAPROXY_CONF, {
'contexts': [context.HAProxyContext(singlenode_mode=True),
nova_cc_context.HAProxyContext()],
@ -313,8 +285,6 @@ def resource_map():
'''
resource_map = deepcopy(BASE_RESOURCE_MAP)
net_manager = network_manager()
if os.path.exists('/etc/apache2/conf-available'):
resource_map.pop(APACHE_CONF)
else:
@ -322,38 +292,6 @@ def resource_map():
resource_map[NOVA_CONF]['contexts'].append(
nova_cc_context.NeutronCCContext())
# pop out irrelevant resources from the OrderedDict (easier than adding
# them late)
if net_manager != 'neutron':
[resource_map.pop(k) for k in list(resource_map.iterkeys())
if 'neutron' in k]
# add neutron plugin requirements. nova-c-c only needs the
# neutron-server associated with configs, not the plugin agent.
if net_manager == 'neutron':
plugin = neutron_plugin()
if plugin:
conf = neutron_plugin_attribute(plugin, 'config', net_manager)
ctxts = (neutron_plugin_attribute(plugin, 'contexts',
net_manager) or [])
services = neutron_plugin_attribute(plugin, 'server_services',
net_manager)
resource_map[conf] = {}
resource_map[conf]['services'] = services
resource_map[conf]['contexts'] = ctxts
resource_map[conf]['contexts'].append(
nova_cc_context.NeutronCCContext())
# update for postgres
resource_map[conf]['contexts'].append(
nova_cc_context.NeutronPostgresqlDBContext())
if is_relation_made('neutron-api'):
for k in list(resource_map.iterkeys()):
# neutron-api runs neutron services
if 'neutron' in k:
resource_map[k]['services'] = []
resource_map[NOVA_CONF]['contexts'].append(
nova_cc_context.NeutronAPIContext())
if os_release('nova-common') >= 'mitaka':
resource_map[NOVA_CONF]['contexts'].append(
@ -444,10 +382,6 @@ def determine_packages():
packages = [] + BASE_PACKAGES
for v in resource_map().values():
packages.extend(v['services'])
if network_manager() == 'neutron':
pkgs = neutron_plugin_attribute(neutron_plugin(), 'server_packages',
network_manager())
packages.extend(pkgs)
if console_attributes('packages'):
packages.extend(console_attributes('packages'))
@ -474,8 +408,6 @@ def save_script_rc():
}
if relation_ids('nova-volume-service'):
env_vars['OPENSTACK_SERVICE_API_OS_VOL'] = 'nova-api-os-volume'
if network_manager() == 'neutron':
env_vars['OPENSTACK_SERVICE_API_NEUTRON'] = 'neutron-server'
_save_script_rc(**env_vars)
@ -509,7 +441,7 @@ POLICY_RC_D = """#!/bin/bash
set -e
case $1 in
neutron-server|quantum-server|nova-*)
nova-*)
[ $2 = "start" ] && exit 101
;;
*)
@ -530,36 +462,12 @@ def disable_policy_rcd():
os.unlink('/usr/sbin/policy-rc.d')
NEUTRON_DB_MANAGE = "neutron-db-manage"
def reset_os_release():
# Ugly hack to make os_release re-read versions
import charmhelpers.contrib.openstack.utils as utils
utils.os_rel = None
def neutron_db_manage(actions):
net_manager = network_manager()
if net_manager == 'neutron':
plugin = neutron_plugin()
conf = neutron_plugin_attribute(plugin, 'config', net_manager)
subprocess.check_call([
NEUTRON_DB_MANAGE,
'--config-file=/etc/{mgr}/{mgr}.conf'.format(mgr=net_manager),
'--config-file={}'.format(conf)] + actions
)
def get_db_connection():
config = ConfigParser.RawConfigParser()
config.read(NEUTRON_CONF)
try:
return config.get('database', 'connection')
except:
return None
def is_db_initialised():
if relation_ids('cluster'):
dbsync_state = peer_retrieve('dbsync_state')
@ -573,7 +481,6 @@ def is_db_initialised():
def _do_openstack_upgrade(new_src):
enable_policy_rcd()
cur_os_rel = os_release('nova-common')
new_os_rel = get_os_codename_install_source(new_src)
log('Performing OpenStack upgrade to %s.' % (new_os_rel))
@ -583,33 +490,18 @@ def _do_openstack_upgrade(new_src):
'--option', 'Dpkg::Options::=--force-confdef',
]
# NOTE(jamespage) pre-stamp neutron database before upgrade from grizzly
if cur_os_rel == 'grizzly':
neutron_db_manage(['stamp', 'grizzly'])
apt_update(fatal=True)
apt_upgrade(options=dpkg_opts, fatal=True, dist=True)
apt_install(determine_packages(), fatal=True)
disable_policy_rcd()
if cur_os_rel == 'grizzly':
# NOTE(jamespage) when upgrading from grizzly->havana, config
# files need to be generated prior to performing the db upgrade
reset_os_release()
configs = register_configs(release=new_os_rel)
configs.write_all()
neutron_db_manage(['upgrade', 'head'])
else:
if new_os_rel < 'kilo':
neutron_db_manage(['stamp', cur_os_rel])
migrate_neutron_database()
# NOTE(jamespage) upgrade with existing config files as the
# havana->icehouse migration enables new service_plugins which
# create issues with db upgrades
reset_os_release()
configs = register_configs(release=new_os_rel)
configs.write_all()
# NOTE(jamespage) upgrade with existing config files as the
# havana->icehouse migration enables new service_plugins which
# create issues with db upgrades
reset_os_release()
configs = register_configs(release=new_os_rel)
configs.write_all()
if new_os_rel >= 'mitaka' and not database_setup(prefix='novaapi'):
# NOTE: Defer service restarts and database migrations for now
@ -678,15 +570,6 @@ def migrate_nova_database():
cmd_all_services('start')
# NOTE(jamespage): Retry deals with sync issues during one-shot HA deploys.
# mysql might be restarting or suchlike.
@retry_on_exception(5, base_delay=3, exc_type=subprocess.CalledProcessError)
def migrate_neutron_database():
'''Runs neutron-db-manage to init a new database or migrate existing'''
log('Migrating the neutron database.', level=INFO)
neutron_db_manage(['upgrade', 'head'])
# TODO: refactor to use unit storage or related data
def auth_token_config(setting):
"""
@ -891,10 +774,6 @@ def determine_endpoints(public_url, internal_url, admin_url):
ec2_admin_url = '%s:%s/services/Cloud' % (admin_url,
api_port('nova-api-ec2'))
neutron_public_url = '%s:%s' % (public_url, api_port('neutron-server'))
neutron_internal_url = '%s:%s' % (internal_url, api_port('neutron-server'))
neutron_admin_url = '%s:%s' % (admin_url, api_port('neutron-server'))
s3_public_url = '%s:%s' % (public_url, api_port('nova-objectstore'))
s3_internal_url = '%s:%s' % (internal_url, api_port('nova-objectstore'))
s3_admin_url = '%s:%s' % (admin_url, api_port('nova-objectstore'))
@ -918,24 +797,6 @@ def determine_endpoints(public_url, internal_url, admin_url):
's3_internal_url': s3_internal_url,
}
# XXX: Keep these relations named quantum_*??
if relation_ids('neutron-api'):
endpoints.update({
'quantum_service': None,
'quantum_region': None,
'quantum_public_url': None,
'quantum_admin_url': None,
'quantum_internal_url': None,
})
elif network_manager() == 'neutron':
endpoints.update({
'quantum_service': 'quantum',
'quantum_region': region,
'quantum_public_url': neutron_public_url,
'quantum_admin_url': neutron_admin_url,
'quantum_internal_url': neutron_internal_url,
})
if os_rel >= 'kilo':
# NOTE(jamespage) drop endpoints for ec2 and s3
# ec2 is deprecated
@ -956,13 +817,6 @@ def determine_endpoints(public_url, internal_url, admin_url):
return endpoints
# TODO: review to see if we can drop quantum-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')
def guard_map():
'''Map of services and required interfaces that must be present before
the service should be allowed to start'''
@ -980,16 +834,6 @@ def guard_map():
for svc in nova_services:
gmap[svc] = nova_interfaces
net_manager = network_manager()
if net_manager == 'neutron' and \
not is_relation_made('neutron-api'):
neutron_interfaces = ['identity-service', 'amqp']
if relation_ids('pgsql-neutron-db'):
neutron_interfaces.append('pgsql-neutron-db')
else:
neutron_interfaces.append('shared-db')
gmap['neutron-server'] = neutron_interfaces
return gmap

View File

@ -30,8 +30,6 @@ requires:
interface: mysql-shared
pgsql-nova-db:
interface: pgsql
pgsql-neutron-db:
interface: pgsql
amqp:
interface: rabbitmq
image-service:

View File

@ -1,30 +0,0 @@
# icehouse
###############################################################################
# [ WARNING ]
# Configuration file maintained by Juju. Local changes may be overwritten.
###############################################################################
[ml2]
type_drivers = gre,vxlan
tenant_network_types = gre,vxlan
mechanism_drivers = openvswitch
[ml2_type_gre]
tunnel_id_ranges = 1:1000
[ml2_type_vxlan]
vni_ranges = 1001:2000
[ovs]
enable_tunneling = True
local_ip = {{ local_ip }}
[agent]
tunnel_types = gre
[securitygroup]
{% if neutron_security_groups -%}
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
{% else -%}
enable_security_group = False
{% endif -%}

View File

@ -1,6 +0,0 @@
# havana
###############################################################################
# [ WARNING ]
# Configuration file maintained by Juju. Local changes may be overwritten.
###############################################################################
NEUTRON_PLUGIN_CONFIG="{{ config }}"

View File

@ -1,75 +0,0 @@
###############################################################################
# [ WARNING ]
# Configuration file maintained by Juju. Local changes may be overwritten.
###############################################################################
[DEFAULT]
state_path = /var/lib/neutron
lock_path = $state_path/lock
bind_host = {{ bind_host }}
auth_strategy = keystone
{% if notifications == 'True' -%}
notification_driver = neutron.openstack.common.notifier.rpc_notifier
{% endif -%}
api_workers = {{ workers }}
use_syslog = {{ use_syslog }}
{% if neutron_bind_port -%}
bind_port = {{ neutron_bind_port }}
{% else -%}
bind_port = 9696
{% endif -%}
{% if core_plugin -%}
core_plugin = {{ core_plugin }}
{% if neutron_plugin in ['ovs', 'ml2'] -%}
service_plugins = neutron.services.l3_router.l3_router_plugin.L3RouterPlugin,neutron.services.firewall.fwaas_plugin.FirewallPlugin,neutron.services.loadbalancer.plugin.LoadBalancerPlugin,neutron.services.vpn.plugin.VPNDriverPlugin,neutron.services.metering.metering_plugin.MeteringPlugin
{% endif -%}
{% endif -%}
{% if neutron_security_groups -%}
allow_overlapping_ips = True
neutron_firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
{% endif -%}
{% include "parts/rabbitmq" %}
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
nova_url = {{ nova_url }}
nova_region_name = {{ region }}
{% if auth_host -%}
nova_admin_username = {{ admin_user }}
nova_admin_tenant_id = {{ admin_tenant_id }}
nova_admin_password = {{ admin_password }}
nova_admin_auth_url = {{ auth_protocol }}://{{ auth_host }}:{{ auth_port }}/v2.0
{% endif -%}
[quotas]
quota_driver = neutron.db.quota_db.DbQuotaDriver
{% if neutron_security_groups -%}
quota_items = network,subnet,port,security_group,security_group_rule
{% endif -%}
[agent]
root_helper = sudo /usr/bin/neutron-rootwrap /etc/neutron/rootwrap.conf
[keystone_authtoken]
signing_dir = {{ signing_dir }}
{% if service_host -%}
service_protocol = {{ service_protocol }}
service_host = {{ service_host }}
service_port = {{ service_port }}
auth_host = {{ auth_host }}
auth_port = {{ auth_port }}
auth_protocol = {{ auth_protocol }}
admin_tenant_name = {{ admin_tenant_name }}
admin_user = {{ admin_user }}
admin_password = {{ admin_password }}
{% endif -%}
{% include "parts/section-database" %}
[service_providers]
service_provider=LOADBALANCER:Haproxy:neutron.services.loadbalancer.drivers.haproxy.plugin_driver.HaproxyOnHostPluginDriver:default
service_provider=VPN:openswan:neutron.services.vpn.service_drivers.ipsec.IPsecVPNDriver:default
service_provider=FIREWALL:Iptables:neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver:default

View File

@ -1,11 +0,0 @@
# icehouse
###############################################################################
# [ WARNING ]
# Configuration file maintained by Juju. Local changes may be overwritten.
###############################################################################
[DEFAULT]
nsx_user = {{ nvp_username }}
nsx_password = {{ nvp_password }}
nsx_controllers = {{ nvp_controllers }}
default_tz_uuid = {{ nvp_tz_uuid }}
default_l3_gw_service_uuid = {{ nvp_l3_uuid }}

View File

@ -1,13 +0,0 @@
# icehouse
###############################################################################
# [ WARNING ]
# Configuration file maintained by Juju. Local changes may be overwritten.
###############################################################################
[restproxy]
server = {{ vsd_server }}
serverauth = {{ vsd_auth }}
auth_resource = {{ vsd_auth_resource }}
organization = {{ vsd_organization }}
serverssl = {{ vsd_auth_ssl }}
base_uri = {{ vsd_base_uri }}
default_net_partition_name = {{ vsd_netpart_name }}

View File

@ -1,11 +0,0 @@
# havana
###############################################################################
# [ WARNING ]
# Configuration file maintained by Juju. Local changes may be overwritten.
###############################################################################
[DEFAULT]
nvp_user = {{ nvp_username }}
nvp_password = {{ nvp_password }}
nvp_controllers = {{ nvp_controllers }}
default_tz_uuid = {{ nvp_tz_uuid }}
default_l3_gw_service_uuid = {{ nvp_l3_uuid }}

View File

@ -18,7 +18,6 @@ TO_PATCH = [
'log',
'relations_for_id',
'https',
'is_relation_made',
]
@ -78,13 +77,10 @@ class NovaComputeContextTests(CharmTestCase):
instance_console())
@mock.patch('charmhelpers.contrib.openstack.neutron.os_release')
@mock.patch.object(context, 'use_local_neutron_api')
@mock.patch('charmhelpers.contrib.openstack.ip.config')
@mock.patch('charmhelpers.contrib.openstack.ip.is_clustered')
def test_neutron_context_single_vip(self, mock_is_clustered, mock_config,
mock_use_local_neutron_api,
_os_release):
mock_use_local_neutron_api.return_value = True
self.https.return_value = False
mock_is_clustered.return_value = True
config = {'vip': '10.0.0.1',
@ -93,22 +89,14 @@ class NovaComputeContextTests(CharmTestCase):
'os-public-network': '10.0.2.0/24'}
mock_config.side_effect = lambda key: config.get(key)
mock_use_local_neutron_api.return_value = False
ctxt = context.NeutronCCContext()()
self.assertEqual(ctxt['nova_url'], 'http://10.0.0.1:8774/v2')
self.assertFalse('neutron_url' in ctxt)
mock_use_local_neutron_api.return_value = True
ctxt = context.NeutronCCContext()()
self.assertEqual(ctxt['nova_url'], 'http://10.0.0.1:8774/v2')
self.assertEqual(ctxt['neutron_url'], 'http://10.0.0.1:9696')
@mock.patch('charmhelpers.contrib.openstack.neutron.os_release')
@mock.patch.object(context, 'use_local_neutron_api')
@mock.patch('charmhelpers.contrib.openstack.ip.config')
@mock.patch('charmhelpers.contrib.openstack.ip.is_clustered')
def test_neutron_context_multi_vip(self, mock_is_clustered, mock_config,
mock_use_local_neutron_api,
_os_release):
self.https.return_value = False
mock_is_clustered.return_value = True
@ -118,26 +106,10 @@ class NovaComputeContextTests(CharmTestCase):
'os-public-network': '10.0.2.0/24'}
mock_config.side_effect = lambda key: config.get(key)
mock_use_local_neutron_api.return_value = False
ctxt = context.NeutronCCContext()()
self.assertEqual(ctxt['nova_url'], 'http://10.0.1.1:8774/v2')
self.assertFalse('neutron_url' in ctxt)
mock_use_local_neutron_api.return_value = True
ctxt = context.NeutronCCContext()()
self.assertEqual(ctxt['nova_url'], 'http://10.0.1.1:8774/v2')
self.assertEqual(ctxt['neutron_url'], 'http://10.0.1.1:9696')
def test_use_local_neutron_api(self):
self.relation_ids.return_value = []
self.related_units.return_value = []
self.assertTrue(context.use_local_neutron_api())
self.relation_ids.return_value = ['rel:0']
self.related_units.return_value = []
self.assertTrue(context.use_local_neutron_api())
self.related_units.return_value = ['unit/0']
self.assertFalse(context.use_local_neutron_api())
@mock.patch.object(neutron, 'network_manager')
@mock.patch('charmhelpers.contrib.hahelpers.cluster.https')
@mock.patch('charmhelpers.contrib.openstack.context.kv')
@ -154,31 +126,9 @@ class NovaComputeContextTests(CharmTestCase):
mock_network_manager):
mock_network_manager.return_value = 'neutron'
mock_https.return_value = False
self.is_relation_made.return_value = False
ctxt = context.HAProxyContext()()
self.assertEqual(ctxt['service_ports']['neutron-server'], [9696, 9686])
@mock.patch.object(neutron, 'network_manager')
@mock.patch('charmhelpers.contrib.hahelpers.cluster.https')
@mock.patch('charmhelpers.contrib.openstack.context.kv')
@mock.patch('charmhelpers.contrib.openstack.context.'
'get_address_in_network')
@mock.patch('charmhelpers.contrib.openstack.context.'
'get_netmask_for_address')
@mock.patch('charmhelpers.contrib.openstack.context.local_unit')
@mock.patch('charmhelpers.contrib.openstack.context.get_ipv6_addr')
@mock.patch('charmhelpers.contrib.openstack.context.relation_ids')
def test_haproxy_context_api_relation(self, mock_relation_ids,
mock_get_ipv6_addr, mock_local_unit,
mock_get_netmask_for_address,
mock_get_address_in_network,
mock_kv, mock_https,
mock_network_manager):
mock_network_manager.return_value = 'neutron'
mock_https.return_value = False
self.is_relation_made.return_value = True
ctxt = context.HAProxyContext()()
self.assertEqual(ctxt['service_ports'].get('neutron-server'), None)
self.assertEqual(ctxt['service_ports']['nova-api-os-compute'],
[8774, 8764])
@mock.patch.object(context, 'config')
def test_console_ssl_disabled(self, mock_config):

View File

@ -4,7 +4,7 @@ import tempfile
import yaml
from mock import MagicMock, patch, call
from test_utils import CharmTestCase, patch_open
from test_utils import CharmTestCase
with patch('charmhelpers.core.hookenv.config') as config:
config.return_value = 'neutron'
@ -29,7 +29,6 @@ utils.register_configs = _reg
utils.restart_map = _map
TO_PATCH = [
'api_port',
'apt_update',
'apt_install',
'configure_installation_source',
@ -59,9 +58,6 @@ TO_PATCH = [
'ssh_authorized_keys_lines',
'save_script_rc',
'service_reload',
'service_restart',
'service_running',
'service_stop',
'services',
'execd_preinstall',
'network_manager',
@ -69,9 +65,7 @@ TO_PATCH = [
'uuid',
'is_elected_leader',
'keystone_ca_cert_b64',
'neutron_plugin',
'migrate_nova_database',
'migrate_neutron_database',
'uuid',
'get_hacluster_config',
'get_iface_for_address',
@ -301,22 +295,15 @@ class NovaCCHooksTests(CharmTestCase):
self.keystone_ca_cert_b64.return_value = 'foocert64'
self.unit_get.return_value = 'nova-cc-host1'
_canonical_url.return_value = 'http://nova-cc-host1'
self.api_port.return_value = '9696'
self.neutron_plugin.return_value = 'nvp'
auth_config.return_value = FAKE_KS_AUTH_CFG
hooks.compute_joined()
self.relation_set.assert_called_with(
relation_id=None,
quantum_url='http://nova-cc-host1:9696',
ca_cert='foocert64',
quantum_port=9696,
quantum_host='nova-cc-host1',
quantum_security_groups='no',
region='RegionOne',
volume_service='cinder',
ec2_host='nova-cc-host1',
quantum_plugin='nvp',
network_manager='neutron', **FAKE_KS_AUTH_CFG)
@patch.object(hooks, 'canonical_url')
@ -339,8 +326,6 @@ class NovaCCHooksTests(CharmTestCase):
self.keystone_ca_cert_b64.return_value = 'foocert64'
self.unit_get.return_value = 'nova-cc-host1'
_canonical_url.return_value = 'http://nova-cc-host1'
self.api_port.return_value = '9696'
self.neutron_plugin.return_value = 'nvp'
auth_config.return_value = FAKE_KS_AUTH_CFG
hooks.compute_joined()
self.relation_set.assert_called_with(
@ -360,15 +345,12 @@ class NovaCCHooksTests(CharmTestCase):
@patch.object(hooks, '_auth_config')
def test_nova_vmware_joined(self, auth_config, _canonical_url):
auth_config.return_value = FAKE_KS_AUTH_CFG
# quantum-security-groups, plugin
self.neutron_plugin.return_value = 'nvp'
self.is_relation_made.return_value = False
self.network_manager.return_value = 'neutron'
_canonical_url.return_value = 'http://nova-cc-host1'
self.api_port.return_value = '9696'
hooks.nova_vmware_relation_joined()
self.relation_set.assert_called_with(
network_manager='neutron', quantum_security_groups='no',
quantum_url='http://nova-cc-host1:9696', quantum_plugin='nvp',
network_manager='neutron',
relation_id=None,
**FAKE_KS_AUTH_CFG)
@ -424,11 +406,6 @@ class NovaCCHooksTests(CharmTestCase):
hooks.pgsql_nova_db_joined()
self.relation_set.assert_called_with(database='nova')
def test_postgresql_neutron_db_joined(self):
self.is_relation_made.return_value = False
hooks.pgsql_neutron_db_joined()
self.relation_set.assert_called_with(database='neutron')
def test_db_joined_with_postgresql(self):
self.is_relation_made.return_value = True
@ -447,15 +424,6 @@ class NovaCCHooksTests(CharmTestCase):
'Attempting to associate a postgresql database when'
' there is already associated a mysql one')
def test_postgresql_neutron_joined_with_db(self):
self.is_relation_made.return_value = True
with self.assertRaises(Exception) as context:
hooks.pgsql_neutron_db_joined()
self.assertEqual(context.exception.message,
'Attempting to associate a postgresql database when'
' there is already associated a mysql one')
@patch.object(hooks, 'CONFIGS')
def test_db_changed_missing_relation_data(self, configs):
configs.complete_contexts = MagicMock()
@ -488,9 +456,8 @@ class NovaCCHooksTests(CharmTestCase):
@patch.object(hooks, 'nova_api_relation_joined')
@patch.object(hooks, 'is_db_initialised')
@patch.object(hooks, 'conditional_neutron_migration')
@patch.object(hooks, 'CONFIGS')
def test_db_changed(self, configs, cond_neutron_mig,
def test_db_changed(self, configs,
mock_is_db_initialised, api_joined):
self.relation_ids.return_value = ['nova-api/0']
mock_is_db_initialised.return_value = False
@ -498,7 +465,6 @@ class NovaCCHooksTests(CharmTestCase):
self._shared_db_test(configs)
self.assertTrue(configs.write_all.called)
self.assertFalse(self.migrate_nova_database.called)
self.assertFalse(cond_neutron_mig.called)
api_joined.asert_called_with(rid='nova-api/0')
@patch.object(hooks, 'is_db_initialised')
@ -607,8 +573,7 @@ class NovaCCHooksTests(CharmTestCase):
self.network_manager.return_value = 'neutron'
hooks.amqp_changed()
self.assertEquals(configs.write.call_args_list,
[call('/etc/nova/nova.conf'),
call('/etc/neutron/neutron.conf')])
[call('/etc/nova/nova.conf')])
cell_joined.assert_called_with(rid='nova-cell-api/0')
api_joined.assert_called_with(rid='nova-api/0')
@ -641,24 +606,19 @@ class NovaCCHooksTests(CharmTestCase):
@patch.object(hooks, 'get_cell_type')
def test_neutron_api_relation_joined(self, get_cell_type, configs, isfile,
rename, _canonical_url):
neutron_conf = '/etc/neutron/neutron.conf'
nova_url = 'http://novaurl:8774/v2'
isfile.return_value = True
self.service_running.return_value = True
_identity_joined = self.patch('identity_joined')
self.relation_ids.return_value = ['relid']
_canonical_url.return_value = 'http://novaurl'
get_cell_type.return_value = 'parent'
self.uuid.uuid4.return_value = 'bob'
with patch_open() as (_open, _file):
hooks.neutron_api_relation_joined(remote_restart=True)
self.service_stop.assert_called_with('neutron-server')
rename.assert_called_with(neutron_conf, neutron_conf + '_unused')
self.assertTrue(_identity_joined.called)
self.relation_set.assert_called_with(relation_id=None,
cell_type='parent',
nova_url=nova_url,
restart_trigger='bob')
hooks.neutron_api_relation_joined(remote_restart=True)
self.assertTrue(_identity_joined.called)
self.relation_set.assert_called_with(relation_id=None,
cell_type='parent',
nova_url=nova_url,
restart_trigger='bob')
@patch.object(hooks, 'CONFIGS')
def test_neutron_api_relation_changed(self, configs):
@ -679,7 +639,6 @@ class NovaCCHooksTests(CharmTestCase):
_compute_joined = self.patch('compute_joined')
_quantum_joined = self.patch('quantum_joined')
hooks.neutron_api_relation_broken()
remove.assert_called_with('/etc/init/neutron-server.override')
self.assertTrue(configs.write_all.called)
self.assertTrue(_compute_joined.called)
self.assertTrue(_quantum_joined.called)
@ -793,30 +752,6 @@ class NovaCCHooksTests(CharmTestCase):
}
self.assertEqual(_con_sets, console_settings)
def test_conditional_neutron_migration(self):
self.os_release.return_value = 'juno'
self.services.return_value = ['neutron-server']
hooks.conditional_neutron_migration()
self.migrate_neutron_database.assert_called_with()
self.service_restart.assert_called_with('neutron-server')
def test_conditional_neutron_migration_juno(self):
self.os_release.return_value = 'icehouse'
hooks.conditional_neutron_migration()
self.log.assert_called_with(
'Not running neutron database migration as migrations are handled'
' by the neutron-server process.'
)
def test_conditional_neutron_migration_kilo(self):
self.os_release.return_value = 'kilo'
self.relation_ids.return_value = []
hooks.conditional_neutron_migration()
self.log.assert_called_with(
'Not running neutron database migration as migrations are by the '
'neutron-api charm.'
)
@patch('nova_cc_utils.config')
def test_ha_relation_joined_no_bound_ip(self, config):
self.get_hacluster_config.return_value = {

View File

@ -1,6 +1,5 @@
from collections import OrderedDict
from mock import patch, MagicMock, call
from copy import deepcopy
with patch('charmhelpers.core.hookenv.config'):
import nova_cc_utils as utils
@ -19,12 +18,7 @@ TO_PATCH = [
'enable_policy_rcd',
'enable_services',
'get_os_codename_install_source',
'is_relation_made',
'log',
'network_manager',
'neutron_db_manage',
'neutron_plugin',
'neutron_plugin_attribute',
'os_release',
'peer_store',
'register_configs',
@ -85,36 +79,11 @@ RESTART_MAP = OrderedDict([
('/etc/nova/api-paste.ini', [
'nova-api-ec2', 'nova-api-os-compute'
]),
('/etc/neutron/neutron.conf', ['neutron-server']),
('/etc/default/neutron-server', ['neutron-server']),
('/etc/haproxy/haproxy.cfg', ['haproxy']),
('/etc/apache2/sites-available/openstack_https_frontend', ['apache2']),
('/etc/neutron/plugins/ml2/ml2_conf.ini', ['neutron-server']),
])
PLUGIN_ATTRIBUTES = {
'ovs': {
'config': '/etc/neutron/plugins/ml2/ml2_conf.ini',
'driver': 'neutron.plugins.ml2.plugin.Ml2Plugin',
'contexts': ['FakeDBContext'],
'services': ['neutron-plugin-openvswitch-agent'],
'packages': ['neutron-plugin-openvswitch-agent'],
'server_packages': ['neutron-server', 'neutron-plugin-ml2'],
'server_services': ['neutron-server'],
},
'nvp': {
'config': '/etc/quantum/plugins/nicira/nvp.ini',
'driver': 'quantum.plugins.nicira.nicira_nvp_plugin.'
'QuantumPlugin.NvpPluginV2',
'services': [],
'packages': [],
'server_packages': ['quantum-server', 'quantum-plugin-nicria'],
'server_services': ['quantum-server'],
}
}
DPKG_OPTS = [
'--option', 'Dpkg::Options::=--force-confnew',
'--option', 'Dpkg::Options::=--force-confdef',
@ -130,14 +99,6 @@ openstack_origin_git = \
branch: stable/juno}"""
def fake_plugin_attribute(plugin, attr, net_manager):
if plugin in PLUGIN_ATTRIBUTES:
try:
return PLUGIN_ATTRIBUTES[plugin][attr]
except KeyError:
pass
class NovaCCUtilsTests(CharmTestCase):
def setUp(self):
@ -145,38 +106,12 @@ class NovaCCUtilsTests(CharmTestCase):
self.config.side_effect = self.test_config.get
self.maxDiff = None
def _resource_map(self, network_manager=None):
if network_manager:
self.network_manager.return_value = network_manager
self.test_config.set('network-manager', network_manager.title())
self.neutron_plugin.return_value = 'ovs'
self.neutron_plugin_attribute.side_effect = fake_plugin_attribute
def _resource_map(self):
with patch('charmhelpers.contrib.openstack.context.'
'SubordinateConfigContext'):
_map = utils.resource_map()
return _map
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
def test_resource_map_neutron(self, subcontext):
self.is_relation_made.return_value = False
self._resource_map(network_manager='neutron')
_map = utils.resource_map()
confs = [
'/etc/neutron/neutron.conf',
]
[self.assertIn(q_conf, _map.keys()) for q_conf in confs]
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
def test_resource_map_neutron_api_rel(self, subcontext):
self.is_relation_made.return_value = True
self._resource_map(network_manager='neutron')
_map = utils.resource_map()
confs = [
'/etc/neutron/neutron.conf',
]
for q_conf in confs:
self.assertEquals(_map[q_conf]['services'], [])
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
def test_resource_map_vmware(self, subcontext):
fake_context = MagicMock()
@ -192,7 +127,7 @@ class NovaCCUtilsTests(CharmTestCase):
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
def test_resource_map_neutron_no_agent_installed(self, subcontext):
self._resource_map(network_manager='neutron')
self._resource_map()
_map = utils.resource_map()
services = []
[services.extend(_map[c]['services'])for c in _map]
@ -246,10 +181,9 @@ class NovaCCUtilsTests(CharmTestCase):
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
def test_restart_map_api_before_frontends(self, subcontext, _exists,
_os_release):
self.is_relation_made.return_value = False
_os_release.return_value = 'icehouse'
_exists.return_value = False
self._resource_map(network_manager='neutron')
self._resource_map()
_map = utils.restart_map()
self.assertTrue(isinstance(_map, OrderedDict))
self.assertEquals(_map, RESTART_MAP)
@ -258,7 +192,7 @@ class NovaCCUtilsTests(CharmTestCase):
@patch('os.path.exists')
def test_restart_map_apache24(self, _exists, subcontext):
_exists.return_Value = True
self._resource_map(network_manager='neutron')
self._resource_map()
_map = utils.restart_map()
self.assertTrue('/etc/apache2/sites-available/'
'openstack_https_frontend.conf' in _map)
@ -308,15 +242,6 @@ class NovaCCUtilsTests(CharmTestCase):
rid='shared-db:12',
unit='mysql/0')
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
@patch.object(utils, 'git_install_requested')
def test_determine_packages_neutron(self, git_requested, subcontext):
git_requested.return_value = False
self.is_relation_made.return_value = False
self._resource_map(network_manager='neutron')
pkgs = utils.determine_packages()
self.assertIn('neutron-server', pkgs)
@patch('charmhelpers.contrib.openstack.context.SubordinateConfigContext')
@patch.object(utils, 'git_install_requested')
def test_determine_packages_console(self, git_requested, subcontext):
@ -343,10 +268,9 @@ class NovaCCUtilsTests(CharmTestCase):
restart_map.return_value = {
'/etc/nova/nova.conf': ['nova-api-os-compute', 'nova-api-ec2'],
'/etc/nova/api-paste.ini': ['nova-api-os-compute', 'nova-api-ec2'],
'/etc/neutron/neutron.conf': ['neutron-server'],
}
ports = utils.determine_ports()
ex = [8773, 8774, 9696]
ex = [8773, 8774]
self.assertEquals(ex, sorted(ports))
def test_save_script_rc_base(self):
@ -354,14 +278,6 @@ class NovaCCUtilsTests(CharmTestCase):
utils.save_script_rc()
self._save_script_rc.called_with(**SCRIPTRC_ENV_VARS)
def test_save_script_neutron(self):
self.relation_ids.return_value = []
self.test_config.set('network-manager', 'Neutron')
utils.save_script_rc()
_ex = deepcopy(SCRIPTRC_ENV_VARS)
_ex['OPENSTACK_SERVICE_API_NEUTRON'] = 'neutron-server'
self._save_script_rc.called_with(**_ex)
@patch.object(utils, 'remove_known_host')
@patch.object(utils, 'ssh_known_host_key')
@patch('subprocess.check_output')
@ -478,45 +394,12 @@ class NovaCCUtilsTests(CharmTestCase):
_file.write.assert_called_with(keys_removed)
def test_determine_endpoints_base(self):
self.is_relation_made.return_value = False
self.relation_ids.return_value = []
self.assertEquals(
BASE_ENDPOINTS, utils.determine_endpoints('http://foohost.com',
'http://foohost.com',
'http://foohost.com'))
def test_determine_endpoints_quantum_neutron(self):
self.is_relation_made.return_value = False
self.relation_ids.return_value = []
self.network_manager.return_value = 'neutron'
endpoints = deepcopy(BASE_ENDPOINTS)
endpoints.update({
'quantum_admin_url': 'http://foohost.com:9696',
'quantum_internal_url': 'http://foohost.com:9696',
'quantum_public_url': 'http://foohost.com:9696',
'quantum_region': 'RegionOne',
'quantum_service': 'quantum'})
self.assertEquals(
endpoints, utils.determine_endpoints('http://foohost.com',
'http://foohost.com',
'http://foohost.com'))
def test_determine_endpoints_neutron_api_rel(self):
self.is_relation_made.return_value = True
self.relation_ids.side_effect = [['neutron-api:1']]
self.network_manager.return_value = 'neutron'
endpoints = deepcopy(BASE_ENDPOINTS)
endpoints.update({
'quantum_admin_url': None,
'quantum_internal_url': None,
'quantum_public_url': None,
'quantum_region': None,
'quantum_service': None})
self.assertEquals(
endpoints, utils.determine_endpoints('http://foohost.com',
'http://foohost.com',
'http://foohost.com'))
@patch.object(utils, 'known_hosts')
@patch('subprocess.check_output')
def test_ssh_known_host_key(self, _check_output, _known_hosts):
@ -598,10 +481,6 @@ class NovaCCUtilsTests(CharmTestCase):
self.is_elected_leader.return_value = True
self.relation_ids.return_value = []
utils.do_openstack_upgrade(self.register_configs())
neutron_db_calls = [call(['stamp', 'icehouse']),
call(['upgrade', 'head'])]
self.neutron_db_manage.assert_has_calls(neutron_db_calls,
any_order=False)
self.apt_update.assert_called_with(fatal=True)
self.apt_upgrade.assert_called_with(options=DPKG_OPTS, fatal=True,
dist=True)
@ -623,7 +502,6 @@ class NovaCCUtilsTests(CharmTestCase):
self.is_elected_leader.return_value = True
self.relation_ids.return_value = []
utils.do_openstack_upgrade(self.register_configs())
self.assertEquals(self.neutron_db_manage.call_count, 0)
self.apt_update.assert_called_with(fatal=True)
self.apt_upgrade.assert_called_with(options=DPKG_OPTS, fatal=True,
dist=True)
@ -648,7 +526,6 @@ class NovaCCUtilsTests(CharmTestCase):
self.relation_ids.return_value = []
database_setup.return_value = False
utils.do_openstack_upgrade(self.register_configs())
self.assertEquals(self.neutron_db_manage.call_count, 0)
self.apt_update.assert_called_with(fatal=True)
self.apt_upgrade.assert_called_with(options=DPKG_OPTS, fatal=True,
dist=True)
@ -672,13 +549,10 @@ class NovaCCUtilsTests(CharmTestCase):
def test_guard_map_neutron(self):
self.relation_ids.return_value = []
self.network_manager.return_value = 'neutron'
self.os_release.return_value = 'icehouse'
self.get_os_codename_install_source.return_value = 'icehouse'
self.is_relation_made.return_value = False
self.assertEqual(
{'neutron-server': ['identity-service', 'amqp', 'shared-db'],
'nova-api-ec2': ['identity-service', 'amqp', 'shared-db'],
{'nova-api-ec2': ['identity-service', 'amqp', 'shared-db'],
'nova-api-os-compute': ['identity-service', 'amqp', 'shared-db'],
'nova-cert': ['identity-service', 'amqp', 'shared-db'],
'nova-conductor': ['identity-service', 'amqp', 'shared-db'],
@ -686,12 +560,10 @@ class NovaCCUtilsTests(CharmTestCase):
'nova-scheduler': ['identity-service', 'amqp', 'shared-db'], },
utils.guard_map()
)
self.network_manager.return_value = 'neutron'
self.os_release.return_value = 'mitaka'
self.get_os_codename_install_source.return_value = 'mitaka'
self.assertEqual(
{'neutron-server': ['identity-service', 'amqp', 'shared-db'],
'nova-api-os-compute': ['identity-service', 'amqp', 'shared-db'],
{'nova-api-os-compute': ['identity-service', 'amqp', 'shared-db'],
'nova-cert': ['identity-service', 'amqp', 'shared-db'],
'nova-conductor': ['identity-service', 'amqp', 'shared-db'],
'nova-scheduler': ['identity-service', 'amqp', 'shared-db'], },
@ -700,13 +572,9 @@ class NovaCCUtilsTests(CharmTestCase):
def test_guard_map_pgsql(self):
self.relation_ids.return_value = ['pgsql:1']
self.network_manager.return_value = 'neutron'
self.is_relation_made.return_value = False
self.os_release.return_value = 'icehouse'
self.assertEqual(
{'neutron-server': ['identity-service', 'amqp',
'pgsql-neutron-db'],
'nova-api-ec2': ['identity-service', 'amqp', 'pgsql-nova-db'],
{'nova-api-ec2': ['identity-service', 'amqp', 'pgsql-nova-db'],
'nova-api-os-compute': ['identity-service', 'amqp',
'pgsql-nova-db'],
'nova-cert': ['identity-service', 'amqp', 'pgsql-nova-db'],