User PPPoE

Dan Morphis dan at milkcarton.com
Mon Oct 9 12:49:02 EDT 2017


You can write a provisioning script which calls an external script and have
the external script query a system to retrieve the username/password and
any other settings for a CPE.

Provision script:

const now = Date.now();

let provisioned = declare("Tags.Provisioned", {value: 1});
if (provisioned.value !== undefined) {
    log('CPE is (allegedly) provisioned, returning');
    return;
}

let model = declare("InternetGatewayDevice.DeviceInfo.ModelName", {value:
1}).value[0];
let serialNumber = declare("DeviceID.SerialNumber", {value: 1}).value[0];
let productClass = declare("DeviceID.ProductClass", {value: 1}).value[0];
let oui = declare("DeviceID.OUI", {value: 1}).value[0];
let args = {serial: serialNumber, productClass: productClass, oui: oui};


//Get the PPPoE creds
let config = ext('cpe-config', 'resetPppoe', JSON.stringify(args));
if (!config) {
    log('No config returned from API');
    return;
}

declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Username",
{value: now}, {value: config.username});
declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevice.*.WANPPPConnection.*.Password",
{value: now}, {value: config.password});



External script:

const API_URL = process.env.API_URL || 'http://my-server/api/ACS/';
const url = require("url");
const http = require(API_URL.split(":", 1)[0]);

function resetPppoe(args, callback) {
  let params = JSON.parse(args[0]);

  const uri = API_URL + "ResetPPPoECreds?serial=" + params.serial +
'&productClass=' + params.productClass + '&oui=' + params.oui;

  console.log({ uri: uri, serial: params.serial });

  let options = url.parse(uri);
  options.headers = {
    accept: 'application/json',
    "content-type": 'application/json'
  };

  let request = http.get(options, function (response) {
    if (response.statusCode == 404) {
      return callback(null, null);
    }

    if (response.statusCode >= 400) {
      return callback(new Error("Unexpected error resetting PPPoE
credentials. Response Code: " + response.statusCode + '. Status
Message: ' + response.statusMessage + '. t: ' + typeof
response.statusCode));
    }

    let data = "";
    response.on("data", function (d) {
      data = data + d.toString();
    });

    response.on("end", function () {
      let result = JSON.parse(data);

      console.log('Returning credentials to client', result);
      return callback(null, result);
    });
  });

  request.on("error", function (err) {
    console.log('args');
    console.log(arguments);
    callback(err);
  });
}

exports.resetPppoe = resetPppoe;



On Mon, Oct 9, 2017 at 12:45 AM, Jose Vela Delgado <josevelacisco at gmail.com>
wrote:

