VPC: reduced visability for some vpc related methods

Conflicts:

	server/src/com/cloud/network/router/VpcVirtualNetworkApplianceManagerImpl.java
	server/src/com/cloud/network/vpc/NetworkACLManagerImpl.java
	server/src/com/cloud/network/vpc/VpcManagerImpl.java
This commit is contained in:
Alena Prokharchyk 2012-07-31 14:12:09 -07:00
parent 70713043cf
commit ebe53a91d7
7 changed files with 54 additions and 100 deletions

View File

@ -30,7 +30,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;
public interface VpcService {
@ -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

View File

@ -135,10 +135,8 @@ import com.cloud.network.PhysicalNetworkServiceProvider;
import com.cloud.network.PublicIpAddress;
import com.cloud.network.RemoteAccessVpn;
import com.cloud.network.Site2SiteCustomerGateway;
import com.cloud.network.Site2SiteCustomerGatewayVO;
import com.cloud.network.Site2SiteVpnConnection;
import com.cloud.network.Site2SiteVpnConnectionVO;
import com.cloud.network.Site2SiteVpnGatewayVO;
import com.cloud.network.SshKeysDistriMonitor;
import com.cloud.network.VirtualNetworkApplianceService;
import com.cloud.network.VirtualRouterProvider;

View File

@ -29,7 +29,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;

View File

@ -694,7 +694,8 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
return sendCommandsToRouter(router, cmds);
}
private void createNetworkACLsCommands(List<? extends FirewallRule> rules, VirtualRouter router, Commands cmds, long guestNetworkId) {
private void createNetworkACLsCommands(List<? extends FirewallRule> rules, VirtualRouter router, Commands cmds,
long guestNetworkId) {
List<NetworkACLTO> rulesTO = null;
String guestVlan = null;
Network guestNtwk = _networkDao.findById(guestNetworkId);
@ -721,7 +722,7 @@ public class VpcVirtualNetworkApplianceManagerImpl extends VirtualNetworkApplian
cmd.setAccessDetail(NetworkElementCommand.ZONE_NETWORK_TYPE, dcVo.getNetworkType().toString());
cmds.addCommand(cmd);
}
@Override
public boolean finalizeCommandsOnStart(Commands cmds, VirtualMachineProfile<DomainRouterVO> profile) {
DomainRouterVO router = profile.getVirtualMachine();
@ -783,7 +784,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);
}

View File

@ -244,8 +244,9 @@ 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) {
@ -258,10 +259,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()
@ -271,7 +276,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");
}
}
@ -305,6 +311,7 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{
return success;
}
@Override
public FirewallRule getNetworkACL(long ACLId) {
@ -315,6 +322,7 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{
return null;
}
@Override
public List<? extends FirewallRule> listNetworkACLs(ListNetworkACLsCmd cmd) {
Long networkId = cmd.getNetworkId();
@ -366,6 +374,7 @@ public class NetworkACLManagerImpl implements Manager,NetworkACLManager{
public List<? extends FirewallRule> listNetworkACLs(long guestNtwkId) {
return _firewallDao.listByNetworkAndPurpose(guestNtwkId, Purpose.NetworkACL);
}
@Override
public boolean revokeAllNetworkACLsForNetwork(long networkId, long userId, Account caller) throws ResourceUnavailableException {
@ -393,7 +402,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;

View File

@ -17,15 +17,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;
@ -33,38 +27,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<Service, Set<Provider>> 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<Service> getSupportedServices();
/**
* @param guestNtwkOff
* @param cidr
@ -78,10 +40,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<? extends Vpc> getVpcsForAccount(long accountId);
@ -111,8 +69,4 @@ public interface VpcManager extends VpcService{
*/
VpcGateway getPrivateGatewayForVpc(long vpcId);
/**
* @return
*/
int getMaxNetworksPerVpc();
}

View File

@ -59,12 +59,9 @@ import com.cloud.network.Networks.BroadcastDomainType;
import com.cloud.network.Networks.TrafficType;
import com.cloud.network.PhysicalNetwork;
import com.cloud.network.dao.FirewallRulesDao;
import com.cloud.network.Site2SiteVpnGateway;
import com.cloud.network.addr.PublicIp;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.NetworkDao;
import com.cloud.network.dao.PhysicalNetworkDao;
import com.cloud.network.dao.Site2SiteVpnConnectionDao;
import com.cloud.network.dao.Site2SiteVpnGatewayDao;
import com.cloud.network.element.VpcProvider;
import com.cloud.network.vpc.VpcOffering.State;
@ -271,11 +268,10 @@ public class VpcManagerImpl implements VpcManager, Manager{
return createVpcOffering(name, displayText, svcProviderMap, false, null);
}
@Override
@DB
public VpcOffering createVpcOffering(String name, String displayText, Map<Network.Service,
protected VpcOffering createVpcOffering(String name, String displayText, Map<Network.Service,
Set<Network.Provider>> svcProviderMap, boolean isDefault, State state) {
Transaction txn = Transaction.currentTxn();
txn.start();
@ -407,12 +403,12 @@ public class VpcManagerImpl implements VpcManager, Manager{
return offerings;
}
}
@Override
public boolean areServicesSupportedByVpcOffering(long vpcOffId, Service... services) {
protected boolean areServicesSupportedByVpcOffering(long vpcOffId, Service... services) {
return (_vpcOffSvcMapDao.areServicesSupportedByNetworkOffering(vpcOffId, services));
}
@Override
@ActionEvent(eventType = EventTypes.EVENT_VPC_OFFERING_DELETE, eventDescription = "deleting vpc offering")
@ -539,9 +535,9 @@ 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)) {
@ -778,21 +774,21 @@ public class VpcManagerImpl implements VpcManager, Manager{
return vpcs;
}
}
@Override
public List<Service> getSupportedServices() {
List<Service> services = new ArrayList<Service>();
services.add(Network.Service.Dhcp);
services.add(Network.Service.Dns);
services.add(Network.Service.UserData);
services.add(Network.Service.NetworkACL);
services.add(Network.Service.PortForwarding);
services.add(Network.Service.Lb);
services.add(Network.Service.SourceNat);
services.add(Network.Service.StaticNat);
services.add(Network.Service.Gateway);
services.add(Network.Service.Vpn);
return services;
protected List<Service> getSupportedServices() {
List<Service> services = new ArrayList<Service>();
services.add(Network.Service.Dhcp);
services.add(Network.Service.Dns);
services.add(Network.Service.UserData);
services.add(Network.Service.NetworkACL);
services.add(Network.Service.PortForwarding);
services.add(Network.Service.Lb);
services.add(Network.Service.SourceNat);
services.add(Network.Service.StaticNat);
services.add(Network.Service.Gateway);
services.add(Network.Service.Vpn);
return services;
}
@Override
@ -870,8 +866,8 @@ 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 {
@ -996,9 +992,9 @@ public class VpcManagerImpl implements VpcManager, Manager{
_vpcDao.releaseFromLockTable(locked.getId());
}
}
@Override
public VpcProvider getVpcElement() {
protected VpcProvider getVpcElement() {
if (vpcElement == null) {
vpcElement = ((VpcProvider)_ntwkMgr.getElementImplementingProvider(Provider.VPCVirtualRouter.getName()));
}
@ -1618,9 +1614,4 @@ public class VpcManagerImpl implements VpcManager, Manager{
public VpcGateway getPrivateGatewayForVpc(long vpcId) {
return _vpcGatewayDao.getPrivateGatewayForVpc(vpcId);
}
public int getMaxNetworksPerVpc() {
return _maxNetworks;
}
}