Added Makefile and charm-helpers-sync.yaml. Fixed lint
This commit is contained in:
parent
2ad2a4b647
commit
42eef07ac5
14
Makefile
Normal file
14
Makefile
Normal file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/make
|
||||
PYTHON := /usr/bin/env python
|
||||
|
||||
lint:
|
||||
@flake8 --exclude hooks/charmhelpers hooks
|
||||
@flake8 --exclude hooks/charmhelpers unit_tests
|
||||
@charm proof
|
||||
|
||||
test:
|
||||
@echo Starting tests...
|
||||
@$(PYTHON) /usr/bin/nosetests --nologcapture unit_tests
|
||||
|
||||
sync:
|
||||
@charm-helper-sync -c charm-helpers-sync.yaml
|
10
charm-helpers-sync.yaml
Normal file
10
charm-helpers-sync.yaml
Normal file
@ -0,0 +1,10 @@
|
||||
branch: lp:charm-helpers
|
||||
destination: hooks/charmhelpers
|
||||
include:
|
||||
- core
|
||||
- fetch
|
||||
- contrib.openstack
|
||||
- contrib.hahelpers
|
||||
- contrib.network.ovs
|
||||
- contrib.storage.linux
|
||||
- payload.execd
|
@ -6,6 +6,7 @@ from charmhelpers.core.hookenv import (
|
||||
)
|
||||
from charmhelpers.contrib.openstack import context
|
||||
|
||||
|
||||
class IdentityServiceContext(context.IdentityServiceContext):
|
||||
|
||||
def __call__(self):
|
||||
@ -15,18 +16,18 @@ class IdentityServiceContext(context.IdentityServiceContext):
|
||||
ctxt['region'] = config('region')
|
||||
return ctxt
|
||||
|
||||
|
||||
class NeutronCCContext(context.NeutronContext):
|
||||
interfaces = []
|
||||
|
||||
@property
|
||||
def network_manager(self):
|
||||
return 'neutron'
|
||||
return 'neutron'
|
||||
|
||||
@property
|
||||
def plugin(self):
|
||||
return config('neutron-plugin')
|
||||
|
||||
|
||||
@property
|
||||
def neutron_security_groups(self):
|
||||
return config('neutron-security-groups')
|
||||
@ -42,9 +43,9 @@ class NeutronCCContext(context.NeutronContext):
|
||||
ctxt['debug'] = config('debug')
|
||||
for rid in relation_ids('neutron-api'):
|
||||
for unit in related_units(rid):
|
||||
ctxt['nova_url'] = relation_get(attribute='nova_url', rid=rid, unit=unit)
|
||||
ctxt['nova_url'] = relation_get(attribute='nova_url',
|
||||
rid=rid,
|
||||
unit=unit)
|
||||
if ctxt['nova_url']:
|
||||
return ctxt
|
||||
return ctxt
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@ from charmhelpers.contrib.openstack.utils import (
|
||||
)
|
||||
from charmhelpers.contrib.openstack.neutron import (
|
||||
network_manager,
|
||||
neutron_plugin_attribute,
|
||||
neutron_plugin_attribute,
|
||||
)
|
||||
|
||||
from neutron_api_utils import (
|
||||
@ -42,13 +42,11 @@ from neutron_api_utils import (
|
||||
restart_map,
|
||||
NEUTRON_CONF,
|
||||
api_port,
|
||||
keystone_ca_cert_b64,
|
||||
CLUSTER_RES,
|
||||
)
|
||||
|
||||
from charmhelpers.contrib.hahelpers.cluster import (
|
||||
canonical_url,
|
||||
eligible_leader,
|
||||
get_hacluster_config,
|
||||
is_leader,
|
||||
)
|
||||
@ -130,6 +128,7 @@ def db_changed():
|
||||
return
|
||||
CONFIGS.write_all()
|
||||
|
||||
|
||||
@hooks.hook('pgsql-db-relation-changed')
|
||||
@restart_on_change(restart_map())
|
||||
def postgresql_neutron_db_changed():
|
||||
@ -138,6 +137,7 @@ def postgresql_neutron_db_changed():
|
||||
# DB config might have been moved to main neutron.conf in H?
|
||||
CONFIGS.write(neutron_plugin_attribute(plugin, 'config'))
|
||||
|
||||
|
||||
@hooks.hook('amqp-relation-broken',
|
||||
'identity-service-relation-broken',
|
||||
'shared-db-relation-broken',
|
||||
@ -145,6 +145,7 @@ def postgresql_neutron_db_changed():
|
||||
def relation_broken():
|
||||
CONFIGS.write_all()
|
||||
|
||||
|
||||
@hooks.hook('upgrade-charm')
|
||||
def upgrade_charm():
|
||||
for r_id in relation_ids('amqp'):
|
||||
@ -152,11 +153,13 @@ def upgrade_charm():
|
||||
for r_id in relation_ids('identity-service'):
|
||||
identity_joined(rid=r_id)
|
||||
|
||||
|
||||
@hooks.hook('identity-service-relation-joined')
|
||||
def identity_joined(rid=None):
|
||||
base_url = canonical_url(CONFIGS)
|
||||
relation_set(relation_id=rid, **determine_endpoints(base_url))
|
||||
|
||||
|
||||
@hooks.hook('identity-service-relation-changed')
|
||||
@restart_on_change(restart_map())
|
||||
def identity_changed():
|
||||
@ -166,23 +169,26 @@ def identity_changed():
|
||||
CONFIGS.write(NEUTRON_CONF)
|
||||
for r_id in relation_ids('neutron-api'):
|
||||
neutron_api_relation_joined(rid=r_id)
|
||||
|
||||
|
||||
|
||||
def _get_keystone_info():
|
||||
keystone_info = {}
|
||||
for lrid in relation_ids('identity-service'):
|
||||
for unit in related_units(lrid):
|
||||
rdata = relation_get(rid=lrid, unit=unit)
|
||||
keystone_info['service_protocol'] = rdata.get('service_protocol')
|
||||
keystone_info['service_host'] = rdata.get('service_host')
|
||||
keystone_info['service_port'] = rdata.get('service_port')
|
||||
keystone_info['service_tenant'] = rdata.get('service_tenant')
|
||||
keystone_info['service_username'] = rdata.get('service_username')
|
||||
keystone_info['service_password'] = rdata.get('service_password')
|
||||
keystone_info['auth_url'] = "%s://%s:%s/v2.0" % (keystone_info['service_protocol'],
|
||||
keystone_info['service_host'],
|
||||
keystone_info['service_port'])
|
||||
keystone_info['service_protocol'] = rdata.get('service_protocol')
|
||||
keystone_info['service_host'] = rdata.get('service_host')
|
||||
keystone_info['service_port'] = rdata.get('service_port')
|
||||
keystone_info['service_tenant'] = rdata.get('service_tenant')
|
||||
keystone_info['service_username'] = rdata.get('service_username')
|
||||
keystone_info['service_password'] = rdata.get('service_password')
|
||||
auth_url = "%s://%s:%s/v2.0" % (keystone_info['service_protocol'],
|
||||
keystone_info['service_host'],
|
||||
keystone_info['service_port'])
|
||||
keystone_info['auth_url'] = auth_url
|
||||
return keystone_info
|
||||
|
||||
|
||||
@hooks.hook('neutron-api-relation-joined')
|
||||
def neutron_api_relation_joined(rid=None):
|
||||
manager = network_manager()
|
||||
@ -208,16 +214,18 @@ def neutron_api_relation_joined(rid=None):
|
||||
manager + '_admin_auth_url': keystone_info['auth_url'],
|
||||
})
|
||||
relation_set(relation_id=rid, **relation_data)
|
||||
# Nova-cc may have grabbed the quantum endpoint so kick identity-service relation to
|
||||
# register that its here
|
||||
# Nova-cc may have grabbed the quantum endpoint so kick identity-service
|
||||
#relation to register that its here
|
||||
for r_id in relation_ids('identity-service'):
|
||||
identity_joined(rid=r_id)
|
||||
|
||||
|
||||
@hooks.hook('neutron-api-relation-changed')
|
||||
@restart_on_change(restart_map())
|
||||
def neutron_api_relation_changed():
|
||||
CONFIGS.write(NEUTRON_CONF)
|
||||
|
||||
|
||||
@hooks.hook('neutron-plugin-api-relation-joined')
|
||||
def neutron_plugin_api_relation_joined(rid=None):
|
||||
relation_data = {
|
||||
@ -225,6 +233,7 @@ def neutron_plugin_api_relation_joined(rid=None):
|
||||
}
|
||||
relation_set(relation_id=rid, **relation_data)
|
||||
|
||||
|
||||
@hooks.hook('cluster-relation-changed',
|
||||
'cluster-relation-departed')
|
||||
@restart_on_change(restart_map(), stopstart=True)
|
||||
@ -275,6 +284,7 @@ def ha_changed():
|
||||
for rid in relation_ids('neutron-api'):
|
||||
neutron_api_relation_joined(rid=rid)
|
||||
|
||||
|
||||
def main():
|
||||
try:
|
||||
hooks.execute(sys.argv)
|
||||
|
@ -1,6 +1,5 @@
|
||||
from collections import OrderedDict
|
||||
from copy import deepcopy
|
||||
import ConfigParser
|
||||
import os
|
||||
from base64 import b64encode
|
||||
from charmhelpers.contrib.openstack import context, templating
|
||||
@ -63,9 +62,12 @@ BASE_RESOURCE_MAP = OrderedDict([
|
||||
'contexts': [neutron_api_context.NeutronCCContext()],
|
||||
}),
|
||||
])
|
||||
|
||||
|
||||
def api_port(service):
|
||||
return API_PORTS[service]
|
||||
|
||||
|
||||
def determine_endpoints(url):
|
||||
'''Generates a dictionary containing all relevant endpoints to be
|
||||
passed to keystone as relation settings.'''
|
||||
@ -80,8 +82,6 @@ def determine_endpoints(url):
|
||||
'quantum_admin_url': neutron_url,
|
||||
'quantum_internal_url': neutron_url,
|
||||
})
|
||||
|
||||
|
||||
return endpoints
|
||||
|
||||
|
||||
@ -90,11 +90,13 @@ def determine_packages():
|
||||
packages = [] + BASE_PACKAGES
|
||||
for v in resource_map().values():
|
||||
packages.extend(v['services'])
|
||||
pkgs = neutron_plugin_attribute(config('neutron-plugin'), 'server_packages',
|
||||
pkgs = neutron_plugin_attribute(config('neutron-plugin'),
|
||||
'server_packages',
|
||||
network_manager())
|
||||
packages.extend(pkgs)
|
||||
return list(set(packages))
|
||||
|
||||
|
||||
def determine_ports():
|
||||
'''Assemble a list of API ports for services we are managing'''
|
||||
ports = []
|
||||
@ -151,7 +153,8 @@ def restart_map():
|
||||
for cfg, v in resource_map().iteritems()
|
||||
if v['services']])
|
||||
|
||||
def keystone_ca_cert_b64():
|
||||
|
||||
def keystone_ca_cert_b64():
|
||||
'''Returns the local Keystone-provided CA cert if it exists, or None.'''
|
||||
if not os.path.isfile(CA_CERT_PATH):
|
||||
return None
|
||||
|
Loading…
Reference in New Issue
Block a user