private ExternalFirewallDeviceVO getExternalFirewallForNetwork(Network network) { NetworkExternalFirewallVO fwDeviceForNetwork = _networkExternalFirewallDao.findByNetworkId(network.getId()); if (fwDeviceForNetwork != null) { long fwDeviceId = fwDeviceForNetwork.getExternalFirewallDeviceId(); ExternalFirewallDeviceVO fwDevice = _externalFirewallDeviceDao.findById(fwDeviceId); assert (fwDevice != null); return fwDevice; } return null; }
@Override public ExternalFirewallDeviceVO getExternalFirewallForNetwork(Network network) { NetworkExternalFirewallVO fwDeviceForNetwork = _networkExternalFirewallDao.findByNetworkId(network.getId()); if (fwDeviceForNetwork != null) { long fwDeviceId = fwDeviceForNetwork.getExternalFirewallDeviceId(); ExternalFirewallDeviceVO fwDevice = _externalFirewallDeviceDao.findById(fwDeviceId); assert (fwDevice != null); return fwDevice; } return null; }
@Override public List<? extends Network> listNetworks(ListPaloAltoFirewallNetworksCmd cmd) { Long fwDeviceId = cmd.getFirewallDeviceId(); List<NetworkVO> networks = new ArrayList<NetworkVO>(); ExternalFirewallDeviceVO fwDeviceVo = _fwDevicesDao.findById(fwDeviceId); if (fwDeviceVo == null || !fwDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.PaloAltoFirewall.getName())) { throw new InvalidParameterValueException("Could not find Palo Alto firewall device with ID " + fwDeviceId); } List<NetworkExternalFirewallVO> networkFirewallMaps = _networkFirewallDao.listByFirewallDeviceId(fwDeviceId); if (networkFirewallMaps != null && !networkFirewallMaps.isEmpty()) { for (NetworkExternalFirewallVO networkFirewallMap : networkFirewallMaps) { NetworkVO network = _networkDao.findById(networkFirewallMap.getNetworkId()); networks.add(network); } } return networks; }
@Override public boolean deletePaloAltoFirewall(DeletePaloAltoFirewallCmd cmd) { Long fwDeviceId = cmd.getFirewallDeviceId(); ExternalFirewallDeviceVO fwDeviceVO = _fwDevicesDao.findById(fwDeviceId); if (fwDeviceVO == null || !fwDeviceVO.getDeviceName().equalsIgnoreCase(NetworkDevice.PaloAltoFirewall.getName())) { throw new InvalidParameterValueException("No Palo Alto firewall device found with ID: " + fwDeviceId); } return deleteExternalFirewall(fwDeviceVO.getHostId()); }
@Override public ExternalFirewallDeviceVO configurePaloAltoFirewall(ConfigurePaloAltoFirewallCmd cmd) { Long fwDeviceId = cmd.getFirewallDeviceId(); Long deviceCapacity = cmd.getFirewallCapacity(); ExternalFirewallDeviceVO fwDeviceVO = _fwDevicesDao.findById(fwDeviceId); if (fwDeviceVO == null || !fwDeviceVO.getDeviceName().equalsIgnoreCase(NetworkDevice.PaloAltoFirewall.getName())) { throw new InvalidParameterValueException("No Palo Alto firewall device found with ID: " + fwDeviceId); } if (deviceCapacity != null) { // check if any networks are using this Palo Alto device List<NetworkExternalFirewallVO> networks = _networkFirewallDao.listByFirewallDeviceId(fwDeviceId); if ((networks != null) && !networks.isEmpty()) { if (deviceCapacity < networks.size()) { throw new CloudRuntimeException("There are more number of networks already using this Palo Alto firewall device than configured capacity"); } } if (deviceCapacity != null) { fwDeviceVO.setCapacity(deviceCapacity); } } fwDeviceVO.setDeviceState(FirewallDeviceState.Enabled); _fwDevicesDao.update(fwDeviceId, fwDeviceVO); return fwDeviceVO; }
@Override public List<ExternalFirewallDeviceVO> listPaloAltoFirewalls(ListPaloAltoFirewallsCmd cmd) { Long physcialNetworkId = cmd.getPhysicalNetworkId(); Long fwDeviceId = cmd.getFirewallDeviceId(); PhysicalNetworkVO pNetwork = null; List<ExternalFirewallDeviceVO> fwDevices = new ArrayList<ExternalFirewallDeviceVO>(); if (physcialNetworkId == null && fwDeviceId == null) { throw new InvalidParameterValueException("Either physical network Id or load balancer device Id must be specified"); } if (fwDeviceId != null) { ExternalFirewallDeviceVO fwDeviceVo = _fwDevicesDao.findById(fwDeviceId); if (fwDeviceVo == null || !fwDeviceVo.getDeviceName().equalsIgnoreCase(NetworkDevice.PaloAltoFirewall.getName())) { throw new InvalidParameterValueException("Could not find Palo Alto firewall device with ID: " + fwDeviceId); } fwDevices.add(fwDeviceVo); } if (physcialNetworkId != null) { pNetwork = _physicalNetworkDao.findById(physcialNetworkId); if (pNetwork == null) { throw new InvalidParameterValueException("Could not find phyical network with ID: " + physcialNetworkId); } fwDevices = _fwDevicesDao.listByPhysicalNetworkAndProvider(physcialNetworkId, Provider.PaloAlto.getName()); } return fwDevices; }