mirror of https://github.com/apache/cloudstack.git
bug 7863: fixed router cleanup thread
status 7863: resolved fixed Router cleanp thread is fixed, here is functionality description: * Runs every "router.cleanup.interval" period of time (1 day by default) * Stops only domRs running in Advance zone * Thread Flow: - gets all Running domRs/dhcps, get their networks, select network that has to be checked (see criteria below): - checks that there is only one nic in the op_networks table for the network, and this nic belongs to domR/dhcp - Stops domR/dhcp * Criteria to choose the network: - Network has to be non-system. - Network should be one of the following: Guest Virtual (TrafficType=Guest; GuestType=Virtual); Direct Tagged (TrafficType=Public; GuestType=Direct) Couple of other fixes: * Added isShared parameter to listNetworks command * Moved guestType from NetworkOffering to Network
This commit is contained in:
parent
ffb8d54dff
commit
d0687f663f
|
|
@ -57,6 +57,9 @@ public class ListNetworksCmd extends BaseListCmd {
|
|||
|
||||
@Parameter(name=ApiConstants.IS_SYSTEM, type=CommandType.BOOLEAN, description="true if network is system, false otherwise")
|
||||
private Boolean isSystem;
|
||||
|
||||
@Parameter(name=ApiConstants.IS_SHARED, type=CommandType.BOOLEAN, description="true if network is shared, false otherwise")
|
||||
private Boolean isShared;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
|
|
@ -86,6 +89,10 @@ public class ListNetworksCmd extends BaseListCmd {
|
|||
return isSystem;
|
||||
}
|
||||
|
||||
public Boolean getIsShared() {
|
||||
return isShared;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import com.cloud.acl.ControlledEntity;
|
|||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.utils.fsm.FiniteState;
|
||||
import com.cloud.utils.fsm.StateMachine;
|
||||
|
||||
|
|
@ -21,6 +20,11 @@ import com.cloud.utils.fsm.StateMachine;
|
|||
*/
|
||||
public interface Network extends ControlledEntity {
|
||||
|
||||
public enum GuestIpType {
|
||||
Virtual,
|
||||
Direct,
|
||||
}
|
||||
|
||||
public static class Service {
|
||||
|
||||
public static final Service Vpn = new Service("Vpn", Capability.SupportedVpnTypes);
|
||||
|
|
|
|||
|
|
@ -25,11 +25,6 @@ import com.cloud.network.Networks.TrafficType;
|
|||
*/
|
||||
public interface NetworkOffering {
|
||||
|
||||
public enum GuestIpType {
|
||||
Virtual,
|
||||
Direct,
|
||||
}
|
||||
|
||||
public enum Availability {
|
||||
Required,
|
||||
Optional,
|
||||
|
|
|
|||
|
|
@ -19,6 +19,8 @@ package com.cloud.offering;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import com.cloud.network.Network;
|
||||
|
||||
/**
|
||||
* ServiceOffering models the different types of service contracts to be
|
||||
* offered.
|
||||
|
|
@ -70,7 +72,7 @@ public interface ServiceOffering {
|
|||
/**
|
||||
* @return the type of IP address to allocate as the primary ip address to a guest
|
||||
*/
|
||||
NetworkOffering.GuestIpType getGuestIpType();
|
||||
Network.GuestIpType getGuestIpType();
|
||||
|
||||
/**
|
||||
* @return whether or not the service offering requires local storage
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import com.cloud.dc.DataCenterVO;
|
|||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.dao.HostPodDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
|
|
@ -250,14 +250,14 @@ public class UserConcentratedAllocator implements PodAllocator {
|
|||
so = _offeringDao.findById(userVm.getServiceOfferingId());
|
||||
} else if(vm.getType() == VirtualMachine.Type.ConsoleProxy) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomP", 1,
|
||||
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
|
||||
_proxyRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true);
|
||||
} else if(vm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true);
|
||||
} else if(vm.getType() == VirtualMachine.Type.DomainRouter) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true);
|
||||
} else {
|
||||
assert(false) : "Unsupported system vm type";
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true);
|
||||
}
|
||||
|
||||
if(capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import com.cloud.exception.PermissionDeniedException;
|
|||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.offering.NetworkOffering.Availability;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
|
|
@ -172,15 +171,14 @@ public interface ConfigurationManager extends Manager {
|
|||
* Creates a new network offering
|
||||
* @param name
|
||||
* @param displayText
|
||||
* @param type
|
||||
* @param trafficType
|
||||
* @param tags
|
||||
* @param maxConnections
|
||||
* @param id
|
||||
* @param specifyVlan;
|
||||
* @param specifyVlan;
|
||||
* @return network offering object
|
||||
*/
|
||||
NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, GuestIpType type, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, Availability availability);
|
||||
NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, Availability availability);
|
||||
|
||||
Vlan createVlanAndPublicIpRange(Long userId, Long zoneId, Long podId, String startIP, String endIP, String vlanGateway, String vlanNetmask, boolean forVirtualNetwork, String vlanId, Account account, Long networkId) throws InsufficientCapacityException, ConcurrentOperationException, InvalidParameterValueException;
|
||||
|
||||
|
|
@ -188,4 +186,5 @@ public interface ConfigurationManager extends Manager {
|
|||
|
||||
Long saveConfigurationEvent(long userId, Long accountId, String type, String description, String... paramsList);
|
||||
|
||||
DataCenterVO getZone(long id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,6 +91,8 @@ import com.cloud.exception.InvalidParameterValueException;
|
|||
import com.cloud.exception.PermissionDeniedException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
|
|
@ -100,7 +102,6 @@ import com.cloud.network.dao.NetworkDao;
|
|||
import com.cloud.offering.DiskOffering;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Availability;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
|
|
@ -1360,7 +1361,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
|
||||
int networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
|
||||
int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||
NetworkOffering.GuestIpType guestIpType = useVirtualNetwork ? NetworkOffering.GuestIpType.Virtual : NetworkOffering.GuestIpType.Direct;
|
||||
Network.GuestIpType guestIpType = useVirtualNetwork ? Network.GuestIpType.Virtual : Network.GuestIpType.Direct;
|
||||
tags = cleanupTags(tags);
|
||||
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, multicastRate, offerHA, displayText, guestIpType, localStorageRequired, false, tags, false,domainId);
|
||||
|
||||
|
|
@ -1442,7 +1443,7 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
if (_serviceOfferingDao.update(id, offering)) {
|
||||
offering = _serviceOfferingDao.findById(id);
|
||||
saveConfigurationEvent(userId, null, EventTypes.EVENT_SERVICE_OFFERING_EDIT, "Successfully updated service offering with name: " + offering.getName() + ".", "soId=" + offering.getId(), "name=" + offering.getName(),
|
||||
"displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == NetworkOffering.GuestIpType.Virtual), "tags=" + offering.getTags(), "domainId=" + offering.getDomainId());
|
||||
"displayText=" + offering.getDisplayText(), "offerHA=" + offering.getOfferHA(), "useVirtualNetwork=" + (offering.getGuestIpType() == Network.GuestIpType.Virtual), "tags=" + offering.getTags(), "domainId=" + offering.getDomainId());
|
||||
return offering;
|
||||
} else {
|
||||
return null;
|
||||
|
|
@ -2684,7 +2685,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
String availabilityStr = cmd.getAvailability();
|
||||
|
||||
TrafficType trafficType = null;
|
||||
GuestIpType type = null;
|
||||
Availability availability = null;
|
||||
|
||||
|
||||
|
|
@ -2710,11 +2710,11 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
|
||||
Integer maxConnections = cmd.getMaxconnections();
|
||||
return createNetworkOffering(userId, name, displayText, type, trafficType, tags, maxConnections, specifyVlan, availability);
|
||||
return createNetworkOffering(userId, name, displayText, trafficType, tags, maxConnections, specifyVlan, availability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, GuestIpType type, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, Availability availability) {
|
||||
public NetworkOfferingVO createNetworkOffering(long userId, String name, String displayText, TrafficType trafficType, String tags, Integer maxConnections, boolean specifyVlan, Availability availability) {
|
||||
String networkRateStr = _configDao.getValue("network.throttling.rate");
|
||||
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
|
||||
int networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
|
||||
|
|
@ -2882,4 +2882,9 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DataCenterVO getZone(long id){
|
||||
return _zoneDao.findById(id);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,11 +104,11 @@ import com.cloud.info.RunningHostInfoAgregator;
|
|||
import com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo;
|
||||
import com.cloud.maid.StackMaid;
|
||||
import com.cloud.network.IpAddrAllocator;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
|
|
@ -1911,7 +1911,7 @@ public class ConsoleProxyManagerImpl implements ConsoleProxyManager, ConsoleProx
|
|||
_itMgr.registerGuru(VirtualMachine.Type.ConsoleProxy, this);
|
||||
|
||||
boolean useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key()));
|
||||
_serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, _proxyRamSize, 0, 0, 0, true, null, NetworkOffering.GuestIpType.Virtual,
|
||||
_serviceOffering = new ServiceOfferingVO("System Offering For Console Proxy", 1, _proxyRamSize, 0, 0, 0, true, null, Network.GuestIpType.Virtual,
|
||||
useLocalStorage, true, null, true);
|
||||
_serviceOffering.setUniqueName("Cloud.com-ConsoleProxy");
|
||||
_serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import com.cloud.host.Host;
|
|||
import com.cloud.host.HostVO;
|
||||
import com.cloud.host.dao.HostDao;
|
||||
import com.cloud.migration.DiskOffering21VO.Type;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.storage.Storage.StoragePoolType;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.Volume.VolumeType;
|
||||
|
|
@ -306,7 +306,7 @@ public class Db20to21MigrationUtil {
|
|||
_configDao.getValue(Config.ConsoleProxyRamSize.key()),
|
||||
ConsoleProxyManager.DEFAULT_PROXY_VM_RAMSIZE);
|
||||
ServiceOffering21VO soConsoleProxy = new ServiceOffering21VO("Fake Offering For DomP", 1,
|
||||
proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual,
|
||||
proxyRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual,
|
||||
useLocalStorage, true, null);
|
||||
soConsoleProxy.setId(seq++);
|
||||
soConsoleProxy.setUniqueName("Cloud.com-ConsoleProxy");
|
||||
|
|
@ -317,7 +317,7 @@ public class Db20to21MigrationUtil {
|
|||
_configDao.getValue(Config.SecStorageVmRamSize.key()),
|
||||
SecondaryStorageVmManager.DEFAULT_SS_VM_RAMSIZE);
|
||||
ServiceOffering21VO soSecondaryVm = new ServiceOffering21VO("Fake Offering For Secondary Storage VM", 1,
|
||||
secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, useLocalStorage, true, null);
|
||||
secStorageVmRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, useLocalStorage, true, null);
|
||||
soSecondaryVm.setId(seq++);
|
||||
soSecondaryVm.setUniqueName("Cloud.com-SecondaryStorage");
|
||||
soSecondaryVm = _serviceOffering21Dao.persist(soSecondaryVm);
|
||||
|
|
@ -325,7 +325,7 @@ public class Db20to21MigrationUtil {
|
|||
|
||||
int routerRamSize = NumbersUtil.parseInt(_configDao.getValue("router.ram.size"), 128);
|
||||
ServiceOffering21VO soDomainRouter = new ServiceOffering21VO("Fake Offering For DomR", 1,
|
||||
routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, useLocalStorage, true, null);
|
||||
routerRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, useLocalStorage, true, null);
|
||||
soDomainRouter.setId(seq++);
|
||||
soDomainRouter.setUniqueName("Cloud.Com-SoftwareRouter");
|
||||
soDomainRouter = _serviceOffering21Dao.persist(soDomainRouter);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
package com.cloud.migration;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetAddress;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.List;
|
||||
|
|
@ -9,13 +8,12 @@ import java.util.List;
|
|||
import org.apache.log4j.xml.DOMConfigurator;
|
||||
|
||||
import com.cloud.configuration.ResourceCount.ResourceType;
|
||||
import com.cloud.configuration.ConfigurationVO;
|
||||
import com.cloud.configuration.ResourceCountVO;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.configuration.dao.ResourceCountDao;
|
||||
import com.cloud.dc.ClusterVO;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.dao.ClusterDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.domain.DomainVO;
|
||||
|
|
@ -28,7 +26,6 @@ import com.cloud.user.Account;
|
|||
import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.utils.PropertiesUtil;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
|
|
|
|||
|
|
@ -11,8 +11,7 @@ import javax.persistence.GenerationType;
|
|||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
|
||||
@Entity
|
||||
|
|
@ -52,7 +51,7 @@ public class ServiceOffering20VO {
|
|||
|
||||
@Column(name="guest_ip_type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private NetworkOffering.GuestIpType guestIpType = NetworkOffering.GuestIpType.Virtual;
|
||||
private Network.GuestIpType guestIpType = Network.GuestIpType.Virtual;
|
||||
|
||||
@Column(name="use_local_storage")
|
||||
private boolean useLocalStorage;
|
||||
|
|
@ -67,10 +66,10 @@ public class ServiceOffering20VO {
|
|||
}
|
||||
|
||||
public ServiceOffering20VO(Long id, String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, boolean localStorageRequired) {
|
||||
this(id, name, cpu, ramSize, speed, rateMbps, multicastRateMbps, offerHA, displayText, NetworkOffering.GuestIpType.Virtual, localStorageRequired);
|
||||
this(id, name, cpu, ramSize, speed, rateMbps, multicastRateMbps, offerHA, displayText, Network.GuestIpType.Virtual, localStorageRequired);
|
||||
}
|
||||
|
||||
public ServiceOffering20VO(Long id, String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, NetworkOffering.GuestIpType guestIpType, boolean useLocalStorage) {
|
||||
public ServiceOffering20VO(Long id, String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, Network.GuestIpType guestIpType, boolean useLocalStorage) {
|
||||
this.id = id;
|
||||
this.name = name;
|
||||
this.cpu = cpu;
|
||||
|
|
@ -168,11 +167,11 @@ public class ServiceOffering20VO {
|
|||
return multicastRateMbps;
|
||||
}
|
||||
|
||||
public void setGuestIpType(NetworkOffering.GuestIpType guestIpType) {
|
||||
public void setGuestIpType(Network.GuestIpType guestIpType) {
|
||||
this.guestIpType = guestIpType;
|
||||
}
|
||||
|
||||
public NetworkOffering.GuestIpType getGuestIpType() {
|
||||
public Network.GuestIpType getGuestIpType() {
|
||||
return guestIpType;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ import javax.persistence.PrimaryKeyJoinColumn;
|
|||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
|
||||
@Entity
|
||||
|
|
@ -37,13 +37,13 @@ public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffe
|
|||
|
||||
@Column(name="guest_ip_type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private NetworkOffering.GuestIpType guestIpType;
|
||||
private Network.GuestIpType guestIpType;
|
||||
|
||||
protected ServiceOffering21VO() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ServiceOffering21VO(String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, NetworkOffering.GuestIpType guestIpType, boolean useLocalStorage, boolean recreatable, String tags) {
|
||||
public ServiceOffering21VO(String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, Network.GuestIpType guestIpType, boolean useLocalStorage, boolean recreatable, String tags) {
|
||||
super(name, displayText, false, tags, recreatable, useLocalStorage);
|
||||
this.cpu = cpu;
|
||||
this.ramSize = ramSize;
|
||||
|
|
@ -119,12 +119,12 @@ public class ServiceOffering21VO extends DiskOffering21VO implements ServiceOffe
|
|||
return multicastRateMbps;
|
||||
}
|
||||
|
||||
public void setGuestIpType(NetworkOffering.GuestIpType guestIpType) {
|
||||
public void setGuestIpType(Network.GuestIpType guestIpType) {
|
||||
this.guestIpType = guestIpType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkOffering.GuestIpType getGuestIpType() {
|
||||
public Network.GuestIpType getGuestIpType() {
|
||||
return guestIpType;
|
||||
}
|
||||
public String gethypervisorType() {
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ public interface NetworkManager extends NetworkService {
|
|||
|
||||
void cleanupNics(VirtualMachineProfile<? extends VMInstanceVO> vm);
|
||||
|
||||
List<? extends Nic> getNics (VirtualMachine vm);
|
||||
List<? extends Nic> getNics(VirtualMachine vm);
|
||||
|
||||
List<AccountVO> getAccountsUsingNetwork(long configurationId);
|
||||
AccountVO getNetworkOwner(long configurationId);
|
||||
|
|
@ -140,6 +140,8 @@ public interface NetworkManager extends NetworkService {
|
|||
PublicIpAddress getPublicIpAddress(Ip ipAddress);
|
||||
|
||||
List<? extends Vlan> listPodVlans(long podId);
|
||||
|
||||
|
||||
Pair<NetworkGuru, NetworkVO> implementNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException;
|
||||
List<NetworkVO> listNetworksUsedByVm(long vmId, boolean isSystem);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ import com.cloud.exception.PermissionDeniedException;
|
|||
import com.cloud.exception.ResourceAllocationException;
|
||||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Networks.AddressFormat;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
|
|
@ -96,7 +97,6 @@ import com.cloud.network.rules.RulesManager;
|
|||
import com.cloud.network.vpn.RemoteAccessVpnElement;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.Availability;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.resource.Resource;
|
||||
|
|
@ -685,19 +685,19 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
_networkGcWait = NumbersUtil.parseInt(_configs.get(Config.NetworkGcWait.key()), 600);
|
||||
_networkGcInterval = NumbersUtil.parseInt(_configs.get(Config.NetworkGcInterval.key()), 600);
|
||||
|
||||
NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemPublicNetwork, TrafficType.Public, null);
|
||||
NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemPublicNetwork, TrafficType.Public);
|
||||
publicNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(publicNetworkOffering);
|
||||
_systemNetworks.put(NetworkOfferingVO.SystemPublicNetwork, publicNetworkOffering);
|
||||
NetworkOfferingVO managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemManagementNetwork, TrafficType.Management, null);
|
||||
NetworkOfferingVO managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemManagementNetwork, TrafficType.Management);
|
||||
managementNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(managementNetworkOffering);
|
||||
_systemNetworks.put(NetworkOfferingVO.SystemManagementNetwork, managementNetworkOffering);
|
||||
NetworkOfferingVO controlNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemControlNetwork, TrafficType.Control, null);
|
||||
NetworkOfferingVO controlNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemControlNetwork, TrafficType.Control);
|
||||
controlNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(controlNetworkOffering);
|
||||
_systemNetworks.put(NetworkOfferingVO.SystemControlNetwork, controlNetworkOffering);
|
||||
NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemStorageNetwork, TrafficType.Storage, null);
|
||||
NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemStorageNetwork, TrafficType.Storage);
|
||||
storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering);
|
||||
_systemNetworks.put(NetworkOfferingVO.SystemStorageNetwork, storageNetworkOffering);
|
||||
NetworkOfferingVO guestNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SysteGuestNetwork, TrafficType.Guest, null);
|
||||
NetworkOfferingVO guestNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SysteGuestNetwork, TrafficType.Guest);
|
||||
guestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(guestNetworkOffering);
|
||||
_systemNetworks.put(NetworkOfferingVO.SysteGuestNetwork, guestNetworkOffering);
|
||||
|
||||
|
|
@ -1424,12 +1424,17 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
String accountName = cmd.getAccountName();
|
||||
String type = cmd.getType();
|
||||
Boolean isSystem = cmd.getIsSystem();
|
||||
Boolean isShared = cmd.getIsShared();
|
||||
Long accountId = null;
|
||||
|
||||
if (isSystem == null) {
|
||||
isSystem = false;
|
||||
}
|
||||
|
||||
if (isShared == null) {
|
||||
isShared = false;
|
||||
}
|
||||
|
||||
//Account/domainId parameters and isSystem are mutually exclusive
|
||||
if (isSystem && (accountName != null || domainId != null)) {
|
||||
throw new InvalidParameterValueException("System network belongs to system, account and domainId parameters can't be specified");
|
||||
|
|
@ -1502,6 +1507,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
sc.addAnd("accountId", SearchCriteria.Op.EQ, accountId);
|
||||
}
|
||||
|
||||
if (isShared != null) {
|
||||
sc.addAnd("isShared", SearchCriteria.Op.EQ, isShared);
|
||||
}
|
||||
|
||||
List<NetworkVO> networks = _networksDao.search(sc, searchFilter);
|
||||
|
||||
return networks;
|
||||
|
|
@ -1844,4 +1853,22 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
|||
return vlans;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<NetworkVO> listNetworksUsedByVm(long vmId, boolean isSystem) {
|
||||
List<NetworkVO> networks = new ArrayList<NetworkVO>();
|
||||
|
||||
List<NicVO> nics = _nicDao.listBy(vmId);
|
||||
if (nics != null) {
|
||||
for (Nic nic : nics) {
|
||||
NetworkVO network = _networksDao.findByIdIncludingRemoved(nic.getNetworkId());
|
||||
NetworkOffering no = _networkOfferingDao.findByIdIncludingRemoved(network.getNetworkOfferingId());
|
||||
if (no.isSystemOnly() == isSystem) {
|
||||
networks.add(network);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return networks;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ import javax.persistence.Transient;
|
|||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
|
|
|
|||
|
|
@ -19,9 +19,9 @@ package com.cloud.network.dao;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.NetworkAccountVO;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
|
||||
|
|
|
|||
|
|
@ -23,13 +23,13 @@ import java.util.Random;
|
|||
import javax.ejb.Local;
|
||||
import javax.persistence.TableGenerator;
|
||||
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.NetworkAccountDaoImpl;
|
||||
import com.cloud.network.NetworkAccountVO;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.utils.component.ComponentLocator;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.GenericDaoBase;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import com.cloud.exception.InsufficientCapacityException;
|
|||
import com.cloud.exception.ResourceUnavailableException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
|
|
@ -42,7 +43,6 @@ import com.cloud.network.dao.NetworkDao;
|
|||
import com.cloud.network.router.VirtualNetworkApplianceManager;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
import com.cloud.utils.component.Inject;
|
||||
|
|
|
|||
|
|
@ -35,6 +35,7 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||
import com.cloud.network.LoadBalancerVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.Capability;
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.Network.Provider;
|
||||
import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.NetworkManager;
|
||||
|
|
@ -52,7 +53,6 @@ import com.cloud.network.rules.FirewallRule.Purpose;
|
|||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.network.vpn.RemoteAccessVpnElement;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.uservm.UserVm;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import com.cloud.exception.InsufficientAddressCapacityException;
|
|||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
|
|
@ -44,7 +45,6 @@ import com.cloud.network.Networks.TrafficType;
|
|||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.resource.Resource.ReservationStrategy;
|
||||
import com.cloud.user.Account;
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import com.cloud.exception.InsufficientAddressCapacityException;
|
|||
import com.cloud.exception.InsufficientVirtualNetworkCapcityException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
|
|
@ -44,7 +45,6 @@ import com.cloud.network.Networks.BroadcastDomainType;
|
|||
import com.cloud.network.Networks.Mode;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.resource.Resource.ReservationStrategy;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.utils.component.AdapterBase;
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ import com.cloud.network.IPAddressVO;
|
|||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.LoadBalancerVO;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
|
|
@ -134,8 +135,6 @@ import com.cloud.network.rules.PortForwardingRule;
|
|||
import com.cloud.network.rules.PortForwardingRuleVO;
|
||||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
|
|
@ -174,6 +173,7 @@ import com.cloud.vm.NicProfile;
|
|||
import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.VirtualMachineGuru;
|
||||
|
|
@ -183,6 +183,7 @@ import com.cloud.vm.VirtualMachineProfile;
|
|||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
|
||||
/**
|
||||
* VirtualNetworkApplianceManagerImpl manages the different types of
|
||||
|
|
@ -291,6 +292,8 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
PortForwardingRulesDao _pfRulesDao;
|
||||
@Inject
|
||||
RemoteAccessVpnDao _vpnDao;
|
||||
@Inject
|
||||
VMInstanceDao _instanceDao;
|
||||
|
||||
long _routerTemplateId = -1;
|
||||
int _routerRamSize;
|
||||
|
|
@ -564,7 +567,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
userStats.setNetBytesSent(userStats.getNetBytesSent() + netBytes);
|
||||
userStats.setCurrentBytesSent(0);
|
||||
_userStatsDao.update(userStats.getId(), userStats);
|
||||
s_logger.debug("Successfully updated user statistics as a part of domR id=" + router.getId() + " reboot/stop");
|
||||
s_logger.debug("Successfully updated user statistics as a part of domR " + router + " reboot/stop");
|
||||
} else {
|
||||
s_logger.warn("User stats were not created for account " + router.getAccountId() + " and dc " + router.getDataCenterId());
|
||||
}
|
||||
|
|
@ -620,12 +623,12 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
throw new ResourceUnavailableException("Unable to reboot domR, it is not in right state " + router.getState(), DataCenter.class, router.getDataCenterId());
|
||||
}
|
||||
|
||||
s_logger.debug("Stopping and starting router id=" + router.getId() + " as a part of router reboot");
|
||||
s_logger.debug("Stopping and starting router " + router + " as a part of router reboot");
|
||||
|
||||
if (stopRouter(routerId) != null) {
|
||||
return startRouter(routerId);
|
||||
} else {
|
||||
throw new CloudRuntimeException("Failed to reboot router id=" + router.getId());
|
||||
throw new CloudRuntimeException("Failed to reboot router " + router);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -682,7 +685,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
_networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
|
||||
_multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||
_offering = new ServiceOfferingVO("System Offering For Software Router", 1, _routerRamSize, 0, 0, 0, true, null,
|
||||
NetworkOffering.GuestIpType.Virtual, useLocalStorage, true, null, true);
|
||||
Network.GuestIpType.Virtual, useLocalStorage, true, null, true);
|
||||
_offering.setUniqueName("Cloud.Com-SoftwareRouter");
|
||||
_offering = _serviceOfferingDao.persistSystemServiceOffering(_offering);
|
||||
_template = _templateDao.findRoutingTemplate();
|
||||
|
|
@ -903,12 +906,22 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
final List<Long> ids = _routerDao.findLonelyRouters();
|
||||
s_logger.info("Found " + ids.size() + " routers to stop. ");
|
||||
|
||||
for (final Long id : ids) {
|
||||
stopRouterInternal(id);
|
||||
final List<Long> ids = findLonelyRouters();
|
||||
Long size;
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
size = 0L;
|
||||
} else {
|
||||
size = Long.valueOf(ids.size());
|
||||
}
|
||||
|
||||
s_logger.info("Found " + size + " routers to stop. ");
|
||||
|
||||
if (ids != null) {
|
||||
for (final Long id : ids) {
|
||||
stopRouterInternal(id);
|
||||
}
|
||||
}
|
||||
|
||||
s_logger.info("Done my job. Time to rest.");
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to stop routers. Will retry. ", e);
|
||||
|
|
@ -1415,7 +1428,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
|
||||
private DomainRouterVO start(DomainRouterVO router, User user, Account caller) throws StorageUnavailableException, InsufficientCapacityException,
|
||||
ConcurrentOperationException, ResourceUnavailableException {
|
||||
s_logger.debug("Starting router id=" + router.getId());
|
||||
s_logger.debug("Starting router " + router);
|
||||
if (_itMgr.start(router, null, user, caller, null) != null) {
|
||||
return _routerDao.findById(router.getId());
|
||||
} else {
|
||||
|
|
@ -1424,7 +1437,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
}
|
||||
|
||||
private DomainRouterVO stop(DomainRouterVO router, User user, Account caller) throws ConcurrentOperationException, ResourceUnavailableException {
|
||||
s_logger.debug("Stopping router id=" + router.getId());
|
||||
s_logger.debug("Stopping router " + router);
|
||||
if (_itMgr.stop(router, user, caller)) {
|
||||
return _routerDao.findById(router.getId());
|
||||
} else {
|
||||
|
|
@ -1692,7 +1705,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
if (vm.getUserData() != null) {
|
||||
NicVO nic = _nicDao.findByInstanceIdAndNetworkId(networkId, vm.getId());
|
||||
if (nic != null) {
|
||||
s_logger.debug("Creating user data entry for vm id=" + vm.getId() + " on domR " + router.getId());
|
||||
s_logger.debug("Creating user data entry for vm " + vm + " on domR " + router);
|
||||
String serviceOffering = _serviceOfferingDao.findById(vm.getServiceOfferingId()).getDisplayText();
|
||||
String zoneName = _dcDao.findById(router.getDataCenterId()).getName();
|
||||
cmds.addCommand(
|
||||
|
|
@ -1712,7 +1725,7 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
for (UserVmVO vm : vms) {
|
||||
NicVO nic = _nicDao.findByInstanceIdAndNetworkId(networkId, vm.getId());
|
||||
if (nic != null) {
|
||||
s_logger.debug("Creating dhcp entry for vm id=" + vm.getId() + " on domR " + router.getId());
|
||||
s_logger.debug("Creating dhcp entry for vm " + vm + " on domR " + router);
|
||||
|
||||
DhcpEntryCommand dhcpCommand = new DhcpEntryCommand(nic.getMacAddress(), nic.getIp4Address(), vm.getName());
|
||||
dhcpCommand.setAccessDetail(NetworkElementCommand.ROUTER_IP, router.getPrivateIpAddress());
|
||||
|
|
@ -1814,4 +1827,42 @@ public class VirtualNetworkApplianceManagerImpl implements VirtualNetworkApplian
|
|||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private List<Long> findLonelyRouters() {
|
||||
List<Long> routersToStop = new ArrayList<Long>();
|
||||
List<VMInstanceVO> runningRouters = _instanceDao.listByTypeAndState(State.Running, VirtualMachine.Type.DomainRouter);
|
||||
|
||||
for (VMInstanceVO router : runningRouters) {
|
||||
DataCenter dc = _configMgr.getZone(router.getDataCenterId());
|
||||
if (dc.getNetworkType() == NetworkType.Advanced) {
|
||||
//Only non-system networks should be reviewed as system network can always have other system vms running
|
||||
List<NetworkVO> routerNetworks = _networkMgr.listNetworksUsedByVm(router.getId(), false);
|
||||
List<Network> networksToCheck = new ArrayList<Network>();
|
||||
for (Network routerNetwork : routerNetworks){
|
||||
if ((routerNetwork.getGuestType() == GuestIpType.Direct && routerNetwork.getTrafficType() == TrafficType.Public) || (routerNetwork.getGuestType() == GuestIpType.Virtual && routerNetwork.getTrafficType() == TrafficType.Guest)) {
|
||||
networksToCheck.add(routerNetwork);
|
||||
}
|
||||
}
|
||||
|
||||
boolean toStop = true;
|
||||
for (Network network : networksToCheck) {
|
||||
int count = _networkMgr.getActiveNicsInNetwork(network.getId());
|
||||
if (count > 1) {
|
||||
s_logger.trace("Network id=" + network.getId() + " used by router " + router + " has more than 1 active nic (number of nics is " + count + ")");
|
||||
toStop = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (toStop) {
|
||||
s_logger.trace("Adding router " + router + " to stop list of Router Monitor");
|
||||
routersToStop.add(router.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return routersToStop;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,13 +36,13 @@ import com.cloud.exception.ResourceUnavailableException;
|
|||
import com.cloud.network.IPAddressVO;
|
||||
import com.cloud.network.IpAddress;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.GuestIpType;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.network.rules.FirewallRule.State;
|
||||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
import com.cloud.user.UserContext;
|
||||
|
|
|
|||
|
|
@ -323,9 +323,8 @@ public class NetworkOfferingVO implements NetworkOffering {
|
|||
* Network Offering for all system vms.
|
||||
* @param name
|
||||
* @param trafficType
|
||||
* @param type
|
||||
*/
|
||||
public NetworkOfferingVO(String name, TrafficType trafficType, GuestIpType type) {
|
||||
public NetworkOfferingVO(String name, TrafficType trafficType) {
|
||||
this(name, "System Offering for " + name, trafficType, true, false, null, null, null, false, Availability.Required, false, false, false, false, false, false, false);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ import com.cloud.domain.dao.DomainDao;
|
|||
import com.cloud.exception.InternalErrorException;
|
||||
import com.cloud.exception.InvalidParameterValueException;
|
||||
import com.cloud.hypervisor.Hypervisor.HypervisorType;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Network.State;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
|
|
@ -667,7 +668,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
String multicastRateStr = _configDao.getValue("multicast.throttling.rate");
|
||||
int networkRate = ((networkRateStr == null) ? 200 : Integer.parseInt(networkRateStr));
|
||||
int multicastRate = ((multicastRateStr == null) ? 10 : Integer.parseInt(multicastRateStr));
|
||||
NetworkOffering.GuestIpType guestIpType = useVirtualNetwork ? NetworkOffering.GuestIpType.Virtual : NetworkOffering.GuestIpType.Direct;
|
||||
Network.GuestIpType guestIpType = useVirtualNetwork ? Network.GuestIpType.Virtual : Network.GuestIpType.Direct;
|
||||
tags = cleanupTags(tags);
|
||||
ServiceOfferingVO offering = new ServiceOfferingVO(name, cpu, ramSize, speed, networkRate, multicastRate, offerHA, displayText, guestIpType, localStorageRequired, false, tags, false);
|
||||
|
||||
|
|
@ -696,15 +697,15 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
Integer rateMbps = getIntegerConfigValue(Config.NetworkThrottlingRate.key(), null);
|
||||
Integer multicastRateMbps = getIntegerConfigValue(Config.MulticastThrottlingRate.key(), null);
|
||||
|
||||
NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemPublicNetwork, TrafficType.Public, null);
|
||||
NetworkOfferingVO publicNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemPublicNetwork, TrafficType.Public);
|
||||
publicNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(publicNetworkOffering);
|
||||
NetworkOfferingVO managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemManagementNetwork, TrafficType.Management, null);
|
||||
NetworkOfferingVO managementNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemManagementNetwork, TrafficType.Management);
|
||||
managementNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(managementNetworkOffering);
|
||||
NetworkOfferingVO controlNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemControlNetwork, TrafficType.Control, null);
|
||||
NetworkOfferingVO controlNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemControlNetwork, TrafficType.Control);
|
||||
controlNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(controlNetworkOffering);
|
||||
NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemStorageNetwork, TrafficType.Storage, null);
|
||||
NetworkOfferingVO storageNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SystemStorageNetwork, TrafficType.Storage);
|
||||
storageNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(storageNetworkOffering);
|
||||
NetworkOfferingVO guestNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SysteGuestNetwork, TrafficType.Guest, null);
|
||||
NetworkOfferingVO guestNetworkOffering = new NetworkOfferingVO(NetworkOfferingVO.SysteGuestNetwork, TrafficType.Guest);
|
||||
guestNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(guestNetworkOffering);
|
||||
|
||||
NetworkOfferingVO defaultGuestNetworkOffering = new NetworkOfferingVO(NetworkOffering.DefaultVirtualizedNetworkOffering, "Virtual Vlan", TrafficType.Guest, false, false, rateMbps, multicastRateMbps, null, true, Availability.Required, false, false, false, false, false, false, false);
|
||||
|
|
@ -732,7 +733,6 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
|||
guruNames.put(TrafficType.Storage, PodBasedNetworkGuru.class.getSimpleName());
|
||||
guruNames.put(TrafficType.Guest, DirectPodBasedNetworkGuru.class.getSimpleName());
|
||||
|
||||
|
||||
for (DataCenterVO zone : zones) {
|
||||
long zoneId = zone.getId();
|
||||
long accountId = 1L;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ import javax.persistence.PrimaryKeyJoinColumn;
|
|||
import javax.persistence.Table;
|
||||
import javax.persistence.Transient;
|
||||
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
|
||||
|
|
@ -56,13 +56,13 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
|
|||
|
||||
@Column(name="guest_ip_type")
|
||||
@Enumerated(EnumType.STRING)
|
||||
private NetworkOffering.GuestIpType guestIpType;
|
||||
private Network.GuestIpType guestIpType;
|
||||
|
||||
protected ServiceOfferingVO() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, NetworkOffering.GuestIpType guestIpType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse) {
|
||||
public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, Network.GuestIpType guestIpType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse) {
|
||||
super(name, displayText, false, tags, recreatable, useLocalStorage, systemUse,false);
|
||||
this.cpu = cpu;
|
||||
this.ramSize = ramSize;
|
||||
|
|
@ -73,7 +73,7 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
|
|||
this.guestIpType = guestIpType;
|
||||
}
|
||||
|
||||
public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, NetworkOffering.GuestIpType guestIpType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, Long domainId) {
|
||||
public ServiceOfferingVO(String name, int cpu, int ramSize, int speed, int rateMbps, int multicastRateMbps, boolean offerHA, String displayText, Network.GuestIpType guestIpType, boolean useLocalStorage, boolean recreatable, String tags, boolean systemUse, Long domainId) {
|
||||
super(name, displayText, false, tags, recreatable, useLocalStorage, systemUse,false,domainId);
|
||||
this.cpu = cpu;
|
||||
this.ramSize = ramSize;
|
||||
|
|
@ -149,12 +149,12 @@ public class ServiceOfferingVO extends DiskOfferingVO implements ServiceOffering
|
|||
return multicastRateMbps;
|
||||
}
|
||||
|
||||
public void setGuestIpType(NetworkOffering.GuestIpType guestIpType) {
|
||||
public void setGuestIpType(Network.GuestIpType guestIpType) {
|
||||
this.guestIpType = guestIpType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NetworkOffering.GuestIpType getGuestIpType() {
|
||||
public Network.GuestIpType getGuestIpType() {
|
||||
return guestIpType;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ import com.cloud.capacity.dao.CapacityDao;
|
|||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.HostPodVO;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
|
|
@ -150,14 +150,14 @@ public class LocalStoragePoolAllocator extends FirstFitStoragePoolAllocator {
|
|||
}
|
||||
} else if(vm.getType() == VirtualMachine.Type.ConsoleProxy) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomP", 1,
|
||||
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
|
||||
_proxyRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true);
|
||||
} else if(vm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true);
|
||||
} else if(vm.getType() == VirtualMachine.Type.DomainRouter) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true);
|
||||
} else {
|
||||
assert(false) : "Unsupported system vm type";
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, false);
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, false);
|
||||
}
|
||||
|
||||
long usedMemory = calcHostAllocatedCpuMemoryCapacity(vmOnHost, CapacityVO.CAPACITY_TYPE_MEMORY);
|
||||
|
|
@ -256,14 +256,14 @@ public class LocalStoragePoolAllocator extends FirstFitStoragePoolAllocator {
|
|||
so = _offeringDao.findById(userVm.getServiceOfferingId());
|
||||
} else if(vm.getType() == VirtualMachine.Type.ConsoleProxy) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomP", 1,
|
||||
_proxyRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
|
||||
_proxyRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true);
|
||||
} else if(vm.getType() == VirtualMachine.Type.SecondaryStorageVm) {
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
|
||||
so = new ServiceOfferingVO("Fake Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true);
|
||||
} else if(vm.getType() == VirtualMachine.Type.DomainRouter) {
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, true);
|
||||
so = new ServiceOfferingVO("Fake Offering For DomR", 1, _routerRamSize, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, true);
|
||||
} else {
|
||||
assert(false) : "Unsupported system vm type";
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, NetworkOffering.GuestIpType.Virtual, false, true, null, false);
|
||||
so = new ServiceOfferingVO("Fake Offering For unknow system VM", 1, 128, 0, 0, 0, false, null, Network.GuestIpType.Virtual, false, true, null, false);
|
||||
}
|
||||
|
||||
if(capacityType == CapacityVO.CAPACITY_TYPE_MEMORY) {
|
||||
|
|
|
|||
|
|
@ -82,12 +82,12 @@ import com.cloud.info.RunningHostCountInfo;
|
|||
import com.cloud.info.RunningHostInfoAgregator;
|
||||
import com.cloud.info.RunningHostInfoAgregator.ZoneHostInfo;
|
||||
import com.cloud.network.IpAddrAllocator;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
import com.cloud.network.dao.NetworkDao;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offerings.NetworkOfferingVO;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDao;
|
||||
|
|
@ -943,7 +943,7 @@ public class SecondaryStorageManagerImpl implements SecondaryStorageVmManager, V
|
|||
|
||||
|
||||
boolean useLocalStorage = Boolean.parseBoolean(configs.get(Config.SystemVMUseLocalStorage.key()));
|
||||
_serviceOffering = new ServiceOfferingVO("System Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, true, null, NetworkOffering.GuestIpType.Virtual, useLocalStorage, true, null, true);
|
||||
_serviceOffering = new ServiceOfferingVO("System Offering For Secondary Storage VM", 1, _secStorageVmRamSize, 0, 0, 0, true, null, Network.GuestIpType.Virtual, useLocalStorage, true, null, true);
|
||||
_serviceOffering.setUniqueName("Cloud.com-SecondaryStorage");
|
||||
_serviceOffering = _offeringDao.persistSystemServiceOffering(_serviceOffering);
|
||||
_template = _templateDao.findConsoleProxyTemplate();
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ import org.xml.sax.SAXException;
|
|||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.service.ServiceOfferingVO;
|
||||
import com.cloud.service.dao.ServiceOfferingDaoImpl;
|
||||
import com.cloud.storage.DiskOfferingVO;
|
||||
|
|
@ -751,11 +751,11 @@ public class DatabaseConfig {
|
|||
boolean ha = Boolean.parseBoolean(_currentObjectParams.get("enableHA"));
|
||||
boolean mirroring = Boolean.parseBoolean(_currentObjectParams.get("mirrored"));
|
||||
String guestIpType = _currentObjectParams.get("guestIpType");
|
||||
NetworkOffering.GuestIpType type = null;
|
||||
Network.GuestIpType type = null;
|
||||
if (guestIpType == null) {
|
||||
type = NetworkOffering.GuestIpType.Virtual;
|
||||
type = Network.GuestIpType.Virtual;
|
||||
} else {
|
||||
type = NetworkOffering.GuestIpType.valueOf(guestIpType);
|
||||
type = Network.GuestIpType.valueOf(guestIpType);
|
||||
}
|
||||
|
||||
boolean useLocalStorage;
|
||||
|
|
|
|||
|
|
@ -122,7 +122,6 @@ import com.cloud.network.IpAddrAllocator;
|
|||
import com.cloud.network.Network;
|
||||
import com.cloud.network.NetworkManager;
|
||||
import com.cloud.network.NetworkVO;
|
||||
import com.cloud.network.Networks.BroadcastDomainType;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.dao.FirewallRulesDao;
|
||||
import com.cloud.network.dao.IPAddressDao;
|
||||
|
|
@ -134,7 +133,6 @@ import com.cloud.network.router.VirtualNetworkApplianceManager;
|
|||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.network.security.SecurityGroupManager;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.offering.NetworkOffering.GuestIpType;
|
||||
import com.cloud.offering.ServiceOffering;
|
||||
import com.cloud.offerings.dao.NetworkOfferingDao;
|
||||
import com.cloud.server.Criteria;
|
||||
|
|
@ -933,7 +931,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
public void releaseGuestIpAddress(UserVmVO userVm) {
|
||||
ServiceOffering offering = _offeringDao.findById(userVm.getServiceOfferingId());
|
||||
|
||||
if (offering.getGuestIpType() != NetworkOffering.GuestIpType.Virtual) {
|
||||
if (offering.getGuestIpType() != Network.GuestIpType.Virtual) {
|
||||
IPAddressVO guestIP = (userVm.getGuestIpAddress() == null) ? null : _ipAddressDao.findById(new Ip(userVm.getGuestIpAddress()));
|
||||
if (guestIP != null && guestIP.getAllocatedTime() != null) {
|
||||
_ipAddressDao.unassignIpAddress(new Ip(userVm.getGuestIpAddress()));
|
||||
|
|
@ -2672,7 +2670,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
|||
}
|
||||
|
||||
if (useVirtualNetwork != null) {
|
||||
sc.setJoinParameters("serviceSearch", "guestIpType", NetworkOffering.GuestIpType.Virtual.toString());
|
||||
sc.setJoinParameters("serviceSearch", "guestIpType", Network.GuestIpType.Virtual.toString());
|
||||
}
|
||||
|
||||
if (keyword != null) {
|
||||
|
|
|
|||
|
|
@ -92,9 +92,6 @@ public interface DomainRouterDao extends GenericDao<DomainRouterVO, Long>, State
|
|||
* @return DomainRouterVO or null if not found.
|
||||
*/
|
||||
public DomainRouterVO findByPublicIpAddress(String ipAddress);
|
||||
|
||||
|
||||
public List<Long> findLonelyRouters();
|
||||
|
||||
/**
|
||||
* Gets the next dhcp ip address to be used for vms from this domain router.
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ package com.cloud.vm.dao;
|
|||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
|
@ -46,7 +45,6 @@ import com.cloud.vm.VirtualMachine.State;
|
|||
public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> implements DomainRouterDao {
|
||||
private static final Logger s_logger = Logger.getLogger(DomainRouterDaoImpl.class);
|
||||
|
||||
private static final String FindLonelyRoutersSql = "SELECT dr.id FROM domain_router dr, vm_instance vm WHERE dr.id=vm.id AND vm.state = 'Running' AND dr.id NOT IN (SELECT DISTINCT domain_router_id FROM user_vm uvm, vm_instance vmi WHERE (vmi.state = 'Running' OR vmi.state = 'Starting' OR vmi.state='Stopping' OR vmi.state = 'Migrating') AND vmi.id = uvm.id)";
|
||||
private static final String GetNextDhcpAddressSql = "UPDATE domain_router set dhcp_ip_address = (@LAST_DHCP:=dhcp_ip_address) + 1 WHERE id = ?";
|
||||
private static final String GetLastDhcpSql = "SELECT @LAST_DHCP";
|
||||
|
||||
|
|
@ -255,24 +253,6 @@ public class DomainRouterDaoImpl extends GenericDaoBase<DomainRouterVO, Long> im
|
|||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Long> findLonelyRouters() {
|
||||
ArrayList<Long> ids = new ArrayList<Long>();
|
||||
PreparedStatement pstmt = null;
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
try {
|
||||
pstmt = txn.prepareAutoCloseStatement(FindLonelyRoutersSql);
|
||||
ResultSet rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
ids.add(rs.getLong(1));
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Problem finding routers: " + pstmt.toString(), e);
|
||||
}
|
||||
return ids;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getNextDhcpIpAddress(long id) {
|
||||
Transaction txn = Transaction.currentTxn();
|
||||
|
|
|
|||
|
|
@ -84,4 +84,6 @@ public interface VMInstanceDao extends GenericDao<VMInstanceVO, Long>, StateDao<
|
|||
List<VMInstanceVO> listByZoneIdAndType(long zoneId, VirtualMachine.Type type);
|
||||
List<VMInstanceVO> listUpByHostId(Long hostId);
|
||||
List<VMInstanceVO> listByLastHostId(Long hostId);
|
||||
|
||||
List<VMInstanceVO> listByTypeAndState(State state, VirtualMachine.Type type);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
|||
protected final SearchBuilder<VMInstanceVO> HostIdTypesSearch;
|
||||
protected final SearchBuilder<VMInstanceVO> HostIdUpTypesSearch;
|
||||
protected final SearchBuilder<VMInstanceVO> HostUpSearch;
|
||||
protected final SearchBuilder<VMInstanceVO> TypeStateSearch;
|
||||
|
||||
protected final Attribute _updateTimeAttr;
|
||||
|
||||
|
|
@ -136,6 +137,11 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
|||
HostUpSearch.and("states", HostUpSearch.entity().getState(), SearchCriteria.Op.IN);
|
||||
HostUpSearch.done();
|
||||
|
||||
TypeStateSearch = createSearchBuilder();
|
||||
TypeStateSearch.and("type", TypeStateSearch.entity().getType(), SearchCriteria.Op.EQ);
|
||||
TypeStateSearch.and("state", TypeStateSearch.entity().getState(), SearchCriteria.Op.EQ);
|
||||
TypeStateSearch.done();
|
||||
|
||||
_updateTimeAttr = _allAttributes.get("updateTime");
|
||||
assert _updateTimeAttr != null : "Couldn't get this updateTime attribute";
|
||||
}
|
||||
|
|
@ -282,6 +288,14 @@ public class VMInstanceDaoImpl extends GenericDaoBase<VMInstanceVO, Long> implem
|
|||
sc.setParameters("types", (Object[]) types);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<VMInstanceVO> listByTypeAndState(State state, VirtualMachine.Type type) {
|
||||
SearchCriteria<VMInstanceVO> sc = TypeStateSearch.create();
|
||||
sc.setParameters("type", type);
|
||||
sc.setParameters("state", state);
|
||||
return listBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public VMInstanceVO findByIdTypes(long id, Type... types) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue