Search in sources :

Example 6 with BigSwitchBcfDeviceVO

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;
}
Also used : InvalidParameterValueException(com.cloud.exception.InvalidParameterValueException) ArrayList(java.util.ArrayList) PhysicalNetworkVO(com.cloud.network.dao.PhysicalNetworkVO) BigSwitchBcfDeviceVO(com.cloud.network.BigSwitchBcfDeviceVO)

Example 7 with BigSwitchBcfDeviceVO

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;
}
Also used : GetControllerDataAnswer(com.cloud.agent.api.GetControllerDataAnswer) GetControllerDataCommand(com.cloud.agent.api.GetControllerDataCommand) BigSwitchBcfDeviceVO(com.cloud.network.BigSwitchBcfDeviceVO) HostVO(com.cloud.host.HostVO)

Aggregations

BigSwitchBcfDeviceVO (com.cloud.network.BigSwitchBcfDeviceVO)7 InvalidParameterValueException (com.cloud.exception.InvalidParameterValueException)5 HostVO (com.cloud.host.HostVO)3 PhysicalNetworkVO (com.cloud.network.dao.PhysicalNetworkVO)3 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)3 BigSwitchBcfDeviceResponse (com.cloud.api.response.BigSwitchBcfDeviceResponse)2 ArrayList (java.util.ArrayList)2 ServerApiException (org.apache.cloudstack.api.ServerApiException)2 GetControllerDataAnswer (com.cloud.agent.api.GetControllerDataAnswer)1 GetControllerDataCommand (com.cloud.agent.api.GetControllerDataCommand)1 DataCenterVO (com.cloud.dc.DataCenterVO)1 DetailVO (com.cloud.host.DetailVO)1 Host (com.cloud.host.Host)1 TopologyData (com.cloud.network.bigswitch.TopologyData)1 NetworkVO (com.cloud.network.dao.NetworkVO)1 PhysicalNetworkServiceProviderVO (com.cloud.network.dao.PhysicalNetworkServiceProviderVO)1 BigSwitchBcfResource (com.cloud.network.resource.BigSwitchBcfResource)1 ServerResource (com.cloud.resource.ServerResource)1 DB (com.cloud.utils.db.DB)1 TransactionCallback (com.cloud.utils.db.TransactionCallback)1