[hopem,r=]

Make RGW port configurable.
Closes-Bug: 1517551
This commit is contained in:
Edward Hope-Morley 2015-11-25 11:09:14 +00:00
parent 6c8eb6c511
commit 1e12314fcb
8 changed files with 40 additions and 18 deletions

View File

@ -21,6 +21,11 @@ options:
description: |
Key ID to import to the apt keyring to support use with arbitary source
configuration from outside of Launchpad archives or PPA's.
port:
type: int
default: 80
description: |
The port that the RADOS Gateway will listen on.
# Keystone integration
operator-roles:
default: "Member,Admin"

View File

@ -21,18 +21,17 @@ class HAProxyContext(context.HAProxyContext):
def __call__(self):
ctxt = super(HAProxyContext, self).__call__()
port = config('port')
# Apache ports
a_cephradosgw_api = determine_apache_port(80,
singlenode_mode=True)
a_cephradosgw_api = determine_apache_port(port, singlenode_mode=True)
port_mapping = {
'cephradosgw-server': [
80, a_cephradosgw_api]
'cephradosgw-server': [port, a_cephradosgw_api]
}
ctxt['cephradosgw_bind_port'] = determine_api_port(
80,
port,
singlenode_mode=True,
)
@ -99,6 +98,8 @@ class MonContext(context.OSContextGenerator):
'old_auth': cmp_pkgrevno('radosgw', "0.51") < 0,
'use_syslog': str(config('use-syslog')).lower(),
'embedded_webserver': config('use-embedded-webserver'),
'port': determine_apache_port(config('port'),
singlenode_mode=True)
}
if self.context_complete(ctxt):

View File

@ -34,6 +34,9 @@ from charmhelpers.core.host import (
lsb_release,
restart_on_change,
)
from charmhelpers.contrib.hahelpers.cluster import (
determine_apache_port,
)
from utils import (
render_template,
enable_pocket,
@ -58,6 +61,9 @@ from charmhelpers.contrib.openstack.ip import (
from charmhelpers.contrib.openstack.utils import (
set_os_workload_status,
)
APACHE_PORTS_CONF = '/etc/apache2/ports.conf'
hooks = Hooks()
CONFIGS = register_configs()
@ -125,7 +131,8 @@ def install():
def emit_apacheconf():
apachecontext = {
"hostname": unit_get('private-address')
"hostname": unit_get('private-address'),
"port": determine_apache_port(config('port'), singlenode_mode=True)
}
site_conf = '/etc/apache2/sites-available/rgw'
if is_apache_24():
@ -152,7 +159,11 @@ def apache_reload():
def apache_ports():
shutil.copy('files/ports.conf', '/etc/apache2/ports.conf')
portscontext = {
"port": determine_apache_port(config('port'), singlenode_mode=True)
}
with open(APACHE_PORTS_CONF, 'w') as portsconf:
portsconf.write(render_template('ports.conf', portscontext))
@hooks.hook('upgrade-charm',
@ -188,22 +199,22 @@ def mon_relation():
@hooks.hook('gateway-relation-joined')
def gateway_relation():
relation_set(hostname=unit_get('private-address'),
port=80)
port=config('port'))
def start():
subprocess.call(['service', 'radosgw', 'start'])
open_port(port=80)
open_port(port=config('port'))
def stop():
subprocess.call(['service', 'radosgw', 'stop'])
open_port(port=80)
open_port(port=config('port'))
def restart():
subprocess.call(['service', 'radosgw', 'restart'])
open_port(port=80)
open_port(port=config('port'))
@hooks.hook('identity-service-relation-joined')
@ -212,7 +223,7 @@ def identity_joined(relid=None):
log('Integration with keystone requires ceph >= 0.55')
sys.exit(1)
port = 80
port = config('port')
admin_url = '%s:%i/swift' % (canonical_url(None, ADMIN), port)
internal_url = '%s:%s/swift/v1' % \
(canonical_url(None, INTERNAL), port)

View File

@ -17,7 +17,7 @@ keyring = /etc/ceph/keyring.rados.gateway
rgw socket path = /tmp/radosgw.sock
log file = /var/log/ceph/radosgw.log
{% if embedded_webserver %}
rgw frontends = civetweb port=70
rgw frontends = civetweb port={{ port }}
{% else %}
# Turn off 100-continue optimization as stock mod_fastcgi
# does not support it

View File

@ -1,4 +1,4 @@
Listen 70
Listen {{ port }}
<IfModule ssl_module>
Listen 443

View File

@ -2,7 +2,7 @@
FastCgiExternalServer /var/www/s3gw.fcgi -socket /tmp/radosgw.sock
</IfModule>
<VirtualHost *:70>
<VirtualHost *:{{ port }}>
ServerName {{ hostname }}
ServerAdmin ceph@ubuntu.com
DocumentRoot /var/www

View File

@ -165,7 +165,8 @@ class MonContextTest(CharmTestCase):
'hostname': '10.0.0.10',
'mon_hosts': '10.5.4.1:6789 10.5.4.2:6789 10.5.4.3:6789',
'old_auth': False,
'use_syslog': 'false'
'use_syslog': 'false',
'port': 70
}
self.assertEqual(expect, mon_ctxt())
@ -197,7 +198,8 @@ class MonContextTest(CharmTestCase):
'hostname': '10.0.0.10',
'mon_hosts': '10.5.4.1:6789 10.5.4.2:6789 10.5.4.3:6789',
'old_auth': False,
'use_syslog': 'false'
'use_syslog': 'false',
'port': 70
}
self.assertEqual(expect, mon_ctxt())
@ -221,6 +223,7 @@ class MonContextTest(CharmTestCase):
'hostname': '10.0.0.10',
'mon_hosts': '10.5.4.1:6789 10.5.4.2:6789 10.5.4.3:6789',
'old_auth': False,
'use_syslog': 'false'
'use_syslog': 'false',
'port': 70
}
self.assertEqual(expect, mon_ctxt())

View File

@ -127,6 +127,7 @@ class CephRadosGWTests(CharmTestCase):
self.unit_get.return_value = '10.0.0.1'
apachecontext = {
"hostname": '10.0.0.1',
"port": 70,
}
vhost_file = '/etc/apache2/sites-available/rgw.conf'
with patch_open() as (_open, _file):
@ -167,6 +168,7 @@ class CephRadosGWTests(CharmTestCase):
]
self.subprocess.call.assert_has_calls(calls)
@patch.object(ceph_hooks, 'apache_ports', lambda *args: True)
def test_config_changed(self):
_install_packages = self.patch('install_packages')
_emit_apacheconf = self.patch('emit_apacheconf')