From 6826dd16b5eb6488cc1381f1720059ae48777a7e Mon Sep 17 00:00:00 2001 From: Alena Prokharchyk Date: Tue, 31 Jul 2012 14:12:09 -0700 Subject: [PATCH] VPC: reduced visability for some vpc related methods --- api/src/com/cloud/network/vpc/VpcService.java | 6 +-- .../VpcVirtualNetworkApplianceManager.java | 1 - ...VpcVirtualNetworkApplianceManagerImpl.java | 9 ++-- .../network/vpc/NetworkACLManagerImpl.java | 28 +++++++---- .../src/com/cloud/network/vpc/VpcManager.java | 46 ------------------- .../com/cloud/network/vpc/VpcManagerImpl.java | 24 ++++------ 6 files changed, 37 insertions(+), 77 deletions(-) diff --git a/api/src/com/cloud/network/vpc/VpcService.java b/api/src/com/cloud/network/vpc/VpcService.java index 98eb27eed87..8ff6d7f3470 100644 --- a/api/src/com/cloud/network/vpc/VpcService.java +++ b/api/src/com/cloud/network/vpc/VpcService.java @@ -26,7 +26,6 @@ import com.cloud.exception.ResourceUnavailableException; import com.cloud.network.Network; import com.cloud.network.Network.Provider; import com.cloud.network.Network.Service; -import com.cloud.network.Site2SiteVpnGateway; /** * @author Alena Prokharchyk @@ -125,8 +124,9 @@ public interface VpcService { * @throws ResourceUnavailableException * @throws ConcurrentOperationException */ - boolean startVpc(long vpcId, boolean destroyOnFailure) throws ConcurrentOperationException, ResourceUnavailableException, InsufficientCapacityException; - + boolean startVpc(long vpcId, boolean destroyOnFailure) throws ConcurrentOperationException, + ResourceUnavailableException, InsufficientCapacityException; + /** * @param vpcId * @return diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManager.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManager.java index aa8139c3fe5..fd05e984217 100644 --- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManager.java +++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManager.java @@ -26,7 +26,6 @@ import com.cloud.network.rules.FirewallRule; import com.cloud.network.vpc.PrivateGateway; import com.cloud.network.vpc.StaticRouteProfile; import com.cloud.network.vpc.Vpc; -import com.cloud.network.vpc.VpcGateway; import com.cloud.user.Account; import com.cloud.vm.DomainRouterVO; import com.cloud.vm.VirtualMachineProfile.Param; diff --git a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java index bfb53ce2150..a500d936646 100644 --- a/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java @@ -695,7 +695,8 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian return sendCommandsToRouter(router, cmds); } - private void createNetworkACLsCommands(List rules, VirtualRouter router, Commands cmds, long guestNetworkId) { + private void createNetworkACLsCommands(List rules, VirtualRouter router, Commands cmds, + long guestNetworkId) { List rulesTO = null; String guestVlan = null; Network guestNtwk = _networkDao.findById(guestNetworkId); @@ -723,7 +724,8 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian cmds.addCommand(cmd); } - protected void finalizeSshAndVersionOnStart(Commands cmds, VirtualMachineProfile profile, DomainRouterVO router, NicProfile controlNic) { + protected void finalizeSshAndVersionOnStart(Commands cmds, VirtualMachineProfile profile, + DomainRouterVO router, NicProfile controlNic) { cmds.addCommand("checkSsh", new CheckSshCommand(profile.getInstanceName(), controlNic.getIp4Address(), 3922)); // Update router template/scripts version @@ -794,7 +796,8 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian } } - PlugNicCommand plugNicCmd = new PlugNicCommand(getNicTO(router, publicNic.getNetworkId(), publicNic.getBroadcastUri().toString()), router.getInstanceName()); + PlugNicCommand plugNicCmd = new PlugNicCommand(getNicTO(router, publicNic.getNetworkId(), + publicNic.getBroadcastUri().toString()), router.getInstanceName()); cmds.addCommand(plugNicCmd); } diff --git a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java index 7637892635b..05254a7c45e 100644 --- a/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java +++ b/server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java @@ -195,7 +195,8 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{ } if (network.getTrafficType() != Networks.TrafficType.Guest) { - throw new InvalidParameterValueException("Network ACL can be created just for networks of type " + Networks.TrafficType.Guest, null); + throw new InvalidParameterValueException("Network ACL can be created just for networks of type " + + Networks.TrafficType.Guest, null); } // Verify that the network guru supports the protocol specified @@ -212,6 +213,7 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{ } } + protected void detectNetworkACLConflict(FirewallRuleVO newRule) throws NetworkRuleConflictException { if (newRule.getPurpose() != Purpose.NetworkACL) { return; @@ -249,7 +251,8 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{ } } - if (newRule.getProtocol().equalsIgnoreCase(NetUtils.ICMP_PROTO) && newRule.getProtocol().equalsIgnoreCase(rule.getProtocol())) { + if (newRule.getProtocol().equalsIgnoreCase(NetUtils.ICMP_PROTO) + && newRule.getProtocol().equalsIgnoreCase(rule.getProtocol())) { if (newRule.getIcmpCode().longValue() == rule.getIcmpCode().longValue() && newRule.getIcmpType().longValue() == rule.getIcmpType().longValue() && newRule.getProtocol().equalsIgnoreCase(rule.getProtocol()) && duplicatedCidrs) { @@ -264,10 +267,14 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{ if (!notNullPorts) { continue; } else if (duplicatedCidrs - && ((rule.getSourcePortStart().intValue() <= newRule.getSourcePortStart().intValue() && rule.getSourcePortEnd().intValue() >= newRule.getSourcePortStart().intValue()) - || (rule.getSourcePortStart().intValue() <= newRule.getSourcePortEnd().intValue() && rule.getSourcePortEnd().intValue() >= newRule.getSourcePortEnd().intValue()) - || (newRule.getSourcePortStart().intValue() <= rule.getSourcePortStart().intValue() && newRule.getSourcePortEnd().intValue() >= rule.getSourcePortStart().intValue()) - || (newRule.getSourcePortStart().intValue() <= rule.getSourcePortEnd().intValue() && newRule.getSourcePortEnd().intValue() >= rule.getSourcePortEnd().intValue()))) { + && ((rule.getSourcePortStart().intValue() <= newRule.getSourcePortStart().intValue() + && rule.getSourcePortEnd().intValue() >= newRule.getSourcePortStart().intValue()) + || (rule.getSourcePortStart().intValue() <= newRule.getSourcePortEnd().intValue() + && rule.getSourcePortEnd().intValue() >= newRule.getSourcePortEnd().intValue()) + || (newRule.getSourcePortStart().intValue() <= rule.getSourcePortStart().intValue() + && newRule.getSourcePortEnd().intValue() >= rule.getSourcePortStart().intValue()) + || (newRule.getSourcePortStart().intValue() <= rule.getSourcePortEnd().intValue() + && newRule.getSourcePortEnd().intValue() >= rule.getSourcePortEnd().intValue()))) { throw new NetworkRuleConflictException("The range specified, " + newRule.getSourcePortStart() + "-" + newRule.getSourcePortEnd() + ", conflicts with rule " + rule.getId() @@ -277,7 +284,8 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{ } if (s_logger.isDebugEnabled()) { - s_logger.debug("No network rule conflicts detected for " + newRule + " against " + (rules.size() - 1) + " existing network ACLs"); + s_logger.debug("No network rule conflicts detected for " + newRule + " against " + (rules.size() - 1) + + " existing network ACLs"); } } @@ -312,6 +320,7 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{ return success; } + @Override public FirewallRule getNetworkACL(long ACLId) { FirewallRule rule = _firewallDao.findById(ACLId); @@ -321,6 +330,7 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{ return null; } + @Override public List listNetworkACLs(ListNetworkACLsCmd cmd) { Long networkId = cmd.getNetworkId(); @@ -396,6 +406,7 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{ return _firewallDao.listByNetworkAndPurpose(guestNtwkId, Purpose.NetworkACL); } + @Override public boolean revokeAllNetworkACLsForNetwork(long networkId, long userId, Account caller) throws ResourceUnavailableException { @@ -422,7 +433,8 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{ boolean success = _firewallMgr.applyFirewallRules(ACLsToRevoke, false, caller); if (s_logger.isDebugEnabled()) { - s_logger.debug("Successfully released Network ACLs for network id=" + networkId + " and # of rules now = " + ACLs.size()); + s_logger.debug("Successfully released Network ACLs for network id=" + networkId + " and # of rules now = " + + ACLs.size()); } return success; diff --git a/server/src/com/cloud/network/vpc/VpcManager.java b/server/src/com/cloud/network/vpc/VpcManager.java index ee59025fcc4..8b3250f7994 100644 --- a/server/src/com/cloud/network/vpc/VpcManager.java +++ b/server/src/com/cloud/network/vpc/VpcManager.java @@ -13,15 +13,9 @@ package com.cloud.network.vpc; import java.util.List; -import java.util.Map; -import java.util.Set; import com.cloud.exception.ConcurrentOperationException; import com.cloud.exception.ResourceUnavailableException; -import com.cloud.network.Network.Provider; -import com.cloud.network.Network.Service; -import com.cloud.network.element.VpcProvider; -import com.cloud.network.vpc.VpcOffering.State; import com.cloud.offering.NetworkOffering; import com.cloud.user.Account; import com.cloud.vm.DomainRouterVO; @@ -32,38 +26,6 @@ import com.cloud.vm.DomainRouterVO; */ public interface VpcManager extends VpcService{ - /** - * @param name - * @param displayText - * @param svcProviderMap - * @param isDefault - * @param state TODO - * @return - */ - VpcOffering createVpcOffering(String name, String displayText, Map> svcProviderMap, - boolean isDefault, State state); - - /** - * @param vpcOffId - * @param services - * @return - */ - boolean areServicesSupportedByVpcOffering(long vpcOffId, Service[] services); - - /** - * @param zoneId - * @param vpcOffId - * @param vpcOwner - * @param vpcName - * @param displayText - * @param cidr - * @param networkDomain TODO - * @return - */ - Vpc createVpc(long zoneId, long vpcOffId, Account vpcOwner, String vpcName, String displayText, String cidr, String networkDomain); - - List getSupportedServices(); - /** * @param guestNtwkOff * @param cidr @@ -77,10 +39,6 @@ public interface VpcManager extends VpcService{ void validateGuestNtkwForVpc(NetworkOffering guestNtwkOff, String cidr, String networkDomain, Account networkOwner, Vpc vpc, Long networkId, String gateway); - /** - * @return - */ - VpcProvider getVpcElement(); List getVpcsForAccount(long accountId); @@ -110,8 +68,4 @@ public interface VpcManager extends VpcService{ */ VpcGateway getPrivateGatewayForVpc(long vpcId); - /** - * @return - */ - int getMaxNetworksPerVpc(); } diff --git a/server/src/com/cloud/network/vpc/VpcManagerImpl.java b/server/src/com/cloud/network/vpc/VpcManagerImpl.java index 9efa8028878..7e28a98b43a 100644 --- a/server/src/com/cloud/network/vpc/VpcManagerImpl.java +++ b/server/src/com/cloud/network/vpc/VpcManagerImpl.java @@ -270,9 +270,8 @@ public class VpcManagerImpl implements VpcManager, Manager{ } - @Override @DB - public VpcOffering createVpcOffering(String name, String displayText, Map> svcProviderMap, boolean isDefault, State state) { Transaction txn = Transaction.currentTxn(); txn.start(); @@ -405,8 +404,7 @@ public class VpcManagerImpl implements VpcManager, Manager{ } } - @Override - public boolean areServicesSupportedByVpcOffering(long vpcOffId, Service... services) { + protected boolean areServicesSupportedByVpcOffering(long vpcOffId, Service... services) { return (_vpcOffSvcMapDao.areServicesSupportedByNetworkOffering(vpcOffId, services)); } @@ -539,8 +537,7 @@ public class VpcManagerImpl implements VpcManager, Manager{ return false; } - @Override - public Vpc createVpc(long zoneId, long vpcOffId, Account vpcOwner, String vpcName, String displayText, String cidr, + protected Vpc createVpc(long zoneId, long vpcOffId, Account vpcOwner, String vpcName, String displayText, String cidr, String networkDomain) { if (!vpcProviderEnabledInZone(zoneId)) { @@ -802,8 +799,8 @@ public class VpcManagerImpl implements VpcManager, Manager{ } } - @Override - public List getSupportedServices() { + + protected List getSupportedServices() { List services = new ArrayList(); services.add(Network.Service.Dhcp); services.add(Network.Service.Dns); @@ -894,7 +891,7 @@ public class VpcManagerImpl implements VpcManager, Manager{ //shutdown provider boolean success = getVpcElement().shutdownVpc(vpc); - //FIXME - once more features are added to vpc (gateway/firewall rules, etc - cleanup them here) + //TODO - cleanup all vpc resources here (ACLs, gateways, etc) if (success) { s_logger.debug("Vpc " + vpc + " has been shutdown succesfully"); } else { @@ -1038,8 +1035,8 @@ public class VpcManagerImpl implements VpcManager, Manager{ } } - @Override - public VpcProvider getVpcElement() { + + protected VpcProvider getVpcElement() { if (vpcElement == null) { vpcElement = ((VpcProvider)_ntwkMgr.getElementImplementingProvider(Provider.VPCVirtualRouter.getName())); } @@ -1681,9 +1678,4 @@ public class VpcManagerImpl implements VpcManager, Manager{ return _vpcGatewayDao.getPrivateGatewayForVpc(vpcId); } - @Override - public int getMaxNetworksPerVpc() { - return _maxNetworks; - } - }