Commit cb339e0a authored by Sigmund Augdal's avatar Sigmund Augdal

Attempt to fix etcd reconnect logic. Use configured host to bootstrap process...

Attempt to fix etcd reconnect logic. Use configured host to bootstrap process then reconnect using list of machines returned from that host
parent 6f6d29da
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function, unicode_literals
import etcd
import argparse
from nova_router import neighbors, security_groups, dns_rr, setupLogfile
from nova_router import neighbors, security_groups, dns_rr, setupLogfile, etcd_connect
from scvmm_client import odata
import logging
import uuid
......@@ -42,9 +41,9 @@ def main():
format='%(asctime)s %(name)s %(levelname)s %(message)s')
logging.info("Process starting")
etcd_client = etcd.Client(host="nova-gw1.bs.unsi.no",
cert=(conf.get('etcd', 'cert'), conf.get('etcd', 'key')),
ca_cert=conf.get('etcd', 'cacert'), protocol='https')
etcd_client = etcd_connect("nova-gw1.bs.unsi.no", conf.get('etcd', 'cert'),
conf.get('etcd', 'key'),
conf.get('etcd', 'cacert'))
vmm_client = odata.VMMClient(conf.get('spf', 'vmm_baseurl'), conf.get('spf', 'username'),
conf.get('spf', 'password'))
dns = dns_rr.client_from_conf(conf)
......
#!/usr/bin/env python
from __future__ import absolute_import, division, print_function, unicode_literals
import etcd
import subprocess
import logging
import time
......@@ -8,7 +7,7 @@ import argparse
from daemonize import Daemonize
import socket
import json
from nova_router import setupLogfile, send_stat, parse_ip, format_ip
from nova_router import setupLogfile, send_stat, parse_ip, format_ip, etcd_connect
CONF_FILE = "/etc/haproxy/haproxy.cfg"
APP = "nova_dhcp_configurator"
......@@ -20,8 +19,7 @@ HOSTS_FILE = "/etc/dhcp/generated_hosts.conf"
class Generator(object):
def __init__(self, etcd_host, cert, key, cacert, logfile=None):
self.etcd_client = etcd.Client(host=etcd_host, cert=(cert, key),
ca_cert=cacert, protocol='https')
self.etcd_client = etcd_connect(etcd_host, cert, key, cacert)
if logfile:
setupLogfile(logfile)
......
......@@ -12,8 +12,7 @@ log = logging.getLogger("neighbors")
# RTM_NEWNEIGH, RTM_DELNEIGH
#
from pyroute2.netlink.iproute import IPRoute
import etcd
from nova_router import neighbors, setupLogfile
from nova_router import neighbors, setupLogfile, etcd_connect
APP = "nova_neighbor_monitor"
......@@ -40,8 +39,7 @@ def unicast_mac(mac):
class NeighborCache(object):
def __init__(self, ssl_cert, ssl_key, cacert, interface, routers):
self.etcd_client = etcd.Client(host="localhost", cert=(ssl_cert, ssl_key),
ca_cert=cacert, protocol='https')
self.etcd_client = etcd_connect('localhost', ssl_cert, ssl_key, cacert)
self.caches = ({}, {}, {})
self.ifindex = ifindex(interface)
self.ir = IPRoute()
......
......@@ -2,6 +2,8 @@ import logging
import logging.handlers
import socket
import time
import etcd
import urlparse
FORMAT = '%(asctime)s %(name)s %(levelname)s %(message)s'
CARBON_SERVER = 'graphite.labs.uninett.no'
......@@ -51,3 +53,14 @@ def parse_ip(ip):
def format_ip(num):
return ".".join(str(x) for x in (num >> 24, (num >> 16) & 0xff, (num >> 8) & 0xff, num & 0xff))
def etcd_connect(etcd_host, cert, key, cacert):
tmp_etcd_client = etcd.Client(host=etcd_host, cert=(cert, key),
ca_cert=cacert, protocol='https')
machines = tmp_etcd_client.machines
machines = (urlparse.urlparse(m) for m in machines)
machines = (u.netloc.split(':') for u in machines)
machines = tuple(((host, int(port)) for host, port in machines))
return etcd.Client(host=tuple(machines), cert=(cert, key),
ca_cert=cacert, protocol='https', allow_reconnect=True)
......@@ -2,10 +2,10 @@
from __future__ import absolute_import, division, print_function, unicode_literals
import subprocess
import logging
from nova_router import security_groups, setupLogfile, send_stat
import etcd
from nova_router import security_groups, setupLogfile, send_stat, etcd_connect
import time
import tempfile
IPTABLES_ANY = "-A NOVAFORWARD -m set --match-set {} dst,dst -j ACCEPT\n"
IPTABLES_ANY_IP = "-A NOVAFORWARD -m set --match-set {} dst -j ACCEPT\n"
IPTABLES_CIDR = "-A NOVAFORWARD -m set --match-set {} dst,dst,src -j ACCEPT\n"
......@@ -56,8 +56,7 @@ class Generator(object):
if logfile:
setupLogfile(logfile)
logging.info("Process starting")
self.etcd_client = etcd.Client(host=etcd_host, cert=(cert, key),
ca_cert=cacert, protocol='https')
self.etcd_client = etcd_connect(etcd_host, cert, key, cacert)
# maps security group id from etcd to the name of a ipset containing its members
self.group_members_groups = {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment