Tuesday, June 5, 2018

NETCONF ? 3W (WHAT, WHY, WHEN)

One of my client using NETCONF, I don't know the purpose. I started to some research and read some documents and find-out, why/what/when NETCONF came into picture.

Why?

SNMP failed:

Simple Network Management Protocol. SNMP supports cable modems, routers, switches, servers, workstations, printers, and more. It's a standard protocol collecting and organising information about devices on network and also updates information that change device behaviour.


SNMP is simple to implement but not simple to use while dealing with configurations.

Easy to Use:

Very easy use when compared to development.

Network wide Transactions:

Most of the operators not concerned about every single device. They want configure a set network devices at the same time. This task is very easy while using NETCONF.

Transactional Base Configuration:

While updating set of configuration if any configuration is failed we want revert/delete some other configuration. This behaviour is achieved using Transactional Base Configuration.

Network Validations:

Another feature that used to validates the configurations of the network not each device. Which help to stop wrong validation at network level not on device level.


  • Distinction between configuration and state data
  • Multiple configuration data stores (candidate, running, startup)
  • Configuration change transactions
  • Configuration testing and validation support
  • Selective data retrieval with filtering
  • Streaming and playback of event notifications
  • Extensible procedure call mechanism


What is NETCONF ?

 NETCONF is a protocol defined by the IETF to “install, manipulate, and delete the configuration of network devices”. NETCONF operations are realized on top of a Remote Procedure Call (RPC) layer using an XML encoding and provides a basic set of operations to edit and query configuration on a network device.
Why NETCONF vs. Other Approaches:
CLI scripting was the primary approach to making automated configuration changes to the network prior to NETCONF. CLI scripting has several limitations including lack of transaction management, no structured error management and ever changing structure and syntax of commands that makes scripts fragile and costly to maintain. These are all side-effects of the basic fact that CLIs are designed to be used by humans and not an API for programmatic access.
SNMP is another approach that could be used to write changes, but, in practice, is mostly used for performance and monitoring applications. Reasons for this include the lack of a defined discovery process that makes it hard to find the correct MIB modules, limitations inherent in the use of the UDP protocol, and the lack of useful standard security and commit mechanisms.
Key NETCONF Capabilities:
The NETCONF protocol was designed to address the shortcomings of existing practices and protocols for configuration management. The background work preceding the design phase has been documented in RFC 3535 Overview of the 2002 IAB Network Management Workshop. The design goals from that work includes:
key characteristics:
  • Unified YANG modeling for both services and devices.
  • One database that combines device configuration and service configuration.
  • Rendering of northbound and southbound interfaces and database schemas from the service and device model. Northbound are the APIs published to users of NCS, be it human or programmatic interfaces. Southbound is the integration point of managed devices, for example NETCONF.
  • A transaction engine that handles transactions from the service order to the actual device configuration deployment.
  • An in-memory high-performance database.




Monday, June 19, 2017

Native HTML5 Drag and Drop

HTML5 Drag and Drop




To check Browser support:

if (Modernizr.draganddrop) {
  // Browser supports HTML5 DnD.
} else {
  // Fallback to a library solution.
}

Drag-able element:

Its very easy to create a drag-able element draggable=true.

<div id="draggablecontainer">
  <div class="a" draggable="true">draggable-A</div>
  <div class="b" draggable="true">draggable-B</div>
</div>

Dragging Events:

  • dragstart
  • drag
  • dragenter
  • dragleave
  • dragover
  • drop
  • dragend
var cols = document.querySelectorAll('#draggablecontainer .a');
[].forEach.call(cols, function(col) {
  col.addEventListener('dragstart', handleDragStart, false);
  col.addEventListener('dragenter', handleDragEnter, false)
  col.addEventListener('dragover', handleDragOver, false);
  col.addEventListener('dragleave', handleDragLeave, false);
  col.addEventListener('drop', handleDrop, false);
  col.addEventListener('dragend', handleDragEnd, false);
});