> Yeah, right, Dan.
>
> My idea is that if you can do that with a single v-parameter script, add
> the pppoe user to all CPEs. I do not know if with a variable in the
> username field of the script.
> Otherwise, I would have to create a v-parameters for all CPEs, and I would
> like that to be something more dynamic, without having to play a lot of
> software myself.
>
> ​I repeat, I do not know if that can be done.​
>
>> Jose Vela
> *Técnico de networking routing, switching y GPON networks.*
>
>
>
> *"El aprendizaje es experiencia, todo lo demás en información" * *Albert
> Einstein.*
>
> Mira mi perfil profesional y conecta conmigo en LinkedIn pinchando en
> este enlace.
> <https://mailtrack.io/trace/link/a1d88716ed69e910043d42bb5f5128eaed9a1ecf?url=https%3A%2F%2Fes.linkedin.com%2Fin%2Fjose-vela-delgado&userId=44382&signature=d2a3dd7e8bd03a84>
>
> 2017-10-06 18:50 GMT+02:00 Dan Morphis <dan at milkcarton.com>:
>
>> You mean like this?
>> [image: Inline image 1]
>>
>> The script I posted doesn't fallback to the *Device* nodes if that is
>> where the pppoe username is stored for your setup, you can easily modify
>> the v-param script to fallback. Look a the v-parameters wiki entry for more
>> information on how to do fallback.
>>
>> -dan
>>
>> On Thu, Oct 5, 2017 at 11:41 PM, Jose Vela Delgado <
>> josevelacisco at gmail.com> wrote:
>>
>>> Hi Dan,
>>>
>>> I can already see the VirtualParameters in the Device Parameters list of
>>> all the CPEs. All perfect.
>>>
>>> But now the parameter appears to me as UNKNOWN in the more than 400 CPEs
>>> we have. If I change that word "UNKNOWN" by a specific user, that user
>>> appears to me.
>>>
>>>
>>> - VirtualParameters
>>> <https://mailtrack.io/trace/link/503c0b6ef402ffe0415ee29892d4ddddbc22b7b0?url=http%3A%2F%2F192.168.106.16%3A3000%2Fdevices%2F00259E-HG8546M-48575443BFFE208C%23&userId=44382&signature=d3cb664e4a1980b6>
>>> - VirtualParameters.pppoeUsername UNKNOWN
>>>
>>> My idea is that instead of appearing the word "UNKNOWN" in the more than
>>> 400 CPEs, I would like to appear each pppoe user of each CPEs. I do not
>>> know if I can explain myself.
>>>
>>> I do not know if it can be done.
>>>
>>> Regards,
>>>
>>>
>>>
>>> ​​
>>>>>>
>>> Jose Vela
>>> *Técnico de networking routing, switching y GPON networks.*
>>>
>>>
>>>
>>> *"El aprendizaje es experiencia, todo lo demás en información" * *Albert
>>> Einstein.*
>>>
>>> Mira mi perfil profesional y conecta conmigo en LinkedIn pinchando en
>>> este enlace.
>>> <https://mailtrack.io/trace/link/9e34b5e1b377df4907e1fc50811a821f2760fb4a?url=https%3A%2F%2Fes.linkedin.com%2Fin%2Fjose-vela-delgado&userId=44382&signature=6418fb8bbed39759>
>>>
>>> 2017-10-05 18:46 GMT+02:00 Dan Morphis <dan at milkcarton.com>:
>>>
>>>> So 2 and 3 are unnecessary if you have a separate provision that sets
>>>> the username. If you do, then refresh the vparam in that provision.
>>>> Refreshing on 2 PERIODIC could be a bit much, but that depends on how often
>>>> your CPEs inform. We have ours set to inform every 30 mins.
>>>>
>>>> To see the param in the gui for a specific device, add this line to
>>>> genieacsgui/config/summary_parameters.yml:
>>>> PPPoE Username: VirtualParameters.pppoeUsername
>>>>
>>>> To see the param on the devices page, add that line to
>>>> index_parameters.yml
>>>>
>>>> -dan
>>>>
>>>> On Thu, Oct 5, 2017 at 12:32 AM, Jose Vela Delgado <
>>>> josevelacisco at gmail.com> wrote:
>>>>
>>>>> Thank you very much Dan for your prompt response.
>>>>>
>>>>>
>>>>>
>>>>> This I have done:
>>>>>
>>>>>
>>>>>
>>>>> 1. I created a virtual parameter with the first script you told me.
>>>>>
>>>>>
>>>>>
>>>>> 2. I have created a provision, called "Refresh-PPPoE" with the second
>>>>> script you told me.
>>>>>
>>>>>
>>>>>
>>>>> 3. Finally I have created a Preset with the name "Refresh-PPPoE" so
>>>>> that it calls the provision every time there is a 2 PERIODIC event.
>>>>>
>>>>>
>>>>>
>>>>> Have I done well? What is the next step to see that parameter in the
>>>>> GenieACS?
>>>>>
>>>>>
>>>>>
>>>>> A greeting.
>>>>>
>>>>>
>>>>>
>>>>> Enviado desde Correo
>>>>> <https://mailtrack.io/trace/link/f1eee036fd0fc4e127f39c90b7b640b6f07746ff?url=https%3A%2F%2Fgo.microsoft.com%2Ffwlink%2F%3FLinkId%3D550986&userId=44382&signature=c2a72393f4b5e9db>
>>>>> para Windows 10
>>>>>
>>>>>
>>>>>
>>>>> *De: *Dan Morphis <dan at milkcarton.com>
>>>>> *Enviado: *miércoles, 4 de octubre de 2017 20:12
>>>>> *Para: *Community support for GenieACS users
>>>>> <users at lists.genieacs.com>
>>>>> *Asunto: *Re: User PPPoE
>>>>>
>>>>>
>>>>>
>>>>> Create a v-param called 'pppoeUsername' with this script:
>>>>>
>>>>>
>>>>>
>>>>> let username = 'UNKNOWN';
>>>>>
>>>>> let igd = declare("InternetGatewayDevice.WANDevice.*.WANConnectionDevi
>>>>> ce.*.WANPPPConnection.*.Username", {value: 1});
>>>>>
>>>>>
>>>>>
>>>>> if (igd.size) {
>>>>>
>>>>>   for (let p of igd) {
>>>>>
>>>>>     if (p.value[0]) {
>>>>>
>>>>>       username = p.value[0];
>>>>>
>>>>>       break;
>>>>>
>>>>>     }
>>>>>
>>>>>   }
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>> return {writable: false, value: [username, "xsd:string"]};
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> Finally, in what ever script you use to set the PPPoE Username field,
>>>>> add this:
>>>>>
>>>>>
>>>>>
>>>>> declare(*"VirtualParameters.pppoeUsername"*, {*value*: Date.*now()*}); //Force the pppoeUsername vparam to update
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> -dan
>>>>>
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Users mailing list
>>>>> Users at lists.genieacs.com
>>>>> http://lists.genieacs.com/mailman/listinfo/users
>>>>> <https://mailtrack.io/trace/link/c61a7ff345be1069e647d7792b5eb8b4b429b722?url=http%3A%2F%2Flists.genieacs.com%2Fmailman%2Flistinfo%2Fusers&userId=44382&signature=652928c71a3a7db1>
>>>>>
>>>>>
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at lists.genieacs.com
>>>> http://lists.genieacs.com/mailman/listinfo/users
>>>> <https://mailtrack.io/trace/link/188ebd4e2c68a2ad4c69c2f1713f371cfa574fc9?url=http%3A%2F%2Flists.genieacs.com%2Fmailman%2Flistinfo%2Fusers&userId=44382&signature=aaf0037c6f3c40df>
>>>>
>>>>
>>>
>>> _______________________________________________
>>> Users mailing list
>>> Users at lists.genieacs.com
>>> http://lists.genieacs.com/mailman/listinfo/users
>>> <https://mailtrack.io/trace/link/188ebd4e2c68a2ad4c69c2f1713f371cfa574fc9?url=http%3A%2F%2Flists.genieacs.com%2Fmailman%2Flistinfo%2Fusers&userId=44382&signature=aaf0037c6f3c40df>
>>>
>>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.genieacs.com
>> http://lists.genieacs.com/mailman/listinfo/users
>> <https://mailtrack.io/trace/link/188ebd4e2c68a2ad4c69c2f1713f371cfa574fc9?url=http%3A%2F%2Flists.genieacs.com%2Fmailman%2Flistinfo%2Fusers&userId=44382&signature=aaf0037c6f3c40df>
>>
>>
>
> _______________________________________________
> Users mailing list
> Users at lists.genieacs.com
> http://lists.genieacs.com/mailman/listinfo/users
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.genieacs.com/pipermail/users/attachments/20171009/93e73752/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 7371 bytes
Desc: not available
URL: <http://lists.genieacs.com/pipermail/users/attachments/20171009/93e73752/attachment-0001.png>


More information about the Users mailing list