diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java index 9be61713e9a..49f380b3d6d 100644 --- a/api/src/com/cloud/network/Network.java +++ b/api/src/com/cloud/network/Network.java @@ -61,8 +61,8 @@ public interface Network extends ControlledEntity, StateObject, I public static final Service Connectivity = new Service("Connectivity"); - private String name; - private Capability[] caps; + private final String name; + private final Capability[] caps; public Service(String name, Capability... caps) { this.name = name; @@ -123,13 +123,13 @@ public interface Network extends ControlledEntity, StateObject, I public static final Provider SecurityGroupProvider = new Provider("SecurityGroupProvider", false); public static final Provider VPCVirtualRouter = new Provider("VpcVirtualRouter", false); public static final Provider None = new Provider("None", false); - // NiciraNvp is not an "External" provider, otherwise we get in trouble with NetworkServiceImpl.providersConfiguredForExternalNetworking + // NiciraNvp is not an "External" provider, otherwise we get in trouble with NetworkServiceImpl.providersConfiguredForExternalNetworking public static final Provider NiciraNvp = new Provider("NiciraNvp", false); public static final Provider InternalLbVm = new Provider("InternalLbVm", false); public static final Provider CiscoVnmc = new Provider("CiscoVnmc", true); - private String name; - private boolean isExternal; + private final String name; + private final boolean isExternal; public Provider(String name, boolean isExternal) { this.name = name; @@ -182,7 +182,7 @@ public interface Network extends ControlledEntity, StateObject, I public static final Capability LbSchemes = new Capability("LbSchemes"); public static final Capability DhcpAccrossMultipleSubnets = new Capability("DhcpAccrossMultipleSubnets"); - private String name; + private final String name; public Capability(String name) { this.name = name; @@ -247,8 +247,8 @@ public interface Network extends ControlledEntity, StateObject, I private String ip6Address; public IpAddresses(String ip4Address, String ip6Address) { - this.setIp4Address(ip4Address); - this.setIp6Address(ip6Address); + setIp4Address(ip4Address); + setIp6Address(ip6Address); } public String getIp4Address() { @@ -297,6 +297,7 @@ public interface Network extends ControlledEntity, StateObject, I long getNetworkOfferingId(); + @Override State getState(); long getRelated(); @@ -325,6 +326,8 @@ public interface Network extends ControlledEntity, StateObject, I boolean getDisplayNetwork(); + String getGuruName(); + /** * @return */ diff --git a/api/src/com/cloud/network/NetworkProfile.java b/api/src/com/cloud/network/NetworkProfile.java index fa63ea286aa..542df3e1f64 100644 --- a/api/src/com/cloud/network/NetworkProfile.java +++ b/api/src/com/cloud/network/NetworkProfile.java @@ -23,68 +23,70 @@ import com.cloud.network.Networks.Mode; import com.cloud.network.Networks.TrafficType; public class NetworkProfile implements Network { - private long id; - private String uuid; - private long dataCenterId; - private long ownerId; - private long domainId; + private final long id; + private final String uuid; + private final long dataCenterId; + private final long ownerId; + private final long domainId; private String dns1; private String dns2; private URI broadcastUri; - private State state; - private String name; - private Mode mode; - private BroadcastDomainType broadcastDomainType; + private final State state; + private final String name; + private final Mode mode; + private final BroadcastDomainType broadcastDomainType; private TrafficType trafficType; - private String gateway; - private String cidr; - private String networkCidr; - private String ip6Gateway; - private String ip6Cidr; - private long networkOfferingId; - private long related; - private String displayText; - private String reservationId; - private String networkDomain; - private Network.GuestType guestType; + private final String gateway; + private final String cidr; + private final String networkCidr; + private final String ip6Gateway; + private final String ip6Cidr; + private final long networkOfferingId; + private final long related; + private final String displayText; + private final String reservationId; + private final String networkDomain; + private final Network.GuestType guestType; private Long physicalNetworkId; - private ACLType aclType; - private boolean restartRequired; - private boolean specifyIpRanges; - private Long vpcId; - private boolean displayNetwork; + private final ACLType aclType; + private final boolean restartRequired; + private final boolean specifyIpRanges; + private final Long vpcId; + private final boolean displayNetwork; private Long networkAclId; + private final String guruName; public NetworkProfile(Network network) { - this.id = network.getId(); - this.uuid = network.getUuid(); - this.broadcastUri = network.getBroadcastUri(); - this.dataCenterId = network.getDataCenterId(); - this.ownerId = network.getAccountId(); - this.state = network.getState(); - this.name = network.getName(); - this.mode = network.getMode(); - this.broadcastDomainType = network.getBroadcastDomainType(); - this.trafficType = network.getTrafficType(); - this.gateway = network.getGateway(); - this.cidr = network.getCidr(); - this.networkCidr = network.getNetworkCidr(); - this.ip6Gateway = network.getIp6Gateway(); - this.ip6Cidr = network.getIp6Cidr(); - this.networkOfferingId = network.getNetworkOfferingId(); - this.related = network.getRelated(); - this.displayText = network.getDisplayText(); - this.reservationId = network.getReservationId(); - this.networkDomain = network.getNetworkDomain(); - this.domainId = network.getDomainId(); - this.guestType = network.getGuestType(); - this.physicalNetworkId = network.getPhysicalNetworkId(); - this.aclType = network.getAclType(); - this.restartRequired = network.isRestartRequired(); - this.specifyIpRanges = network.getSpecifyIpRanges(); - this.vpcId = network.getVpcId(); - this.displayNetwork = network.getDisplayNetwork(); - this.networkAclId = network.getNetworkACLId(); + id = network.getId(); + uuid = network.getUuid(); + broadcastUri = network.getBroadcastUri(); + dataCenterId = network.getDataCenterId(); + ownerId = network.getAccountId(); + state = network.getState(); + name = network.getName(); + mode = network.getMode(); + broadcastDomainType = network.getBroadcastDomainType(); + trafficType = network.getTrafficType(); + gateway = network.getGateway(); + cidr = network.getCidr(); + networkCidr = network.getNetworkCidr(); + ip6Gateway = network.getIp6Gateway(); + ip6Cidr = network.getIp6Cidr(); + networkOfferingId = network.getNetworkOfferingId(); + related = network.getRelated(); + displayText = network.getDisplayText(); + reservationId = network.getReservationId(); + networkDomain = network.getNetworkDomain(); + domainId = network.getDomainId(); + guestType = network.getGuestType(); + physicalNetworkId = network.getPhysicalNetworkId(); + aclType = network.getAclType(); + restartRequired = network.isRestartRequired(); + specifyIpRanges = network.getSpecifyIpRanges(); + vpcId = network.getVpcId(); + displayNetwork = network.getDisplayNetwork(); + networkAclId = network.getNetworkACLId(); + guruName = network.getGuruName(); } public String getDns1() { @@ -103,6 +105,11 @@ public class NetworkProfile implements Network { this.dns2 = dns2; } + @Override + public String getGuruName() { + return guruName; + } + public void setBroadcastUri(URI broadcastUri) { this.broadcastUri = broadcastUri; } @@ -252,12 +259,12 @@ public class NetworkProfile implements Network { @Override public void setNetworkACLId(Long networkACLId) { - this.networkAclId = networkACLId; + networkAclId = networkACLId; } @Override public void setTrafficType(TrafficType type) { - this.trafficType = type; + trafficType = type; } @Override diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in index de52c36d117..5fe89851965 100644 --- a/client/tomcatconf/applicationContext.xml.in +++ b/client/tomcatconf/applicationContext.xml.in @@ -848,7 +848,6 @@ - diff --git a/server/src/com/cloud/network/NetworkManager.java b/engine/api/src/com/cloud/network/NetworkManager.java similarity index 67% rename from server/src/com/cloud/network/NetworkManager.java rename to engine/api/src/com/cloud/network/NetworkManager.java index 4acf8c30842..6ec96f5c62e 100755 --- a/server/src/com/cloud/network/NetworkManager.java +++ b/engine/api/src/com/cloud/network/NetworkManager.java @@ -33,7 +33,6 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; -import com.cloud.network.dao.NetworkVO; import com.cloud.network.element.DhcpServiceProvider; import com.cloud.network.element.LoadBalancingServiceProvider; import com.cloud.network.element.StaticNatServiceProvider; @@ -41,13 +40,11 @@ import com.cloud.network.element.UserDataServiceProvider; import com.cloud.network.guru.NetworkGuru; import com.cloud.network.rules.LoadBalancerContainer.Scheme; import com.cloud.offering.NetworkOffering; -import com.cloud.offerings.NetworkOfferingVO; import com.cloud.user.Account; import com.cloud.user.User; import com.cloud.utils.Pair; import com.cloud.vm.Nic; import com.cloud.vm.NicProfile; -import com.cloud.vm.NicVO; import com.cloud.vm.ReservationContext; import com.cloud.vm.VirtualMachine; import com.cloud.vm.VirtualMachine.Type; @@ -57,22 +54,20 @@ import com.cloud.vm.VirtualMachineProfile; * NetworkManager manages the network for the different end users. * */ -public interface NetworkManager { +public interface NetworkManager { + List setupNetwork(Account owner, NetworkOffering offering, DeploymentPlan plan, String name, String displayText, boolean isDefault) + throws ConcurrentOperationException; - List setupNetwork(Account owner, NetworkOffering offering, DeploymentPlan plan, String name, String displayText, boolean isDefault) - throws ConcurrentOperationException; - - List setupNetwork(Account owner, NetworkOffering offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean errorIfAlreadySetup, Long domainId, - ACLType aclType, Boolean subdomainAccess, Long vpcId, Boolean isDisplayNetworkEnabled) throws ConcurrentOperationException; + List setupNetwork(Account owner, NetworkOffering offering, Network predefined, DeploymentPlan plan, String name, String displayText, + boolean errorIfAlreadySetup, Long domainId, ACLType aclType, Boolean subdomainAccess, Long vpcId, Boolean isDisplayNetworkEnabled) throws ConcurrentOperationException; void allocate(VirtualMachineProfile vm, LinkedHashMap networks) throws InsufficientCapacityException, ConcurrentOperationException; void prepare(VirtualMachineProfile profile, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException, - ResourceUnavailableException; + ResourceUnavailableException; - void release(VirtualMachineProfile vmProfile, boolean forced) throws - ConcurrentOperationException, ResourceUnavailableException; + void release(VirtualMachineProfile vmProfile, boolean forced) throws ConcurrentOperationException, ResourceUnavailableException; void cleanupNics(VirtualMachineProfile vm); @@ -80,8 +75,8 @@ public interface NetworkManager { List getNicProfiles(VirtualMachine vm); - Pair implementNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, - InsufficientCapacityException; + Pair implementNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, + ResourceUnavailableException, InsufficientCapacityException; /** * prepares vm nic change for migration @@ -116,17 +111,16 @@ public interface NetworkManager { boolean destroyNetwork(long networkId, ReservationContext context); - Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr, - String vlanId, String networkDomain, Account owner, Long domainId, PhysicalNetwork physicalNetwork, - long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String ip6Gateway, String ip6Cidr, - Boolean displayNetworkEnabled, String isolatedPvlan) - throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException; + Network createGuestNetwork(long networkOfferingId, String name, String displayText, String gateway, String cidr, String vlanId, String networkDomain, Account owner, + Long domainId, PhysicalNetwork physicalNetwork, long zoneId, ACLType aclType, Boolean subdomainAccess, Long vpcId, String ip6Gateway, String ip6Cidr, + Boolean displayNetworkEnabled, String isolatedPvlan) throws ConcurrentOperationException, InsufficientCapacityException, ResourceAllocationException; UserDataServiceProvider getPasswordResetProvider(Network network); UserDataServiceProvider getSSHKeyResetProvider(Network network); - boolean startNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException; + boolean startNetwork(long networkId, DeployDestination dest, ReservationContext context) throws ConcurrentOperationException, ResourceUnavailableException, + InsufficientCapacityException; boolean reallocate(VirtualMachineProfile vm, DataCenterDeployment dest) throws InsufficientCapacityException, ConcurrentOperationException; @@ -141,10 +135,8 @@ public interface NetworkManager { * @throws InsufficientAddressCapacityException * @throws ConcurrentOperationException */ - Pair allocateNic(NicProfile requested, Network network, Boolean isDefaultNic, int deviceId, - VirtualMachineProfile vm) throws InsufficientVirtualNetworkCapcityException, - InsufficientAddressCapacityException, ConcurrentOperationException; - + Pair allocateNic(NicProfile requested, Network network, Boolean isDefaultNic, int deviceId, VirtualMachineProfile vm) + throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException; /** * @param vmProfile @@ -159,10 +151,9 @@ public interface NetworkManager { * @throws InsufficientCapacityException * @throws ResourceUnavailableException */ - NicProfile prepareNic(VirtualMachineProfile vmProfile, DeployDestination dest, - ReservationContext context, long nicId, NetworkVO network) throws InsufficientVirtualNetworkCapcityException, - InsufficientAddressCapacityException, ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException; - + NicProfile prepareNic(VirtualMachineProfile vmProfile, DeployDestination dest, ReservationContext context, long nicId, Network network) + throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException, InsufficientCapacityException, + ResourceUnavailableException; /** * @param vm @@ -170,7 +161,6 @@ public interface NetworkManager { */ void removeNic(VirtualMachineProfile vm, Nic nic); - /** * @param network * @param provider @@ -178,16 +168,13 @@ public interface NetworkManager { */ boolean setupDns(Network network, Provider provider); - /** * @param vmProfile * @param nic TODO * @throws ConcurrentOperationException * @throws ResourceUnavailableException */ - void releaseNic(VirtualMachineProfile vmProfile, Nic nic) - throws ConcurrentOperationException, ResourceUnavailableException; - + void releaseNic(VirtualMachineProfile vmProfile, Nic nic) throws ConcurrentOperationException, ResourceUnavailableException; /** * @param network @@ -203,9 +190,8 @@ public interface NetworkManager { * @throws ResourceUnavailableException */ NicProfile createNicForVm(Network network, NicProfile requested, ReservationContext context, VirtualMachineProfile vmProfile, boolean prepare) - throws InsufficientVirtualNetworkCapcityException, - InsufficientAddressCapacityException, ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException; - + throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException, InsufficientCapacityException, + ResourceUnavailableException; NetworkProfile convertNetworkToNetworkProfile(long networkId); @@ -213,28 +199,21 @@ public interface NetworkManager { * @return */ int getNetworkLockTimeout(); - - boolean restartNetwork(Long networkId, Account callerAccount, - User callerUser, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException; + boolean restartNetwork(Long networkId, Account callerAccount, User callerUser, boolean cleanup) throws ConcurrentOperationException, ResourceUnavailableException, + InsufficientCapacityException; + boolean shutdownNetworkElementsAndResources(ReservationContext context, boolean b, Network network); - boolean shutdownNetworkElementsAndResources(ReservationContext context, - boolean b, NetworkVO network); + void implementNetworkElementsAndResources(DeployDestination dest, ReservationContext context, Network network, NetworkOffering findById) throws ConcurrentOperationException, + InsufficientAddressCapacityException, ResourceUnavailableException, InsufficientCapacityException; - - void implementNetworkElementsAndResources(DeployDestination dest, - ReservationContext context, NetworkVO network, - NetworkOfferingVO findById) throws ConcurrentOperationException, InsufficientAddressCapacityException, ResourceUnavailableException, InsufficientCapacityException; - - - Map finalizeServicesAndProvidersForNetwork(NetworkOffering offering, - Long physicalNetworkId); + Map finalizeServicesAndProvidersForNetwork(NetworkOffering offering, Long physicalNetworkId); List getProvidersForServiceInNetwork(Network network, Service service); StaticNatServiceProvider getStaticNatProviderForNetwork(Network network); - + boolean isNetworkInlineMode(Network network); LoadBalancingServiceProvider getLoadBalancingProviderForNetwork(Network network, Scheme lbScheme); @@ -242,9 +221,10 @@ public interface NetworkManager { boolean isSecondaryIpSetForNic(long nicId); List listVmNics(Long vmId, Long nicId); - - NicVO savePlaceholderNic(Network network, String ip4Address, String ip6Address, Type vmType); + + Nic savePlaceholderNic(Network network, String ip4Address, String ip6Address, Type vmType); DhcpServiceProvider getDhcpServiceProvider(Network network); - void removeDhcpServiceInSubnet(NicVO nic); + + void removeDhcpServiceInSubnet(Nic nic); } diff --git a/server/src/com/cloud/network/NetworkManagerImpl.java b/server/src/com/cloud/network/NetworkManagerImpl.java index 8c939f3636a..c683809fc9d 100755 --- a/server/src/com/cloud/network/NetworkManagerImpl.java +++ b/server/src/com/cloud/network/NetworkManagerImpl.java @@ -611,7 +611,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L } @Override - public List setupNetwork(Account owner, NetworkOffering offering, DeploymentPlan plan, String name, + public List setupNetwork(Account owner, NetworkOffering offering, DeploymentPlan plan, String name, String displayText, boolean isDefault) throws ConcurrentOperationException { return setupNetwork(owner, offering, null, plan, name, displayText, false, null, null, null, null, true); @@ -619,7 +619,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L @Override @DB - public List setupNetwork(Account owner, NetworkOffering offering, Network predefined, DeploymentPlan + public List setupNetwork(Account owner, NetworkOffering offering, Network predefined, DeploymentPlan plan, String name, String displayText, boolean errorIfAlreadySetup, Long domainId, ACLType aclType, Boolean subdomainAccess, Long vpcId, Boolean isDisplayNetworkEnabled) throws ConcurrentOperationException { @@ -1024,7 +1024,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L @Override public void implementNetworkElementsAndResources(DeployDestination dest, ReservationContext context, - NetworkVO network, NetworkOfferingVO offering) + Network network, NetworkOffering offering) throws ConcurrentOperationException, InsufficientAddressCapacityException, ResourceUnavailableException, InsufficientCapacityException { // Associate a source NAT IP (if one isn't already associated with the network) if this is a @@ -1093,7 +1093,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L } // This method re-programs the rules/ips for existing network - protected boolean reprogramNetworkRules(long networkId, Account caller, NetworkVO network) throws ResourceUnavailableException { + protected boolean reprogramNetworkRules(long networkId, Account caller, Network network) throws ResourceUnavailableException { boolean success = true; // associate all ip addresses if (!_ipAddrMgr.applyIpAssociations(network, false)) { @@ -1176,7 +1176,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L return success; } - protected boolean prepareElement(NetworkElement element, NetworkVO network, + protected boolean prepareElement(NetworkElement element, Network network, NicProfile profile, VirtualMachineProfile vmProfile, DeployDestination dest, ReservationContext context) throws InsufficientCapacityException, ConcurrentOperationException, ResourceUnavailableException { @@ -1257,7 +1257,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L @Override public NicProfile prepareNic(VirtualMachineProfile vmProfile, DeployDestination - dest, ReservationContext context, long nicId, NetworkVO network) + dest, ReservationContext context, long nicId, Network network) throws InsufficientVirtualNetworkCapcityException, InsufficientAddressCapacityException, ConcurrentOperationException, InsufficientCapacityException, ResourceUnavailableException { @@ -1553,7 +1553,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L @DB @Override - public void removeDhcpServiceInSubnet(NicVO nic) { + public void removeDhcpServiceInSubnet(Nic nic) { Network network = _networksDao.findById(nic.getNetworkId()); DhcpServiceProvider dhcpServiceProvider = getDhcpServiceProvider(network); try { @@ -1869,8 +1869,8 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L } } - List networks = setupNetwork(owner, ntwkOff, userNetwork, plan, name, displayText, true, domainId, - aclType, subdomainAccess, vpcId, isDisplayNetworkEnabled); + List networks = setupNetwork(owner, ntwkOff, userNetwork, plan, name, displayText, true, domainId, aclType, subdomainAccess, vpcId, + isDisplayNetworkEnabled); Network network = null; if (networks == null || networks.isEmpty()) { @@ -1988,7 +1988,7 @@ public class NetworkManagerImpl extends ManagerBase implements NetworkManager, L } @Override - public boolean shutdownNetworkElementsAndResources(ReservationContext context, boolean cleanupElements, NetworkVO network) { + public boolean shutdownNetworkElementsAndResources(ReservationContext context, boolean cleanupElements, Network network) { // 1) Cleanup all the rules for the network. If it fails, just log the failure and proceed with shutting down // the elements boolean cleanupResult = true;