mirror of
https://github.com/Telecominfraproject/wlan-cloud-opensync-controller.git
synced 2025-11-03 20:17:53 +00:00
WIFI-691: modify OSGW to send to the AP a new set of commands for managing remote ssh agent and sessions
Handle the start and stop of the debug engine REST commands coming via gateway controller. Change gateway controller to use new method to handle redirector change. NB. Ap commands being sent via the command config in OvsdbDao are not finalized and will change.
This commit is contained in:
@@ -275,6 +275,7 @@ public class OpensyncExternalIntegrationCloud implements OpensyncExternalIntegra
|
|||||||
+ autoProvisionedCustomerId);
|
+ autoProvisionedCustomerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// String dbUrlString = customer.getDetails().getClientFingerPrintsDbUrl();
|
||||||
ce = new Equipment();
|
ce = new Equipment();
|
||||||
ce.setEquipmentType(EquipmentType.AP);
|
ce.setEquipmentType(EquipmentType.AP);
|
||||||
ce.setInventoryId(apId);
|
ce.setInventoryId(apId);
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import com.telecominfraproject.wlan.core.model.service.ServiceInstanceInformatio
|
|||||||
import com.telecominfraproject.wlan.core.server.container.ConnectorProperties;
|
import com.telecominfraproject.wlan.core.server.container.ConnectorProperties;
|
||||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWBaseCommand;
|
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWBaseCommand;
|
||||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWBlinkRequest;
|
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWBlinkRequest;
|
||||||
|
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWChangeRedirectorHost;
|
||||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWClientBlocklistChangeNotification;
|
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWClientBlocklistChangeNotification;
|
||||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWCloseSessionRequest;
|
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWCloseSessionRequest;
|
||||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWCommandResultCode;
|
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWCommandResultCode;
|
||||||
@@ -42,6 +43,7 @@ import com.telecominfraproject.wlan.equipmentgateway.models.CEGWFirmwareFlashReq
|
|||||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWRadioResetRequest;
|
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWRadioResetRequest;
|
||||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWRouteCheck;
|
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWRouteCheck;
|
||||||
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWStartDebugEngine;
|
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWStartDebugEngine;
|
||||||
|
import com.telecominfraproject.wlan.equipmentgateway.models.CEGWStopDebugEngine;
|
||||||
import com.telecominfraproject.wlan.equipmentgateway.models.EquipmentCommand;
|
import com.telecominfraproject.wlan.equipmentgateway.models.EquipmentCommand;
|
||||||
import com.telecominfraproject.wlan.equipmentgateway.models.EquipmentCommandResponse;
|
import com.telecominfraproject.wlan.equipmentgateway.models.EquipmentCommandResponse;
|
||||||
import com.telecominfraproject.wlan.equipmentgateway.models.GatewayDefaults;
|
import com.telecominfraproject.wlan.equipmentgateway.models.GatewayDefaults;
|
||||||
@@ -66,6 +68,7 @@ import com.telecominfraproject.wlan.server.exceptions.ConfigurationException;
|
|||||||
public class OpensyncCloudGatewayController {
|
public class OpensyncCloudGatewayController {
|
||||||
|
|
||||||
public static class ListOfEquipmentCommandResponses extends ArrayList<EquipmentCommandResponse> {
|
public static class ListOfEquipmentCommandResponses extends ArrayList<EquipmentCommandResponse> {
|
||||||
|
|
||||||
private static final long serialVersionUID = 3070319062835500930L;
|
private static final long serialVersionUID = 3070319062835500930L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,6 +115,7 @@ public class OpensyncCloudGatewayController {
|
|||||||
* latestTimetamp used when updating {@link #activeCustomerMap}
|
* latestTimetamp used when updating {@link #activeCustomerMap}
|
||||||
*/
|
*/
|
||||||
private final BiFunction<Long, Long, Long> latestTimestamp = new BiFunction<>() {
|
private final BiFunction<Long, Long, Long> latestTimestamp = new BiFunction<>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Long apply(Long oldValue, Long newValue) {
|
public Long apply(Long oldValue, Long newValue) {
|
||||||
if (newValue.compareTo(oldValue) > 0) {
|
if (newValue.compareTo(oldValue) > 0) {
|
||||||
@@ -131,6 +135,7 @@ public class OpensyncCloudGatewayController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
commands.stream().forEach(new Consumer<CEGWBaseCommand>() {
|
commands.stream().forEach(new Consumer<CEGWBaseCommand>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void accept(CEGWBaseCommand command) {
|
public void accept(CEGWBaseCommand command) {
|
||||||
LOG.debug("sendCommands - processing {}", command);
|
LOG.debug("sendCommands - processing {}", command);
|
||||||
@@ -156,43 +161,51 @@ public class OpensyncCloudGatewayController {
|
|||||||
|
|
||||||
switch (command.getCommandType()) {
|
switch (command.getCommandType()) {
|
||||||
|
|
||||||
case ConfigChangeNotification:
|
case ConfigChangeNotification:
|
||||||
ret.add(sendConfigChangeNotification(session, (CEGWConfigChangeNotification) command));
|
ret.add(sendConfigChangeNotification(session, (CEGWConfigChangeNotification) command));
|
||||||
break;
|
break;
|
||||||
case CloseSessionRequest:
|
case CloseSessionRequest:
|
||||||
ret.add(closeSession(session, (CEGWCloseSessionRequest) command));
|
ret.add(closeSession(session, (CEGWCloseSessionRequest) command));
|
||||||
break;
|
break;
|
||||||
case CheckRouting:
|
case CheckRouting:
|
||||||
ret.add(checkEquipmentRouting(session, (CEGWRouteCheck) command));
|
ret.add(checkEquipmentRouting(session, (CEGWRouteCheck) command));
|
||||||
break;
|
break;
|
||||||
case BlinkRequest:
|
case BlinkRequest:
|
||||||
ret.add(processBlinkRequest(session, (CEGWBlinkRequest) command));
|
ret.add(processBlinkRequest(session, (CEGWBlinkRequest) command));
|
||||||
break;
|
break;
|
||||||
case StartDebugEngine:
|
case ChangeRedirectorHost:
|
||||||
ret.add(processChangeRedirector(session, (CEGWStartDebugEngine) command));
|
ret.add(processChangeRedirector(session, (CEGWChangeRedirectorHost) command));
|
||||||
break;
|
break;
|
||||||
case FirmwareDownloadRequest:
|
case StartDebugEngine:
|
||||||
ret.add(processFirmwareDownload(session, (CEGWFirmwareDownloadRequest) command));
|
ret.add(processStartDebugEngine(session, (CEGWStartDebugEngine) command));
|
||||||
break;
|
break;
|
||||||
case FirmwareFlashRequest:
|
case StopDebugEngine:
|
||||||
ret.add(processFirmwareFlash(session, (CEGWFirmwareFlashRequest) command));
|
ret.add(processStopDebugEngine(session, (CEGWStopDebugEngine) command));
|
||||||
break;
|
break;
|
||||||
case RadioReset:
|
case FirmwareDownloadRequest:
|
||||||
ret.add(processRadioReset(session, (CEGWRadioResetRequest) command));
|
ret.add(processFirmwareDownload(session, (CEGWFirmwareDownloadRequest) command));
|
||||||
break;
|
break;
|
||||||
case ClientBlocklistChangeNotification:
|
case FirmwareFlashRequest:
|
||||||
ret.add(sendClientBlocklistChangeNotification(session,
|
ret.add(processFirmwareFlash(session, (CEGWFirmwareFlashRequest) command));
|
||||||
(CEGWClientBlocklistChangeNotification) command));
|
break;
|
||||||
break;
|
case RadioReset:
|
||||||
default:
|
ret.add(processRadioReset(session, (CEGWRadioResetRequest) command));
|
||||||
LOG.warn("[{}] Failed to deliver command {}, unsupported command type", inventoryId, command);
|
break;
|
||||||
ret.add(new EquipmentCommandResponse(
|
case ClientBlocklistChangeNotification:
|
||||||
CEGWCommandResultCode.UnsupportedCommand, "Invalid command type ("
|
ret.add(sendClientBlocklistChangeNotification(session,
|
||||||
+ command.getCommandType() + ") for equipment (" + inventoryId + ")",
|
(CEGWClientBlocklistChangeNotification) command));
|
||||||
command, registeredGateway.getHostname(), registeredGateway.getPort()));
|
break;
|
||||||
|
default:
|
||||||
|
LOG.warn("[{}] Failed to deliver command {}, unsupported command type", inventoryId, command);
|
||||||
|
ret.add(new EquipmentCommandResponse(
|
||||||
|
CEGWCommandResultCode.UnsupportedCommand, "Invalid command type ("
|
||||||
|
+ command.getCommandType() + ") for equipment (" + inventoryId + ")",
|
||||||
|
command, registeredGateway.getHostname(), registeredGateway.getPort()));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -286,14 +299,15 @@ public class OpensyncCloudGatewayController {
|
|||||||
} else if (command instanceof CEGWClientBlocklistChangeNotification) {
|
} else if (command instanceof CEGWClientBlocklistChangeNotification) {
|
||||||
tipwlanOvsdbClient.processClientBlocklistChange(inventoryId,
|
tipwlanOvsdbClient.processClientBlocklistChange(inventoryId,
|
||||||
((CEGWClientBlocklistChangeNotification) command).getBlockList());
|
((CEGWClientBlocklistChangeNotification) command).getBlockList());
|
||||||
|
} else if (command instanceof CEGWChangeRedirectorHost) {
|
||||||
|
String newRedirectorAddress = ((CEGWChangeRedirectorHost) command).getRedirectorHost();
|
||||||
|
tipwlanOvsdbClient.changeRedirectorHost(inventoryId, newRedirectorAddress);
|
||||||
} else if (command instanceof CEGWStartDebugEngine) {
|
} else if (command instanceof CEGWStartDebugEngine) {
|
||||||
// dtop: we will be using CEGWStartDebugEngine command to deliver
|
String gatewayHostname = ((CEGWStartDebugEngine) command).getGatewayHostname();
|
||||||
// request to
|
int gatewayPort = ((CEGWStartDebugEngine) command).getGatewayPort();
|
||||||
// change redirector
|
tipwlanOvsdbClient.startDebugEngine(inventoryId, gatewayHostname, gatewayPort);
|
||||||
// TODO: after the demo introduce a specialized command for this!
|
} else if (command instanceof CEGWStopDebugEngine) {
|
||||||
String newRedirectorAddress = ((CEGWStartDebugEngine) command).getGatewayHostname();
|
tipwlanOvsdbClient.stopDebugEngine(inventoryId);
|
||||||
tipwlanOvsdbClient.changeRedirectorAddress(inventoryId, newRedirectorAddress);
|
|
||||||
// TODO: add support for additional commands below
|
|
||||||
} else if (command instanceof CEGWFirmwareDownloadRequest) {
|
} else if (command instanceof CEGWFirmwareDownloadRequest) {
|
||||||
|
|
||||||
CEGWFirmwareDownloadRequest dlRequest = (CEGWFirmwareDownloadRequest) command;
|
CEGWFirmwareDownloadRequest dlRequest = (CEGWFirmwareDownloadRequest) command;
|
||||||
@@ -330,10 +344,19 @@ public class OpensyncCloudGatewayController {
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
private EquipmentCommandResponse processChangeRedirector(OvsdbSession session, CEGWStartDebugEngine command) {
|
private EquipmentCommandResponse processChangeRedirector(OvsdbSession session, CEGWChangeRedirectorHost command) {
|
||||||
return sendMessage(session, command.getInventoryId(), command);
|
return sendMessage(session, command.getInventoryId(), command);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private EquipmentCommandResponse processStartDebugEngine(OvsdbSession session, CEGWStartDebugEngine command) {
|
||||||
|
return sendMessage(session, command.getInventoryId(), command);
|
||||||
|
}
|
||||||
|
|
||||||
|
private EquipmentCommandResponse processStopDebugEngine(OvsdbSession session, CEGWStopDebugEngine command) {
|
||||||
|
return sendMessage(session, command.getInventoryId(), command);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private EquipmentCommandResponse processBlinkRequest(OvsdbSession session, CEGWBlinkRequest command) {
|
private EquipmentCommandResponse processBlinkRequest(OvsdbSession session, CEGWBlinkRequest command) {
|
||||||
|
|
||||||
return sendMessage(session, command.getInventoryId(), command);
|
return sendMessage(session, command.getInventoryId(), command);
|
||||||
@@ -403,11 +426,10 @@ public class OpensyncCloudGatewayController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method does the following:
|
* This method does the following: See WIFI-540 1. Retrieves the existing
|
||||||
* See WIFI-540
|
* list of Gateway entries from the Routing Service 2. Check each one of
|
||||||
* 1. Retrieves the existing list of Gateway entries from the Routing Service
|
* them for reachability (using PING method) 3. If the Gw does not respond
|
||||||
* 2. Check each one of them for reachability (using PING method)
|
* (stale IP), they will be unregistered/cleaned
|
||||||
* 3. If the Gw does not respond (stale IP), they will be unregistered/cleaned
|
|
||||||
*/
|
*/
|
||||||
protected void cleanupStaleGwRecord() {
|
protected void cleanupStaleGwRecord() {
|
||||||
LOG.debug("In CleanUp stale registered Gateways records ");
|
LOG.debug("In CleanUp stale registered Gateways records ");
|
||||||
@@ -433,10 +455,11 @@ public class OpensyncCloudGatewayController {
|
|||||||
} else {
|
} else {
|
||||||
LOG.debug("No gateways registered with Routing Service");
|
LOG.debug("No gateways registered with Routing Service");
|
||||||
}
|
}
|
||||||
} catch (Exception ex) { // Catching Exception to prevent crashing the register thread
|
} catch (Exception ex) { // Catching Exception to prevent crashing the
|
||||||
LOG.debug("Generic Exception encountered when trying to cleanup " +
|
// register thread
|
||||||
"the stale not-reachable GateWays. Continuing to register the new Gateway." +
|
LOG.debug("Generic Exception encountered when trying to cleanup "
|
||||||
" Error: {} ", ex.getMessage());
|
+ "the stale not-reachable GateWays. Continuing to register the new Gateway." + " Error: {} ",
|
||||||
|
ex.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -514,13 +537,14 @@ public class OpensyncCloudGatewayController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deletes the Equipment to Gateway relationship for gateway's that don't respond
|
* Deletes the Equipment to Gateway relationship for gateway's that don't
|
||||||
* See WIFI-540
|
* respond See WIFI-540 1. Get List of EquipmentRoutingRecords for an
|
||||||
* 1. Get List of EquipmentRoutingRecords for an Equipment
|
* Equipment 2. Get the GW from GW-Id associated with 'this'
|
||||||
* 2. Get the GW from GW-Id associated with 'this' EquipmentRoutingRecord
|
* EquipmentRoutingRecord 3. Try to ping the gateway 4. If ping fails or
|
||||||
* 3. Try to ping the gateway
|
* Gateway does not exist, delete the equipmentRouting entry.
|
||||||
* 4. If ping fails or Gateway does not exist, delete the equipmentRouting entry.
|
*
|
||||||
* @param equipmentId: Equipment's ID
|
* @param equipmentId:
|
||||||
|
* Equipment's ID
|
||||||
*/
|
*/
|
||||||
protected void cleanupStaleEqptRoutingRecord(Long equipmentId) {
|
protected void cleanupStaleEqptRoutingRecord(Long equipmentId) {
|
||||||
LOG.debug("In Clean Up stale Equipment Routing record for Equipment ID {}", equipmentId);
|
LOG.debug("In Clean Up stale Equipment Routing record for Equipment ID {}", equipmentId);
|
||||||
@@ -533,27 +557,31 @@ public class OpensyncCloudGatewayController {
|
|||||||
if (gwRec != null) {
|
if (gwRec != null) {
|
||||||
if (!isGwReachable(gwRec.getIpAddr(), gwRec.getPort())) {
|
if (!isGwReachable(gwRec.getIpAddr(), gwRec.getPort())) {
|
||||||
// GW isn't reachable --> invoke unregister
|
// GW isn't reachable --> invoke unregister
|
||||||
LOG.debug("Gateway {} is not-reachable... Deleting the equipment routing entry", gwRec.getHostname());
|
LOG.debug("Gateway {} is not-reachable... Deleting the equipment routing entry",
|
||||||
|
gwRec.getHostname());
|
||||||
deleteUnresponiveGwRoutingRecord(eqRouting.getId(), equipmentId);
|
deleteUnresponiveGwRoutingRecord(eqRouting.getId(), equipmentId);
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("Gateway {} is reachable.", gwRec.getHostname());
|
LOG.debug("Gateway {} is reachable.", gwRec.getHostname());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("Gateway with ID {} not found. Deleting the equipment routing entry ", eqRouting.getGatewayId());
|
LOG.debug("Gateway with ID {} not found. Deleting the equipment routing entry ",
|
||||||
|
eqRouting.getGatewayId());
|
||||||
deleteUnresponiveGwRoutingRecord(eqRouting.getId(), equipmentId);
|
deleteUnresponiveGwRoutingRecord(eqRouting.getId(), equipmentId);
|
||||||
}
|
}
|
||||||
} catch (DsEntityNotFoundException entityNotFoundException) {
|
} catch (DsEntityNotFoundException entityNotFoundException) {
|
||||||
LOG.debug("Gateway ID: {} not found... Deleting the equipment routing entry", eqRouting.getGatewayId());
|
LOG.debug("Gateway ID: {} not found... Deleting the equipment routing entry",
|
||||||
|
eqRouting.getGatewayId());
|
||||||
deleteUnresponiveGwRoutingRecord(eqRouting.getId(), equipmentId);
|
deleteUnresponiveGwRoutingRecord(eqRouting.getId(), equipmentId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
LOG.debug("No gateways registered with Routing Service for Equipment ID {}", equipmentId);
|
LOG.debug("No gateways registered with Routing Service for Equipment ID {}", equipmentId);
|
||||||
}
|
}
|
||||||
} catch (Exception genericException) { // Catching Exception to prevent crashing the register thread
|
} catch (Exception genericException) { // Catching Exception to prevent
|
||||||
LOG.debug("Generic Exception encountered when trying to cleanup " +
|
// crashing the register thread
|
||||||
"the stale routing records for equipment ID: {}. Continuing to register the new RoutingRecord." +
|
LOG.debug("Generic Exception encountered when trying to cleanup "
|
||||||
" Error: {} ", equipmentId, genericException.getMessage());
|
+ "the stale routing records for equipment ID: {}. Continuing to register the new RoutingRecord."
|
||||||
|
+ " Error: {} ", equipmentId, genericException.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -562,8 +590,8 @@ public class OpensyncCloudGatewayController {
|
|||||||
eqRoutingSvc.delete(routingId);
|
eqRoutingSvc.delete(routingId);
|
||||||
} catch (RuntimeException e) {
|
} catch (RuntimeException e) {
|
||||||
// failed
|
// failed
|
||||||
LOG.error("Failed to delete Equipment routing record (ID={}) from Routing Service: {}",
|
LOG.error("Failed to delete Equipment routing record (ID={}) from Routing Service: {}", eqptId,
|
||||||
eqptId, e.getLocalizedMessage());
|
e.getLocalizedMessage());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -9,7 +9,11 @@ public interface OvsdbClientInterface {
|
|||||||
|
|
||||||
Set<String> getConnectedClientIds();
|
Set<String> getConnectedClientIds();
|
||||||
|
|
||||||
String changeRedirectorAddress(String apId, String newRedirectorAddress);
|
String changeRedirectorHost(String apId, String newRedirectorHost);
|
||||||
|
|
||||||
|
String startDebugEngine(String apId, String gatewayHostname, Integer gatewayPort);
|
||||||
|
|
||||||
|
String stopDebugEngine(String apId);
|
||||||
|
|
||||||
void processConfigChanged(String apId);
|
void processConfigChanged(String apId);
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class OpenSyncGatewayController {
|
|||||||
@RequestMapping(value = "/changeRedirectorAddress", method = RequestMethod.POST)
|
@RequestMapping(value = "/changeRedirectorAddress", method = RequestMethod.POST)
|
||||||
public String changeRedirectorAddress(@RequestParam String apId, @RequestParam String newRedirectorAddress) {
|
public String changeRedirectorAddress(@RequestParam String apId, @RequestParam String newRedirectorAddress) {
|
||||||
LOG.info("Changing redirector address for AP {} to {}", apId, newRedirectorAddress);
|
LOG.info("Changing redirector address for AP {} to {}", apId, newRedirectorAddress);
|
||||||
String ret = tipwlanOvsdbClient.changeRedirectorAddress(apId, newRedirectorAddress);
|
String ret = tipwlanOvsdbClient.changeRedirectorHost(apId, newRedirectorAddress);
|
||||||
LOG.info("Changed redirector address for AP {} to {}", apId, ret);
|
LOG.info("Changed redirector address for AP {} to {}", apId, ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,7 +235,7 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
* @return updated value of the redirector
|
* @return updated value of the redirector
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public String changeRedirectorAddress(String apId, String newRedirectorAddress) {
|
public String changeRedirectorHost(String apId, String newRedirectorAddress) {
|
||||||
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
|
OvsdbSession ovsdbSession = ovsdbSessionMapInterface.getSession(apId);
|
||||||
if (ovsdbSession == null) {
|
if (ovsdbSession == null) {
|
||||||
throw new IllegalStateException("AP with id " + apId + " is not connected");
|
throw new IllegalStateException("AP with id " + apId + " is not connected");
|
||||||
@@ -746,4 +746,38 @@ public class TipWlanOvsdbClient implements OvsdbClientInterface {
|
|||||||
return "Initiated firmware flash for AP " + apId + " to " + firmwareVersion;
|
return "Initiated firmware flash for AP " + apId + " to " + firmwareVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String startDebugEngine(String apId, String gatewayHostname, Integer gatewayPort) {
|
||||||
|
LOG.debug("TipWlanOvsdbClient::startDebugEngine apId {} gatewayHostname {} gatewayPort {}", apId,gatewayHostname,gatewayPort);
|
||||||
|
|
||||||
|
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
|
||||||
|
OvsdbClient ovsdbClient = session.getOvsdbClient();
|
||||||
|
|
||||||
|
// TODO: need to establish what the command will be to start debug logging, on the AP side
|
||||||
|
// For now, use start_debug_engine
|
||||||
|
// Map will have gateway_host and gateway_port for now
|
||||||
|
// Delay/Duration TBD, just use 0s for now
|
||||||
|
Map<String,String> payload = new HashMap<>();
|
||||||
|
payload.put("gateway_hostname", gatewayHostname);
|
||||||
|
payload.put("gateway_port", gatewayPort.toString());
|
||||||
|
ovsdbDao.configureCommands(ovsdbClient, OvsdbDao.StartDebugEngineApCommand, payload, Long.valueOf(0L), Long.valueOf(0L));
|
||||||
|
|
||||||
|
LOG.debug("Started debug engine on AP {} with gateway {} port {}", apId, gatewayHostname, gatewayPort);
|
||||||
|
return "Started debug engine on AP " + apId + " with gateway " + gatewayHostname + " port " + gatewayPort;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String stopDebugEngine(String apId) {
|
||||||
|
LOG.debug("TipWlanOvsdbClient::stopDebugEngine apId {}", apId);
|
||||||
|
|
||||||
|
OvsdbSession session = ovsdbSessionMapInterface.getSession(apId);
|
||||||
|
OvsdbClient ovsdbClient = session.getOvsdbClient();
|
||||||
|
|
||||||
|
Map<String,String> payload = new HashMap<>();
|
||||||
|
ovsdbDao.configureCommands(ovsdbClient, OvsdbDao.StopDebugEngineApCommand, payload, Long.valueOf(0L), Long.valueOf(0L));
|
||||||
|
|
||||||
|
LOG.debug("Stop debug engine on AP {}", apId);
|
||||||
|
return "Stop debug engine on AP " + apId ;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,6 +177,10 @@ public class OvsdbDao {
|
|||||||
|
|
||||||
public static final String commandStateDbTable = "Command_State";
|
public static final String commandStateDbTable = "Command_State";
|
||||||
|
|
||||||
|
public static final String StartDebugEngineApCommand = "start_debug_engine";
|
||||||
|
|
||||||
|
public static final String StopDebugEngineApCommand = "stop_debug_engine";
|
||||||
|
|
||||||
public ConnectNodeInfo getConnectNodeInfo(OvsdbClient ovsdbClient) {
|
public ConnectNodeInfo getConnectNodeInfo(OvsdbClient ovsdbClient) {
|
||||||
ConnectNodeInfo ret = new ConnectNodeInfo();
|
ConnectNodeInfo ret = new ConnectNodeInfo();
|
||||||
|
|
||||||
@@ -988,10 +992,10 @@ public class OvsdbDao {
|
|||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, CommandConfigInfo> getProvisionedCommandConfigs(OvsdbClient ovsdbClient) {
|
public Map<String, CommandConfigInfo> getProvisionedCommandConfigs(OvsdbClient ovsdbClient) {
|
||||||
Map<String, CommandConfigInfo> ret = new HashMap<>();
|
Map<String, CommandConfigInfo> ret = new HashMap<>();
|
||||||
|
|
||||||
List<Operation> operations = new ArrayList<>();
|
List<Operation> operations = new ArrayList<>();
|
||||||
List<Condition> conditions = new ArrayList<>();
|
List<Condition> conditions = new ArrayList<>();
|
||||||
List<String> columns = new ArrayList<>();
|
List<String> columns = new ArrayList<>();
|
||||||
@@ -1002,7 +1006,7 @@ public class OvsdbDao {
|
|||||||
columns.add("command");
|
columns.add("command");
|
||||||
columns.add("payload");
|
columns.add("payload");
|
||||||
columns.add("timestamp");
|
columns.add("timestamp");
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
LOG.debug("Retrieving CommandConfig:");
|
LOG.debug("Retrieving CommandConfig:");
|
||||||
@@ -1019,24 +1023,24 @@ public class OvsdbDao {
|
|||||||
|
|
||||||
CommandConfigInfo commandConfigInfo = new CommandConfigInfo();
|
CommandConfigInfo commandConfigInfo = new CommandConfigInfo();
|
||||||
commandConfigInfo.uuid = row.getUuidColumn("_uuid");
|
commandConfigInfo.uuid = row.getUuidColumn("_uuid");
|
||||||
commandConfigInfo.delay = row.getIntegerColumn("delay");
|
commandConfigInfo.delay = row.getIntegerColumn("delay");
|
||||||
commandConfigInfo.duration = row.getIntegerColumn("duration");
|
commandConfigInfo.duration = row.getIntegerColumn("duration");
|
||||||
commandConfigInfo.command = row.getStringColumn("command");
|
commandConfigInfo.command = row.getStringColumn("command");
|
||||||
commandConfigInfo.payload = row.getMapColumn("payload");
|
commandConfigInfo.payload = row.getMapColumn("payload");
|
||||||
commandConfigInfo.timestamp = row.getIntegerColumn("timestamp");
|
commandConfigInfo.timestamp = row.getIntegerColumn("timestamp");
|
||||||
|
|
||||||
ret.put(commandConfigInfo.command, commandConfigInfo);
|
ret.put(commandConfigInfo.command, commandConfigInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG.debug("Retrieved CommandConfig: {}", ret);
|
LOG.debug("Retrieved CommandConfig: {}", ret);
|
||||||
|
|
||||||
} catch (ExecutionException | InterruptedException | OvsdbClientException | TimeoutException e) {
|
} catch (ExecutionException | InterruptedException | OvsdbClientException | TimeoutException e) {
|
||||||
|
|
||||||
LOG.error("Error in getProvisionedCommandConfigs", e);
|
LOG.error("Error in getProvisionedCommandConfigs", e);
|
||||||
|
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2202,6 +2206,8 @@ public class OvsdbDao {
|
|||||||
public void configureCommands(OvsdbClient ovsdbClient, String command, Map<String, String> payload, Long delay,
|
public void configureCommands(OvsdbClient ovsdbClient, String command, Map<String, String> payload, Long delay,
|
||||||
Long duration) {
|
Long duration) {
|
||||||
|
|
||||||
|
LOG.debug("OvsdbDao::configureCommands command {}, payload {}, delay {} duration {}", command, payload, delay,
|
||||||
|
duration);
|
||||||
|
|
||||||
List<Operation> operations = new ArrayList<>();
|
List<Operation> operations = new ArrayList<>();
|
||||||
Map<String, Value> commandConfigColumns = new HashMap<>();
|
Map<String, Value> commandConfigColumns = new HashMap<>();
|
||||||
@@ -2226,13 +2232,13 @@ public class OvsdbDao {
|
|||||||
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
CompletableFuture<OperationResult[]> fResult = ovsdbClient.transact(ovsdbName, operations);
|
||||||
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
OperationResult[] result = fResult.get(ovsdbTimeoutSec, TimeUnit.SECONDS);
|
||||||
|
|
||||||
LOG.debug("Configured command {} for duration {} payload {}", command, duration, payload);
|
LOG.debug("OvsdbDao::configureCommands successfully configured command {} for duration {} payload {}", command, duration, payload);
|
||||||
|
|
||||||
for (OperationResult res : result) {
|
for (OperationResult res : result) {
|
||||||
LOG.debug("Op Result {}", res);
|
LOG.debug("Op Result {}", res);
|
||||||
}
|
}
|
||||||
} catch (OvsdbClientException | InterruptedException | ExecutionException | TimeoutException e) {
|
} catch (OvsdbClientException | InterruptedException | ExecutionException | TimeoutException e) {
|
||||||
LOG.error("configureCommands interrupted.", e);
|
LOG.error("OvsdbDao::configureCommands failed.", e);
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3065,7 +3071,8 @@ public class OvsdbDao {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: when schema support is added, these should be part of the bulk provisioning operation above.
|
// TODO: when schema support is added, these should be part of the
|
||||||
|
// bulk provisioning operation above.
|
||||||
provisionUccStatsConfig(ovsdbClient);
|
provisionUccStatsConfig(ovsdbClient);
|
||||||
provisionEventReporting(ovsdbClient);
|
provisionEventReporting(ovsdbClient);
|
||||||
|
|
||||||
@@ -3327,7 +3334,7 @@ public class OvsdbDao {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void provisionEventReporting(OvsdbClient ovsdbClient) {
|
public void provisionEventReporting(OvsdbClient ovsdbClient) {
|
||||||
|
|
||||||
LOG.debug("Enable event reporting from AP");
|
LOG.debug("Enable event reporting from AP");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user