public AggregationControlCommand(Action action, String name, String ip, String guestIp) { super(); this.action = action; this.setAccessDetail(NetworkElementCommand.ROUTER_NAME, name); this.setAccessDetail(NetworkElementCommand.ROUTER_IP, ip); this.setAccessDetail(NetworkElementCommand.ROUTER_GUEST_IP, guestIp); }
private Answer execute(AggregationControlCommand cmd) { Action action = cmd.getAction(); String routerName = cmd.getAccessDetail(NetworkElementCommand.ROUTER_NAME); assert routerName != null; assert cmd.getRouterAccessIp() != null; List<ConfigItem> cfg = generateCommandCfg(command); if (cfg == null) { s_logger.warn("Unknown commands for VirtualRoutingResource, but continue: " + cmd.toString()); continue; ExecutionResult result = applyConfigToVR(cmd.getRouterAccessIp(), fileConfigItem, timeout); if (!result.isSuccess()) { return new Answer(cmd, false, result.getDetails()); result = applyConfigToVR(cmd.getRouterAccessIp(), scriptConfigItem, timeout); if (!result.isSuccess()) { return new Answer(cmd, false, result.getDetails());
protected boolean aggregationExecution(final AggregationControlCommand.Action action, final Network network, final List<DomainRouterVO> routers) throws AgentUnavailableException, ResourceUnavailableException { int errors = 0; for (final DomainRouterVO router : routers) { final String routerControlIp = _routerControlHelper.getRouterControlIp(router.getId()); final String routerIpInNetwork = _routerControlHelper.getRouterIpInNetwork(network.getId(), router.getId()); if (routerIpInNetwork == null) { // Nic hasn't been created in this router yet. Try to configure the next one. s_logger.warn("The Network is not configured in the router " + router.getHostName() + " yet. Try the next router!"); errors++; continue; } final AggregationControlCommand cmd = new AggregationControlCommand(action, router.getInstanceName(), routerControlIp, routerIpInNetwork); final Commands cmds = new Commands(cmd); if (!_nwHelper.sendCommandsToRouter(router, cmds)) { return false; } } if (errors == routers.size()) { s_logger.error("aggregationExecution() on " + getClass().getName() + " failed! Network is not configured in any router."); return false; } return true; }
final AggregationControlCommand startCmd = new AggregationControlCommand(Action.Start, router.getInstanceName(), controlNic.getIPv4Address(), _routerControlHelper.getRouterIpInNetwork( guestNetworkId, router.getId())); cmds.addCommand(startCmd); final AggregationControlCommand finishCmd = new AggregationControlCommand(Action.Finish, router.getInstanceName(), controlNic.getIPv4Address(), _routerControlHelper.getRouterIpInNetwork( guestNetworkId, router.getId())); cmds.addCommand(finishCmd);
final AggregationControlCommand startCmd = new AggregationControlCommand(Action.Start, domainRouterVO.getInstanceName(), controlNic.getIPv4Address(), _routerControlHelper.getRouterIpInNetwork( guestNic.getNetworkId(), domainRouterVO.getId())); cmds.addCommand(startCmd); final AggregationControlCommand finishCmd = new AggregationControlCommand(Action.Finish, domainRouterVO.getInstanceName(), controlNic.getIPv4Address(), _routerControlHelper.getRouterIpInNetwork( guestNic.getNetworkId(), domainRouterVO.getId())); cmds.addCommand(finishCmd);