You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mc...@apache.org on 2012/12/20 08:50:15 UTC
[2/3] Remove IdentityProxy from CloudException and ExceptionResponse.
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/a88ce6bb/server/src/com/cloud/network/NetworkManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java
index 651f33b..347cb2f 100755
--- a/server/src/com/cloud/network/NetworkManagerImpl.java
+++ b/server/src/com/cloud/network/NetworkManagerImpl.java
@@ -5,7 +5,7 @@
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
-//
+//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
@@ -59,6 +59,8 @@ import com.cloud.agent.api.StartupCommand;
import com.cloud.agent.api.StartupRoutingCommand;
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;
@@ -377,7 +379,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
@DB
- public PublicIp fetchNewPublicIp(long dcId, Long podId, Long vlanDbId, Account owner, VlanType vlanUse,
+ public PublicIp fetchNewPublicIp(long dcId, Long podId, Long vlanDbId, Account owner, VlanType vlanUse,
Long guestNetworkId, boolean sourceNat, boolean assign, String requestedIp, boolean isSystem, Long vpcId)
throws InsufficientAddressCapacityException {
StringBuilder errorMessage = new StringBuilder("Unable to get ip adress in ");
@@ -423,13 +425,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException
("Insufficient address capacity", Pod.class, podId);
// for now, we hardcode the table names, but we should ideally do a lookup for the tablename from the VO object.
- ex.addProxyObject("Pod", podId, "podId");
+ ex.addProxyObject(ApiDBUtils.findPodById(podId).getUuid());
throw ex;
}
s_logger.warn(errorMessage.toString());
InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException
("Insufficient address capacity", DataCenter.class, dcId);
- ex.addProxyObject("data_center", dcId, "dcId");
+ ex.addProxyObject(ApiDBUtils.findZoneById(dcId).getUuid());
throw ex;
}
@@ -487,9 +489,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
VlanVO vlan = _vlanDao.findById(addr.getVlanId());
String guestType = vlan.getVlanType().toString();
-
- UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_NET_IP_ASSIGN, owner.getId(),
- addr.getDataCenterId(), addr.getId(), addr.getAddress().toString(), addr.isSourceNat(), guestType,
+
+ UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_NET_IP_ASSIGN, owner.getId(),
+ addr.getDataCenterId(), addr.getId(), addr.getAddress().toString(), addr.isSourceNat(), guestType,
addr.getSystem());
_usageEventDao.persist(usageEvent);
// don't increment resource count for direct ip addresses
@@ -501,9 +503,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
txn.commit();
}
-
+
@Override
- public PublicIp assignSourceNatIpAddressToGuestNetwork(Account owner, Network guestNetwork)
+ public PublicIp assignSourceNatIpAddressToGuestNetwork(Account owner, Network guestNetwork)
throws InsufficientAddressCapacityException, ConcurrentOperationException {
assert (guestNetwork.getTrafficType() != null) : "You're asking for a source nat but your network " +
"can't participate in source nat. What do you have to say for yourself?";
@@ -513,28 +515,28 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
PublicIp ipToReturn = null;
if (sourceNatIp != null) {
- ipToReturn = new PublicIp(sourceNatIp, _vlanDao.findById(sourceNatIp.getVlanId()),
+ ipToReturn = new PublicIp(sourceNatIp, _vlanDao.findById(sourceNatIp.getVlanId()),
NetUtils.createSequenceBasedMacAddress(sourceNatIp.getMacAddress()));
} else {
ipToReturn = assignDedicateIpAddress(owner, guestNetwork.getId(), null, dcId, true);
}
-
+
return ipToReturn;
}
-
+
@Override
public PublicIp assignVpnGatewayIpAddress(long dcId, Account owner, long vpcId) throws InsufficientAddressCapacityException, ConcurrentOperationException {
return assignDedicateIpAddress(owner, null, vpcId, dcId, false);
}
-
+
@DB
@Override
- public PublicIp assignDedicateIpAddress(Account owner, Long guestNtwkId, Long vpcId, long dcId, boolean isSourceNat)
+ public PublicIp assignDedicateIpAddress(Account owner, Long guestNtwkId, Long vpcId, long dcId, boolean isSourceNat)
throws ConcurrentOperationException, InsufficientAddressCapacityException {
long ownerId = owner.getId();
-
+
// Check that the maximum number of public IPs for the given accountId will not be exceeded
try {
_resourceLimitMgr.checkResourceLimit(owner, ResourceType.public_ip);
@@ -558,7 +560,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (s_logger.isDebugEnabled()) {
s_logger.debug("lock account " + ownerId + " is acquired");
}
-
+
// If account has Account specific ip ranges, try to allocate ip from there
Long vlanId = null;
List<AccountVlanMapVO> maps = _accountVlanMapDao.listAccountVlanMapsByAccount(ownerId);
@@ -567,7 +569,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
- ip = fetchNewPublicIp(dcId, null, vlanId, owner, VlanType.VirtualNetwork, guestNtwkId,
+ ip = fetchNewPublicIp(dcId, null, vlanId, owner, VlanType.VirtualNetwork, guestNtwkId,
isSourceNat, false, null, false, vpcId);
IPAddressVO publicIp = ip.ip();
@@ -593,7 +595,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
/**
* Returns the target account for an api command
- *
+ *
* @param accountName
* - non-null if the account name was passed in in the command
* @param domainId
@@ -637,7 +639,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
List<PublicIp> publicIps = new ArrayList<PublicIp>();
if (userIps != null && !userIps.isEmpty()) {
for (IPAddressVO userIp : userIps) {
- PublicIp publicIp = new PublicIp(userIp, _vlanDao.findById(userIp.getVlanId()),
+ PublicIp publicIp = new PublicIp(userIp, _vlanDao.findById(userIp.getVlanId()),
NetUtils.createSequenceBasedMacAddress(userIp.getMacAddress()));
publicIps.add(publicIp);
}
@@ -654,7 +656,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
// system
if (cleanupIpResources(addr.getId(), Account.ACCOUNT_ID_SYSTEM, _accountMgr.getSystemAccount())) {
s_logger.debug("Unassiging ip address " + addr);
- _ipAddressDao.unassignIpAddress(addr.getId());
+ _ipAddressDao.unassignIpAddress(addr.getId());
} else {
success = false;
s_logger.warn("Failed to release resources for ip address id=" + addr.getId());
@@ -737,7 +739,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (purposes == null || purposes.isEmpty()) {
// since no active rules are there check if any rules are applied on the public IP but are in
// revoking state
-
+
purposes = getPublicIpPurposeInRules(ip, true, includingFirewall);
if (ip.isOneToOneNat()) {
if (purposes == null) {
@@ -851,11 +853,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (services == null || services.isEmpty()) {
return true;
}
-
+
if (networkId == null) {
networkId = publicIp.getAssociatedWithNetworkId();
}
-
+
// We only support one provider for one service now
Map<Service, Set<Provider>> serviceToProviders = getServiceProvidersMap(networkId);
Set<Provider> oldProviders = serviceToProviders.get(services.toArray()[0]);
@@ -924,7 +926,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
return providerToIpList;
}
- protected boolean applyIpAssociations(Network network, boolean rulesRevoked, boolean continueOnError,
+ protected boolean applyIpAssociations(Network network, boolean rulesRevoked, boolean continueOnError,
List<PublicIp> publicIps) throws ResourceUnavailableException {
boolean success = true;
@@ -1004,7 +1006,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
return _networksDao.listByZoneAndGuestType(owner.getId(), zoneId, Network.GuestType.Isolated, false);
}
-
+
@Override
public List<? extends Network> getIsolatedNetworksWithSourceNATOwnedByAccountInZone(long zoneId, Account owner) {
@@ -1014,23 +1016,23 @@ 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, boolean isSystem, long zoneId)
+ public IpAddress allocateIP(Account ipOwner, boolean isSystem, long zoneId)
throws ResourceAllocationException, InsufficientAddressCapacityException, ConcurrentOperationException {
Account caller = UserContext.current().getCaller();
long callerUserId = UserContext.current().getCallerUserId();
// check permissions
_accountMgr.checkAccess(caller, null, false, ipOwner);
-
+
DataCenter zone = _configMgr.getZone(zoneId);
-
+
return allocateIp(ipOwner, isSystem, caller, callerUserId, zone);
}
@DB
- public IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerUserId, DataCenter zone)
+ public IpAddress allocateIp(Account ipOwner, boolean isSystem, Account caller, long callerUserId, DataCenter zone)
throws ConcurrentOperationException, ResourceAllocationException,
InsufficientAddressCapacityException {
-
+
VlanType vlanType = VlanType.VirtualNetwork;
boolean assign = false;
@@ -1066,14 +1068,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
txn.start();
- ip = fetchNewPublicIp(zone.getId(), null, null, ipOwner, vlanType, null,
+ ip = fetchNewPublicIp(zone.getId(), null, null, ipOwner, vlanType, null,
false, assign, null, isSystem, null);
if (ip == null) {
InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException
("Unable to find available public IP addresses", DataCenter.class, zone.getId());
- ex.addProxyObject("data_center", zone.getId(), "zoneId");
+ ex.addProxyObject(ApiDBUtils.findZoneById(zone.getId()).getUuid());
throw ex;
}
UserContext.current().setEventDetails("Ip Id: " + ip.getId());
@@ -1094,7 +1096,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
return ip;
}
-
+
protected IPAddressVO getExistingSourceNatInNetwork(long ownerId, Long networkId) {
List<IPAddressVO> addrs = listPublicIpsAssignedToGuestNtwk(ownerId, networkId, true);
@@ -1113,15 +1115,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
assert (sourceNatIp != null) : "How do we get a bunch of ip addresses but none of them are source nat? " +
"account=" + ownerId + "; networkId=" + networkId;
- }
-
+ }
+
return sourceNatIp;
}
@DB
@Override
- public IPAddressVO associateIPToGuestNetwork(long ipId, long networkId, boolean releaseOnFailure)
- throws ResourceAllocationException, ResourceUnavailableException,
+ public IPAddressVO associateIPToGuestNetwork(long ipId, long networkId, boolean releaseOnFailure)
+ throws ResourceAllocationException, ResourceUnavailableException,
InsufficientAddressCapacityException, ConcurrentOperationException {
Account caller = UserContext.current().getCaller();
Account owner = null;
@@ -1134,12 +1136,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
s_logger.debug("Unable to find ip address by id: " + ipId);
return null;
}
-
+
if (ipToAssoc.getAssociatedWithNetworkId() != null) {
s_logger.debug("IP " + ipToAssoc + " is already assocaited with network id" + networkId);
return ipToAssoc;
}
-
+
Network network = _networksDao.findById(networkId);
if (network != null) {
_accountMgr.checkAccess(owner, AccessType.UseNetwork, false, network);
@@ -1147,12 +1149,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
s_logger.debug("Unable to find ip address by id: " + ipId);
return null;
}
-
+
DataCenter zone = _configMgr.getZone(network.getDataCenterId());
// allow associating IP addresses to guest network only
if (network.getTrafficType() != TrafficType.Guest) {
- throw new InvalidParameterValueException("Ip address can be associated to the network with trafficType " +
+ throw new InvalidParameterValueException("Ip address can be associated to the network with trafficType " +
TrafficType.Guest);
}
@@ -1161,16 +1163,16 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
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
- if (zone.getNetworkType() == NetworkType.Advanced &&
- !(network.getGuestType() == GuestType.Isolated && areServicesSupportedInNetwork(network.getId(),
+ if (zone.getNetworkType() == NetworkType.Advanced &&
+ !(network.getGuestType() == GuestType.Isolated && areServicesSupportedInNetwork(network.getId(),
Service.SourceNat))) {
- throw new InvalidParameterValueException("In zone of type " + NetworkType.Advanced +
+ 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");
}
-
+
NetworkOffering offering = _networkOfferingDao.findById(network.getNetworkOfferingId());
boolean sharedSourceNat = offering.getSharedSourceNat();
boolean isSourceNat = false;
@@ -1181,15 +1183,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
}
}
-
+
s_logger.debug("Associating ip " + ipToAssoc + " to network " + network);
-
+
IPAddressVO ip = _ipAddressDao.findById(ipId);
//update ip address with networkId
ip.setAssociatedWithNetworkId(networkId);
ip.setSourceNat(isSourceNat);
_ipAddressDao.update(ipId, ip);
-
+
boolean success = false;
try {
success = applyIpAssociations(network, false);
@@ -1217,7 +1219,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
}
}
-
+
@Override
@DB
@@ -1317,7 +1319,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
sgProviders.add(Provider.SecurityGroupProvider);
defaultSharedSGEnabledNetworkOfferingProviders.put(Service.SecurityGroup, sgProviders);
- Map<Network.Service, Set<Network.Provider>> defaultIsolatedSourceNatEnabledNetworkOfferingProviders =
+ Map<Network.Service, Set<Network.Provider>> defaultIsolatedSourceNatEnabledNetworkOfferingProviders =
new HashMap<Network.Service, Set<Network.Provider>>();
defaultProviders.clear();
defaultProviders.add(Network.Provider.VirtualRouter);
@@ -1331,9 +1333,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
defaultIsolatedSourceNatEnabledNetworkOfferingProviders.put(Service.StaticNat, defaultProviders);
defaultIsolatedSourceNatEnabledNetworkOfferingProviders.put(Service.PortForwarding, defaultProviders);
defaultIsolatedSourceNatEnabledNetworkOfferingProviders.put(Service.Vpn, defaultProviders);
-
-
- Map<Network.Service, Set<Network.Provider>> defaultVPCOffProviders =
+
+
+ Map<Network.Service, Set<Network.Provider>> defaultVPCOffProviders =
new HashMap<Network.Service, Set<Network.Provider>>();
defaultProviders.clear();
defaultProviders.add(Network.Provider.VirtualRouter);
@@ -1389,7 +1391,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
offering.setState(NetworkOffering.State.Enabled);
_networkOfferingDao.update(offering.getId(), offering);
}
-
+
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks) == null) {
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworks,
"Offering for Isolated VPC networks with Source Nat service enabled", TrafficType.Guest,
@@ -1398,7 +1400,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
offering.setState(NetworkOffering.State.Enabled);
_networkOfferingDao.update(offering.getId(), offering);
}
-
+
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOfferingForVpcNetworksNoLB) == null) {
//remove LB service
defaultVPCOffProviders.remove(Service.Lb);
@@ -1411,14 +1413,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultIsolatedNetworkOffering) == null) {
- offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOffering,
+ offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultIsolatedNetworkOffering,
"Offering for Isolated networks with no Source Nat service", TrafficType.Guest, null, true,
Availability.Optional, null, defaultIsolatedNetworkOfferingProviders, true, Network.GuestType.Isolated,
false, null, true, null, true);
offering.setState(NetworkOffering.State.Enabled);
_networkOfferingDao.update(offering.getId(), offering);
}
-
+
Map<Network.Service, Set<Network.Provider>> netscalerServiceProviders = new HashMap<Network.Service, Set<Network.Provider>>();
Set<Network.Provider> vrProvider = new HashSet<Network.Provider>();
vrProvider.add(Provider.VirtualRouter);
@@ -1432,7 +1434,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
netscalerServiceProviders.put(Service.SecurityGroup, sgProvider);
netscalerServiceProviders.put(Service.StaticNat, nsProvider);
netscalerServiceProviders.put(Service.Lb, nsProvider);
-
+
Map<Service, Map<Capability, String>> serviceCapabilityMap = new HashMap<Service, Map<Capability, String>>();
Map<Capability, String> elb = new HashMap<Capability, String>();
elb.put(Capability.ElasticLb, "true");
@@ -1440,7 +1442,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
eip.put(Capability.ElasticIp, "true");
serviceCapabilityMap.put(Service.Lb, elb);
serviceCapabilityMap.put(Service.StaticNat, eip);
-
+
if (_networkOfferingDao.findByUniqueName(NetworkOffering.DefaultSharedEIPandELBNetworkOffering) == null) {
offering = _configMgr.createNetworkOffering(NetworkOffering.DefaultSharedEIPandELBNetworkOffering, "Offering for Shared networks with Elastic IP and Elastic LB capabilities", TrafficType.Guest, null, true,
Availability.Optional, null, netscalerServiceProviders, true, Network.GuestType.Shared, false, null, true, serviceCapabilityMap, true);
@@ -1559,7 +1561,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
public List<IPAddressVO> listPublicIpsAssignedToGuestNtwk(long accountId, long associatedNetworkId, Boolean sourceNat) {
SearchCriteria<IPAddressVO> sc = IpAddressSearch.create();
sc.setParameters("accountId", accountId);
- sc.setParameters("associatedWithNetworkId", associatedNetworkId);
+ sc.setParameters("associatedWithNetworkId", associatedNetworkId);
if (sourceNat != null) {
sc.addAnd("sourceNat", SearchCriteria.Op.EQ, sourceNat);
@@ -1568,7 +1570,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
return _ipAddressDao.search(sc, null);
}
-
+
@Override
public List<IPAddressVO> listPublicIpsAssignedToAccount(long accountId, long dcId, Boolean sourceNat) {
SearchCriteria<IPAddressVO> sc = IpAddressSearch.create();
@@ -1585,7 +1587,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
- public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name,
+ public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, DeploymentPlan plan, String name,
String displayText, boolean isDefault)
throws ConcurrentOperationException {
return setupNetwork(owner, offering, null, plan, name, displayText, false, null, null, null, null);
@@ -1593,10 +1595,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
@DB
- public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan
+ public List<NetworkVO> setupNetwork(Account owner, NetworkOfferingVO offering, Network predefined, DeploymentPlan
plan, String name, String displayText, boolean errorIfAlreadySetup, Long domainId,
ACLType aclType, Boolean subdomainAccess, Long vpcId) throws ConcurrentOperationException {
-
+
Account locked = _accountDao.acquireInLockTable(owner.getId());
if (locked == null) {
throw new ConcurrentOperationException("Unable to acquire lock on " + owner);
@@ -1604,7 +1606,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
try {
if (predefined == null
- || (offering.getTrafficType() != TrafficType.Guest && predefined.getCidr() == null && predefined.getBroadcastUri() == null &&
+ || (offering.getTrafficType() != TrafficType.Guest && predefined.getCidr() == null && predefined.getBroadcastUri() == null &&
!(predefined.getBroadcastDomainType() == BroadcastDomainType.Vlan || predefined.getBroadcastDomainType() == BroadcastDomainType.Lswitch))) {
List<NetworkVO> configs = _networksDao.listBy(owner.getId(), offering.getId(), plan.getDataCenterId());
if (configs.size() > 0) {
@@ -1615,7 +1617,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (errorIfAlreadySetup) {
InvalidParameterValueException ex = new InvalidParameterValueException("Found existing network configuration (with specified id) for offering (with specified id)");
ex.addProxyObject(offering, offering.getId(), "offeringId");
- ex.addProxyObject(configs.get(0), configs.get(0).getId(), "networkConfigId");
+ ex.addProxyObject(configs.get(0), configs.get(0).getId(), "networkConfigId");
throw ex;
} else {
return configs;
@@ -1632,7 +1634,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (errorIfAlreadySetup) {
InvalidParameterValueException ex = new InvalidParameterValueException("Found existing network configuration (with specified id) for offering (with specified id)");
ex.addProxyObject(offering, offering.getId(), "offeringId");
- ex.addProxyObject(configs.get(0), configs.get(0).getId(), "networkConfigId");
+ ex.addProxyObject(configs.get(0), configs.get(0).getId(), "networkConfigId");
throw ex;
} else {
return configs;
@@ -1668,9 +1670,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
txn.start();
NetworkVO vo = new NetworkVO(id, network, offering.getId(), guru.getName(), owner.getDomainId(), owner.getId(),
- related, name, displayText, predefined.getNetworkDomain(), offering.getGuestType(),
+ related, name, displayText, predefined.getNetworkDomain(), offering.getGuestType(),
plan.getDataCenterId(), plan.getPhysicalNetworkId(), aclType, offering.getSpecifyIpRanges(), vpcId);
- networks.add(_networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated,
+ networks.add(_networksDao.persist(vo, vo.getGuestType() == Network.GuestType.Isolated,
finalizeServicesAndProvidersForNetwork(offering, plan.getPhysicalNetworkId())));
if (domainId != null && aclType == ACLType.Domain) {
@@ -1709,7 +1711,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
@DB
- public void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkVO, NicProfile>> networks)
+ public void allocate(VirtualMachineProfile<? extends VMInstanceVO> vm, List<Pair<NetworkVO, NicProfile>> networks)
throws InsufficientCapacityException, ConcurrentOperationException {
Transaction txn = Transaction.currentTxn();
txn.start();
@@ -1725,26 +1727,26 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
for (Pair<NetworkVO, NicProfile> network : networks) {
NetworkVO config = network.first();
NicProfile requested = network.second();
-
+
Boolean isDefaultNic = false;
if (vm != null && (requested != null && requested.isDefaultNic())) {
isDefaultNic = true;
}
-
+
while (deviceIds[deviceId] && deviceId < deviceIds.length) {
deviceId++;
}
-
- Pair<NicProfile,Integer> vmNicPair = allocateNic(requested, config, isDefaultNic,
+
+ Pair<NicProfile,Integer> vmNicPair = allocateNic(requested, config, isDefaultNic,
deviceId, vm);
-
+
NicProfile vmNic = vmNicPair.first();
if (vmNic == null) {
continue;
}
-
+
deviceId = vmNicPair.second();
-
+
int devId = vmNic.getDeviceId();
if (devId > deviceIds.length) {
throw new IllegalArgumentException("Device id for nic is too large: " + vmNic);
@@ -1754,18 +1756,18 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
deviceIds[devId] = true;
-
+
if (vmNic.isDefaultNic()) {
if (defaultNic != null) {
- throw new IllegalArgumentException("You cannot specify two nics as default nics: nic 1 = " +
+ throw new IllegalArgumentException("You cannot specify two nics as default nics: nic 1 = " +
defaultNic + "; nic 2 = " + vmNic);
}
defaultNic = vmNic;
}
-
+
nics.add(vmNic);
vm.addNic(vmNic);
-
+
}
if (nics.size() != networks.size()) {
@@ -1779,14 +1781,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
txn.commit();
}
-
-
+
+
@DB
@Override
- public Pair<NicProfile,Integer> allocateNic(NicProfile requested, Network network, Boolean isDefaultNic,
+ public Pair<NicProfile,Integer> allocateNic(NicProfile requested, Network network, Boolean isDefaultNic,
int deviceId, VirtualMachineProfile<? extends VMInstanceVO> vm) throws InsufficientVirtualNetworkCapcityException,
InsufficientAddressCapacityException, ConcurrentOperationException{
-
+
NetworkVO ntwkVO = _networksDao.findById(network.getId());
s_logger.debug("Allocating nic for vm " + vm.getVirtualMachine() + " in network " + network + " with requested profile " + requested);
NetworkGuru guru = _networkGurus.get(ntwkVO.getGuruName());
@@ -1814,14 +1816,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
deviceId = applyProfileToNic(vo, profile, deviceId);
vo = _nicDao.persist(vo);
-
+
Integer networkRate = getNetworkRate(network.getId(), vm.getId());
- NicProfile vmNic = new NicProfile(vo, network, vo.getBroadcastUri(), vo.getIsolationUri(), networkRate,
+ NicProfile vmNic = new NicProfile(vo, network, vo.getBroadcastUri(), vo.getIsolationUri(), networkRate,
isSecurityGroupSupportedInNetwork(network), getNetworkTag(vm.getHypervisorType(),
network));
-
+
return new Pair<NicProfile,Integer>(vmNic, Integer.valueOf(deviceId));
- }
+ }
protected Integer applyProfileToNic(NicVO vo, NicProfile profile, Integer deviceId) {
if (profile.getDeviceId() != null) {
@@ -1907,7 +1909,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
Integer networkRate = getNetworkRate(config.getId(), null);
to.setNetworkRateMbps(networkRate);
-
+
to.setUuid(config.getUuid());
return to;
@@ -1925,10 +1927,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (network == null) {
// see NetworkVO.java
ConcurrentOperationException ex = new ConcurrentOperationException("Unable to acquire network configuration");
- ex.addProxyObject("networks", networkId, "networkId");
+ ex.addProxyObject(ApiDBUtils.findNetworkById(networkId).getUuid());
throw ex;
}
-
+
if (s_logger.isDebugEnabled()) {
s_logger.debug("Lock is acquired for network id " + networkId + " as a part of network implement");
}
@@ -1977,7 +1979,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
shutdownNetwork(networkId, context, false);
}
-
+
_networksDao.releaseFromLockTable(networkId);
if (s_logger.isDebugEnabled()) {
s_logger.debug("Lock is released for network id " + networkId + " as a part of network implement");
@@ -1985,7 +1987,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
}
- private void implementNetworkElementsAndResources(DeployDestination dest, ReservationContext context,
+ private void implementNetworkElementsAndResources(DeployDestination dest, ReservationContext context,
NetworkVO network, NetworkOfferingVO offering)
throws ConcurrentOperationException, InsufficientAddressCapacityException, ResourceUnavailableException, InsufficientCapacityException {
// If this is a 1) guest virtual network 2) network has sourceNat service 3) network offering does not support a
@@ -1994,10 +1996,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
boolean sharedSourceNat = offering.getSharedSourceNat();
- if (network.getGuestType() == Network.GuestType.Isolated
- && areServicesSupportedInNetwork(network.getId(), Service.SourceNat)
+ if (network.getGuestType() == Network.GuestType.Isolated
+ && areServicesSupportedInNetwork(network.getId(), Service.SourceNat)
&& !sharedSourceNat) {
-
+
List<IPAddressVO> ips = null;
if (network.getVpcId() != null) {
ips = _ipAddressDao.listByAssociatedVpc(network.getVpcId(), true);
@@ -2024,7 +2026,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
// because the serializer would look up the NetworkVO class's table and retrieve the
// network id instead of the physical network id.
// So just throw this exception as is. We may need to TBD by changing the serializer.
- throw new CloudRuntimeException("Service provider " + element.getProvider().getName() +
+ throw new CloudRuntimeException("Service provider " + element.getProvider().getName() +
" either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId());
}
if (s_logger.isDebugEnabled()) {
@@ -2033,7 +2035,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (!element.implement(network, offering, dest, context)) {
CloudRuntimeException ex = new CloudRuntimeException("Failed to implement provider " + element.getProvider().getName() + " for network with specified id");
ex.addProxyObject(network, network.getId(), "networkId");
- throw ex;
+ throw ex;
}
}
}
@@ -2044,12 +2046,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
s_logger.warn("Failed to re-program the network as a part of network " + network + " implement");
// see DataCenterVO.java
ResourceUnavailableException ex = new ResourceUnavailableException("Unable to apply network rules as a part of network " + network + " implement", DataCenter.class, network.getDataCenterId());
- ex.addProxyObject("data_center", network.getDataCenterId(), "dataCenterId");
+ ex.addProxyObject(ApiDBUtils.findZoneById(network.getDataCenterId()).getUuid());
throw ex;
}
}
- protected void prepareElement(NetworkElement element, NetworkVO network,
+ protected void prepareElement(NetworkElement element, NetworkVO network,
NicProfile profile, VirtualMachineProfile<? extends VMInstanceVO> vmProfile,
DeployDestination dest, ReservationContext context) throws InsufficientCapacityException,
ConcurrentOperationException, ResourceUnavailableException {
@@ -2084,7 +2086,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (nic.getVmType() == VirtualMachine.Type.User || (nic.getVmType() == VirtualMachine.Type.DomainRouter && getNetwork(networkId).getTrafficType() == TrafficType.Guest)) {
_networksDao.setCheckForGc(networkId);
}
-
+
txn.commit();
}
@@ -2109,7 +2111,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
for (NicVO nic : nics) {
Pair<NetworkGuru, NetworkVO> implemented = implementNetwork(nic.getNetworkId(), dest, context);
-
+
NetworkVO network = implemented.second();
NicProfile profile = prepareNic(vmProfile, dest, context, nic.getId(), network);
vmProfile.addNic(profile);
@@ -2117,15 +2119,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
@Override
- public NicProfile prepareNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, DeployDestination
+ public NicProfile prepareNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, DeployDestination
dest, ReservationContext context, long nicId, NetworkVO network)
- throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException,
+ throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException,
ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException {
-
+
Integer networkRate = getNetworkRate(network.getId(), vmProfile.getId());
NetworkGuru guru = _networkGurus.get(network.getGuruName());
NicVO nic = _nicDao.findById(nicId);
-
+
NicProfile profile = null;
if (nic.getReservationStrategy() == Nic.ReservationStrategy.Start) {
nic.setState(Nic.State.Reserving);
@@ -2138,7 +2140,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
URI isolationUri = nic.getIsolationUri();
- profile = new NicProfile(nic, network, broadcastUri, isolationUri,
+ profile = new NicProfile(nic, network, broadcastUri, isolationUri,
networkRate, isSecurityGroupSupportedInNetwork(network), getNetworkTag(vmProfile.getHypervisorType(), network));
guru.reserve(profile, network, vmProfile, dest, context);
@@ -2159,7 +2161,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
updateNic(nic, network.getId(), 1);
} else {
- profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(),
+ profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(),
networkRate, isSecurityGroupSupportedInNetwork(network), getNetworkTag(vmProfile.getHypervisorType(), network));
guru.updateNicProfile(profile, network);
nic.setState(Nic.State.Reserved);
@@ -2186,7 +2188,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
Integer networkRate = getNetworkRate(network.getId(), vm.getId());
NetworkGuru guru = _networkGurus.get(network.getGuruName());
- NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate,
+ NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(), networkRate,
isSecurityGroupSupportedInNetwork(network), getNetworkTag(vm.getHypervisorType(), network));
guru.updateNicProfile(profile, network);
vm.addNic(profile);
@@ -2206,27 +2208,27 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
@DB
- public void releaseNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, Nic nic)
+ public void releaseNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, Nic nic)
throws ConcurrentOperationException, ResourceUnavailableException {
NicVO nicVO = _nicDao.findById(nic.getId());
releaseNic(vmProfile, nicVO);
}
@DB
- protected void releaseNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, NicVO nicVO)
+ protected void releaseNic(VirtualMachineProfile<? extends VMInstanceVO> vmProfile, NicVO nicVO)
throws ConcurrentOperationException, ResourceUnavailableException {
//lock the nic
Transaction txn = Transaction.currentTxn();
txn.start();
-
+
NicVO nic = _nicDao.lockRow(nicVO.getId(), true);
if (nic == null) {
throw new ConcurrentOperationException("Unable to acquire lock on nic " + nic);
}
-
+
Nic.State originalState = nic.getState();
NetworkVO network = _networksDao.findById(nicVO.getNetworkId());
-
+
if (originalState == Nic.State.Reserved || originalState == Nic.State.Reserving) {
if (nic.getReservationStrategy() == Nic.ReservationStrategy.Start) {
NetworkGuru guru = _networkGurus.get(network.getGuruName());
@@ -2245,17 +2247,17 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
//commit the transaction before proceeding releasing nic profile on the network elements
txn.commit();
-
+
// Perform release on network elements
for (NetworkElement element : _networkElements) {
if (s_logger.isDebugEnabled()) {
s_logger.debug("Asking " + element.getName() + " to release " + nic);
}
- //NOTE: Context appear to never be used in release method
+ //NOTE: Context appear to never be used in release method
//implementations. Consider removing it from interface Element
element.release(network, profile, vmProfile, null);
}
-
+
} else {
nic.setState(Nic.State.Allocated);
updateNic(nic, network.getId(), -1);
@@ -2280,7 +2282,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
Integer networkRate = getNetworkRate(network.getId(), vm.getId());
NetworkGuru guru = _networkGurus.get(network.getGuruName());
- NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(),
+ NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(),
networkRate, isSecurityGroupSupportedInNetwork(network), getNetworkTag(vm.getHypervisorType(), network));
guru.updateNicProfile(profile, network);
profiles.add(profile);
@@ -2288,7 +2290,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
return profiles;
}
-
+
@Override
public NicProfile getNicProfile(VirtualMachine vm, long networkId, String broadcastUri) {
NicVO nic = null;
@@ -2299,12 +2301,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
NetworkVO network = _networksDao.findById(networkId);
Integer networkRate = getNetworkRate(network.getId(), vm.getId());
-
+
NetworkGuru guru = _networkGurus.get(network.getGuruName());
- NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(),
+ NicProfile profile = new NicProfile(nic, network, nic.getBroadcastUri(), nic.getIsolationUri(),
networkRate, isSecurityGroupSupportedInNetwork(network), getNetworkTag(vm.getHypervisorType(), network));
- guru.updateNicProfile(profile, network);
-
+ guru.updateNicProfile(profile, network);
+
return profile;
}
@@ -2341,7 +2343,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
// Check for account wide pool. It will have an entry for account_vlan_map.
- if (_accountVlanMapDao.findAccountVlanMap(ipVO.getAllocatedToAccountId(), ipVO.getVlanId()) != null) {
+ if (_accountVlanMapDao.findAccountVlanMap(ipVO.getAllocatedToAccountId(), ipVO.getVlanId()) != null) {
//see IPaddressVO.java
InvalidParameterValueException ex = new InvalidParameterValueException("Sepcified IP address uuid belongs to" +
" Account wide IP pool and cannot be disassociated");
@@ -2395,7 +2397,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
public String getNextAvailableMacAddressInNetwork(long networkId) throws InsufficientAddressCapacityException {
String mac = _networksDao.getNextAvailableMacAddress(networkId);
if (mac == null) {
- throw new InsufficientAddressCapacityException("Unable to create another mac address", Network.class, networkId);
+ throw new InsufficientAddressCapacityException("Unable to create another mac address", Network.class, networkId);
}
return mac;
}
@@ -2443,7 +2445,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
removeNic(vm, nic);
}
}
-
+
@Override
public void removeNic(VirtualMachineProfile<? extends VMInstanceVO> vm, Nic nic) {
removeNic(vm, _nicDao.findById(nic.getId()));
@@ -2496,7 +2498,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (ntwkOff == null || ntwkOff.isSystemOnly()) {
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find network offering by specified id");
if (ntwkOff != null) {
- ex.addProxyObject(ntwkOff, networkOfferingId, "networkOfferingId");
+ ex.addProxyObject(ntwkOff, networkOfferingId, "networkOfferingId");
// Get the VO object's table name.
String tablename = AnnotationHelper.getTableName(ntwkOff);
if (tablename != null) {
@@ -2526,12 +2528,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (zone == null) {
throw new InvalidParameterValueException("Specified zone id was not found");
}
-
+
if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType())) {
// See DataCenterVO.java
PermissionDeniedException ex = new PermissionDeniedException("Cannot perform this operation since specified Zone is currently disabled");
ex.addProxyObject(zone, zoneId, "zoneId");
- throw ex;
+ throw ex;
}
// Only domain and account ACL types are supported in Acton.
@@ -2551,7 +2553,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
} else if (ntwkOff.getGuestType() == GuestType.Shared) {
if (!(aclType == ACLType.Domain || aclType == ACLType.Account)) {
- throw new InvalidParameterValueException("AclType should be " + ACLType.Domain + " or " +
+ throw new InvalidParameterValueException("AclType should be " + ACLType.Domain + " or " +
ACLType.Account + " for network of type " + Network.GuestType.Shared);
}
}
@@ -2587,7 +2589,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
DomainVO domain = _domainDao.findById(domainId);
- if (domain == null) {
+ if (domain == null) {
throw new InvalidParameterValueException("Unable to find domain by specified id");
}
_accountMgr.checkAccess(caller, domain);
@@ -2671,7 +2673,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
// 2) GuestType is Isolated, but SourceNat service is disabled
boolean createVlan = (startIP != null && endIP != null && zone.getNetworkType() == NetworkType.Advanced
&& ((ntwkOff.getGuestType() == Network.GuestType.Shared)
- || (ntwkOff.getGuestType() == GuestType.Isolated &&
+ || (ntwkOff.getGuestType() == GuestType.Isolated &&
!areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat))));
// Can add vlan range only to the network which allows it
@@ -2684,7 +2686,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
} else {
s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n");
}
- throw ex;
+ throw ex;
}
Transaction txn = Transaction.currentTxn();
@@ -2711,15 +2713,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (!_configMgr.isOfferingForVpc(ntwkOff)){
throw new InvalidParameterValueException("Network offering can't be used for VPC networks");
}
- network = _vpcMgr.createVpcGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId,
+ network = _vpcMgr.createVpcGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId,
networkDomain, owner, sharedDomainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId, caller);
} else {
if (_configMgr.isOfferingForVpc(ntwkOff)){
throw new InvalidParameterValueException("Network offering can be used for VPC networks only");
}
- network = createGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId,
+ network = createGuestNetwork(networkOfferingId, name, displayText, gateway, cidr, vlanId,
networkDomain, owner, sharedDomainId, pNtwk, zoneId, aclType, subdomainAccess, vpcId);
- }
+ }
if (caller.getType() == Account.ACCOUNT_TYPE_ADMIN && createVlan) {
// Create vlan ip range
@@ -2734,9 +2736,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
@DB
- public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway,
+ public Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway,
String cidr, String vlanId, String networkDomain, Account owner, Long domainId,
- PhysicalNetwork pNtwk, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId)
+ PhysicalNetwork pNtwk, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId)
throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException {
NetworkOfferingVO ntwkOff = _networkOfferingDao.findById(networkOfferingId);
@@ -2776,7 +2778,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (aclType == null || aclType != ACLType.Domain) {
throw new InvalidParameterValueException("Only AclType=Domain can be specified for network creation in Basic zone");
}
-
+
// Only one guest network is supported in Basic zone
List<NetworkVO> guestNetworks = _networksDao.listByZoneAndTrafficType(zone.getId(), TrafficType.Guest);
if (!guestNetworks.isEmpty()) {
@@ -2785,7 +2787,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
// if zone is basic, only Shared network offerings w/o source nat service are allowed
- if (!(ntwkOff.getGuestType() == GuestType.Shared &&
+ if (!(ntwkOff.getGuestType() == GuestType.Shared &&
!areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat))) {
throw new InvalidParameterValueException("For zone of type " + NetworkType.Basic + " only offerings of " +
"guestType " + GuestType.Shared + " with disabled " + Service.SourceNat.getName()
@@ -2816,14 +2818,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (zone.isSecurityGroupEnabled()) {
// Only Account specific Isolated network with sourceNat service disabled are allowed in security group
// enabled zone
- boolean allowCreation = (ntwkOff.getGuestType() == GuestType.Isolated
+ boolean allowCreation = (ntwkOff.getGuestType() == GuestType.Isolated
&& !areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat));
if (!allowCreation) {
throw new InvalidParameterValueException("Only Account specific Isolated network with sourceNat " +
"service disabled are allowed in security group enabled zone");
}
}
-
+
//don't allow eip/elb networks in Advance zone
if (ntwkOff.getElasticIp() || ntwkOff.getElasticLb()) {
throw new InvalidParameterValueException("Elastic IP and Elastic LB services are supported in zone of type " + NetworkType.Basic);
@@ -2855,7 +2857,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
}
}
-
+
// If networkDomain is not specified, take it from the global configuration
if (areServicesSupportedByNetworkOffering(networkOfferingId, Service.Dns)) {
Map<Network.Capability, String> dnsCapabilities = getNetworkOfferingServiceCapabilities
@@ -2897,7 +2899,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
// limitation, remove after we introduce support for multiple ip ranges
// with different Cidrs for the same Shared network
boolean cidrRequired = zone.getNetworkType() == NetworkType.Advanced && ntwkOff.getTrafficType() == TrafficType.Guest
- && (ntwkOff.getGuestType() == GuestType.Shared || (ntwkOff.getGuestType() == GuestType.Isolated
+ && (ntwkOff.getGuestType() == GuestType.Shared || (ntwkOff.getGuestType() == GuestType.Isolated
&& !areServicesSupportedByNetworkOffering(ntwkOff.getId(), Service.SourceNat)));
if (cidr == null && cidrRequired) {
throw new InvalidParameterValueException("StartIp/endIp/gateway/netmask are required when create network of" +
@@ -2949,7 +2951,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (networks == null || networks.isEmpty()) {
throw new CloudRuntimeException("Fail to create a network");
} else {
- if (networks.size() > 0 && networks.get(0).getGuestType() == Network.GuestType.Isolated &&
+ if (networks.size() > 0 && networks.get(0).getGuestType() == Network.GuestType.Isolated &&
networks.get(0).getTrafficType() == TrafficType.Guest) {
Network defaultGuestNetwork = networks.get(0);
for (Network nw : networks) {
@@ -2963,7 +2965,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
network = networks.get(0);
}
}
-
+
if (updateResourceCount) {
_resourceLimitMgr.incrementResourceCount(owner.getId(), ResourceType.network);
}
@@ -3045,13 +3047,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
} else {
permittedAccounts.clear();
Project project = _projectMgr.getProject(projectId);
- if (project == null) {
+ if (project == null) {
throw new InvalidParameterValueException("Unable to find project by specified id");
}
if (!_projectMgr.canAccessProjectAccount(caller, project.getProjectAccountId())) {
// getProject() returns type ProjectVO.
InvalidParameterValueException ex = new InvalidParameterValueException("Account " + caller + " cannot access specified project id");
- ex.addProxyObject(project, projectId, "projectId");
+ ex.addProxyObject(project, projectId, "projectId");
throw ex;
}
permittedAccounts.add(project.getProjectAccountId());
@@ -3063,15 +3065,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
path = _domainDao.findById(domainId).getPath();
} else {
path = _domainDao.findById(caller.getDomainId()).getPath();
- }
-
+ }
+
if (listAll && domainId == null) {
isRecursive = true;
}
Filter searchFilter = new Filter(NetworkVO.class, "id", false, cmd.getStartIndex(), cmd.getPageSizeVal());
SearchBuilder<NetworkVO> sb = _networksDao.createSearchBuilder();
-
+
if (forVpc != null) {
if (forVpc) {
sb.and("vpc", sb.entity().getVpcId(), Op.NNULL);
@@ -3115,8 +3117,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
SearchBuilder<AccountVO> accountSearch = _accountDao.createSearchBuilder();
accountSearch.and("typeNEQ", accountSearch.entity().getType(), SearchCriteria.Op.NEQ);
accountSearch.and("typeEQ", accountSearch.entity().getType(), SearchCriteria.Op.EQ);
-
-
+
+
sb.join("accountSearch", accountSearch, sb.entity().getAccountId(), accountSearch.entity().getId(), JoinBuilder.JoinType.INNER);
List<NetworkVO> networksToReturn = new ArrayList<NetworkVO>();
@@ -3125,7 +3127,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (!permittedAccounts.isEmpty()) {
//get account level networks
networksToReturn.addAll(listAccountSpecificNetworks(
- buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
+ buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags), searchFilter,
permittedAccounts));
//get domain level networks
@@ -3139,12 +3141,12 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
} else {
//add account specific networks
networksToReturn.addAll(listAccountSpecificNetworksByDomainPath(
- buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
+ buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags), searchFilter, path,
isRecursive));
//add domain specific networks of domain + parent domains
networksToReturn.addAll(listDomainSpecificNetworksByDomainPath(
- buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
+ buildNetworkSearchCriteria(sb, keyword, id, isSystem, zoneId, guestIpType, trafficType,
physicalNetworkId, aclType, skipProjectNetworks, restartRequired, specifyIpRanges, vpcId, tags), searchFilter, path,
isRecursive));
//add networks of subdomains
@@ -3184,7 +3186,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
networksToReturn=supportedNetworks;
}
-
+
if (canUseForDeploy != null) {
List<NetworkVO> networksForDeploy = new ArrayList<NetworkVO>();
for (NetworkVO network : networksToReturn) {
@@ -3192,10 +3194,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
networksForDeploy.add(network);
}
}
-
+
networksToReturn=networksForDeploy;
}
-
+
return networksToReturn;
}
@@ -3210,11 +3212,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
} else {
hasFreeIps = (getAvailableIps(network, null)).size() > 0;
}
-
+
return hasFreeIps;
}
- private SearchCriteria<NetworkVO> buildNetworkSearchCriteria(SearchBuilder<NetworkVO> sb, String keyword, Long id,
+ private SearchCriteria<NetworkVO> buildNetworkSearchCriteria(SearchBuilder<NetworkVO> sb, String keyword, Long id,
Boolean isSystem, Long zoneId, String guestIpType, String trafficType, Long physicalNetworkId,
String aclType, boolean skipProjectNetworks, Boolean restartRequired, Boolean specifyIpRanges, Long vpcId, Map<String, String> tags) {
@@ -3267,11 +3269,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (specifyIpRanges != null) {
sc.addAnd("specifyIpRanges", SearchCriteria.Op.EQ, specifyIpRanges);
}
-
+
if (vpcId != null) {
sc.addAnd("vpcId", SearchCriteria.Op.EQ, vpcId);
}
-
+
if (tags != null && !tags.isEmpty()) {
int count = 0;
sc.setJoinParameters("tagSearch", "resourceType", TaggedResourceType.Network.toString());
@@ -3354,7 +3356,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
List<Long> networkIds = new ArrayList<Long>();
-
+
List<NetworkDomainVO> maps = _networkDomainDao.listDomainNetworkMapByDomain(allowedDomains.toArray());
for (NetworkDomainVO map : maps) {
@@ -3383,16 +3385,16 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
NetworkVO network = _networksDao.findById(networkId);
if (network == null) {
// see NetworkVO.java
-
+
InvalidParameterValueException ex = new InvalidParameterValueException("unable to find network with specified id");
- ex.addProxyObject(network, networkId, "networkId");
+ ex.addProxyObject(network, networkId, "networkId");
throw ex;
}
// don't allow to delete system network
if (isNetworkSystem(network)) {
InvalidParameterValueException ex = new InvalidParameterValueException("Network with specified id is system and can't be removed");
- ex.addProxyObject(network, network.getId(), "networkId");
+ ex.addProxyObject(network, network.getId(), "networkId");
throw ex;
}
@@ -3411,7 +3413,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@DB
public boolean shutdownNetwork(long networkId, ReservationContext context, boolean cleanupElements) {
boolean result = false;
-
+
NetworkVO network = _networksDao.lockRow(networkId, true);
if (network == null) {
s_logger.debug("Unable to find network with id: " + networkId);
@@ -3529,11 +3531,11 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
return false;
}
}
-
+
//In Basic zone, make sure that there are no non-removed console proxies and SSVMs using the network
DataCenter zone = _configMgr.getZone(network.getDataCenterId());
if (zone.getNetworkType() == NetworkType.Basic) {
- List<VMInstanceVO> systemVms = _vmDao.listNonRemovedVmsByTypeAndNetwork(network.getId(),
+ List<VMInstanceVO> systemVms = _vmDao.listNonRemovedVmsByTypeAndNetwork(network.getId(),
Type.ConsoleProxy, Type.SecondaryStorageVm);
if (systemVms != null && !systemVms.isEmpty()) {
s_logger.warn("Can't delete the network, not all consoleProxy/secondaryStorage vms are expunged");
@@ -3608,7 +3610,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
network.setState(Network.State.Destroy);
_networksDao.update(network.getId(), network);
_networksDao.remove(network.getId());
-
+
NetworkOffering ntwkOff = _configMgr.getNetworkOffering(network.getNetworkOfferingId());
boolean updateResourceCount = resourceCountNeedsUpdate(ntwkOff, network.getAclType());
if (updateResourceCount) {
@@ -3627,7 +3629,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
protected boolean deleteVlansInNetwork(long networkId, long userId, Account callerAccount) {
-
+
//cleanup Public vlans
List<VlanVO> publicVlans = _vlanDao.listVlansByNetworkId(networkId);
boolean result = true;
@@ -3636,8 +3638,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
s_logger.warn("Failed to delete vlan " + vlan.getId() + ");");
result = false;
}
- }
-
+ }
+
//cleanup private vlans
int privateIpAllocCount = _privateIpDao.countAllocatedByNetworkId(networkId);
if (privateIpAllocCount > 0) {
@@ -3828,7 +3830,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
// Check if network exists
NetworkVO network = _networksDao.findById(networkId);
- if (network == null) {
+ if (network == null) {
InvalidParameterValueException ex = new InvalidParameterValueException("Network with specified id doesn't exist");
ex.addProxyObject("networks", networkId, "networkId");
throw ex;
@@ -3838,9 +3840,9 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (!(network.getState() == Network.State.Implemented || network.getState() == Network.State.Setup)) {
throw new InvalidParameterValueException("Network is not in the right state to be restarted. Correct states are: " + Network.State.Implemented + ", " + Network.State.Setup);
}
-
+
if (network.getBroadcastDomainType() == BroadcastDomainType.Lswitch ) {
- /**
+ /**
* Unable to restart these networks now.
* TODO Restarting a SDN based network requires updating the nics and the configuration
* in the controller. This requires a non-trivial rewrite of the restart procedure.
@@ -3868,7 +3870,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
NetworkVO network = _networksDao.findById(networkId);
if (network == null) {
InvalidParameterValueException ex = new InvalidParameterValueException("Network with specified id doesn't exist");
- ex.addProxyObject(network, networkId, "networkId");
+ ex.addProxyObject(network, networkId, "networkId");
throw ex;
}
@@ -3978,13 +3980,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
}
}
-
+
//apply network ACLs
if (!_networkACLMgr.applyNetworkACLs(networkId, caller)) {
s_logger.warn("Failed to reapply network ACLs as a part of of network id=" + networkId + " restart");
success = false;
}
-
+
return success;
}
@@ -4047,7 +4049,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
public Map<Capability, String> getNetworkOfferingServiceCapabilities(NetworkOffering offering, Service service) {
if (!areServicesSupportedByNetworkOffering(offering.getId(), service)) {
- // TBD: We should be sending networkOfferingId and not the offering object itself.
+ // TBD: We should be sending networkOfferingId and not the offering object itself.
throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the network offering " + offering);
}
@@ -4099,7 +4101,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
List<NetworkVO> networks = _networksDao.listBy(Account.ACCOUNT_ID_SYSTEM, networkOfferingId, zoneId);
if (networks == null || networks.isEmpty()) {
- // TBD: send uuid instead of zoneId. Hardcode tablename in call to addProxyObject().
+ // TBD: send uuid instead of zoneId. Hardcode tablename in call to addProxyObject().
throw new InvalidParameterValueException("Unable to find network with traffic type " + trafficType + " in zone " + zoneId);
}
return networks.get(0);
@@ -4184,7 +4186,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
ResourceUnavailableException, ResourceAllocationException {
Account owner = _accountMgr.getActiveAccountById(accountId);
boolean createNetwork = false;
-
+
if (guestNetwork != null && guestNetwork.getTrafficType() != TrafficType.Guest) {
throw new InvalidParameterValueException("Network " + guestNetwork + " is not of a type " + TrafficType.Guest);
}
@@ -4208,22 +4210,22 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (createNetwork) {
List<NetworkOfferingVO> requiredOfferings = _networkOfferingDao.listByAvailability(Availability.Required, false);
if (requiredOfferings.size() < 1) {
- throw new CloudRuntimeException("Unable to find network offering with availability=" +
+ throw new CloudRuntimeException("Unable to find network offering with availability=" +
Availability.Required + " to automatically create the network as part of createVlanIpRange");
}
if (requiredOfferings.get(0).getState() == NetworkOffering.State.Enabled) {
-
+
long physicalNetworkId = findPhysicalNetworkId(zoneId, requiredOfferings.get(0).getTags(), requiredOfferings.get(0).getTrafficType());
// Validate physical network
PhysicalNetwork physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
if (physicalNetwork == null) {
throw new InvalidParameterValueException("Unable to find physical network with id: "+physicalNetworkId + " and tag: " +requiredOfferings.get(0).getTags());
}
-
- s_logger.debug("Creating network for account " + owner + " from the network offering id=" +
+
+ s_logger.debug("Creating network for account " + owner + " from the network offering id=" +
requiredOfferings.get(0).getId() + " as a part of createVlanIpRange process");
guestNetwork = createGuestNetwork(requiredOfferings.get(0).getId(), owner.getAccountName() + "-network"
- , owner.getAccountName() + "-network", null, null, null, null, owner, null, physicalNetwork,
+ , owner.getAccountName() + "-network", null, null, null, null, owner, null, physicalNetwork,
zoneId, ACLType.Account,
null, null);
if (guestNetwork == null) {
@@ -4232,8 +4234,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
"service enabled as a part of createVlanIpRange, for the account " + accountId + "in zone " + zoneId);
}
} else {
- throw new CloudRuntimeException("Required network offering id=" + requiredOfferings.get(0).getId()
- + " is not in " + NetworkOffering.State.Enabled);
+ throw new CloudRuntimeException("Required network offering id=" + requiredOfferings.get(0).getId()
+ + " is not in " + NetworkOffering.State.Enabled);
}
}
@@ -4336,7 +4338,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
s_logger.debug("Network " + network + " doesn't support service " + Service.UserData.getName());
return null;
}
-
+
return (UserDataServiceProvider)getElementImplementingProvider(passwordProvider);
}
@@ -4484,7 +4486,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
return networks;
}
-
+
@DB
@Override
public IPAddressVO markIpAsUnavailable(long addrId) {
@@ -4512,7 +4514,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
String guestType = vlan.getVlanType().toString();
UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_NET_IP_RELEASE,
- ip.getAllocatedToAccountId(), ip.getDataCenterId(), addrId, ip.getAddress().addr(),
+ ip.getAllocatedToAccountId(), ip.getDataCenterId(), addrId, ip.getAddress().addr(),
ip.isSourceNat(), guestType, ip.getSystem());
_usageEventDao.persist(usageEvent);
}
@@ -4568,15 +4570,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
private boolean checkForNonStoppedVmInNetwork(long networkId) {
- List<UserVmVO> vms = _userVmDao.listByNetworkIdAndStates(networkId, VirtualMachine.State.Starting,
+ List<UserVmVO> vms = _userVmDao.listByNetworkIdAndStates(networkId, VirtualMachine.State.Starting,
VirtualMachine.State.Running, VirtualMachine.State.Migrating, VirtualMachine.State.Stopping);
return vms.isEmpty();
}
-
+
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_NETWORK_UPDATE, eventDescription = "updating network", async = true)
- public Network updateGuestNetwork(long networkId, String name, String displayText, Account callerAccount,
+ public Network updateGuestNetwork(long networkId, String name, String displayText, Account callerAccount,
User callerUser, String domainSuffix, Long networkOfferingId, Boolean changeCidr) {
boolean restartNetwork = false;
@@ -4604,7 +4606,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (network.getTrafficType() != Networks.TrafficType.Guest) {
throw new InvalidParameterValueException("Can't allow networks which traffic type is not " + TrafficType.Guest);
}
-
+
_accountMgr.checkAccess(callerAccount, null, true, network);
if (name != null) {
@@ -4628,18 +4630,18 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId);
if (networkOffering == null || networkOffering.isSystemOnly()) {
InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find network offering with specified id");
- ex.addProxyObject(networkOffering, networkOfferingId, "networkOfferingId");
+ ex.addProxyObject(networkOffering, networkOfferingId, "networkOfferingId");
throw ex;
}
-
+
// network offering should be in Enabled state
if (networkOffering.getState() != NetworkOffering.State.Enabled) {
InvalidParameterValueException ex = new InvalidParameterValueException("Network offering with specified id is not in " + NetworkOffering.State.Enabled + " state, can't upgrade to it");
- ex.addProxyObject(networkOffering, networkOfferingId, "networkOfferingId");
+ ex.addProxyObject(networkOffering, networkOfferingId, "networkOfferingId");
throw ex;
}
-
-
+
+
//can't update from vpc to non-vpc network offering
boolean forVpcNew = _configMgr.isOfferingForVpc(networkOffering);
boolean vorVpcOriginal = _configMgr.isOfferingForVpc(_configMgr.getNetworkOffering(oldNetworkOfferingId));
@@ -4656,7 +4658,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (changeCidr) {
if (!checkForNonStoppedVmInNetwork(network.getId())) {
InvalidParameterValueException ex = new InvalidParameterValueException("All user vm of network of specified id should be stopped before changing CIDR!");
- ex.addProxyObject(network, networkId, "networkId");
+ ex.addProxyObject(network, networkId, "networkId");
throw ex;
}
}
@@ -4711,7 +4713,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (!shutdownNetworkElementsAndResources(context, true, network)) {
s_logger.warn("Failed to shutdown the network elements and resources as a part of network restart: " + network);
CloudRuntimeException ex = new CloudRuntimeException("Failed to shutdown the network elements and resources as a part of update to network of specified id");
- ex.addProxyObject(network, networkId, "networkId");
+ ex.addProxyObject(network, networkId, "networkId");
throw ex;
}
} else {
@@ -4721,13 +4723,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (!shutdownNetwork(network.getId(), context, true)) {
s_logger.warn("Failed to shutdown the network as a part of update to network with specified id");
CloudRuntimeException ex = new CloudRuntimeException("Failed to shutdown the network as a part of update of specified network id");
- ex.addProxyObject(network, networkId, "networkId");
+ ex.addProxyObject(network, networkId, "networkId");
throw ex;
}
}
} else {
CloudRuntimeException ex = new CloudRuntimeException("Failed to shutdown the network elements and resources as a part of update to network with specified id; network is in wrong state: " + network.getState());
- ex.addProxyObject(network, networkId, "networkId");
+ ex.addProxyObject(network, networkId, "networkId");
throw ex;
}
}
@@ -4738,7 +4740,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
boolean validStateToImplement = (networkState == Network.State.Implemented || networkState == Network.State.Setup || networkState == Network.State.Allocated);
if (restartNetwork && !validStateToImplement) {
CloudRuntimeException ex = new CloudRuntimeException("Failed to implement the network elements and resources as a part of update to network with specified id; network is in wrong state: " + networkState);
- ex.addProxyObject(network, networkId, "networkId");
+ ex.addProxyObject(network, networkId, "networkId");
throw ex;
}
@@ -4788,7 +4790,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
} catch (Exception ex) {
s_logger.warn("Failed to implement network " + network + " elements and resources as a part of network update due to ", ex);
CloudRuntimeException e = new CloudRuntimeException("Failed to implement network (with specified id) elements and resources as a part of network update");
- e.addProxyObject(network, networkId, "networkId");
+ e.addProxyObject(network, networkId, "networkId");
throw e;
}
}
@@ -4867,8 +4869,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
String[] cidr = network.getCidr().split("/");
List<String> ips = _nicDao.listIpAddressInNetwork(network.getId());
Set<Long> allPossibleIps = NetUtils.getAllIpsFromCidr(cidr[0], Integer.parseInt(cidr[1]));
- Set<Long> usedIps = new TreeSet<Long>();
-
+ Set<Long> usedIps = new TreeSet<Long>();
+
for (String ip : ips) {
if (requestedIp != null && requestedIp.equals(ip)) {
s_logger.warn("Requested ip address " + requestedIp + " is already in use in network" + network);
@@ -4882,7 +4884,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
return allPossibleIps;
}
-
+
private String getZoneNetworkDomain(long zoneId) {
return _dcDao.findById(zoneId).getDomain();
@@ -5004,7 +5006,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
}
}
}
-
+
// if all the rules configured on public IP are revoked then, dis-associate IP with network service provider
applyIpAssociations(network, true, continueOnError, publicIps);
@@ -5181,7 +5183,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
@Override
@DB
@ActionEvent(eventType = EventTypes.EVENT_PHYSICAL_NETWORK_CREATE, eventDescription = "Creating Physical Network", create = true)
- public PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed, List<String>
+ public PhysicalNetwork createPhysicalNetwork(Long zoneId, String vnetRange, String networkSpeed, List<String>
isolationMethods, String broadcastDomainRangeStr, Long domainId, List<String> tags, String name) {
// Check if zone exists
@@ -5235,7 +5237,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
} catch (NumberFormatException e) {
throw new InvalidParameterValueException("Please specify valid integers for the vlan range.");
}
-
+
//check for vnet conflicts with other physical network(s) in the zone
checkGuestVnetsConflicts(zoneId, vnetStart, vnetEnd, null);
@@ -5290,7 +5292,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
// add security group provider to the physical network
addDefaultSecurityGroupProviderToPhysicalNetwork(pNetwork.getId());
-
+
// add VPCVirtualRouter as the defualt network service provider
addDefaultVpcVirtualRouterToPhysicalNetwork(pNetwork.getId());
@@ -5332,7 +5334,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
PhysicalNetworkVO network = _physicalNetworkDao.findById(id);
if (network == null) {
InvalidParameterValueException ex = new InvalidParameterValueException("Physical Network with specified id doesn't exist in the system");
- ex.addProxyObject(network, id, "physicalNetworkId");
+ ex.addProxyObject(network, id, "physicalNetworkId");
throw ex;
}
@@ -5340,7 +5342,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
DataCenter zone = _dcDao.findById(network.getDataCenterId());
if (zone == null) {
InvalidParameterValueException ex = new InvalidParameterValueException("Zone with id=" + network.getDataCenterId() + " doesn't exist in the system");
- ex.addProxyObject(zone, network.getDataCenterId(), "dataCenterId");
+ ex.addProxyObject(zone, network.getDataCenterId(), "dataCenterId");
throw ex;
}
if (newVnetRangeString != null) {
@@ -5386,14 +5388,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
String[] newVnetRange = newVnetRangeString.split("-");
int maxVnet = 4096;
// for GRE phynets allow up to 32bits
- // TODO: Not happy about this test.
+ // TODO: Not happy about this test.
// What about guru-like objects for physical networs?
s_logger.debug("ISOLATION METHODS:" + network.getIsolationMethods());
// Java does not have unsigned types...
- if (network.getIsolationMethods().contains("GRE")) {
+ if (network.getIsolationMethods().contains("GRE")) {
maxVnet = (int)(Math.pow(2, 32)-1);
}
- String rangeMessage = " between 0 and " + maxVnet;
+ String rangeMessage = " between 0 and " + maxVnet;
if (newVnetRange.length < 2) {
throw new InvalidParameterValueException("Please provide valid vnet range" + rangeMessage);
}
@@ -5416,7 +5418,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
if (newStartVnet > newEndVnet) {
throw new InvalidParameterValueException("Vnet range has to be" + rangeMessage + " and start range should be lesser than or equal to stop range");
}
-
+
//check if new vnet conflicts with vnet ranges of other physical networks
checkGuestVnetsConflicts(network.getDataCenterId(), newStartVnet, newEndVnet, network.getId());
@@ -5478,7 +5480,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
|| (newEndVnet <= endVnet && newEndVnet >= startVnet)) {
throw new InvalidParameterValueException("Vnet range for physical network conflicts with another " +
"physical network's vnet in the zone");
- }
+ }
}
}
@@ -5495,7 +5497,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag
PhysicalNetworkVO pNetwork = _physicalNetworkDao.findById(physicalNetworkId);
if (pNetwork == null
<TRUNCATED>