use of com.cloud.network.BigSwitchBcfDeviceVO in project cloudstack by apache.
the class BigSwitchBcfElement method listBigSwitchBcfDevices.
@Override
public List<BigSwitchBcfDeviceVO> listBigSwitchBcfDevices(ListBigSwitchBcfDevicesCmd cmd) {
Long physicalNetworkId = cmd.getPhysicalNetworkId();
Long bigswitchBcfDeviceId = cmd.getBigSwitchBcfDeviceId();
List<BigSwitchBcfDeviceVO> responseList = new ArrayList<BigSwitchBcfDeviceVO>();
if (physicalNetworkId == null && bigswitchBcfDeviceId == null) {
throw new InvalidParameterValueException("Either physical network Id or bigswitch device Id must be specified");
}
if (bigswitchBcfDeviceId != null) {
BigSwitchBcfDeviceVO bigswitchBcfDevice = _bigswitchBcfDao.findById(bigswitchBcfDeviceId);
if (bigswitchBcfDevice == null) {
throw new InvalidParameterValueException("Could not find BigSwitch controller with id: " + bigswitchBcfDevice);
}
responseList.add(bigswitchBcfDevice);
} else {
PhysicalNetworkVO physicalNetwork = _physicalNetworkDao.findById(physicalNetworkId);
if (physicalNetwork == null) {
throw new InvalidParameterValueException("Could not find a physical network with id: " + physicalNetworkId);
}
responseList = _bigswitchBcfDao.listByPhysicalNetwork(physicalNetworkId);
}
return responseList;
}
use of com.cloud.network.BigSwitchBcfDeviceVO in project cloudstack by apache.
the class BigSwitchBcfUtils method getControlClusterData.
public ControlClusterData getControlClusterData(long physicalNetworkId) {
ControlClusterData cluster = new ControlClusterData();
// reusable command to query all devices
GetControllerDataCommand cmd = new GetControllerDataCommand();
// retrieve all registered BCF devices
List<BigSwitchBcfDeviceVO> devices = _bigswitchBcfDao.listByPhysicalNetwork(physicalNetworkId);
for (BigSwitchBcfDeviceVO d : devices) {
HostVO bigswitchBcfHost = _hostDao.findById(d.getHostId());
if (bigswitchBcfHost == null) {
continue;
}
_hostDao.loadDetails(bigswitchBcfHost);
GetControllerDataAnswer answer = (GetControllerDataAnswer) _agentMgr.easySend(bigswitchBcfHost.getId(), cmd);
if (answer != null) {
if (answer.isPrimary()) {
cluster.setPrimary(bigswitchBcfHost);
} else {
cluster.setSecondary(bigswitchBcfHost);
}
}
}
return cluster;
}
Aggregations