Search in sources :

Example 1 with TrashNetworkVspCommand

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

the class NuageVspResourceTest method testTrashNetworkVspCommand.

@Test
public void testTrashNetworkVspCommand() throws Exception {
    _resource.configure("NuageVspResource", _hostDetails);
    VspNetwork vspNetwork = buildVspNetwork();
    TrashNetworkVspCommand cmd = new TrashNetworkVspCommand(vspNetwork);
    Answer trashNtwkAns = _resource.executeRequest(cmd);
    assertTrue(trashNtwkAns.getResult());
}
Also used : TrashNetworkVspCommand(com.cloud.agent.api.guru.TrashNetworkVspCommand) Answer(com.cloud.agent.api.Answer) VspNetwork(net.nuage.vsp.acs.client.api.model.VspNetwork) NuageTest(com.cloud.NuageTest) Test(org.junit.Test)

Example 2 with TrashNetworkVspCommand

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

the class NuageVspGuestNetworkGuru method trash.

@Override
public boolean trash(Network network, NetworkOffering offering) {
    long networkId = network.getId();
    network = _networkDao.acquireInLockTable(networkId, 1200);
    if (network == null) {
        throw new ConcurrentOperationException("Unable to acquire lock on network " + networkId);
    }
    try {
        if (s_logger.isDebugEnabled()) {
            s_logger.debug("Handling trash() call back to delete the network " + network.getName() + " with uuid " + network.getUuid() + " from VSP");
        }
        VspNetwork vspNetwork = _nuageVspEntityBuilder.buildVspNetwork(network);
        HostVO nuageVspHost = _nuageVspManager.getNuageVspHost(network.getPhysicalNetworkId());
        TrashNetworkVspCommand cmd = new TrashNetworkVspCommand(vspNetwork);
        Answer answer = _agentMgr.easySend(nuageVspHost.getId(), cmd);
        if (answer == null || !answer.getResult()) {
            s_logger.error("TrashNetworkNuageVspCommand for network " + network.getUuid() + " failed");
            if ((null != answer) && (null != answer.getDetails())) {
                s_logger.error(answer.getDetails());
            }
            return false;
        }
    } finally {
        _networkDao.releaseFromLockTable(network.getId());
    }
    return super.trash(network, offering);
}
Also used : TrashNetworkVspCommand(com.cloud.agent.api.guru.TrashNetworkVspCommand) Answer(com.cloud.agent.api.Answer) VspNetwork(net.nuage.vsp.acs.client.api.model.VspNetwork) ConcurrentOperationException(com.cloud.exception.ConcurrentOperationException) HostVO(com.cloud.host.HostVO)

Aggregations

Answer (com.cloud.agent.api.Answer)2 TrashNetworkVspCommand (com.cloud.agent.api.guru.TrashNetworkVspCommand)2 VspNetwork (net.nuage.vsp.acs.client.api.model.VspNetwork)2 NuageTest (com.cloud.NuageTest)1 ConcurrentOperationException (com.cloud.exception.ConcurrentOperationException)1 HostVO (com.cloud.host.HostVO)1 Test (org.junit.Test)1