use of com.cloud.agent.api.PingRoutingWithNwGroupsCommand in project cloudstack by apache.
the class AgentRoutingResource method getCurrentStatus.
@Override
public PingCommand getCurrentStatus(long id) {
TransactionLegacy txn = TransactionLegacy.open(TransactionLegacy.SIMULATOR_DB);
try {
MockConfigurationVO config = _simMgr.getMockConfigurationDao().findByNameBottomUP(agentHost.getDataCenterId(), agentHost.getPodId(), agentHost.getClusterId(), agentHost.getId(), "PingCommand");
if (config != null) {
Map<String, String> configParameters = config.getParameters();
for (Map.Entry<String, String> entry : configParameters.entrySet()) {
if (entry.getKey().equalsIgnoreCase("result")) {
String value = entry.getValue();
if (value.equalsIgnoreCase("fail")) {
return null;
}
}
}
}
config = _simMgr.getMockConfigurationDao().findByNameBottomUP(agentHost.getDataCenterId(), agentHost.getPodId(), agentHost.getClusterId(), agentHost.getId(), "PingRoutingWithNwGroupsCommand");
if (config != null) {
String message = config.getJsonResponse();
if (message != null) {
// json response looks like {"<Type>":....}
String objectType = message.split(":")[0].substring(2).replace("\"", "");
String objectData = message.substring(message.indexOf(':') + 1, message.length() - 1);
if (objectType != null) {
Class<?> clz = null;
try {
clz = Class.forName(objectType);
} catch (ClassNotFoundException e) {
s_logger.info("[ignored] ping returned class", e);
}
if (clz != null) {
StringReader reader = new StringReader(objectData);
JsonReader jsonReader = new JsonReader(reader);
jsonReader.setLenient(true);
return (PingCommand) s_gson.fromJson(jsonReader, clz);
}
}
}
}
} catch (Exception e) {
txn.rollback();
} finally {
txn.close();
txn = TransactionLegacy.open(TransactionLegacy.CLOUD_DB);
txn.close();
}
if (isStopped()) {
return null;
}
HashMap<String, Pair<Long, Long>> nwGrpStates = _simMgr.syncNetworkGroups(hostGuid);
return new PingRoutingWithNwGroupsCommand(getType(), id, getHostVmStateReport(), nwGrpStates);
}
use of com.cloud.agent.api.PingRoutingWithNwGroupsCommand in project cloudstack by apache.
the class SecurityGroupListener method processCommands.
@Override
public boolean processCommands(long agentId, long seq, Command[] commands) {
boolean processed = false;
for (Command cmd : commands) {
if (cmd instanceof PingRoutingWithNwGroupsCommand) {
PingRoutingWithNwGroupsCommand ping = (PingRoutingWithNwGroupsCommand) cmd;
if (ping.getNewGroupStates().size() > 0) {
_securityGroupManager.fullSync(agentId, ping.getNewGroupStates());
}
processed = true;
}
}
return processed;
}
Aggregations