mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-8934 - Add default gateway when the public interface is up again
This commit is contained in:
parent
ca9e934e96
commit
45642b8382
|
|
@ -155,7 +155,7 @@ class CsInterface:
|
|||
return self.get_attr("netmask")
|
||||
|
||||
def get_gateway(self):
|
||||
if self.config.is_vpc():
|
||||
if self.config.is_vpc() or self.config.cmdline().is_redundant():
|
||||
return self.get_attr("gateway")
|
||||
else:
|
||||
return self.config.cmdline().get_guest_gw()
|
||||
|
|
@ -308,7 +308,7 @@ class CsIP:
|
|||
if not self.config.is_vpc():
|
||||
self.setup_router_control()
|
||||
|
||||
if self.config.is_vpc():
|
||||
if self.config.is_vpc() or self.cl.is_redundant():
|
||||
# The code looks redundant here, but we actually have to cater for routers and
|
||||
# VPC routers in a different manner. Please do not remove this block otherwise
|
||||
# The VPC default route will be broken.
|
||||
|
|
@ -329,10 +329,10 @@ class CsIP:
|
|||
cmd2 = "ip link set %s up" % self.getDevice()
|
||||
# If redundant do not bring up public interfaces
|
||||
# master.py and keepalived deal with tham
|
||||
if self.config.cmdline().is_redundant() and not self.is_public():
|
||||
if self.cl.is_redundant() and not self.is_public():
|
||||
CsHelper.execute(cmd2)
|
||||
# if not redundant bring everything up
|
||||
if not self.config.cmdline().is_redundant():
|
||||
if not self.cl.is_redundant():
|
||||
CsHelper.execute(cmd2)
|
||||
|
||||
def set_mark(self):
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ from CsFile import CsFile
|
|||
from CsProcess import CsProcess
|
||||
from CsApp import CsPasswdSvc
|
||||
from CsAddress import CsDevice
|
||||
from CsRoute import CsRoute
|
||||
import socket
|
||||
from time import sleep
|
||||
|
||||
|
|
@ -267,16 +268,26 @@ class CsRedundant(object):
|
|||
|
||||
ads = [o for o in self.address.get_ips() if o.is_public()]
|
||||
dev = ''
|
||||
route = CsRoute()
|
||||
for o in ads:
|
||||
if dev == o.get_device():
|
||||
continue
|
||||
cmd2 = "ip link set %s up" % o.get_device()
|
||||
if CsDevice(o.get_device(), self.config).waitfordevice():
|
||||
dev = o.get_device()
|
||||
logging.info("Will proceed configuring device ==> %s" % dev)
|
||||
cmd2 = "ip link set %s up" % dev
|
||||
if CsDevice(dev, self.config).waitfordevice():
|
||||
CsHelper.execute(cmd2)
|
||||
dev = o.get_device()
|
||||
logging.info("Bringing public interface %s up" % o.get_device())
|
||||
logging.info("Bringing public interface %s up" % dev)
|
||||
|
||||
try:
|
||||
gateway = o.get_gateway()
|
||||
logging.info("Adding gateway ==> %s to device ==> %s" % (gateway, dev))
|
||||
route.add_defaultroute(gateway)
|
||||
except:
|
||||
logging.error("ERROR getting gateway from device %s" % dev)
|
||||
|
||||
else:
|
||||
logging.error("Device %s was not ready could not bring it up" % o.get_device())
|
||||
logging.error("Device %s was not ready could not bring it up" % dev)
|
||||
|
||||
# ip route add default via $gw table Table_$dev proto static
|
||||
cmd = "%s -C %s" % (self.CONNTRACKD_BIN, self.CONNTRACKD_CONF)
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
# Licensed to the Apache Software Foundation (ASF) under one
|
||||
# or more contributor license agreements. See the NOTICE file
|
||||
# distributed with this work for additional information
|
||||
# regarding copyright ownership. The ASF licenses this file
|
||||
# to you under the Apache License, Version 2.0 (the
|
||||
# "License"); you may not use this file except in compliance
|
||||
# with the License. You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing,
|
||||
# software distributed under the License is distributed on an
|
||||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
# KIND, either express or implied. See the License for the
|
||||
# specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from cs.CsGuestNetwork import CsGuestNetwork
|
||||
import merge
|
||||
|
||||
merge.DataBag.DPATH = "."
|
||||
csguestnetwork = CsGuestNetwork({}, {})
|
||||
csguestnetwork.guest = True
|
||||
csguestnetwork.set_dns("1.1.1.1,2.2.2.2")
|
||||
csguestnetwork.set_router("3.3.3.3")
|
||||
dns = csguestnetwork.get_dns()
|
||||
print dns
|
||||
|
|
@ -462,7 +462,8 @@ class TestVPCRedundancy(cloudstackTestCase):
|
|||
self.check_master_status(2)
|
||||
self.add_nat_rules()
|
||||
self.do_vpc_test(False)
|
||||
|
||||
time.sleep(30)
|
||||
|
||||
self.stop_router_by_type("MASTER")
|
||||
# wait for the backup router to transit to master state
|
||||
time.sleep(30)
|
||||
|
|
@ -476,7 +477,7 @@ class TestVPCRedundancy(cloudstackTestCase):
|
|||
|
||||
self.start_routers()
|
||||
self.add_nat_rules()
|
||||
time.sleep(45)
|
||||
time.sleep(30)
|
||||
self.check_master_status(2)
|
||||
self.do_vpc_test(False)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue