}
@Override
public boolean deleteBigSwitchVnsDevice(DeleteBigSwitchVnsDeviceCmd cmd) {
Long bigswitchVnsDeviceId = cmd.getBigSwitchVnsDeviceId();
BigSwitchVnsDeviceVO bigswitchVnsDevice = _bigswitchVnsDao.findById(bigswitchVnsDeviceId);
if (bigswitchVnsDevice == null) {
throw new InvalidParameterValueException("Could not find a BigSwitch Controller with id " + bigswitchVnsDevice);
}
// Find the physical network we work for
Long physicalNetworkId = bigswitchVnsDevice.getPhysicalNetworkId();
PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
if (physicalNetwork != null) {
List<NetworkVO> networkList = _networkDao.listByPhysicalNetwork(physicalNetworkId);
// Networks with broadcast type lswitch are ours
for (NetworkVO network : networkList) {
if (network.getBroadcastDomainType() == Networks.BroadcastDomainType.Lswitch) {
if ((network.getState() != Network.State.Shutdown) && (network.getState() != Network.State.Destroy)) {
throw new CloudRuntimeException("This BigSwitch Controller device can not be deleted as there are one or more "
+ "logical networks provisioned by cloudstack.");
}
}
}
}
HostVO bigswitchHost = _hostDao.findById(bigswitchVnsDevice.getHostId());
Long hostId = bigswitchHost.getId();
//bigswitchHost.setResourceState(ResourceState.Maintenance);
//_hostDao.update(hostId, bigswitchHost);
_hostDao.remove(hostId);