Skip to content

Commit 40eb842

Browse files
Ian Southamwilderrodrigues
authored andcommitted
Fixed hostname on router
1 parent d89c1e2 commit 40eb842

6 files changed

Lines changed: 40 additions & 10 deletions

File tree

systemvm/patches/debian/config/opt/cloud/bin/configure.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
from cs.CsDhcp import CsDhcp
3636
from cs.CsRedundant import *
3737
from cs.CsFile import CsFile
38-
from cs.CsAddress import CsAddress
3938
from cs.CsApp import CsApache, CsPasswdSvc, CsDnsmasq
4039
from cs.CsMonitor import CsMonitor
4140
from cs.CsLoadBalancer import CsLoadBalancer
@@ -536,11 +535,12 @@ def main(argv):
536535
level=config.get_level(),
537536
format=config.get_format())
538537
config.set_cl()
538+
config.set_address()
539539
cl = config.get_cmdline()
540540

541-
address = CsAddress("ips", config)
542-
address.compare()
543-
address.process()
541+
# IP configuration
542+
config.address().compare()
543+
config.address().process()
544544

545545
password = CsPassword("vmpassword", config)
546546
password.process()
@@ -560,7 +560,7 @@ def main(argv):
560560
vpns = CsSite2SiteVpn("site2sitevpn", config)
561561
vpns.process()
562562

563-
red = CsRedundant(config, address)
563+
red = CsRedundant(config)
564564
red.set()
565565

566566
nf = CsNetfilters()

systemvm/patches/debian/config/opt/cloud/bin/cs/CsAddress.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,16 @@ def get_ips(self):
4343
ret.append(CsInterface(ip))
4444
return ret
4545

46+
def get_guest_ip(self):
47+
"""
48+
Return the ip of the first guest interface
49+
For use with routers not vpcrouters
50+
"""
51+
for ip in self.get_ips():
52+
if ip.is_guest():
53+
return ip.get_ip()
54+
return None
55+
4656
def needs_vrrp(self, o):
4757
"""
4858
Returns if the ip needs to be managed by keepalived or not
@@ -146,6 +156,11 @@ def is_control(self):
146156
return True
147157
return False
148158

159+
def is_guest(self):
160+
if "nw_type" in self.address and self.address['nw_type'] in ['guest']:
161+
return True
162+
return False
163+
149164
def to_str(self):
150165
pprint(self.address)
151166

systemvm/patches/debian/config/opt/cloud/bin/cs/CsConfig.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
# under the License.
1818

1919
from CsDatabag import CsCmdLine
20+
from CsAddress import CsAddress
2021
import logging
2122

2223

@@ -30,12 +31,19 @@ class CsConfig(object):
3031

3132
def __init__(self, load=False):
3233
if load:
33-
self.cl = self_set_cl()
34+
self_set_cl()
35+
self_set_address()
3436
self.fw = []
3537

3638
def set_cl(self):
3739
self.cl = CsCmdLine("cmdline")
3840

41+
def address(self):
42+
return self.ips
43+
44+
def set_address(self):
45+
self.ips = CsAddress("ips", self)
46+
3947
def get_cmdline(self):
4048
return self.cl
4149

@@ -51,6 +59,9 @@ def get_level(self):
5159
def is_vpc(self):
5260
return self.cl.get_type() == "vpcrouter"
5361

62+
def is_router(self):
63+
return self.cl.get_type() == "router"
64+
5465
def get_domain(self):
5566
return self.cl.get_domain()
5667

systemvm/patches/debian/config/opt/cloud/bin/cs/CsDhcp.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,10 @@ def __init__(self, config, preload=True):
7070
self.add_host("::1", "localhost ip6-localhost ip6-loopback")
7171
self.add_host("ff02::1", "ip6-allnodes")
7272
self.add_host("ff02::2", "ip6-allrouters")
73-
self.add_host("127.0.0.1", CsHelper.get_hostname())
73+
if config.is_vpc():
74+
self.add_host("127.0.0.1", CsHelper.get_hostname())
75+
if config.is_router():
76+
self.add_host(self.config.address().get_guest_ip(), "%s data-server" % CsHelper.get_hostname())
7477

7578
def delete_leases(self, clist):
7679
try:

systemvm/patches/debian/config/opt/cloud/bin/cs/CsRedundant.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ class CsRedundant(object):
5353
CONNTRACKD_LOCK = "/var/lock/conntrack.lock"
5454
CONNTRACKD_CONFIG = "/etc/conntrackd/conntrackd.conf"
5555

56-
def __init__(self, config, address):
56+
def __init__(self, config):
5757
self.cl = config.get_cmdline()
58-
self.address = address
58+
self.address = config.address()
5959

6060
def set(self):
6161
logging.debug("Router redundancy status is %s", self.cl.is_redundant())

systemvm/test/python/TestCsRedundant.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,9 @@ def setUp(self):
1212
def test_init(self):
1313
csconfig = CsConfig()
1414
csconfig.set_cl()
15+
csconfig.set_address()
1516

16-
csredundant = CsRedundant(csconfig, "address")
17+
csredundant = CsRedundant(csconfig)
1718
self.assertTrue(csredundant is not None)
1819

1920
if __name__ == '__main__':

0 commit comments

Comments
 (0)