I got the problem fixed. Had to dig through the code to see what methods and attributes were available in the object. Working code is below - I am not used to javascript development but it seems to work well enough:

// Fetch IP for 'loopback0' Interface
let m = '';
let x = 'temp';
let foundint = false;
let goodint = false;
let intnames = declare(
  "Device.X_MIKROTIK_Interface.Generic.*.Name",
  {value: Date.now()});
let lowerlayers = declare(
  "Device.IP.Interface.*.LowerLayers",
  {value: Date.now()});
if (intnames.size) {
  for (let myint of intnames) {
    if (myint.value[0]=='loopback0') {
      x = myint.path.substr(0, myint.path.lastIndexOf("."));
      foundint = true;
      break;
    }
  }
}
if (foundint) {
if (lowerlayers.size) {
  for (let myint of lowerlayers) {
    if (myint.value[0]==x) {
      x = myint.path.substr(0, myint.path.lastIndexOf("."));
      goodint = true;
      break;
    }
  }
}
}

if (goodint) {
let ipaddress = declare(
  x + ".IPv4Address.*.IPAddress",
  {value: Date.now()});

if (ipaddress.size) {
  for (let myaddress of ipaddress) {
    if (ipaddress.value[0]) {
      m = ipaddress.value[0];
      break;
    }
  }
}
}

return {writable: false, value: [m, "xsd:string"]};


_______________________________________________
Users mailing list
[email protected]
http://lists.genieacs.com/mailman/listinfo/users

Reply via email to