Skip to content

Commit

Permalink
Synced in lp:~ajkavanagh/charm-helpers/add-service-checks-lp1524388 v…
Browse files Browse the repository at this point in the history
…ersion

of charm-helpers to test that modification will work - this is for demo
purposes only and will be revised prior to merge proposal.

Also changed tests to to work with revision 514:
"misc changes for haproxy template and context ..."
which required changes to the test_haproxy_context_service_enabled test
in unit_tests/test_keystone_contexts.py
  • Loading branch information
ajkavanagh committed Feb 10, 2016
1 parent 85b3723 commit 873d96b
Show file tree
Hide file tree
Showing 13 changed files with 271 additions and 104 deletions.
2 changes: 1 addition & 1 deletion charm-helpers-hooks.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
branch: lp:charm-helpers
branch: lp:~ajkavanagh/charm-helpers/add-service-checks-lp1524388
destination: charmhelpers
include:
- core
Expand Down
2 changes: 1 addition & 1 deletion charm-helpers-tests.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
branch: lp:charm-helpers
branch: lp:~ajkavanagh/charm-helpers/add-service-checks-lp1524388
destination: tests/charmhelpers
include:
- contrib.amulet
Expand Down
15 changes: 15 additions & 0 deletions charmhelpers/contrib/network/ip.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,3 +456,18 @@ def get_hostname(address, fqdn=True):
return result
else:
return result.split('.')[0]


def port_has_listener(address, port):
"""
Returns True if the address:port is open and being listened to,
else False.
@param address: an IP address or hostname
@param port: integer port
Note calls 'zc' via a subprocess shell
"""
cmd = ['nc', '-z', address, str(port)]
result = subprocess.call(cmd)
return not(bool(result))
5 changes: 3 additions & 2 deletions charmhelpers/contrib/openstack/amulet/deployment.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@ def _add_services(self, this_service, other_services):

# Charms which should use the source config option
use_source = ['mysql', 'mongodb', 'rabbitmq-server', 'ceph',
'ceph-osd', 'ceph-radosgw']
'ceph-osd', 'ceph-radosgw', 'ceph-mon']

# Charms which can not use openstack-origin, ie. many subordinates
no_origin = ['cinder-ceph', 'hacluster', 'neutron-openvswitch', 'nrpe',
'openvswitch-odl', 'neutron-api-odl', 'odl-controller']
'openvswitch-odl', 'neutron-api-odl', 'odl-controller',
'cinder-backup']

if self.openstack:
for svc in services:
Expand Down
32 changes: 23 additions & 9 deletions charmhelpers/contrib/openstack/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
get_nic_hwaddr,
mkdir,
write_file,
pwgen,
)
from charmhelpers.contrib.hahelpers.cluster import (
determine_apache_port,
Expand Down Expand Up @@ -87,6 +88,14 @@
is_bridge_member,
)
from charmhelpers.contrib.openstack.utils import get_host_ip
from charmhelpers.core.unitdata import kv

try:
import psutil
except ImportError:
apt_install('python-psutil', fatal=True)
import psutil

CA_CERT_PATH = '/usr/local/share/ca-certificates/keystone_juju_ca_cert.crt'
ADDRESS_TYPES = ['admin', 'internal', 'public']

Expand Down Expand Up @@ -636,11 +645,18 @@ def __call__(self):
ctxt['ipv6'] = True
ctxt['local_host'] = 'ip6-localhost'
ctxt['haproxy_host'] = '::'
ctxt['stat_port'] = ':::8888'
else:
ctxt['local_host'] = '127.0.0.1'
ctxt['haproxy_host'] = '0.0.0.0'
ctxt['stat_port'] = ':8888'

ctxt['stat_port'] = '8888'

db = kv()
ctxt['stat_password'] = db.get('stat-password')
if not ctxt['stat_password']:
ctxt['stat_password'] = db.set('stat-password',
pwgen(32))
db.flush()

