mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-03 04:12:31 +01:00
Merge branch 'master' into api_limit
This commit is contained in:
commit
e83fe471c7
@ -170,7 +170,6 @@ public interface Network extends ControlledEntity, InternalIdentity, Identity {
|
||||
public static final Capability AllowDnsSuffixModification = new Capability("AllowDnsSuffixModification");
|
||||
public static final Capability RedundantRouter = new Capability("RedundantRouter");
|
||||
public static final Capability ElasticIp = new Capability("ElasticIp");
|
||||
public static final Capability AssociatePublicIP = new Capability("AssociatePublicIP");
|
||||
public static final Capability ElasticLb = new Capability("ElasticLb");
|
||||
public static final Capability AutoScaleCounters = new Capability("AutoScaleCounters");
|
||||
public static final Capability InlineMode = new Capability("InlineMode");
|
||||
|
||||
@ -41,7 +41,7 @@ public interface NetworkService {
|
||||
|
||||
List<? extends Network> getIsolatedNetworksOwnedByAccountInZone(long zoneId, Account owner);
|
||||
|
||||
IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) throws ResourceAllocationException,
|
||||
IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId) throws ResourceAllocationException,
|
||||
InsufficientAddressCapacityException, ConcurrentOperationException;
|
||||
|
||||
boolean releaseIpAddress(long ipAddressId) throws InsufficientAddressCapacityException;
|
||||
|
||||
@ -105,8 +105,6 @@ public interface NetworkOffering extends InfrastructureEntity, InternalIdentity,
|
||||
|
||||
boolean getElasticIp();
|
||||
|
||||
boolean getAssociatePublicIP();
|
||||
|
||||
boolean getElasticLb();
|
||||
|
||||
boolean getSpecifyIpRanges();
|
||||
|
||||
@ -213,7 +213,7 @@ public class AssociateIPAddrCmd extends BaseAsyncCreateCmd {
|
||||
@Override
|
||||
public void create() throws ResourceAllocationException{
|
||||
try {
|
||||
IpAddress ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), getZoneId(), getNetworkId());
|
||||
IpAddress ip = _networkService.allocateIP(_accountService.getAccount(getEntityOwnerId()), false, getZoneId());
|
||||
|
||||
if (ip != null) {
|
||||
this.setEntityId(ip.getId());
|
||||
|
||||
@ -122,7 +122,7 @@ public class F5ExternalLoadBalancerElement extends ExternalLoadBalancerDeviceMan
|
||||
ConfigurationDao _configDao;
|
||||
|
||||
private boolean canHandle(Network config) {
|
||||
if ((config.getGuestType() != Network.GuestType.Isolated && config.getGuestType() != Network.GuestType.Shared) || config.getTrafficType() != TrafficType.Guest) {
|
||||
if (config.getGuestType() != Network.GuestType.Isolated || config.getTrafficType() != TrafficType.Guest) {
|
||||
s_logger.trace("Not handling network with Type " + config.getGuestType() + " and traffic type " + config.getTrafficType());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -130,8 +130,7 @@ public class JuniperSRXExternalFirewallElement extends ExternalFirewallDeviceMan
|
||||
|
||||
private boolean canHandle(Network network, Service service) {
|
||||
DataCenter zone = _configMgr.getZone(network.getDataCenterId());
|
||||
if ((zone.getNetworkType() == NetworkType.Advanced && !(network.getGuestType() == Network.GuestType.Isolated || network.getGuestType() == Network.GuestType.Shared ))
|
||||
|| (zone.getNetworkType() == NetworkType.Basic && network.getGuestType() != Network.GuestType.Shared)) {
|
||||
if ((zone.getNetworkType() == NetworkType.Advanced && network.getGuestType() != Network.GuestType.Isolated) || (zone.getNetworkType() == NetworkType.Basic && network.getGuestType() != Network.GuestType.Shared)) {
|
||||
s_logger.trace("Element " + getProvider().getName() + "is not handling network type = " + network.getGuestType());
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -154,8 +154,7 @@ StaticNatServiceProvider {
|
||||
|
||||
private boolean canHandle(Network config, Service service) {
|
||||
DataCenter zone = _dcDao.findById(config.getDataCenterId());
|
||||
boolean handleInAdvanceZone = (zone.getNetworkType() == NetworkType.Advanced &&
|
||||
(config.getGuestType() == Network.GuestType.Isolated || config.getGuestType() == Network.GuestType.Shared) && config.getTrafficType() == TrafficType.Guest);
|
||||
boolean handleInAdvanceZone = (zone.getNetworkType() == NetworkType.Advanced && config.getGuestType() == Network.GuestType.Isolated && config.getTrafficType() == TrafficType.Guest);
|
||||
boolean handleInBasicZone = (zone.getNetworkType() == NetworkType.Basic && config.getGuestType() == Network.GuestType.Shared && config.getTrafficType() == TrafficType.Guest);
|
||||
|
||||
if (!(handleInAdvanceZone || handleInBasicZone)) {
|
||||
|
||||
@ -3163,33 +3163,20 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
|
||||
void validateStaticNatServiceCapablities(Map<Capability, String> staticNatServiceCapabilityMap) {
|
||||
if (staticNatServiceCapabilityMap != null && !staticNatServiceCapabilityMap.isEmpty()) {
|
||||
if (staticNatServiceCapabilityMap.keySet().size() > 2) {
|
||||
throw new InvalidParameterValueException("Only " + Capability.ElasticIp.getName() + " and " + Capability.AssociatePublicIP.getName() + " capabilitiy can be sepcified for static nat service");
|
||||
if (staticNatServiceCapabilityMap.keySet().size() > 1) {
|
||||
throw new InvalidParameterValueException("Only " + Capability.ElasticIp.getName() + " capability can be specified for static nat service");
|
||||
}
|
||||
boolean eipEnabled = false;
|
||||
boolean eipDisabled = false;
|
||||
boolean associatePublicIP = true;
|
||||
|
||||
for (Capability capability : staticNatServiceCapabilityMap.keySet()) {
|
||||
String value = staticNatServiceCapabilityMap.get(capability);
|
||||
if (capability == Capability.ElasticIp) {
|
||||
eipEnabled = value.contains("true");
|
||||
eipDisabled = value.contains("false");
|
||||
if (!eipEnabled && !eipDisabled) {
|
||||
boolean enabled = value.contains("true");
|
||||
boolean disabled = value.contains("false");
|
||||
if (!enabled && !disabled) {
|
||||
throw new InvalidParameterValueException("Unknown specified value for " + Capability.ElasticIp.getName());
|
||||
}
|
||||
} else if (capability == Capability.AssociatePublicIP) {
|
||||
if (value.contains("true")) {
|
||||
associatePublicIP = true;
|
||||
} else if (value.contains("false")) {
|
||||
associatePublicIP = false;
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Unknown specified value for " + Capability.AssociatePublicIP.getName());
|
||||
}
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Only " + Capability.ElasticIp.getName() + " and " + Capability.AssociatePublicIP.getName() + " capabilitiy can be sepcified for static nat service");
|
||||
}
|
||||
if (eipDisabled && associatePublicIP) {
|
||||
throw new InvalidParameterValueException("Capability " + Capability.AssociatePublicIP.getName() + " can only be set when capability " + Capability.ElasticIp.getName() + " is true");
|
||||
throw new InvalidParameterValueException("Only " + Capability.ElasticIp.getName() + " capability can be specified for static nat service");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3243,7 +3230,6 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
boolean sharedSourceNat = false;
|
||||
boolean redundantRouter = false;
|
||||
boolean elasticIp = false;
|
||||
boolean associatePublicIp = false;
|
||||
boolean inline = false;
|
||||
if (serviceCapabilityMap != null && !serviceCapabilityMap.isEmpty()) {
|
||||
Map<Capability, String> lbServiceCapabilityMap = serviceCapabilityMap.get(Service.Lb);
|
||||
@ -3293,17 +3279,13 @@ public class ConfigurationManagerImpl implements ConfigurationManager, Configura
|
||||
String param = staticNatServiceCapabilityMap.get(Capability.ElasticIp);
|
||||
if (param != null) {
|
||||
elasticIp = param.contains("true");
|
||||
String associatePublicIP = staticNatServiceCapabilityMap.get(Capability.AssociatePublicIP);
|
||||
if (associatePublicIP != null) {
|
||||
associatePublicIp = associatePublicIP.contains("true");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NetworkOfferingVO offering = new NetworkOfferingVO(name, displayText, trafficType, systemOnly, specifyVlan,
|
||||
networkRate, multicastRate, isDefault, availability, tags, type, conserveMode, dedicatedLb,
|
||||
sharedSourceNat, redundantRouter, elasticIp, elasticLb, associatePublicIp, specifyIpRanges, inline);
|
||||
sharedSourceNat, redundantRouter, elasticIp, elasticLb, specifyIpRanges, inline);
|
||||
|
||||
if (serviceOfferingId != null) {
|
||||
offering.setServiceOfferingId(serviceOfferingId);
|
||||
|
||||
@ -16,58 +16,19 @@
|
||||
// under the License.
|
||||
package com.cloud.network;
|
||||
|
||||
import java.net.URI;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.utils.db.*;
|
||||
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.Listener;
|
||||
import com.cloud.agent.api.*;
|
||||
import com.cloud.agent.api.to.NicTO;
|
||||
import com.cloud.alert.AlertManager;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
|
||||
import com.cloud.configuration.Config;
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.configuration.Resource.ResourceType;
|
||||
import com.cloud.configuration.dao.ConfigurationDao;
|
||||
import com.cloud.dc.*;
|
||||
import com.cloud.dc.DataCenter.NetworkType;
|
||||
import com.cloud.dc.DataCenterVO;
|
||||
import com.cloud.dc.Pod;
|
||||
import com.cloud.dc.PodVlanMapVO;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
import com.cloud.dc.VlanVO;
|
||||
import com.cloud.dc.dao.AccountVlanMapDao;
|
||||
import com.cloud.dc.dao.DataCenterDao;
|
||||
import com.cloud.dc.dao.PodVlanMapDao;
|
||||
@ -110,13 +71,6 @@ import com.cloud.network.lb.LoadBalancingRule.LbStickinessPolicy;
|
||||
import com.cloud.network.lb.LoadBalancingRulesManager;
|
||||
import com.cloud.network.rules.*;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
import com.cloud.network.rules.FirewallRuleVO;
|
||||
import com.cloud.network.rules.PortForwardingRule;
|
||||
import com.cloud.network.rules.PortForwardingRuleVO;
|
||||
import com.cloud.network.rules.RulesManager;
|
||||
import com.cloud.network.rules.StaticNat;
|
||||
import com.cloud.network.rules.StaticNatRule;
|
||||
import com.cloud.network.rules.StaticNatRuleImpl;
|
||||
import com.cloud.network.rules.dao.PortForwardingRulesDao;
|
||||
import com.cloud.network.vpc.NetworkACLManager;
|
||||
import com.cloud.network.vpc.PrivateIpVO;
|
||||
@ -145,30 +99,38 @@ import com.cloud.utils.component.Adapters;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.db.*;
|
||||
import com.cloud.utils.db.JoinBuilder.JoinType;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.Ip;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.Nic;
|
||||
import com.cloud.vm.NicProfile;
|
||||
import com.cloud.vm.NicVO;
|
||||
import com.cloud.vm.ReservationContext;
|
||||
import com.cloud.vm.ReservationContextImpl;
|
||||
import com.cloud.vm.SecondaryStorageVmVO;
|
||||
import com.cloud.vm.UserVmVO;
|
||||
import com.cloud.vm.VMInstanceVO;
|
||||
import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.*;
|
||||
import com.cloud.vm.VirtualMachine.Type;
|
||||
import com.cloud.vm.VirtualMachineProfile;
|
||||
import com.cloud.vm.VirtualMachineProfileImpl;
|
||||
import com.cloud.vm.dao.DomainRouterDao;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import com.cloud.vm.dao.VMInstanceDao;
|
||||
import edu.emory.mathcs.backport.java.util.Collections;
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.net.URI;
|
||||
import java.security.InvalidParameterException;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* NetworkManagerImpl implements NetworkManager.
|
||||
@ -980,39 +942,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_NET_IP_ASSIGN, eventDescription = "allocating Ip", create = true)
|
||||
public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId)
|
||||
throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
|
||||
if (networkId != null) {
|
||||
Network network = _networksDao.findById(networkId);
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Invalid network id is given");
|
||||
}
|
||||
if (network.getGuestType() == Network.GuestType.Shared) {
|
||||
DataCenter zone = _configMgr.getZone(zoneId);
|
||||
if (zone == null) {
|
||||
throw new InvalidParameterValueException("Invalid zone Id is given");
|
||||
}
|
||||
|
||||
// if shared network in the advanced zone, then check the caller against the network for 'AccessType.UseNetwork'
|
||||
if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) && zone.getNetworkType() == NetworkType.Advanced) {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
long callerUserId = UserContext.current().getCallerUserId();
|
||||
_accountMgr.checkAccess(caller, AccessType.UseNetwork, false, network);
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId());
|
||||
}
|
||||
return allocateIp(ipOwner, false, caller, zone);
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Associate IP address can only be called on the shared networks in the advanced zone" +
|
||||
" with Firewall/Source Nat/Static Nat/Port Forwarding/Load balancing services enabled");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return allocateIP(ipOwner, false, zoneId);
|
||||
}
|
||||
|
||||
public IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId)
|
||||
throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
Account caller = UserContext.current().getCaller();
|
||||
@ -1022,11 +951,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
DataCenter zone = _configMgr.getZone(zoneId);
|
||||
|
||||
return allocateIp(ipOwner, isSystem, caller, zone);
|
||||
return allocateIp(ipOwner, isSystem, caller, callerUserId, zone);
|
||||
}
|
||||
|
||||
@DB
|
||||
public IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, DataCenter zone)
|
||||
public IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerUserId, DataCenter zone)
|
||||
throws ConcurrentOperationException, ResourceAllocationException,
|
||||
InsufficientAddressCapacityException {
|
||||
|
||||
@ -1047,7 +976,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
Account accountToLock = null;
|
||||
try {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Associate IP address called by the user " + caller.getId());
|
||||
s_logger.debug("Associate IP address called by the user " + callerUserId + " account " + ipOwner.getId());
|
||||
}
|
||||
accountToLock = _accountDao.acquireInLockTable(ipOwner.getId());
|
||||
if (accountToLock == null) {
|
||||
@ -1127,22 +1056,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
IPAddressVO ipToAssoc = _ipAddressDao.findById(ipId);
|
||||
if (ipToAssoc != null) {
|
||||
Network network = _networksDao.findById(networkId);
|
||||
if (network == null) {
|
||||
throw new InvalidParameterValueException("Invalid network id is given");
|
||||
}
|
||||
|
||||
DataCenter zone = _configMgr.getZone(network.getDataCenterId());
|
||||
if (network.getGuestType() == Network.GuestType.Shared && zone.getNetworkType() == NetworkType.Advanced) {
|
||||
if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId())) {
|
||||
_accountMgr.checkAccess(UserContext.current().getCaller(), AccessType.UseNetwork, false, network);
|
||||
} else {
|
||||
throw new InvalidParameterValueException("IP can be associated with guest network of 'shared' type only if" +
|
||||
"network service Source Nat, Static Nat, Port Forwarding, Load balancing, firewall are enabled in the network");
|
||||
}
|
||||
} else {
|
||||
_accountMgr.checkAccess(caller, null, true, ipToAssoc);
|
||||
}
|
||||
_accountMgr.checkAccess(caller, null, true, ipToAssoc);
|
||||
owner = _accountMgr.getAccount(ipToAssoc.getAllocatedToAccountId());
|
||||
} else {
|
||||
s_logger.debug("Unable to find ip address by id: " + ipId);
|
||||
@ -1169,20 +1083,16 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
throw new InvalidParameterValueException("Ip address can be associated to the network with trafficType " + TrafficType.Guest);
|
||||
}
|
||||
|
||||
// Check that network belongs to IP owner - skip this check
|
||||
// - if zone is basic zone as there is just one guest network,
|
||||
// - if shared network in Advanced zone
|
||||
// - and it belongs to the system
|
||||
if (network.getAccountId() != owner.getId()) {
|
||||
if (zone.getNetworkType() != NetworkType.Basic && !(zone.getNetworkType() == NetworkType.Advanced && network.getGuestType() == Network.GuestType.Shared)) {
|
||||
throw new InvalidParameterValueException("The owner of the network is not the same as owner of the IP");
|
||||
}
|
||||
// Check that network belongs to IP owner - skip this check for Basic zone as there is just one guest network,
|
||||
// and it belongs to the system
|
||||
if (zone.getNetworkType() != NetworkType.Basic && network.getAccountId() != owner.getId()) {
|
||||
throw new InvalidParameterValueException("The owner of the network is not the same as owner of the IP");
|
||||
}
|
||||
|
||||
// In Advance zone only allow to do IP assoc
|
||||
// - for Isolated networks with source nat service enabled
|
||||
// - for shared networks with source nat service enabled
|
||||
if (zone.getNetworkType() == NetworkType.Advanced && (!areServicesSupportedInNetwork(network.getId(), Service.SourceNat))) {
|
||||
// In Advance zone only allow to do IP assoc for Isolated networks with source nat service enabled
|
||||
if (zone.getNetworkType() == NetworkType.Advanced &&
|
||||
!(network.getGuestType() == GuestType.Isolated && areServicesSupportedInNetwork(network.getId(),
|
||||
Service.SourceNat))) {
|
||||
throw new InvalidParameterValueException("In zone of type " + NetworkType.Advanced +
|
||||
" ip address can be associated only to the network of guest type " + GuestType.Isolated + " with the "
|
||||
+ Service.SourceNat.getName() + " enabled");
|
||||
@ -1953,21 +1863,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
try {
|
||||
NetworkGuru guru = _networkGurus.get(network.getGuruName());
|
||||
Network.State state = network.getState();
|
||||
if (state == Network.State.Implemented || state == Network.State.Implementing) {
|
||||
if (state == Network.State.Implemented || state == Network.State.Setup || state == Network.State.Implementing) {
|
||||
s_logger.debug("Network id=" + networkId + " is already implemented");
|
||||
implemented.set(guru, network);
|
||||
return implemented;
|
||||
}
|
||||
|
||||
if (state == Network.State.Setup) {
|
||||
DataCenterVO zone = _dcDao.findById(network.getDataCenterId());
|
||||
if (!isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) || (zone.getNetworkType() == NetworkType.Basic)) {
|
||||
s_logger.debug("Network id=" + networkId + " is already implemented");
|
||||
implemented.set(guru, network);
|
||||
return implemented;
|
||||
}
|
||||
}
|
||||
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Asking " + guru.getName() + " to implement " + network);
|
||||
}
|
||||
@ -2011,25 +1912,19 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
return super.equals(o); //To change body of overridden methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
private void implementNetworkElementsAndResources(DeployDestination dest, ReservationContext context,
|
||||
NetworkVO network, NetworkOfferingVO offering)
|
||||
throws ConcurrentOperationException, InsufficientAddressCapacityException, ResourceUnavailableException, InsufficientCapacityException {
|
||||
|
||||
// Associate a source NAT IP (if one isn't already associated with the network) if this is a
|
||||
// 1) 'Isolated' or 'Shared' guest virtual network in the advance zone
|
||||
// 2) network has sourceNat service
|
||||
// 3) network offering does not support a shared source NAT rule
|
||||
// If this is a 1) guest virtual network 2) network has sourceNat service 3) network offering does not support a
|
||||
// Shared source NAT rule,
|
||||
// associate a source NAT IP (if one isn't already associated with the network)
|
||||
|
||||
boolean sharedSourceNat = offering.getSharedSourceNat();
|
||||
DataCenter zone = _dcDao.findById(network.getDataCenterId());
|
||||
if (!sharedSourceNat && areServicesSupportedInNetwork(network.getId(), Service.SourceNat)
|
||||
&& (network.getGuestType() == Network.GuestType.Isolated ||
|
||||
(network.getGuestType() == Network.GuestType.Shared && zone.getNetworkType() == NetworkType.Advanced))) {
|
||||
if (network.getGuestType() == Network.GuestType.Isolated
|
||||
&& areServicesSupportedInNetwork(network.getId(), Service.SourceNat)
|
||||
&& !sharedSourceNat) {
|
||||
|
||||
List<IPAddressVO> ips = null;
|
||||
if (network.getVpcId() != null) {
|
||||
@ -2510,82 +2405,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
}
|
||||
}
|
||||
|
||||
private void checkSharedNetworkCidrOverlap(Long zoneId, long physicalNetworkId, String cidr) {
|
||||
if (zoneId == null || cidr == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
DataCenter zone = _dcDao.findById(zoneId);
|
||||
List<NetworkVO> networks = _networksDao.listByZone(zoneId);
|
||||
Map<Long, String> networkToCidr = new HashMap<Long, String>();
|
||||
|
||||
// check for CIDR overlap with all possible CIDR for isolated guest networks
|
||||
// in the zone when using external networking
|
||||
PhysicalNetworkVO pNetwork = _physicalNetworkDao.findById(physicalNetworkId);
|
||||
if (pNetwork.getVnet() != null) {
|
||||
String vlanRange[] = pNetwork.getVnet().split("-");
|
||||
int lowestVlanTag = Integer.valueOf(vlanRange[0]);
|
||||
int highestVlanTag = Integer.valueOf(vlanRange[1]);
|
||||
for (int vlan=lowestVlanTag; vlan <= highestVlanTag; ++vlan) {
|
||||
int offset = vlan - lowestVlanTag;
|
||||
String globalVlanBits = _configDao.getValue(Config.GuestVlanBits.key());
|
||||
int cidrSize = 8 + Integer.parseInt(globalVlanBits);
|
||||
String guestNetworkCidr = zone.getGuestNetworkCidr();
|
||||
String[] cidrTuple = guestNetworkCidr.split("\\/");
|
||||
long newCidrAddress = (NetUtils.ip2Long(cidrTuple[0]) & 0xff000000) | (offset << (32 - cidrSize));
|
||||
if (NetUtils.isNetworksOverlap(NetUtils.long2Ip(newCidrAddress), cidr)) {
|
||||
throw new InvalidParameterValueException("Specified CIDR for shared network conflict with CIDR that is reserved for zone vlan " + vlan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check for CIDR overlap with all CIDR's of the shared networks in the zone
|
||||
for (NetworkVO network : networks) {
|
||||
if (network.getGuestType() == GuestType.Isolated) {
|
||||
continue;
|
||||
}
|
||||
if (network.getCidr() != null) {
|
||||
networkToCidr.put(network.getId(), network.getCidr());
|
||||
}
|
||||
}
|
||||
if (networkToCidr != null && !networkToCidr.isEmpty()) {
|
||||
for (long networkId : networkToCidr.keySet()) {
|
||||
String ntwkCidr = networkToCidr.get(networkId);
|
||||
if (NetUtils.isNetworksOverlap(ntwkCidr, cidr)) {
|
||||
throw new InvalidParameterValueException("Specified CIDR for shared network conflict with CIDR of a shared network in the zone.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
public void checkVirtualNetworkCidrOverlap(Long zoneId, String cidr) {
|
||||
if (zoneId == null) {
|
||||
return;
|
||||
}
|
||||
if (cidr == null) {
|
||||
return;
|
||||
}
|
||||
List<NetworkVO> networks = _networksDao.listByZone(zoneId);
|
||||
Map<Long, String> networkToCidr = new HashMap<Long, String>();
|
||||
for (NetworkVO network : networks) {
|
||||
if (network.getGuestType() != GuestType.Isolated) {
|
||||
continue;
|
||||
}
|
||||
if (network.getCidr() != null) {
|
||||
networkToCidr.put(network.getId(), network.getCidr());
|
||||
}
|
||||
}
|
||||
if (networkToCidr == null || networkToCidr.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (long networkId : networkToCidr.keySet()) {
|
||||
String ntwkCidr = networkToCidr.get(networkId);
|
||||
if (NetUtils.isNetworksOverlap(ntwkCidr, cidr)) {
|
||||
throw new InvalidParameterValueException("Warning: The specified existing network has conflict CIDR subnets with new network!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_CREATE, eventDescription = "creating network")
|
||||
@ -2781,16 +2600,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
Collection<String> ntwkProviders = finalizeServicesAndProvidersForNetwork(ntwkOff, physicalNetworkId).values();
|
||||
if (cidr != null && providersConfiguredForExternalNetworking(ntwkProviders)) {
|
||||
if (ntwkOff.getGuestType() == GuestType.Shared && (zone.getNetworkType() == NetworkType.Advanced) &&
|
||||
isSharedNetworkOfferingWithServices(networkOfferingId)) {
|
||||
// validate if CIDR specified overlaps with any of the CIDR's allocated for isolated networks and shared networks in the zone
|
||||
checkSharedNetworkCidrOverlap(zoneId, pNtwk.getId(), cidr);
|
||||
} else {
|
||||
throw new InvalidParameterValueException("Cannot specify CIDR when using network offering with external devices!");
|
||||
}
|
||||
throw new InvalidParameterValueException("Cannot specify CIDR when using network offering with external devices!");
|
||||
}
|
||||
|
||||
|
||||
// Vlan is created in 2 cases - works in Advance zone only:
|
||||
// 1) GuestType is Shared
|
||||
// 2) GuestType is Isolated, but SourceNat service is disabled
|
||||
@ -2973,11 +2785,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
throw new InvalidParameterValueException("Network with vlan " + vlanId + " already exists in zone " + zoneId);
|
||||
}
|
||||
} else {
|
||||
//don't allow to creating shared network with given Vlan ID, if there already exists a isolated network or
|
||||
//shared network with same Vlan ID in the zone
|
||||
if (_networksDao.countByZoneUriAndGuestType(zoneId, uri, GuestType.Isolated) > 0 ||
|
||||
_networksDao.countByZoneUriAndGuestType(zoneId, uri, GuestType.Shared) > 0) {
|
||||
throw new InvalidParameterValueException("There is a isolated/shared network with vlan id: " + vlanId + " already exists " + "in zone " + zoneId);
|
||||
//don't allow to create Shared network with Vlan that already exists in the zone for Isolated networks
|
||||
if (_networksDao.countByZoneUriAndGuestType(zoneId, uri, GuestType.Isolated) > 0) {
|
||||
throw new InvalidParameterValueException("Isolated network with vlan " + vlanId + " already exists " +
|
||||
"in zone " + zoneId);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3565,13 +3376,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
|
||||
applyProfileToNetwork(network, profile);
|
||||
|
||||
DataCenterVO zone = _dcDao.findById(network.getDataCenterId());
|
||||
if (isSharedNetworkOfferingWithServices(network.getNetworkOfferingId()) && (zone.getNetworkType() == NetworkType.Advanced)) {
|
||||
network.setState(Network.State.Setup);
|
||||
} else {
|
||||
network.setState(Network.State.Allocated);
|
||||
}
|
||||
|
||||
network.setState(Network.State.Allocated);
|
||||
network.setRestartRequired(false);
|
||||
_networksDao.update(network.getId(), network);
|
||||
_networksDao.clearCheckForGc(networkId);
|
||||
@ -4517,19 +4322,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSharedNetworkOfferingWithServices(long networkOfferingId) {
|
||||
NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId);
|
||||
if ( (networkOffering.getGuestType() == Network.GuestType.Shared) && (
|
||||
areServicesSupportedByNetworkOffering(networkOfferingId, Service.SourceNat) ||
|
||||
areServicesSupportedByNetworkOffering(networkOfferingId, Service.StaticNat) ||
|
||||
areServicesSupportedByNetworkOffering(networkOfferingId, Service.Firewall) ||
|
||||
areServicesSupportedByNetworkOffering(networkOfferingId, Service.PortForwarding) ||
|
||||
areServicesSupportedByNetworkOffering(networkOfferingId, Service.Lb))) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areServicesSupportedByNetworkOffering(long networkOfferingId, Service... services) {
|
||||
return (_ntwkOfferingSrvcDao.areServicesSupportedByNetworkOffering(networkOfferingId, services));
|
||||
|
||||
@ -16,18 +16,6 @@
|
||||
// under the License.
|
||||
package com.cloud.network.rules;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.firewall.ListPortForwardingRulesCmd;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.configuration.ConfigurationManager;
|
||||
import com.cloud.domain.dao.DomainDao;
|
||||
import com.cloud.event.ActionEvent;
|
||||
@ -65,13 +53,8 @@ import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.Ternary;
|
||||
import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.JoinBuilder;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.*;
|
||||
import com.cloud.utils.db.SearchCriteria.Op;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.Ip;
|
||||
import com.cloud.vm.Nic;
|
||||
@ -80,6 +63,7 @@ import com.cloud.vm.VirtualMachine;
|
||||
import com.cloud.vm.VirtualMachine.Type;
|
||||
import com.cloud.vm.dao.NicDao;
|
||||
import com.cloud.vm.dao.UserVmDao;
|
||||
import org.apache.cloudstack.api.command.user.firewall.ListPortForwardingRulesCmd;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.ejb.Local;
|
||||
@ -1189,12 +1173,11 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
Network guestNetwork = _networkMgr.getNetwork(ipAddress.getAssociatedWithNetworkId());
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
if (offering.getElasticIp()) {
|
||||
if (offering.getAssociatePublicIP()) {
|
||||
getSystemIpAndEnableStaticNatForVm(_vmDao.findById(vmId), true);
|
||||
return true;
|
||||
}
|
||||
getSystemIpAndEnableStaticNatForVm(_vmDao.findById(vmId), true);
|
||||
return true;
|
||||
} else {
|
||||
return disableStaticNat(ipId, caller, ctx.getCallerUserId(), false);
|
||||
}
|
||||
return disableStaticNat(ipId, caller, ctx.getCallerUserId(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1380,11 +1363,6 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
Network guestNetwork = _networkMgr.getNetwork(nic.getNetworkId());
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
if (offering.getElasticIp()) {
|
||||
boolean isSystemVM = (vm.getType() == Type.ConsoleProxy || vm.getType() == Type.SecondaryStorageVm);
|
||||
// for user VM's associate public IP only if offering is marked to associate a public IP by default on start of VM
|
||||
if (!isSystemVM && !offering.getAssociatePublicIP()) {
|
||||
continue;
|
||||
}
|
||||
// check if there is already static nat enabled
|
||||
if (_ipAddressDao.findByAssociatedVmId(vm.getId()) != null && !getNewIp) {
|
||||
s_logger.debug("Vm " + vm + " already has ip associated with it in guest network " + guestNetwork);
|
||||
@ -1399,6 +1377,7 @@ public class RulesManagerImpl implements RulesManager, RulesService, Manager {
|
||||
|
||||
s_logger.debug("Allocated system ip " + ip + ", now enabling static nat on it for vm " + vm);
|
||||
|
||||
boolean isSystemVM = (vm.getType() == Type.ConsoleProxy || vm.getType() == Type.SecondaryStorageVm);
|
||||
try {
|
||||
success = enableStaticNat(ip.getId(), vm.getId(), guestNetwork.getId(), isSystemVM);
|
||||
} catch (NetworkRuleConflictException ex) {
|
||||
|
||||
@ -16,26 +16,10 @@
|
||||
// under the License.
|
||||
package com.cloud.offerings;
|
||||
|
||||
import com.cloud.network.Networks;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.EnumType;
|
||||
import javax.persistence.Enumerated;
|
||||
import javax.persistence.GeneratedValue;
|
||||
import javax.persistence.GenerationType;
|
||||
import javax.persistence.Id;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.apache.cloudstack.api.Identity;
|
||||
import com.cloud.network.Network;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.offering.NetworkOffering;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
import org.apache.cloudstack.api.InternalIdentity;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
@ -129,9 +113,6 @@ public class NetworkOfferingVO implements NetworkOffering {
|
||||
@Column(name = "elastic_lb_service")
|
||||
boolean elasticLb;
|
||||
|
||||
@Column(name = "eip_associate_public_ip")
|
||||
boolean eipAssociatePublicIp;
|
||||
|
||||
@Column(name = "inline")
|
||||
boolean inline;
|
||||
|
||||
@ -295,21 +276,19 @@ public class NetworkOfferingVO implements NetworkOffering {
|
||||
this.redundantRouter = false;
|
||||
this.elasticIp = false;
|
||||
this.elasticLb = false;
|
||||
this.eipAssociatePublicIp = true;
|
||||
this.inline = false;
|
||||
this.specifyIpRanges = specifyIpRanges;
|
||||
}
|
||||
|
||||
public NetworkOfferingVO(String name, String displayText, TrafficType trafficType, boolean systemOnly, boolean specifyVlan, Integer rateMbps, Integer multicastRateMbps, boolean isDefault,
|
||||
Availability availability, String tags, Network.GuestType guestType, boolean conserveMode, boolean dedicatedLb, boolean sharedSourceNat, boolean redundantRouter, boolean elasticIp, boolean elasticLb,
|
||||
boolean associatePublicIP, boolean specifyIpRanges, boolean inline) {
|
||||
boolean specifyIpRanges, boolean inline) {
|
||||
this(name, displayText, trafficType, systemOnly, specifyVlan, rateMbps, multicastRateMbps, isDefault, availability, tags, guestType, conserveMode, specifyIpRanges);
|
||||
this.dedicatedLB = dedicatedLb;
|
||||
this.sharedSourceNat = sharedSourceNat;
|
||||
this.redundantRouter = redundantRouter;
|
||||
this.elasticIp = elasticIp;
|
||||
this.elasticLb = elasticLb;
|
||||
this.eipAssociatePublicIp = associatePublicIP;
|
||||
this.inline = inline;
|
||||
}
|
||||
|
||||
@ -372,11 +351,6 @@ public class NetworkOfferingVO implements NetworkOffering {
|
||||
return elasticIp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAssociatePublicIP() {
|
||||
return eipAssociatePublicIp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getElasticLb() {
|
||||
return elasticLb;
|
||||
|
||||
@ -70,7 +70,6 @@ import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.utils.script.Script;
|
||||
import com.cloud.uuididentity.dao.IdentityDao;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
@ -972,7 +971,7 @@ public class ConfigurationServerImpl implements ConfigurationServer {
|
||||
"Offering for Shared networks with Elastic IP and Elastic LB capabilities",
|
||||
TrafficType.Guest,
|
||||
false, true, null, null, true, Availability.Optional,
|
||||
null, Network.GuestType.Shared, true, false, false, false, true, true, true, true, false);
|
||||
null, Network.GuestType.Shared, true, false, false, false, true, true, true, false);
|
||||
|
||||
defaultNetscalerNetworkOffering.setState(NetworkOffering.State.Enabled);
|
||||
defaultNetscalerNetworkOffering = _networkOfferingDao.persistDefaultNetworkOffering(defaultNetscalerNetworkOffering);
|
||||
|
||||
@ -22,12 +22,6 @@ import com.cloud.utils.script.Script;
|
||||
|
||||
import java.io.File;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.script.Script;
|
||||
|
||||
/**
|
||||
* @author htrippaers
|
||||
@ -84,7 +78,7 @@ public class Upgrade40to41 implements DbUpgrade {
|
||||
*/
|
||||
@Override
|
||||
public void performDataMigration(Connection conn) {
|
||||
upgradeEIPNetworkOfferings(conn);
|
||||
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@ -95,36 +89,4 @@ public class Upgrade40to41 implements DbUpgrade {
|
||||
return new File[0];
|
||||
}
|
||||
|
||||
private void upgradeEIPNetworkOfferings(Connection conn) {
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
|
||||
try {
|
||||
pstmt = conn.prepareStatement("select id, elastic_ip_service from `cloud`.`network_offerings` where traffic_type='Guest'");
|
||||
rs = pstmt.executeQuery();
|
||||
while (rs.next()) {
|
||||
long id = rs.getLong(1);
|
||||
// check if elastic IP service is enabled for network offering
|
||||
if (rs.getLong(2) != 0) {
|
||||
//update network offering with eip_associate_public_ip set to true
|
||||
pstmt = conn.prepareStatement("UPDATE `cloud`.`network_offerings` set eip_associate_public_ip=? where id=?");
|
||||
pstmt.setBoolean(1, true);
|
||||
pstmt.setLong(2, id);
|
||||
pstmt.executeUpdate();
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new CloudRuntimeException("Unable to set elastic_ip_service for network offerings with EIP service enabled.", e);
|
||||
} finally {
|
||||
try {
|
||||
if (rs != null) {
|
||||
rs.close();
|
||||
}
|
||||
if (pstmt != null) {
|
||||
pstmt.close();
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,32 +16,6 @@
|
||||
// under the License.
|
||||
package com.cloud.vm;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.*;
|
||||
import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd;
|
||||
import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.*;
|
||||
import com.cloud.agent.api.storage.CreatePrivateTemplateAnswer;
|
||||
@ -53,17 +27,6 @@ import com.cloud.alert.AlertManager;
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.api.query.dao.UserVmJoinDao;
|
||||
import com.cloud.api.query.vo.UserVmJoinVO;
|
||||
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.DestroyVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.RebootVMCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.ResetVMPasswordCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.RestoreVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.UpdateVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.UpgradeVMCmd;
|
||||
import com.cloud.async.AsyncJobExecutor;
|
||||
import com.cloud.async.AsyncJobManager;
|
||||
import com.cloud.async.AsyncJobVO;
|
||||
@ -151,12 +114,7 @@ import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.utils.concurrency.NamedThreadFactory;
|
||||
import com.cloud.utils.crypt.RSAHelper;
|
||||
import com.cloud.utils.db.DB;
|
||||
import com.cloud.utils.db.Filter;
|
||||
import com.cloud.utils.db.GlobalLock;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
import com.cloud.utils.db.Transaction;
|
||||
import com.cloud.utils.db.*;
|
||||
import com.cloud.utils.db.SearchCriteria.Func;
|
||||
import com.cloud.utils.exception.CloudRuntimeException;
|
||||
import com.cloud.utils.exception.ExecutionException;
|
||||
@ -164,6 +122,26 @@ import com.cloud.utils.fsm.NoTransitionException;
|
||||
import com.cloud.utils.net.NetUtils;
|
||||
import com.cloud.vm.VirtualMachine.State;
|
||||
import com.cloud.vm.dao.*;
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import org.apache.cloudstack.api.BaseCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.CreateTemplateCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.*;
|
||||
import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd;
|
||||
import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.AttachVolumeCmd;
|
||||
import org.apache.cloudstack.api.command.user.volume.DetachVolumeCmd;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Local(value = { UserVmManager.class, UserVmService.class })
|
||||
public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager {
|
||||
@ -2788,10 +2766,6 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager
|
||||
if (ip != null && ip.getSystem()) {
|
||||
UserContext ctx = UserContext.current();
|
||||
try {
|
||||
long networkId = ip.getAssociatedWithNetworkId();
|
||||
Network guestNetwork = _networkMgr.getNetwork(networkId);
|
||||
NetworkOffering offering = _configMgr.getNetworkOffering(guestNetwork.getNetworkOfferingId());
|
||||
assert (offering.getAssociatePublicIP() == true) : "User VM should not have system owned public IP associated with it when offering configured not to associate public IP.";
|
||||
_rulesMgr.disableStaticNat(ip.getId(), ctx.getCaller(), ctx.getCallerUserId(), true);
|
||||
} catch (Exception ex) {
|
||||
s_logger.warn("Failed to disable static nat and release system ip " + ip + " as a part of vm " + profile.getVirtualMachine() + " stop due to exception ", ex);
|
||||
|
||||
@ -797,7 +797,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager, NetworkS
|
||||
* @see com.cloud.network.NetworkService#allocateIP(com.cloud.user.Account, long, Long)
|
||||
*/
|
||||
@Override
|
||||
public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
public IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -16,22 +16,6 @@
|
||||
// under the License.
|
||||
package com.cloud.vpc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
|
||||
import com.cloud.dc.DataCenter;
|
||||
import com.cloud.dc.Vlan;
|
||||
import com.cloud.dc.Vlan.VlanType;
|
||||
@ -48,12 +32,7 @@ import com.cloud.network.Network.Service;
|
||||
import com.cloud.network.Networks.TrafficType;
|
||||
import com.cloud.network.addr.PublicIp;
|
||||
import com.cloud.network.dao.NetworkServiceMapDao;
|
||||
import com.cloud.network.element.LoadBalancingServiceProvider;
|
||||
import com.cloud.network.element.NetworkElement;
|
||||
import com.cloud.network.element.RemoteAccessVPNServiceProvider;
|
||||
import com.cloud.network.element.Site2SiteVpnServiceProvider;
|
||||
import com.cloud.network.element.StaticNatServiceProvider;
|
||||
import com.cloud.network.element.UserDataServiceProvider;
|
||||
import com.cloud.network.element.*;
|
||||
import com.cloud.network.guru.NetworkGuru;
|
||||
import com.cloud.network.rules.FirewallRule;
|
||||
import com.cloud.network.rules.FirewallRule.Purpose;
|
||||
@ -70,6 +49,16 @@ import com.cloud.utils.component.Inject;
|
||||
import com.cloud.utils.component.Manager;
|
||||
import com.cloud.vm.*;
|
||||
import com.cloud.vpc.dao.MockVpcVirtualRouterElement;
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.api.command.admin.usage.ListTrafficTypeImplementorsCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.CreateNetworkCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.ListNetworksCmd;
|
||||
import org.apache.cloudstack.api.command.user.network.RestartNetworkCmd;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import javax.ejb.Local;
|
||||
import javax.naming.ConfigurationException;
|
||||
import java.util.*;
|
||||
|
||||
@Local(value = { NetworkManager.class, NetworkService.class })
|
||||
public class MockNetworkManagerImpl implements NetworkManager, Manager{
|
||||
@ -1481,7 +1470,7 @@ public class MockNetworkManagerImpl implements NetworkManager, Manager{
|
||||
* @see com.cloud.network.NetworkService#allocateIP(com.cloud.user.Account, boolean, long)
|
||||
*/
|
||||
@Override
|
||||
public IpAddress allocateIP(Account ipOwner, long zoneId, Long networkId) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
public IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId) throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -306,7 +306,6 @@ CREATE TABLE `cloud`.`network_offerings` (
|
||||
`state` char(32) COMMENT 'state of the network offering that has Disabled value by default',
|
||||
`guest_type` char(32) COMMENT 'type of guest network that can be shared or isolated',
|
||||
`elastic_ip_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if the network offering provides elastic ip service',
|
||||
`eip_associate_public_ip` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if public IP is associated with user VM creation by default when EIP service is enabled.',
|
||||
`elastic_lb_service` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if the network offering provides elastic lb service',
|
||||
`specify_ip_ranges` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if the network offering provides an ability to define ip ranges',
|
||||
`inline` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Is this network offering LB provider is in inline mode',
|
||||
|
||||
@ -58,7 +58,6 @@ ALTER TABLE `cloud`.`snapshots` ADD COLUMN `s3_id` bigint unsigned COMMENT 'S3 t
|
||||
|
||||
ALTER TABLE `cloud`.`snapshots` ADD CONSTRAINT `fk_snapshots__s3_id` FOREIGN KEY `fk_snapshots__s3_id` (`s3_id`) REFERENCES `s3` (`id`);
|
||||
|
||||
ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `eip_associate_public_ip` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'true if public IP is associated with user VM creation by default when EIP service is enabled.' AFTER `elastic_ip_service`;
|
||||
ALTER TABLE `cloud`.`network_offerings` ADD COLUMN `inline` int(1) unsigned NOT NULL DEFAULT 0 COMMENT 'Is this network offering LB provider is in inline mode';
|
||||
|
||||
ALTER TABLE `cloud`.`external_load_balancer_devices` DROP COLUMN `is_inline`;
|
||||
|
||||
@ -41,7 +41,7 @@ class Services:
|
||||
"displaytext": "Tiny Instance",
|
||||
"cpunumber": 1,
|
||||
"cpuspeed": 100, # in MHz
|
||||
"memory": 64, # In MBs
|
||||
"memory": 128, # In MBs
|
||||
},
|
||||
"virtual_machine":
|
||||
{
|
||||
|
||||
@ -39,7 +39,7 @@ class Services:
|
||||
"displaytext": "Service Offering",
|
||||
"cpunumber": 1,
|
||||
"cpuspeed": 100, # MHz
|
||||
"memory": 64, # in MBs
|
||||
"memory": 128, # in MBs
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ class Services:
|
||||
"displaytext": "Tiny Instance",
|
||||
"cpunumber": 1,
|
||||
"cpuspeed": 100, # in MHz
|
||||
"memory": 64, # In MBs
|
||||
"memory": 128, # In MBs
|
||||
},
|
||||
"disk_offering": {
|
||||
"displaytext": "Small",
|
||||
|
||||
@ -80,7 +80,7 @@ class Services:
|
||||
"displaytext": "Tiny Instance",
|
||||
"cpunumber": 1,
|
||||
"cpuspeed": 100, # in MHz
|
||||
"memory": 64, # In MBs
|
||||
"memory": 128, # In MBs
|
||||
},
|
||||
"small":
|
||||
{
|
||||
|
||||
@ -53,7 +53,7 @@ class Services:
|
||||
"displaytext": "Tiny Instance",
|
||||
"cpunumber": 1,
|
||||
"cpuspeed": 100, # in MHz
|
||||
"memory": 64, # In MBs
|
||||
"memory": 128, # In MBs
|
||||
},
|
||||
"disk_offering": {
|
||||
"displaytext": "Small",
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
|
||||
|
||||
INSERT INTO `cloud`.`disk_offering` (id, name, uuid, display_text, created, use_local_storage, type, disk_size) VALUES (17, 'tinyOffering', UUID(), 'tinyOffering', NOW(), 1, 'Service', 0);
|
||||
INSERT INTO `cloud`.`service_offering` (id, cpu, speed, ram_size) VALUES (17, 1, 100, 100);
|
||||
INSERT INTO `cloud`.`service_offering` (id, cpu, speed, ram_size) VALUES (17, 1, 100, 128);
|
||||
INSERT INTO `cloud`.`disk_offering` (id, name, uuid, display_text, created, type, disk_size) VALUES (18, 'tinyDiskOffering', UUID(), 'tinyDiskOffering', NOW(), 'Disk', 1073741824);
|
||||
INSERT INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','router.ram.size', '100');
|
||||
INSERT INTO `cloud`.`configuration` (instance, name,value) VALUE('DEFAULT','router.cpu.mhz','100');
|
||||
@ -37,4 +37,5 @@ INSERT INTO `cloud`.`configuration` (instance, name, value) VALUE('DEFAULT', 'se
|
||||
UPDATE `cloud`.`configuration` SET value='10' where name = 'storage.overprovisioning.factor';
|
||||
UPDATE `cloud`.`configuration` SET value='10' where name = 'cpu.overprovisioning.factor';
|
||||
UPDATE `cloud`.`configuration` SET value='10' where name = 'mem.overprovisioning.factor';
|
||||
UPDATE `cloud`.`vm_template` SET unique_name="tiny Linux",name="tiny Linux",url="http://marcus.mlsorensen.com/cloudstack-extras/ttylinux_pv.qcow2",checksum="81dcf4b4ca05a3b637a040e851568f29",display_text="tiny Linux",format='QCOW2',hypervisor_type='KVM' where id=5;
|
||||
UPDATE `cloud`.`vm_template` SET unique_name="tiny CentOS 6.3",name="tiny CentOS 6.3",url="http://marcus.mlsorensen.com/cloudstack-extras/tiny-centos-63.qcow2",checksum="4bbb806aa8570f4dfac13b4c38ea1603",display_text="tiny CentOS 6.3",format='QCOW2',hypervisor_type='KVM' where id=5;
|
||||
UPDATE `cloud`.`vm_template` SET url="http://dontdownloadthistemplate" where id=4;
|
||||
|
||||
@ -560,8 +560,8 @@
|
||||
return $(this).index() == index;
|
||||
});
|
||||
|
||||
if ($target.index() > $tr.index()) $target.after($tr);
|
||||
else $target.before($tr);
|
||||
// if ($target.index() > $tr.index()) $target.after($tr);
|
||||
// else $target.before($tr);
|
||||
|
||||
$tr.closest('.list-view').scrollTop($tr.position().top - $tr.height() * 2);
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user