use of com.cloud.network.dao.PhysicalNetworkVO in project cloudstack by apache.
the class BrocadeVcsGuestNetworkGuruTest method testDesign.
@Test
public void testDesign() {
final PhysicalNetworkVO physnet = mock(PhysicalNetworkVO.class);
when(physnetdao.findById((Long) any())).thenReturn(physnet);
when(physnet.getIsolationMethods()).thenReturn(Arrays.asList(new String[] { "VCS" }));
when(physnet.getId()).thenReturn(NETWORK_ID);
final NetworkOffering offering = mock(NetworkOffering.class);
when(offering.getId()).thenReturn(NETWORK_ID);
when(offering.getTrafficType()).thenReturn(TrafficType.Guest);
when(offering.getGuestType()).thenReturn(GuestType.Isolated);
when(nosd.areServicesSupportedByNetworkOffering(NETWORK_ID, Service.Connectivity)).thenReturn(true);
final DeploymentPlan plan = mock(DeploymentPlan.class);
final Network network = mock(Network.class);
final Account account = mock(Account.class);
final Network designednetwork = guru.design(offering, plan, network, account);
assertTrue(designednetwork != null);
assertTrue(designednetwork.getBroadcastDomainType() == BroadcastDomainType.Vcs);
}
use of com.cloud.network.dao.PhysicalNetworkVO in project cloudstack by apache.
the class BrocadeVcsElement method listBrocadeVcsDevices.
@Override
public List<BrocadeVcsDeviceVO> listBrocadeVcsDevices(ListBrocadeVcsDevicesCmd cmd) {
Long physicalNetworkId = cmd.getPhysicalNetworkId();
Long brocadeVcsDeviceId = cmd.getBrocadeVcsDeviceId();
List<BrocadeVcsDeviceVO> responseList = new ArrayList<BrocadeVcsDeviceVO>();
if (physicalNetworkId == null && brocadeVcsDeviceId == null) {
throw new InvalidParameterValueException("Either physical network Id or brocade vcs switch Id must be specified");
}
if (brocadeVcsDeviceId != null) {
BrocadeVcsDeviceVO brocadeVcsDevice = _brocadeVcsDao.findById(brocadeVcsDeviceId);
if (brocadeVcsDevice == null) {
throw new InvalidParameterValueException("Could not find Brocade VCS Switch with id: " + brocadeVcsDeviceId);
}
responseList.add(brocadeVcsDevice);
} else {
PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
if (physicalNetwork == null) {
throw new InvalidParameterValueException("Could not find a physical network with id: " + physicalNetworkId);
}
responseList = _brocadeVcsDao.listByPhysicalNetwork(physicalNetworkId);
}
return responseList;
}
use of com.cloud.network.dao.PhysicalNetworkVO in project cloudstack by apache.
the class NiciraNvpGuestNetworkGuru method design.
@Override
public Network design(final NetworkOffering offering, final DeploymentPlan plan, final Network userSpecified, final Account owner) {
// Check of the isolation type of the related physical network is supported
final PhysicalNetworkVO physnet = physicalNetworkDao.findById(plan.getPhysicalNetworkId());
final DataCenter dc = _dcDao.findById(plan.getDataCenterId());
if (!canHandle(offering, dc.getNetworkType(), physnet)) {
s_logger.debug("Refusing to design this network");
return null;
}
final List<NiciraNvpDeviceVO> devices = niciraNvpDao.listByPhysicalNetwork(physnet.getId());
if (devices.isEmpty()) {
s_logger.error("No NiciraNvp Controller on physical network " + physnet.getName());
return null;
}
s_logger.debug("Nicira Nvp " + devices.get(0).getUuid() + " found on physical network " + physnet.getId());
s_logger.debug("Physical isolation type is supported, asking GuestNetworkGuru to design this network");
final NetworkVO networkObject = (NetworkVO) super.design(offering, plan, userSpecified, owner);
if (networkObject == null) {
return null;
}
networkObject.setBroadcastDomainType(BroadcastDomainType.Lswitch);
if (offering.getGuestType().equals(GuestType.Shared)) {
networkObject.setState(State.Allocated);
}
return networkObject;
}
use of com.cloud.network.dao.PhysicalNetworkVO in project cloudstack by apache.
the class NetscalerElement method findGslbProvider.
private ExternalLoadBalancerDeviceVO findGslbProvider(long zoneId, long physicalNetworkId) {
List<PhysicalNetworkVO> pNtwks = _physicalNetworkDao.listByZoneAndTrafficType(zoneId, TrafficType.Guest);
if (pNtwks == null || pNtwks.isEmpty()) {
throw new InvalidParameterValueException("Unable to get physical network: " + physicalNetworkId + " in zone id = " + zoneId);
} else {
for (PhysicalNetwork physicalNetwork : pNtwks) {
if (physicalNetwork.getId() == physicalNetworkId) {
PhysicalNetworkVO physNetwork = pNtwks.get(0);
ExternalLoadBalancerDeviceVO nsGslbProvider = _externalLoadBalancerDeviceDao.findGslbServiceProvider(physNetwork.getId(), Provider.Netscaler.getName());
return nsGslbProvider;
}
}
}
return null;
}
use of com.cloud.network.dao.PhysicalNetworkVO in project cloudstack by apache.
the class NiciraNvpElement method listNiciraNvpDeviceNetworks.
@Override
public List<? extends Network> listNiciraNvpDeviceNetworks(ListNiciraNvpDeviceNetworksCmd cmd) {
Long niciraDeviceId = cmd.getNiciraNvpDeviceId();
NiciraNvpDeviceVO niciraNvpDevice = niciraNvpDao.findById(niciraDeviceId);
if (niciraNvpDevice == null) {
throw new InvalidParameterValueException("Could not find a nicira device with id " + niciraDeviceId);
}
// Find the physical network we work for
Long physicalNetworkId = niciraNvpDevice.getPhysicalNetworkId();
PhysicalNetworkVO physicalNetwork = physicalNetworkDao.findById(physicalNetworkId);
if (physicalNetwork == null) {
// No such physical network, so no provisioned networks
return Collections.emptyList();
}
// Find the nicira networks on this physical network
List<NetworkVO> networkList = networkDao.listByPhysicalNetwork(physicalNetworkId);
if (networkList == null) {
return Collections.emptyList();
}
// Networks with broadcast type lswitch are ours
List<NetworkVO> responseList = new ArrayList<NetworkVO>();
for (NetworkVO network : networkList) {
if (network.getBroadcastDomainType() == Networks.BroadcastDomainType.Lswitch) {
responseList.add(network);
}
}
return responseList;
}
Aggregations