mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
This patch enable redundant virtual routers. 1. To enable this feature, db need to be updated using follow SQL by now(we would get a UI way later): UPDATE network_offerings SET redundant_router=1 WHERE guest_type="Virtual" AND system_only=0; 2. System would try to start up two routers at different hosts. But if there is only one host in the zone, system would start up two routers on it. 3. The failover part is using keepalived, and connection tracking part is using conntrackd. There would be one master router and one backup router. The status of router(master or backup) can be query from the database table domain_router now. Management server would update the status every 30s by default. 4. The routers for the same zone would use same external NIC(same ip and mac). The script used for fail-over would ensure only one external NIC present in the network at any time. 5. Currently management server don't got the ability to stop one of router is both of them reported as master. The feature is in the todo list. After two routers start up, disconnect anyone of them, the guest network shouldn't be affected, and established connection(http, ssh, etc.) should still works. The fail-over on gateway part should be 3~4 seconds. Currently the patch works with KVM. Would deal with vmware and XenServer soon.
91 lines
4.2 KiB
Java
91 lines
4.2 KiB
Java
/**
|
|
* Copyright (C) 2010 Cloud.com, Inc. All rights reserved.
|
|
*
|
|
* This software is licensed under the GNU General Public License v3 or later.
|
|
*
|
|
* It is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License as published by
|
|
* the Free Software Foundation, either version 3 of the License, or any later version.
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
package com.cloud.network.router;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import com.cloud.deploy.DeployDestination;
|
|
import com.cloud.exception.ConcurrentOperationException;
|
|
import com.cloud.exception.InsufficientCapacityException;
|
|
import com.cloud.exception.ResourceUnavailableException;
|
|
import com.cloud.network.Network;
|
|
import com.cloud.network.PublicIpAddress;
|
|
import com.cloud.network.RemoteAccessVpn;
|
|
import com.cloud.network.VirtualNetworkApplianceService;
|
|
import com.cloud.network.VpnUser;
|
|
import com.cloud.network.rules.FirewallRule;
|
|
import com.cloud.user.Account;
|
|
import com.cloud.user.User;
|
|
import com.cloud.uservm.UserVm;
|
|
import com.cloud.utils.component.Manager;
|
|
import com.cloud.vm.DomainRouterVO;
|
|
import com.cloud.vm.NicProfile;
|
|
import com.cloud.vm.ReservationContext;
|
|
import com.cloud.vm.VirtualMachineProfile;
|
|
|
|
/**
|
|
* NetworkManager manages the network for the different end users.
|
|
*
|
|
*/
|
|
public interface VirtualNetworkApplianceManager extends Manager, VirtualNetworkApplianceService{
|
|
public static final int DEFAULT_ROUTER_VM_RAMSIZE = 128; // 128M
|
|
public static final int DEFAULT_ROUTER_CPU_MHZ = 500; // 500 MHz
|
|
public static final boolean USE_POD_VLAN = false;
|
|
/**
|
|
/*
|
|
* Send ssh public/private key pair to specified host
|
|
* @param hostId
|
|
* @param pubKey
|
|
* @param prvKey
|
|
*/
|
|
boolean sendSshKeysToHost(Long hostId, String pubKey, String prvKey);
|
|
|
|
/**
|
|
* save a vm password on the router.
|
|
*
|
|
*/
|
|
boolean savePasswordToRouter(Network network, NicProfile nic, VirtualMachineProfile<UserVm> profile) throws ResourceUnavailableException;
|
|
|
|
boolean destroyRouter(long routerId) throws ResourceUnavailableException, ConcurrentOperationException;
|
|
|
|
boolean getRouterStatistics(long vmId, Map<String, long[]> netStats, Map<String, long[]> diskStats);
|
|
|
|
List<DomainRouterVO> getRouters(long accountId, long zoneId);
|
|
|
|
List<DomainRouterVO> deployVirtualRouter(Network guestNetwork, DeployDestination dest, Account owner, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
|
|
|
|
List<DomainRouterVO> deployDhcp(Network guestNetwork, DeployDestination dest, Account owner, Map<VirtualMachineProfile.Param, Object> params) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException;
|
|
|
|
boolean startRemoteAccessVpn(Network network, RemoteAccessVpn vpn) throws ResourceUnavailableException;
|
|
|
|
boolean deleteRemoteAccessVpn(Network network, RemoteAccessVpn vpn) throws ResourceUnavailableException;
|
|
|
|
List<VirtualRouter> addVirtualMachineIntoNetwork(Network config, NicProfile nic, VirtualMachineProfile<UserVm> vm, DeployDestination dest, ReservationContext context, Boolean startDhcp) throws ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException;
|
|
|
|
boolean associateIP (Network network, List<? extends PublicIpAddress> ipAddress) throws ResourceUnavailableException;
|
|
|
|
boolean applyFirewallRules(Network network, List<? extends FirewallRule> rules) throws ResourceUnavailableException;
|
|
|
|
String[] applyVpnUsers(Network network, List<? extends VpnUser> users) throws ResourceUnavailableException;
|
|
|
|
List<VirtualRouter> getRoutersForNetwork(long networkId);
|
|
|
|
VirtualRouter stop(VirtualRouter router, boolean forced, User callingUser, Account callingAccount) throws ConcurrentOperationException, ResourceUnavailableException;
|
|
}
|