for frontend in cluster_hosts:
if (len(cluster_hosts[frontend]['backends']) > 1 or
Expand Down Expand Up @@ -1248,13 +1264,11 @@ class WorkerConfigContext(OSContextGenerator):

@property
def num_cpus(self):
try:
from psutil import NUM_CPUS
except ImportError:
apt_install('python-psutil', fatal=True)
from psutil import NUM_CPUS

return NUM_CPUS
# NOTE: use cpu_count if present (16.04 support)
if hasattr(psutil, 'cpu_count'):
return psutil.cpu_count()
else:
return psutil.NUM_CPUS

def __call__(self):
multiplier = config('worker-multiplier') or 0
Expand Down
20 changes: 14 additions & 6 deletions charmhelpers/contrib/openstack/neutron.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def determine_dkms_package():
if kernel_version() >= (3, 13):
return []
else:
return ['openvswitch-datapath-dkms']
return [headers_package(), 'openvswitch-datapath-dkms']


# legacy
Expand All @@ -70,7 +70,7 @@ def quantum_plugins():
relation_prefix='neutron',
ssl_dir=QUANTUM_CONF_DIR)],
'services': ['quantum-plugin-openvswitch-agent'],
'packages': [[headers_package()] + determine_dkms_package(),
'packages': [determine_dkms_package(),
['quantum-plugin-openvswitch-agent']],
'server_packages': ['quantum-server',
'quantum-plugin-openvswitch'],
Expand Down Expand Up @@ -111,7 +111,7 @@ def neutron_plugins():
relation_prefix='neutron',
ssl_dir=NEUTRON_CONF_DIR)],
'services': ['neutron-plugin-openvswitch-agent'],
'packages': [[headers_package()] + determine_dkms_package(),
'packages': [determine_dkms_package(),
['neutron-plugin-openvswitch-agent']],
'server_packages': ['neutron-server',
'neutron-plugin-openvswitch'],
Expand Down Expand Up @@ -155,7 +155,7 @@ def neutron_plugins():
relation_prefix='neutron',
ssl_dir=NEUTRON_CONF_DIR)],
'services': [],
'packages': [[headers_package()] + determine_dkms_package(),
'packages': [determine_dkms_package(),
['neutron-plugin-cisco']],
'server_packages': ['neutron-server',
'neutron-plugin-cisco'],
Expand All @@ -174,7 +174,7 @@ def neutron_plugins():
'neutron-dhcp-agent',
'nova-api-metadata',
'etcd'],
'packages': [[headers_package()] + determine_dkms_package(),
'packages': [determine_dkms_package(),
['calico-compute',
'bird',
'neutron-dhcp-agent',
Expand Down Expand Up @@ -219,7 +219,7 @@ def neutron_plugins():
relation_prefix='neutron',
ssl_dir=NEUTRON_CONF_DIR)],
'services': [],
'packages': [[headers_package()] + determine_dkms_package()],
'packages': [determine_dkms_package()],
'server_packages': ['neutron-server',
'python-neutron-plugin-midonet'],
'server_services': ['neutron-server']
Expand All @@ -233,6 +233,14 @@ def neutron_plugins():
'neutron-plugin-ml2']
# NOTE: patch in vmware renames nvp->nsx for icehouse onwards
plugins['nvp'] = plugins['nsx']
if release >= 'kilo':
plugins['midonet']['driver'] = (
'neutron.plugins.midonet.plugin.MidonetPluginV2')
if release >= 'liberty':
midonet_origin = config('midonet-origin')
if midonet_origin is not None and midonet_origin[4:5] == '1':
plugins['midonet']['driver'] = (
'midonet.neutron.plugin_v1.MidonetPluginV2')
return plugins


Expand Down
5 changes: 3 additions & 2 deletions charmhelpers/contrib/openstack/templates/haproxy.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@ defaults
timeout server 30000
{%- endif %}

listen stats {{ stat_port }}
listen stats
bind {{ local_host }}:{{ stat_port }}
mode http
stats enable
stats hide-version
stats realm Haproxy\ Statistics
stats uri /
stats auth admin:password
stats auth admin:{{ stat_password }}

{% if frontends -%}
{% for service, ports in service_ports.items() -%}
Expand Down
Loading

0 comments on commit 873d96b

Please sign in to comment.