use of com.cloud.legacymodel.communication.command.NetworkElementCommand in project cosmic by MissionCriticalCloud.
the class VirtualRoutingResource method execute.
private Answer execute(final AggregationControlCommand aggregationCommand) {
assert aggregationCommand.getRouterAccessIp() != null;
final String routerName = aggregationCommand.getAccessDetail(NetworkElementCommand.ROUTER_NAME);
assert routerName != null;
final Action action = aggregationCommand.getAction();
if (Action.Start.equals(action)) {
assert (!this._vrAggregateCommandsSet.containsKey(routerName));
this._vrAggregateCommandsSet.put(routerName, new LinkedBlockingQueue<>());
return new Answer(aggregationCommand, true, "Command aggregation started");
} else if (Action.Finish.equals(action)) {
final Queue<NetworkElementCommand> queue = this._vrAggregateCommandsSet.get(routerName);
try {
for (final NetworkElementCommand command : queue) {
final List<ConfigItem> cfg = generateCommandCfg(command);
if (cfg == null) {
s_logger.warn("Unknown commands for VirtualRoutingResource, but continue: " + aggregationCommand.toString());
continue;
}
final Answer commandAnswer = applyConfig(command, cfg);
if (!commandAnswer.getResult()) {
return new Answer(aggregationCommand, false, "Aggregated command failed to execute " + commandAnswer.getDetails());
}
}
return new Answer(aggregationCommand, true, "Command aggregation finished");
} finally {
queue.clear();
this._vrAggregateCommandsSet.remove(routerName);
}
}
return new Answer(aggregationCommand, false, "Fail to recognize aggregation action " + action.toString());
}
Aggregations