Search in sources :

Example 1 with CacheBcfTopologyCommand

use of com.cloud.agent.api.CacheBcfTopologyCommand in project cloudstack by apache.

the class BigSwitchBcfUtils method sendBcfCommandWithNetworkSyncCheck.

public BcfAnswer sendBcfCommandWithNetworkSyncCheck(BcfCommand cmd, Network network) throws IllegalArgumentException {
    // get registered Big Switch controller
    ControlClusterData cluster = getControlClusterData(network.getPhysicalNetworkId());
    if (cluster.getMaster() == null) {
        return new BcfAnswer(cmd, new CloudRuntimeException("Big Switch Network controller temporarily unavailable"));
    }
    TopologyData topo = getTopology(network.getPhysicalNetworkId());
    cmd.setTopology(topo);
    BcfAnswer answer = (BcfAnswer) _agentMgr.easySend(cluster.getMaster().getId(), cmd);
    if (answer == null || !answer.getResult()) {
        s_logger.error("BCF API Command failed");
        throw new IllegalArgumentException("Failed API call to Big Switch Network plugin");
    }
    String newHash = answer.getHash();
    if (cmd.isTopologySyncRequested()) {
        newHash = syncTopologyToBcfHost(cluster.getMaster());
    }
    if (newHash != null) {
        commitTopologyHash(network.getPhysicalNetworkId(), newHash);
    }
    HostVO slave = cluster.getSlave();
    if (slave != null) {
        TopologyData newTopo = getTopology(network.getPhysicalNetworkId());
        CacheBcfTopologyCommand cacheCmd = new CacheBcfTopologyCommand(newTopo);
        _agentMgr.easySend(cluster.getSlave().getId(), cacheCmd);
    }
    return answer;
}
Also used : BcfAnswer(com.cloud.agent.api.BcfAnswer) CacheBcfTopologyCommand(com.cloud.agent.api.CacheBcfTopologyCommand) CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) HostVO(com.cloud.host.HostVO)

Aggregations

BcfAnswer (com.cloud.agent.api.BcfAnswer)1 CacheBcfTopologyCommand (com.cloud.agent.api.CacheBcfTopologyCommand)1 HostVO (com.cloud.host.HostVO)1 CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1