...
In order to register a resource, a resource descriptor file is required. This file describes resource device type and name, all capabilities OpenNaaS should load for it, and what drivers will it use. More information about the Resource descriptor concept is available in System Architecture section.
For this tutorial, a A descriptor from the project examples directory, or a custom one can be used.
The CLI command to register a device with this descriptor will be:
Code Block |
---|
resource:create /path/to/descriptor/resource.descriptor |
...
Note: For this guide, we used a router descriptor, specifying junos20 as name.
Registering protocol contexts
Each resource has to be linked to the necessary protocols which are used can use many different protocols to communicate with the physical device it represents. Required protocols are determined by the driver in use. For a resource to be able to use a required protocol, a Protocol Context is needed. Protocol Context stores all required information to communicate with the physical device and send its operations. This is an example which uses a netconf protocol to connect with the resourcedevice using a protocol known to OpenNaaS.
In this example we're going to use netconf protocol. Hence, we introduce all netconf Protocol Context required data:
- protocol type
- authentication type
- uri
- authentication parameters
The following command illustrates how to register a protocol context for our resource using password authentication:
Code Block |
---|
protocols:context router:junos20 netconf password ssh://myuser:mypassword@193.1.190.254:22/netconf |
or and the following if you're , using key uathenticationauthentication:
Code Block |
---|
protocols:context router:junos20 netconf publickey ssh://myuser@193.1.190.254.22/netconf privateKeyPath {key-passphrase} |
Description of the connection parameters:
- router:junos20 - specify resource type (router) and resource name (junos20) for the resource we want to assign a protocol to.
- netconf - name to identify the protocol configuration.
- ssh://myuser:mypassword@1.1.1.1:22/netconf - URI to describe connection parameters.
- privateKeyPath - path where the private key is stored.
- key-passphrase - passphrase to unlock the private key (if any)
The information about the used protocols is in this link.
Resources states
A resource is in a set of states which each allow a set of operations. This picture describes these states:
Notice that only one context per protocol type is registered in a resource. Last one lasts.
Starting resources
A resource will populate its model and Mainly, a resource will enable all its capabilities when started. For this reason, the next step will be start our resourceHence, in order to operate with it using opennaas, it must be started.
To start it, we use the following command:
Code Block |
---|
resource:start router:junos20
|
Doing operations with
...
resources
A resource includes a set of capabilities or features. These capabilities are determine the set of available operations a device has. Mantychore supports:
...
for this resource.
OpenNaaS supported capabilities are specified in this section.
Please, remember that capabilities to load for a particular resource are specified in the resource descriptor.
Removing a resource
Finally, if the resource isn't needed anymore, it can be stopped and removed. First, we stop it:
...
The resource will deactivate all its capabilities and it will be reset. After, we'll destroy it and delete any resource information in Mantychore.OpenNaaS.
Code Block |
---|
resource:remove router:junos20 |
Note |
---|
Notice that stopping and removing a resource causes no changes in real device configuration (e.g. resource:remove router:logicalrouter1 does not delete the logical router, but only removes it from OpenNaaS.) |