diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index e28e4b8f7c6..9959cc76303 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -173,6 +173,7 @@ import com.cloud.user.User; import com.cloud.user.UserContext; import com.cloud.user.dao.AccountDao; import com.cloud.user.dao.UserStatisticsDao; +import com.cloud.utils.AnnotationHelper; import com.cloud.utils.NumbersUtil; import com.cloud.utils.Pair; import com.cloud.utils.component.Adapters; @@ -402,15 +403,10 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (addrs.size() == 0) { if (podId != null) { - 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"); - throw ex; + throw new InsufficientAddressCapacityException("Insufficient address capacity", Pod.class, podId); } s_logger.warn(errorMessage.toString()); - InsufficientAddressCapacityException ex = new InsufficientAddressCapacityException("Insufficient address capacity", DataCenter.class, dcId); - ex.addProxyObject("data_center", dcId, "dcId"); - throw ex; + throw new InsufficientAddressCapacityException("Insufficient address capacity", DataCenter.class, dcId); } assert (addrs.size() == 1) : "Return size is incorrect: " + addrs.size(); @@ -496,8 +492,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // this ownerId comes from owner or type Account. See the class "AccountVO" and the annotations in that class // to get the table name and field name that is queried to fill this ownerid. ConcurrentOperationException ex = new ConcurrentOperationException("Unable to lock account"); - ex.addProxyObject("account", ownerId, "ownerId"); - throw ex; } if (s_logger.isDebugEnabled()) { s_logger.debug("lock account " + ownerId + " is acquired"); @@ -577,6 +571,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // The admin is making the call, determine if it is for someone else or for himself if (domainId != null) { if ((account != null) && !_domainDao.isChildDomain(account.getDomainId(), domainId)) { + // TBD: Check if call to addProxyObject() needs correction. PermissionDeniedException ex = new PermissionDeniedException("Invalid domain id given, permission denied"); ex.addProxyObject("domain", domainId, "domainId"); throw ex; @@ -586,6 +581,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (userAccount != null) { account = userAccount; } else { + // TBD: Check if call to addProxyObject() needs correction. PermissionDeniedException ex = new PermissionDeniedException("Unable to find account " + accountName + " in specified domain, permission denied"); ex.addProxyObject("domain", domainId, "domainId"); throw ex; @@ -971,7 +967,13 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag Network network = _networksDao.findById(networkId); if (network == null) { InvalidParameterValueException ex = new InvalidParameterValueException("Network id is invalid"); - ex.addProxyObject("networks", networkId, "networkId"); + // Get the VO object's table name. + String tablename = AnnotationHelper.getTableName(network); + if (tablename != null) { + ex.addProxyObject(tablename, networkId, "networkId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } throw ex; } @@ -1004,8 +1006,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (Grouping.AllocationState.Disabled == zone.getAllocationState() && !_accountMgr.isRootAdmin(caller.getType())) { // zone is of type DataCenter. See DataCenterVO.java. - PermissionDeniedException ex = new PermissionDeniedException("Cannot perform this operation, Zone is currently disabled"); - ex.addProxyObject("data_center", zone.getId(), "zoneId"); + PermissionDeniedException ex = new PermissionDeniedException("Cannot perform this operation, zone with specified id is currently disabled"); + // Get the VO object's table name. + String tablename = AnnotationHelper.getTableName(zone); + if (tablename != null) { + ex.addProxyObject(tablename, zone.getId(), "zoneId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } throw ex; } @@ -1051,8 +1059,6 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag 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"); - throw ex; } UserContext.current().setEventDetails("Ip Id: " + ip.getId()); Ip ipAddress = ip.getAddress(); @@ -1433,7 +1439,21 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } if (errorIfAlreadySetup) { - throw new InvalidParameterValueException("Found existing network configuration for offering " + offering + ": " + configs.get(0)); + InvalidParameterValueException ex = new InvalidParameterValueException("Found existing network configuration (with specified id) for offering (with specified id)"); + // Get the VO object's table name. + String tablename = AnnotationHelper.getTableName(offering); + if (tablename != null) { + ex.addProxyObject(tablename, offering.getId(), "offeringId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + tablename = AnnotationHelper.getTableName(configs.get(0)); + if (tablename != null) { + ex.addProxyObject(tablename, configs.get(0).getId(), "networkConfigId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } else { return configs; } @@ -1447,7 +1467,21 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } if (errorIfAlreadySetup) { - throw new InvalidParameterValueException("Found existing network configuration for offering " + offering + ": " + configs.get(0)); + InvalidParameterValueException ex = new InvalidParameterValueException("Found existing network configuration (with specified id) for offering (with specified id)"); + // Get the VO object's table name. + String tablename = AnnotationHelper.getTableName(offering); + if (tablename != null) { + ex.addProxyObject(tablename, offering.getId(), "offeringId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + tablename = AnnotationHelper.getTableName(configs.get(0)); + if (tablename != null) { + ex.addProxyObject(tablename, configs.get(0).getId(), "networkConfigId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } else { return configs; } @@ -1494,9 +1528,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (networks.size() < 1) { // see networkOfferingVO.java - CloudRuntimeException ex = new CloudRuntimeException("Unable to convert network offering to network profile"); - ex.addProxyObject("network_offerings", offering.getId(), "networkOfferingId"); - throw ex; + CloudRuntimeException ex = new CloudRuntimeException("Unable to convert network offering with specified id to network profile"); + String tablename = AnnotationHelper.getTableName(offering); + if (tablename != null) { + ex.addProxyObject(tablename, offering.getId(), "networkOfferingId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } return networks; @@ -1775,16 +1814,24 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag for (NetworkElement element : _networkElements) { if (providersToImplement.contains(element.getProvider())) { if (!isProviderEnabledInPhysicalNetwork(getPhysicalNetworkId(network), "VirtualRouter")) { - // see NetworkVO.java. - CloudRuntimeException ex = new CloudRuntimeException("Service provider " + element.getProvider().getName() + "either doesn't exist or is not enabled in specified physical network id"); - ex.addProxyObject("networks", network.getPhysicalNetworkId(), "physicalNetworkId"); - throw ex; + // The physicalNetworkId will not get translated into a uuid by the reponse serializer, + // 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() + "either doesn't exist or is not enabled in physical network id: " + network.getPhysicalNetworkId()); } if (s_logger.isDebugEnabled()) { s_logger.debug("Asking " + element.getName() + " to implemenet " + network); } if (!element.implement(network, offering, dest, context)) { - throw new CloudRuntimeException("Failed to implement provider " + element.getProvider().getName() + " for network " + network); + CloudRuntimeException ex = new CloudRuntimeException("Failed to implement provider " + element.getProvider().getName() + " for network with specified id"); + String tablename = AnnotationHelper.getTableName(network); + if (tablename != null) { + ex.addProxyObject(tablename, network.getId(), "networkId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } } } @@ -2020,13 +2067,25 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag 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"); - ex.addProxyObject("user_ip_address", ipAddressId, "ipAddressId"); - throw ex; + String tablename = AnnotationHelper.getTableName(ipVO); + if (tablename != null) { + ex.addProxyObject(tablename, ipVO.getId(), "systemIpAddrId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } // don't allow releasing system ip address if (ipVO.getSystem()) { - throw new InvalidParameterValueException("Can't release system IP address " + ipVO); + InvalidParameterValueException ex = new InvalidParameterValueException("Can't release system IP address with specified id"); + String tablename = AnnotationHelper.getTableName(ipVO); + if (tablename != null) { + ex.addProxyObject(tablename, ipVO.getId(), "systemIpAddrId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } boolean success = releasePublicIpAddress(ipAddressId, userId, caller); @@ -2367,7 +2426,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // Can add vlan range only to the network which allows it if (createVlan && !networkOffering.getSpecifyIpRanges()) { - throw new InvalidParameterValueException("Network offering " + networkOffering + " doesn't support adding multiple ip ranges"); + InvalidParameterValueException ex = new InvalidParameterValueException("Network offering with specified id doesn't support adding multiple ip ranges"); + String tablename = AnnotationHelper.getTableName(networkOffering); + if (tablename != null) { + ex.addProxyObject(tablename, networkOffering.getId(), "networkOfferingId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } Transaction txn = Transaction.currentTxn(); @@ -2492,6 +2558,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag String uri = "vlan://" + vlanId; List networks = _networksDao.listBy(zoneId, uri); if ((networks != null && !networks.isEmpty())) { + // TBD: If zoneId and vlanId are being passed in as params, how to get the VO object or class? Hard code + // the tablename in a call to addProxyObject(). throw new InvalidParameterValueException("Network with vlan " + vlanId + " already exists in zone " + zoneId); } } @@ -2501,6 +2569,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification); if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) { if (networkDomain != null) { + // TBD: NetworkOfferingId and zoneId. Send uuids instead. throw new InvalidParameterValueException("Domain name change is not supported by network offering id=" + networkOfferingId + " in zone id=" + zoneId); } } else { @@ -2890,12 +2959,26 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (network == null) { // see NetworkVO.java - throw new InvalidParameterValueException("unable to find network " + networkId); + InvalidParameterValueException ex = new InvalidParameterValueException("unable to find network with specified id"); + String tablename = AnnotationHelper.getTableName(network); + if (tablename != null) { + ex.addProxyObject(tablename, networkId, "networkId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } // don't allow to delete system network if (isNetworkSystem(network)) { - throw new InvalidParameterValueException("Network " + network + " is system and can't be removed"); + InvalidParameterValueException ex = new InvalidParameterValueException("Network with specified id is system and can't be removed"); + String tablename = AnnotationHelper.getTableName(network); + if (tablename != null) { + ex.addProxyObject(tablename, network.getId(), "networkId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } Account owner = _accountMgr.getAccount(network.getAccountId()); @@ -3323,7 +3406,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // Check if network exists NetworkVO network = _networksDao.findById(networkId); if (network == null) { - throw new InvalidParameterValueException("Network with id=" + networkId + " doesn't exist"); + InvalidParameterValueException ex = new InvalidParameterValueException("Network with specified id doesn't exist"); + String tablename = AnnotationHelper.getTableName(network); + if (tablename != null) { + ex.addProxyObject(tablename, networkId, "networkId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } // implement the network @@ -3470,6 +3560,8 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag public Map getNetworkServiceCapabilities(long networkId, Service service) { if (!areServicesSupportedInNetwork(networkId, service)) { + // TBD: networkId to uuid. No VO object being passed. So we will need to call + // addProxyObject with hardcoded tablename. throw new UnsupportedServiceException("Service " + service.getName() + " is not supported in the network id=" + networkId); } @@ -3496,6 +3588,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag public Map getNetworkOfferingServiceCapabilities(NetworkOffering offering, Service service) { if (!areServicesSupportedByNetworkOffering(offering.getId(), service)) { + // 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); } @@ -3504,6 +3597,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // get the Provider for this Service for this offering List providers = _ntwkOfferingSrvcDao.listProvidersForServiceForNetworkOffering(offering.getId(), service); if (providers.isEmpty()) { + // TBD: We should be sending networkOfferingId and not the offering object itself. throw new InvalidParameterValueException("Service " + service.getName() + " is not supported by the network offering " + offering); } @@ -3519,6 +3613,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag ; if (elementCapabilities == null || !elementCapabilities.containsKey(service)) { + // TBD: We should be sending providerId and not the offering object itself. throw new UnsupportedServiceException("Service " + service.getName() + " is not supported by the element=" + element.getName() + " implementing Provider=" + provider); } serviceCapabilities = elementCapabilities.get(service); @@ -3545,6 +3640,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag List 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(). throw new InvalidParameterValueException("Unable to find network with traffic type " + trafficType + " in zone " + zoneId); } return networks.get(0); @@ -3974,8 +4070,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag NetworkVO network = _networksDao.findById(networkId); if (network == null) { // see NetworkVO.java - //throw new InvalidParameterValueException("Network id=" + networkId + "doesn't exist in the system"); - InvalidParameterValueException ex = new InvalidParameterValueException("Specified network id doesn't exist in the system"); + InvalidParameterValueException ex = new InvalidParameterValueException("Specified network id doesn't exist in the system"); ex.addProxyObject("networks", networkId, "networkId"); throw ex; } @@ -4018,12 +4113,28 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag NetworkOfferingVO networkOffering = _networkOfferingDao.findById(networkOfferingId); if (networkOffering == null || networkOffering.isSystemOnly()) { - throw new InvalidParameterValueException("Unable to find network offering by id " + networkOfferingId); + InvalidParameterValueException ex = new InvalidParameterValueException("Unable to find network offering with specified id"); + // Get the VO object's table name. + String tablename = AnnotationHelper.getTableName(networkOffering); + if (tablename != null) { + ex.addProxyObject(tablename, networkOfferingId, "networkOfferingId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } // network offering should be in Enabled state if (networkOffering.getState() != NetworkOffering.State.Enabled) { - throw new InvalidParameterValueException("Network offering " + networkOffering + " is not in " + NetworkOffering.State.Enabled + " state, can't upgrade to it"); + InvalidParameterValueException ex = new InvalidParameterValueException("Network offering with specified id is not in " + NetworkOffering.State.Enabled + " state, can't upgrade to it"); + // Get the VO object's table name. + String tablename = AnnotationHelper.getTableName(networkOffering); + if (tablename != null) { + ex.addProxyObject(tablename, networkOfferingId, "networkOfferingId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } if (networkOfferingId != oldNetworkOfferingId) { @@ -4033,7 +4144,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } if (changeCidr) { if (!checkForNonStoppedVmInNetwork(network.getId())) { - throw new InvalidParameterValueException("All user vm of network: " + network + " should be stopped before changing CIDR!"); + InvalidParameterValueException ex = new InvalidParameterValueException("All user vm of network of specified id should be stopped before changing CIDR!"); + String tablename = AnnotationHelper.getTableName(network); + if (tablename != null) { + // We could use network.getId() instead of networkId too. + ex.addProxyObject(tablename, networkId, "networkId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } } // check if the network is upgradable @@ -4066,6 +4185,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag Map dnsCapabilities = getNetworkOfferingServiceCapabilities(_configMgr.getNetworkOffering(offeringId), Service.Dns); String isUpdateDnsSupported = dnsCapabilities.get(Capability.AllowDnsSuffixModification); if (isUpdateDnsSupported == null || !Boolean.valueOf(isUpdateDnsSupported)) { + // TBD: use uuid instead of networkOfferingId. May need to hardcode tablename in call to addProxyObject(). throw new InvalidParameterValueException("Domain name change is not supported by the network offering id=" + networkOfferingId); } @@ -4085,19 +4205,43 @@ 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); - throw new CloudRuntimeException("Failed to shutdown the network elements and resources as a part of network update: " + network); + CloudRuntimeException ex = new CloudRuntimeException("Failed to shutdown the network elements and resources as a part of update to network of specified id"); + String tablename = AnnotationHelper.getTableName(network); + if (tablename != null) { + // We could use network.getId() instead of networkId too. + ex.addProxyObject(tablename, networkId, "networkId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } } else { // We need to shutdown the network, since we want to re-implement the network. s_logger.debug("Shutting down network id=" + networkId + " as a part of network update"); if (!shutdownNetwork(network.getId(), context, true)) { - s_logger.warn("Failed to shutdown the network as a part of network update: " + network); - throw new CloudRuntimeException("Failed to shutdown the network as a part of network update: " + network); + 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"); + String tablename = AnnotationHelper.getTableName(network); + if (tablename != null) { + // We could use network.getId() instead of networkId too. + ex.addProxyObject(tablename, networkId, "networkId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } } } else { - throw new CloudRuntimeException("Failed to shutdown the network elements and resources as a part of network update: " + network + "; network is in wrong state: " + network.getState()); + 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()); + String tablename = AnnotationHelper.getTableName(network); + if (tablename != null) { + // We could use network.getId() instead of networkId too. + ex.addProxyObject(tablename, networkId, "networkId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } } @@ -4106,7 +4250,15 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag Network.State networkState = _networksDao.findById(networkId).getState(); boolean validStateToImplement = (networkState == Network.State.Implemented || networkState == Network.State.Setup || networkState == Network.State.Allocated); if (restartNetwork && !validStateToImplement) { - throw new CloudRuntimeException("Failed to implement the network elements and resources as a part of network update: " + network + "; network is in wrong state: " + networkState); + 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); + String tablename = AnnotationHelper.getTableName(network); + if (tablename != null) { + // We could use network.getId() instead of networkId too. + ex.addProxyObject(tablename, networkId, "networkId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } if (networkOfferingId != null) { @@ -4154,7 +4306,15 @@ 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); - throw new CloudRuntimeException("Failed to implement network " + network + " elements and resources as a part of network update"); + CloudRuntimeException e = new CloudRuntimeException("Failed to implement network (with specified id) elements and resources as a part of network update"); + String tablename = AnnotationHelper.getTableName(network); + if (tablename != null) { + // We could use network.getId() instead of networkId too. + e.addProxyObject(tablename, networkId, "networkId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw e; } } } @@ -4543,6 +4703,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } if (Grouping.AllocationState.Enabled == zone.getAllocationState()) { + // TBD: Send uuid instead of zoneId; may have to hardcode tablename in call to addProxyObject(). throw new PermissionDeniedException("Cannot create PhysicalNetwork since the Zone is currently enabled, zone Id: " + zoneId); } @@ -4550,6 +4711,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag if (zoneType == NetworkType.Basic) { if (!_physicalNetworkDao.listByZone(zoneId).isEmpty()) { + // TBD: Send uuid instead of zoneId; may have to hardcode tablename in call to addProxyObject(). throw new CloudRuntimeException("Cannot add the physical network to basic zone id: " + zoneId + ", there is a physical network already existing in this basic Zone"); } } @@ -4669,13 +4831,27 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // verify input parameters PhysicalNetworkVO network = _physicalNetworkDao.findById(id); if (network == null) { - throw new InvalidParameterValueException("Physical Network id=" + id + "doesn't exist in the system"); + InvalidParameterValueException ex = new InvalidParameterValueException("Physical Network with specified id doesn't exist in the system"); + String tablename = AnnotationHelper.getTableName(network); + if (tablename != null) { + ex.addProxyObject(tablename, id, "physicalNetworkId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } // if zone is of Basic type, don't allow to add vnet range DataCenter zone = _dcDao.findById(network.getDataCenterId()); if (zone == null) { - throw new InvalidParameterValueException("Zone with id=" + network.getDataCenterId() + " doesn't exist in the system"); + InvalidParameterValueException ex = new InvalidParameterValueException("Zone with id=" + network.getDataCenterId() + " doesn't exist in the system"); + String tablename = AnnotationHelper.getTableName(zone); + if (tablename != null) { + ex.addProxyObject(tablename, network.getDataCenterId(), "dataCenterId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } if (newVnetRangeString != null) { if (zone.getNetworkType() == NetworkType.Basic @@ -4799,7 +4975,14 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // verify input parameters PhysicalNetworkVO pNetwork = _physicalNetworkDao.findById(physicalNetworkId); if (pNetwork == null) { - throw new InvalidParameterValueException("Network id=" + physicalNetworkId + "doesn't exist in the system"); + InvalidParameterValueException ex = new InvalidParameterValueException("Physical Network with specified id doesn't exist in the system"); + String tablename = AnnotationHelper.getTableName(pNetwork); + if (tablename != null) { + ex.addProxyObject(tablename, physicalNetworkId, "physicalNetworkId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } checkIfPhysicalNetworkIsDeletable(physicalNetworkId); @@ -4972,14 +5155,28 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag // verify input parameters PhysicalNetworkVO network = _physicalNetworkDao.findById(physicalNetworkId); if (network == null) { - throw new InvalidParameterValueException("Physical Network id=" + physicalNetworkId + "doesn't exist in the system"); + InvalidParameterValueException ex = new InvalidParameterValueException("Physical Network with specified id doesn't exist in the system"); + String tablename = AnnotationHelper.getTableName(network); + if (tablename != null) { + ex.addProxyObject(tablename, physicalNetworkId, "physicalNetworkId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } // verify input parameters if (destinationPhysicalNetworkId != null) { PhysicalNetworkVO destNetwork = _physicalNetworkDao.findById(destinationPhysicalNetworkId); if (destNetwork == null) { - throw new InvalidParameterValueException("Destination Physical Network id=" + destinationPhysicalNetworkId + "doesn't exist in the system"); + InvalidParameterValueException ex = new InvalidParameterValueException("Destination Physical Network with specified id doesn't exist in the system"); + String tablename = AnnotationHelper.getTableName(destNetwork); + if (tablename != null) { + ex.addProxyObject(tablename, destinationPhysicalNetworkId, "destinationPhysicalNetworkId"); + } else { + s_logger.info("\nCould not retrieve table name (annotation) from " + tablename + " VO proxy object\n"); + } + throw ex; } } @@ -4991,6 +5188,7 @@ public class NetworkManagerImpl implements NetworkManager, NetworkService, Manag } if (_pNSPDao.findByServiceProvider(physicalNetworkId, providerName) != null) { + // TBD: send uuid instead of physicalNetworkId. throw new CloudRuntimeException("The '" + providerName + "' provider already exists on physical network : " + physicalNetworkId); }