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.CsRedundant import *
|
||||
from cs.CsFile import CsFile
|
||||
from cs.CsAddress import CsAddress
|
||||
from cs.CsApp import CsApache, CsPasswdSvc, CsDnsmasq
|
||||
from cs.CsMonitor import CsMonitor
|
||||
from cs.CsLoadBalancer import CsLoadBalancer
|
||||
@ -536,11 +535,12 @@ def main(argv):
|
||||
level=config.get_level(),
|
||||
format=config.get_format())
|
||||
config.set_cl()
|
||||
config.set_address()
|
||||
cl = config.get_cmdline()
|
||||
|
||||
address = CsAddress("ips", config)
|
||||
address.compare()
|
||||
address.process()
|
||||
# IP configuration
|
||||
config.address().compare()
|
||||
config.address().process()
|
||||
|
||||
password = CsPassword("vmpassword", config)
|
||||
password.process()
|
||||
@ -560,7 +560,7 @@ def main(argv):
|
||||
vpns = CsSite2SiteVpn("site2sitevpn", config)
|
||||
vpns.process()
|
||||
|
||||
red = CsRedundant(config, address)
|
||||
red = CsRedundant(config)
|
||||
red.set()
|
||||
|
||||
nf = CsNetfilters()
|
||||
|
||||
@ -43,6 +43,16 @@ class CsAddress(CsDataBag):
|
||||
ret.append(CsInterface(ip))
|
||||
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):
|
||||
"""
|
||||
Returns if the ip needs to be managed by keepalived or not
|
||||
@ -146,6 +156,11 @@ class CsInterface:
|
||||
return True
|
||||
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):
|
||||
pprint(self.address)
|
||||
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
# under the License.
|
||||
|
||||
from CsDatabag import CsCmdLine
|
||||
from CsAddress import CsAddress
|
||||
import logging
|
||||
|
||||
|
||||
@ -30,12 +31,19 @@ class CsConfig(object):
|
||||
|
||||
def __init__(self, load=False):
|
||||
if load:
|
||||
self.cl = self_set_cl()
|
||||
self_set_cl()
|
||||
self_set_address()
|
||||
self.fw = []
|
||||
|
||||
def set_cl(self):
|
||||
self.cl = CsCmdLine("cmdline")
|
||||
|
||||
def address(self):
|
||||
return self.ips
|
||||
|
||||
def set_address(self):
|
||||
self.ips = CsAddress("ips", self)
|
||||
|
||||
def get_cmdline(self):
|
||||
return self.cl
|
||||
|
||||
@ -51,6 +59,9 @@ class CsConfig(object):
|
||||
def is_vpc(self):
|
||||
return self.cl.get_type() == "vpcrouter"
|
||||
|
||||
def is_router(self):
|
||||
return self.cl.get_type() == "router"
|
||||
|
||||
def get_domain(self):
|
||||
return self.cl.get_domain()
|
||||
|
||||
|
||||
@ -70,7 +70,10 @@ class CsDnsMasq(object):
|
||||
self.add_host("::1", "localhost ip6-localhost ip6-loopback")
|
||||
self.add_host("ff02::1", "ip6-allnodes")
|
||||
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):
|
||||
try:
|
||||
|
||||
@ -53,9 +53,9 @@ class CsRedundant(object):
|
||||
CONNTRACKD_LOCK = "/var/lock/conntrack.lock"
|
||||
CONNTRACKD_CONFIG = "/etc/conntrackd/conntrackd.conf"
|
||||
|
||||
def __init__(self, config, address):
|
||||
def __init__(self, config):
|
||||
self.cl = config.get_cmdline()
|
||||
self.address = address
|
||||
self.address = config.address()
|
||||
|
||||
def set(self):
|
||||
logging.debug("Router redundancy status is %s", self.cl.is_redundant())
|
||||
|
||||
@ -12,8 +12,9 @@ class TestCsRedundant(unittest.TestCase):
|
||||
def test_init(self):
|
||||
csconfig = CsConfig()
|
||||
csconfig.set_cl()
|
||||
csconfig.set_address()
|
||||
|
||||
csredundant = CsRedundant(csconfig, "address")
|
||||
csredundant = CsRedundant(csconfig)
|
||||
self.assertTrue(csredundant is not None)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user