mirror of https://github.com/apache/cloudstack.git
Implementing redundant router arguments to add redundant_state
Implementing the arguments on the python side
This commit is contained in:
parent
279f1a2741
commit
a5d6f90f66
|
|
@ -1060,8 +1060,8 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
|||
|
||||
/*
|
||||
* In order to make fail-over works well at any time, we have to ensure:
|
||||
* 1. Backup router's priority = Master's priority - DELTA + 1 2. Backup
|
||||
* router's priority hasn't been bumped up.
|
||||
* 1. Backup router's priority = Master's priority - DELTA + 1
|
||||
* 2. Backup router's priority hasn't been bumped up.
|
||||
*/
|
||||
private void checkSanity(final List<DomainRouterVO> routers) {
|
||||
final Set<Long> checkedNetwork = new HashSet<Long>();
|
||||
|
|
@ -1137,15 +1137,8 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
|||
protected void runInContext() {
|
||||
while (true) {
|
||||
try {
|
||||
final Long networkId = _vrUpdateQueue.take(); // This is a
|
||||
// blocking
|
||||
// call so
|
||||
// this thread
|
||||
// won't run
|
||||
// all the
|
||||
// time if no
|
||||
// work item
|
||||
// in queue.
|
||||
final Long networkId = _vrUpdateQueue.take();
|
||||
// This is a blocking call so this thread won't run all the time if no work item in queue.
|
||||
final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(networkId, Role.VIRTUAL_ROUTER);
|
||||
|
||||
if (routers.size() != 2) {
|
||||
|
|
@ -1159,7 +1152,7 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
|||
final DomainRouterVO router0 = routers.get(0);
|
||||
final DomainRouterVO router1 = routers.get(1);
|
||||
DomainRouterVO router = router0;
|
||||
if (router0.getId() < router1.getId() && router0.getHostId() != null) {
|
||||
if (router0.getId() < router1.getId()) {
|
||||
router = router0;
|
||||
} else {
|
||||
router = router1;
|
||||
|
|
@ -1596,7 +1589,28 @@ Configurable, StateListener<State, VirtualMachine.Event, VirtualMachine> {
|
|||
final boolean isRedundant = router.getIsRedundantRouter();
|
||||
if (isRedundant) {
|
||||
buf.append(" redundant_router=1");
|
||||
final List<DomainRouterVO> routers = _routerDao.listByNetworkAndRole(nic.getNetworkId(), Role.VIRTUAL_ROUTER);
|
||||
|
||||
final Long vpcId = router.getVpcId();
|
||||
final List<DomainRouterVO> routers;
|
||||
if (vpcId != null) {
|
||||
routers = _routerDao.listByVpcId(vpcId);
|
||||
} else {
|
||||
routers = _routerDao.listByNetworkAndRole(nic.getNetworkId(), Role.VIRTUAL_ROUTER);
|
||||
}
|
||||
|
||||
String redundantState = RedundantState.BACKUP.toString();
|
||||
if (routers.size() == 0) {
|
||||
redundantState = RedundantState.MASTER.toString();
|
||||
} else {
|
||||
final DomainRouterVO router0 = routers.get(0);
|
||||
|
||||
if (router.getId() == router0.getId()) {
|
||||
redundantState = RedundantState.MASTER.toString();
|
||||
}
|
||||
}
|
||||
|
||||
buf.append(" redundant_state=").append(redundantState);
|
||||
|
||||
try {
|
||||
final int priority = getUpdatedPriority(network, routers, router);
|
||||
router.setPriority(priority);
|
||||
|
|
|
|||
|
|
@ -236,7 +236,9 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
public boolean finalizeVirtualMachineProfile(final VirtualMachineProfile profile, final DeployDestination dest, final ReservationContext context) {
|
||||
final DomainRouterVO domainRouterVO = _routerDao.findById(profile.getId());
|
||||
|
||||
if (domainRouterVO.getVpcId() != null) {
|
||||
final Long vpcId = domainRouterVO.getVpcId();
|
||||
|
||||
if (vpcId != null) {
|
||||
if (domainRouterVO.getState() == State.Starting || domainRouterVO.getState() == State.Running) {
|
||||
String defaultDns1 = null;
|
||||
String defaultDns2 = null;
|
||||
|
|
@ -257,7 +259,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
|
||||
// add vpc cidr/dns/networkdomain to the boot load args
|
||||
final StringBuilder buf = profile.getBootArgsBuilder();
|
||||
final Vpc vpc = _entityMgr.findById(Vpc.class, domainRouterVO.getVpcId());
|
||||
final Vpc vpc = _entityMgr.findById(Vpc.class, vpcId);
|
||||
buf.append(" vpccidr=" + vpc.getCidr() + " domain=" + vpc.getNetworkDomain());
|
||||
|
||||
buf.append(" dns1=").append(defaultDns1);
|
||||
|
|
@ -688,16 +690,6 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
|
|||
return _routerDao.listByVpcId(vpcId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean start() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean stop() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean startRemoteAccessVpn(final RemoteAccessVpn vpn, final VirtualRouter router) throws ResourceUnavailableException {
|
||||
if (router.getState() != State.Running) {
|
||||
|
|
|
|||
|
|
@ -125,3 +125,8 @@ class CsCmdLine(CsDataBag):
|
|||
if "redundant_master" in self.idata():
|
||||
return self.idata()['redundant_master'] == "true"
|
||||
return False
|
||||
|
||||
def get_state(self):
|
||||
if "redundant_state" in self.idata():
|
||||
return self.idata()['redundant_state']
|
||||
return "MASTER"
|
||||
|
|
@ -101,6 +101,7 @@ class CsRedundant(object):
|
|||
file.search(" router_id ", " router_id %s" % self.cl.get_name())
|
||||
file.search(" priority ", " priority %s" % self.cl.get_priority())
|
||||
file.search(" weight ", " weight %s" % 2)
|
||||
file.search(" state ", " state %s" % self.cl.get_state())
|
||||
file.greplace("[RROUTER_BIN_PATH]", self.CS_ROUTER_DIR)
|
||||
file.section("virtual_ipaddress {", "}", self._collect_ips())
|
||||
file.commit()
|
||||
|
|
@ -121,7 +122,7 @@ class CsRedundant(object):
|
|||
if connt.is_changed():
|
||||
CsHelper.service("conntrackd", "restart")
|
||||
|
||||
if file.is_changed():
|
||||
if file.is_changed() and self.cl.get_state() == 'MASTER':
|
||||
CsHelper.service("keepalived", "restart")
|
||||
|
||||
# FIXME
|
||||
|
|
|
|||
Loading…
Reference in New Issue