use of com.cloud.agent.api.CleanupPersistentNetworkResourceAnswer in project cloudstack by apache.
the class NetworkOrchestrator method cleanupPersistentnNetworkResources.
private void cleanupPersistentnNetworkResources(NetworkVO network) {
long networkOfferingId = network.getNetworkOfferingId();
NetworkOfferingVO offering = _networkOfferingDao.findById(networkOfferingId);
if (offering != null) {
if (networkMeetsPersistenceCriteria(network, offering, true) && _networksDao.getOtherPersistentNetworksCount(network.getId(), network.getBroadcastUri().toString(), offering.isPersistent()) == 0) {
List<HostVO> hosts = resourceManager.listAllUpAndEnabledHostsInOneZoneByType(Host.Type.Routing, network.getDataCenterId());
for (HostVO host : hosts) {
try {
NicTO to = createNicTOFromNetworkAndOffering(network, offering, host);
CleanupPersistentNetworkResourceCommand cmd = new CleanupPersistentNetworkResourceCommand(to);
CleanupPersistentNetworkResourceAnswer answer = (CleanupPersistentNetworkResourceAnswer) _agentMgr.send(host.getId(), cmd);
if (answer == null) {
s_logger.warn("Unable to get an answer to the CleanupPersistentNetworkResourceCommand from agent:" + host.getId());
continue;
}
if (!answer.getResult()) {
s_logger.warn("Unable to setup agent " + host.getId() + " due to " + answer.getDetails());
}
} catch (Exception e) {
s_logger.warn("Failed to cleanup network resources on host: " + host.getName());
}
}
}
}
}
use of com.cloud.agent.api.CleanupPersistentNetworkResourceAnswer in project cloudstack by apache.
the class CitrixCleanupPersistentNetworkResourceCommandWrapper method execute.
@Override
public Answer execute(CleanupPersistentNetworkResourceCommand command, CitrixResourceBase citrixResourceBase) {
final Connection conn = citrixResourceBase.getConnection();
final XsHost host = citrixResourceBase.getHost();
NicTO nic = command.getNicTO();
try {
Network network = citrixResourceBase.getNetwork(conn, nic);
if (network == null) {
return new CleanupPersistentNetworkResourceAnswer(command, false, "Failed to find network on host " + host.getIp() + " to cleanup");
}
citrixResourceBase.disableVlanNetwork(conn, network, true);
return new CleanupPersistentNetworkResourceAnswer(command, true, "Successfully deleted network VLAN on host: " + host.getIp());
} catch (final Exception e) {
final String msg = " Failed to cleanup network VLAN on host: " + host.getIp() + " due to: " + e.toString();
s_logger.error(msg, e);
return new CleanupPersistentNetworkResourceAnswer(command, false, msg);
}
}
use of com.cloud.agent.api.CleanupPersistentNetworkResourceAnswer in project cloudstack by apache.
the class LibvirtCleanupPersistentNetworkResourceCommandWrapper method execute.
@Override
public Answer execute(CleanupPersistentNetworkResourceCommand command, LibvirtComputingResource serverResource) {
NicTO nic = command.getNicTO();
VifDriver driver = serverResource.getVifDriver(nic.getType());
if (driver instanceof BridgeVifDriver) {
driver.deleteBr(nic);
}
return new CleanupPersistentNetworkResourceAnswer(command, true, "Successfully deleted bridge");
}
Aggregations