mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Fixed hostname on router
This commit is contained in:
parent
d89c1e28ab
commit
40eb8423b9
@ -35,7 +35,6 @@ from cs.CsNetfilter import CsNetfilters
|
|||||||
from cs.CsDhcp import CsDhcp
|
from cs.CsDhcp import CsDhcp
|
||||||
from cs.CsRedundant import *
|
from cs.CsRedundant import *
|
||||||
from cs.CsFile import CsFile
|
from cs.CsFile import CsFile
|
||||||
from cs.CsAddress import CsAddress
|
|
||||||
from cs.CsApp import CsApache, CsPasswdSvc, CsDnsmasq
|
from cs.CsApp import CsApache, CsPasswdSvc, CsDnsmasq
|
||||||
from cs.CsMonitor import CsMonitor
|
from cs.CsMonitor import CsMonitor
|
||||||
from cs.CsLoadBalancer import CsLoadBalancer
|
from cs.CsLoadBalancer import CsLoadBalancer
|
||||||
@ -536,11 +535,12 @@ def main(argv):
|
|||||||
level=config.get_level(),
|
level=config.get_level(),
|
||||||
format=config.get_format())
|
format=config.get_format())
|
||||||
config.set_cl()
|
config.set_cl()
|
||||||
|
config.set_address()
|
||||||
cl = config.get_cmdline()
|
cl = config.get_cmdline()
|
||||||
|
|
||||||
address = CsAddress("ips", config)
|
# IP configuration
|
||||||
address.compare()
|
config.address().compare()
|
||||||
address.process()
|
config.address().process()
|
||||||
|
|
||||||
password = CsPassword("vmpassword", config)
|
password = CsPassword("vmpassword", config)
|
||||||
password.process()
|
password.process()
|
||||||
@ -560,7 +560,7 @@ def main(argv):
|
|||||||
vpns = CsSite2SiteVpn("site2sitevpn", config)
|
vpns = CsSite2SiteVpn("site2sitevpn", config)
|
||||||
vpns.process()
|
vpns.process()
|
||||||
|
|
||||||
red = CsRedundant(config, address)
|
red = CsRedundant(config)
|
||||||
red.set()
|
red.set()
|
||||||
|
|
||||||
nf = CsNetfilters()
|
nf = CsNetfilters()
|
||||||
|
|||||||
@ -43,6 +43,16 @@ class CsAddress(CsDataBag):
|
|||||||
ret.append(CsInterface(ip))
|
ret.append(CsInterface(ip))
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
def get_guest_ip(self):
|
||||||
|
"""
|
||||||
|
Return the ip of the first guest interface
|
||||||
|
For use with routers not vpcrouters
|
||||||
|
"""
|
||||||
|
for ip in self.get_ips():
|
||||||
|
if ip.is_guest():
|
||||||
|
return ip.get_ip()
|
||||||
|
return None
|
||||||
|
|
||||||
def needs_vrrp(self, o):
|
def needs_vrrp(self, o):
|
||||||
"""
|
"""
|
||||||
Returns if the ip needs to be managed by keepalived or not
|
Returns if the ip needs to be managed by keepalived or not
|
||||||
@ -146,6 +156,11 @@ class CsInterface:
|
|||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
def is_guest(self):
|
||||||
|
if "nw_type" in self.address and self.address['nw_type'] in ['guest']:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def to_str(self):
|
def to_str(self):
|
||||||
pprint(self.address)
|
pprint(self.address)
|
||||||
|
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
from CsDatabag import CsCmdLine
|
from CsDatabag import CsCmdLine
|
||||||
|
from CsAddress import CsAddress
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
@ -30,12 +31,19 @@ class CsConfig(object):
|
|||||||
|
|
||||||
def __init__(self, load=False):
|
def __init__(self, load=False):
|
||||||
if load:
|
if load:
|
||||||
self.cl = self_set_cl()
|
self_set_cl()
|
||||||
|
self_set_address()
|
||||||
self.fw = []
|
self.fw = []
|
||||||
|
|
||||||
def set_cl(self):
|
def set_cl(self):
|
||||||
self.cl = CsCmdLine("cmdline")
|
self.cl = CsCmdLine("cmdline")
|
||||||
|
|
||||||
|
def address(self):
|
||||||
|
return self.ips
|
||||||
|
|
||||||
|
def set_address(self):
|
||||||
|
self.ips = CsAddress("ips", self)
|
||||||
|
|
||||||
def get_cmdline(self):
|
def get_cmdline(self):
|
||||||
return self.cl
|
return self.cl
|
||||||
|
|
||||||
@ -51,6 +59,9 @@ class CsConfig(object):
|
|||||||
def is_vpc(self):
|
def is_vpc(self):
|
||||||
return self.cl.get_type() == "vpcrouter"
|
return self.cl.get_type() == "vpcrouter"
|
||||||
|
|
||||||
|
def is_router(self):
|
||||||
|
return self.cl.get_type() == "router"
|
||||||
|
|
||||||
def get_domain(self):
|
def get_domain(self):
|
||||||
return self.cl.get_domain()
|
return self.cl.get_domain()
|
||||||
|
|
||||||
|
|||||||
@ -70,7 +70,10 @@ class CsDnsMasq(object):
|
|||||||
self.add_host("::1", "localhost ip6-localhost ip6-loopback")
|
self.add_host("::1", "localhost ip6-localhost ip6-loopback")
|
||||||
self.add_host("ff02::1", "ip6-allnodes")
|
self.add_host("ff02::1", "ip6-allnodes")
|
||||||
self.add_host("ff02::2", "ip6-allrouters")
|
self.add_host("ff02::2", "ip6-allrouters")
|
||||||
self.add_host("127.0.0.1", CsHelper.get_hostname())
|
if config.is_vpc():
|
||||||
|
self.add_host("127.0.0.1", CsHelper.get_hostname())
|
||||||
|
if config.is_router():
|
||||||
|
self.add_host(self.config.address().get_guest_ip(), "%s data-server" % CsHelper.get_hostname())
|
||||||
|
|
||||||
def delete_leases(self, clist):
|
def delete_leases(self, clist):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@ -53,9 +53,9 @@ class CsRedundant(object):
|
|||||||
CONNTRACKD_LOCK = "/var/lock/conntrack.lock"
|
CONNTRACKD_LOCK = "/var/lock/conntrack.lock"
|
||||||
CONNTRACKD_CONFIG = "/etc/conntrackd/conntrackd.conf"
|
CONNTRACKD_CONFIG = "/etc/conntrackd/conntrackd.conf"
|
||||||
|
|
||||||
def __init__(self, config, address):
|
def __init__(self, config):
|
||||||
self.cl = config.get_cmdline()
|
self.cl = config.get_cmdline()
|
||||||
self.address = address
|
self.address = config.address()
|
||||||
|
|
||||||
def set(self):
|
def set(self):
|
||||||
logging.debug("Router redundancy status is %s", self.cl.is_redundant())
|
logging.debug("Router redundancy status is %s", self.cl.is_redundant())
|
||||||
|
|||||||
@ -12,8 +12,9 @@ class TestCsRedundant(unittest.TestCase):
|
|||||||
def test_init(self):
|
def test_init(self):
|
||||||
csconfig = CsConfig()
|
csconfig = CsConfig()
|
||||||
csconfig.set_cl()
|
csconfig.set_cl()
|
||||||
|
csconfig.set_address()
|
||||||
|
|
||||||
csredundant = CsRedundant(csconfig, "address")
|
csredundant = CsRedundant(csconfig)
|
||||||
self.assertTrue(csredundant is not None)
|
self.assertTrue(csredundant is not None)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user