Monday, September 28, 2015

Deleting a variable from the window object (Not possible to delete if var is used)

Most of the times all javascript applications deals with objects and their properties. I used empty a property which I longer needed. After that I came to know about delete operator which used to remove a property from an object.

While using delete operator I got doubt like,

is it possible to delete a variable?

So the answer to the question depends on how the global variable or property is defined.
  • If it is created using var, it cannot be deleted.
               var global = 32;           // global is a variable created using 'var'
               delete global;               // returns false
               console.log(global)      // global is still 32

  • If it is created without var, it can be deleted.
               global = 1;                    // global is a variable created without using 'var'
               delete global;               // return true
               console.log(global);     // error, global is not defined

Explanation:

1. Using `var`

In this case reference global is created in "VariableEnvironment" that is attached to the current scope.
This may be a function execution context in the case of using var inside a function (though it may be get a little more complicated when you consider let)
or 
In the case of "global" code the VariableEnvironment is attached to the global object (often window).

References in VariableEnvironment are not normally deletable - unless your code is executed in an eval context (which most browser-based development consoles use), then variables declared with var cannot be deleted.

2. Without Using `var`

When trying to assign a value to a variable without using the `var` keyword, Javascript tries to locate the named reference in "LexicalEnvironment".

LexicalEnvironments are nested and has a parent ("outer environment reference") and when Javascript fails to locate the reference in a LexicalEnvironment, it looks in the parent LexicalEnvironment.

The top level LexicalEnvironment is the "global environment", and that is bound to the global object in that its references are the global object's properties.
So if you try to access a name that was not declared using a var keyword in the current scope or any outer scopes, Javascript will eventually fetch a property of the window object to serve as that reference.
As we've learned before, properties on objects can be deleted.


Notes

  1. It is important to remember that var declarations are "hoisted" - i.e. they are always considered to have happened in the beginning of the scope that they are in - though not the value initialisation that may be done in a var statement - that is left where it is. So in the following code, a is a reference from the VariableEnvironment and not the window property and its value will be 10 at the end of the code:

    function test() { a = 5; var a = 10; }
  2. The above discussion is when "strict mode" is not enabled. Lookup rules are a bit different when using "strict mode" and lexical references that would have resolved to window properties without "strict mode" will raise "undeclared variable" errors under "strict mode". I didn't really understand where this is specified, but its how browsers behave.
  3. The delete command has no effect on regular variables, only properties. After the delete command the property doesn't have the value null, it doesn't exist at all.
    If the property is an object reference, the delete command deletes the property then the delete operator deletes only a reference, never an object itself. If it did delete the object itself, other remaining references would be dangling, like a C++ delete. (And accessing one of them would cause a crash. To make them all turn null would mean having extra work when deleting or extra memory for each object.)
  4. Since Javascript is garbage collected, you don't need to delete objects themselves - they will be removed when there is no way to refer to them anymore. It can be useful to delete references to an object if you are finished with them, because this gives the garbage collector more information about what is able to be reclaimed. If references remain to a large object, this can cause it to be unreclaimed - even if the rest of your program doesn't actually use that object.

Friday, September 25, 2015

delete in javascript

The delete command has no effect on regular variables, only properties. After the delete command the property doesn't have the value null, it doesn't exist at all.
If the property is an object reference, the delete command deletes the property then the delete operator deletes only a reference, never an object itself. If it did delete the object itself, other remaining references would be dangling, like a C++ delete. (And accessing one of them would cause a crash. To make them all turn null would mean having extra work when deleting or extra memory for each object.) Since Javascript is garbage collected, you don't need to delete objects themselves - they will be removed when there is no way to refer to them anymore.
It can be useful to delete references to an object if you are finished with them, because this gives the garbage collector more information about what is able to be reclaimed. If references remain to a large object, this can cause it to be unreclaimed - even if the rest of your program doesn't actually use that object.