Skip to content

Commit

Permalink
Update for zbroker #49
Browse files Browse the repository at this point in the history
* add zyre settings for node name
* add hostif lookup to force interface for zyre
  • Loading branch information
rpedde committed May 27, 2014
1 parent d6aaa1b commit 0244f1d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 1 deletion.
49 changes: 49 additions & 0 deletions lookup_plugins/hostif.py
@@ -0,0 +1,49 @@
# Copyright (c) 2014 Ron Pedde <ron@pedde.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from ansible import utils, errors
import os
import ipaddr

class LookupModule(object):
def __init__(self, basedir=None, **kwargs):
self.basedir = basedir

def templatize(self, term, inject=None):
return utils.template.template(self.basedir, term, inject)

def run(self, terms, inject=None, **kwargs):
terms = utils.listify_lookup_plugin_terms(terms, self.basedir, inject)

if isinstance(terms, basestring):
terms = [ terms ]

ret = []

for term in terms:
found_iface = "eth0"

net = ipaddr.IPv4Network(term)
for iface in kwargs['vars'].get('ansible_interfaces', []):
addrs = kwargs['vars'].get('ansible_%s' % iface, {}).get('ipv4', [])
if isinstance(addrs, dict):
addrs = [addrs]

for addr in addrs:
if 'address' in addr and ipaddr.IPv4Address(addr['address']) in net:
found_iface = iface

ret.append(found_iface)
return ret
2 changes: 2 additions & 0 deletions roles/object/defaults/main.yml
Expand Up @@ -6,7 +6,9 @@ swift_statsd_ip: "{{lookup('hostip', 'host={{swift_statsd_host}} cidr={{swift_st
swift_zerovm_objectquery_debug: false

swift_zbroker_client_timeout: 10000
swift_zbroker_interface: "{{lookup('hostif', swift_nets['swift'])}}"

# default timeout slightly less than default proxy timeouts
zerovm_timeout: 59


7 changes: 6 additions & 1 deletion roles/object/templates/zbroker.cfg.j2
Expand Up @@ -8,7 +8,12 @@ server
# user = swift
# group = swift

# Apply to the zpipes server only
zyre
port = 5670
interval = 250
name = {{inventory_hostname}}
interface = {{swift_zbroker_interface}}

zpipes_server
echo = binding zpipes service to 'ipc://@/zpipes/local'
bind
Expand Down

0 comments on commit 0244f1d

Please sign in to comment.