Commit 75e3167e authored by Muhammad Umair Khan's avatar Muhammad Umair Khan
Browse files

Fix silent UE deletion on scenario activation without sandbox metadata

This fixes an issue reported by Kaleb where deploying a scenario without deployment.userMeta['mec-sandbox'] caused the frontend to default the UE counts to 0 and silently trim them via REMOVE events. The initial UE counters in parseUes() now properly initialize to -1 and fallback to the total number of physical locations mapped in the scenario if the metadata is missing. This preserves the initial scenario topology and routing state in the traffic control engine.
parent e500b5eb
Loading
Loading
Loading
Loading
+12 −7
Original line number Diff line number Diff line
@@ -335,7 +335,7 @@ export function getNetworkInfo(scenario) {

export function parseUes(scenario) {
  var totalHv = 0, totalLv = 0, totalZv = 0;
  var initHv = 0, initLv = 0, initZv = 0;
  var initHv = -1, initLv = -1, initZv = -1;
  var velocityThreshold = DEFAULT_VELOCITY_THRESHOLD;

  if (!scenario) {
@@ -348,22 +348,22 @@ export function parseUes(scenario) {
    if (mecSandboxUserMeta) {
      var jsonUeObj = JSON.parse(mecSandboxUserMeta);

      if (jsonUeObj.defaultStaticUeCount) {
      if (jsonUeObj.defaultStaticUeCount !== undefined && jsonUeObj.defaultStaticUeCount !== null) {
        initZv = parseInt(jsonUeObj.defaultStaticUeCount);
        if (isNaN(initZv)) {
          initZv = 0;
          initZv = -1;
        }
      }
      if (jsonUeObj.defaultLowVelocityUeCount) {
      if (jsonUeObj.defaultLowVelocityUeCount !== undefined && jsonUeObj.defaultLowVelocityUeCount !== null) {
        initLv = parseInt(jsonUeObj.defaultLowVelocityUeCount);
        if (isNaN(initLv)) {
          initLv = 0;
          initLv = -1;
        }
      }
      if (jsonUeObj.defaultHighVelocityUeCount) {
      if (jsonUeObj.defaultHighVelocityUeCount !== undefined && jsonUeObj.defaultHighVelocityUeCount !== null) {
        initHv = parseInt(jsonUeObj.defaultHighVelocityUeCount);
        if (isNaN(initHv)) {
          initHv = 0;
          initHv = -1;
        }
      }
      if (jsonUeObj.highVelocitySpeedThreshold) {
@@ -410,6 +410,11 @@ export function parseUes(scenario) {
    }
  }

  // Fallback unspecified initialization counts to total physical locations
  if (initHv === -1) { initHv = totalHv; }
  if (initLv === -1) { initLv = totalLv; }
  if (initZv === -1) { initZv = totalZv; }

  return {
    initHv: initHv,
    initLv: initLv,
+4 −4

File changed.

Contains only whitespace changes.