Difference between revisions of "SAFplus Management Framework"

(Answer:)
 
(42 intermediate revisions by 2 users not shown)
Line 1: Line 1:
1. Git clone:
+
== Download Framework via github  ==
git clone https://github.com/OpenClovis/SAFplus-Mgt.git <path>
+
root@desktop:/# git clone https://github.com/OpenClovis/SAFplus-Mgt.git <path>
  
 +
== Building thirdparty library ==
  
2. cd <path>/3rdparty
+
root@desktop:/# cd <path>/3rdparty
make
+
root@desktop:<path>/3rdparty# make
  
3. Need to rebuild SAFplus SDK with environment variable BUILD_CPP=1
+
==Building CPP component on SAFplus Framework==
$cd <safplusdir>
+
This may be done in one of the following two ways:
$<safplusdir>/src/SAFplus/configure --with-safplus-build
+
$export BUILD_CPP=1
+
$cd build/local
+
$make
+
  
4. Launch OpenClovis IDE and Import Framework Model (i.e <path>/model)
+
===Re-building SAFplus===
 +
root@desktop:/# cd <safplusdir>
 +
root@desktop:/# mkdir -p prebuild
 +
root@desktop:/# export BUILD_CPP=1
 +
root@desktop:/# <safplusdir>/src/SAFplus/configure --with-safplus-build
 +
root@desktop:/# cd build/local
 +
root@desktop:/# make
  
5. Defined your YANG model view at <model>/src/extras/share/netconf/modules
+
===Building your model with extra configure===
In case you would like to convert YANG model to MIB model, follow the link: [[Convert YANG to MIB model]] and put your MIB model at <model>/src/extras/share/snmp/mibs
+
root@desktop:/# cd <project root>
 +
root@desktop:<project root># export BUILD_CPP=1
 +
root@desktop:<project root># <safplusdir>/src/SAFplus/configure '''--with-safplus-build''' --with-model-name=<your model name>
 +
root@desktop:<project root># cd <your model name>/build/local
 +
root@desktop:/# make
  
6. Create your object implementor that derive from ClMgtObject mainly base class
+
==Development your source code==
or ClMgtObjectContainer or ClMgtList.
+
* Using OpenClovis IDE:
 +
: File -> Import -> General -> Existing Projects into Workspace -> Next -> Locate <git checkout Framework path>/models -> Finish.
 +
:[[File:import_fw_model.png]]
  
Example:
+
===Defined your YANG model===
<code>
+
: Using vim, gedit or IDE to create your Yang model and put those models into <model>/src/extras/share/netconf/modules.
class NetworkInterface : public ClMgtObjectContainer {
+
:*In case you would like to convert YANG model to MIB model, follow instruction at the link: [[Convert YANG to MIB model]] and also put the MIB model at <model>/src/extras/share/snmp/mibs.
private:
+
  
    ClMgtIndex<string>        name;  // Interface name ex. "eth0".  This is also the index into this data.
+
===Implementation your model===
 +
:System provides a set of data modeling classes to build a flexible data model which have object-oriented relationships (containment, inheritance, association). User can implement his own C++ classes derived from the MGT base classes to match with the model defined in the input Yang file.
  
 +
:*ClMgtModule
 +
:*ClMgtObject
 +
:*ClMgtContainer
 +
:*ClMgtList
 +
:*ClMgtIndex
 +
:*ClMgtProvision
 +
:*ClMgtStatistic
 +
:*ClMgtHistoryStatistic
 +
:*ClMgtRpc
 +
:*ClMgtNotification
 +
 +
====Example====
 +
 +
class NetworkInterface : public ClMgtObjectContainer {
 +
private:
 +
    ClMgtIndex<string>        name;  // Interface name ex. "eth0".  This is also the index into this data.
 
     /*
 
     /*
 
     * "Prov" objects are "provisioned" -- that is, they are stored in the replicated database.
 
     * "Prov" objects are "provisioned" -- that is, they are stored in the replicated database.
Line 39: Line 64:
 
     ClMgtProv<ClIpAddress>  netMask;
 
     ClMgtProv<ClIpAddress>  netMask;
 
     ClMgtProv<ClIpAddress>  gateway;
 
     ClMgtProv<ClIpAddress>  gateway;
 
 
     ClMgtStat<uint64_t>      errorCount;  // Cumulative count of errors
 
     ClMgtStat<uint64_t>      errorCount;  // Cumulative count of errors
 
 
     /*
 
     /*
 
     * ClMgtHistoryStat is an in-ram statistic that returns cumulative count AND contains sub-nodes which are arrays of 10 values containing historical (starting now and extending into the past) data:
 
     * ClMgtHistoryStat is an in-ram statistic that returns cumulative count AND contains sub-nodes which are arrays of 10 values containing historical (starting now and extending into the past) data:
Line 55: Line 78:
 
     ClMgtHistoryStat<uint64_t> bytesSent;
 
     ClMgtHistoryStat<uint64_t> bytesSent;
 
     ClMgtHistoryStat<uint64_t> bytesReceived;
 
     ClMgtHistoryStat<uint64_t> bytesReceived;
public:
+
public:
 
     NetworkInterface(const char* objName);
 
     NetworkInterface(const char* objName);
 
     virtual ~NetworkInterface();
 
     virtual ~NetworkInterface();
Line 62: Line 85:
 
     void set(void *pBuffer, ClUint64T buffLen, ClTransaction& t = NO_TRANSACTION);
 
     void set(void *pBuffer, ClUint64T buffLen, ClTransaction& t = NO_TRANSACTION);
 
     string IpAddress();
 
     string IpAddress();
};
+
};
</code>
+
  
7. Declare your YANG/MIB model:
+
====Declare your YANG/MIB model:====
For YANG model:
+
:: /*
<code>
+
::  * Declare "<your model name>" module  
/* Declare "network" module */
+
::  * Should be defined at your main program or header file.
ClMgtModule         yangModule("<your yang model name>");
+
::  */
yangModule.loadModule();
+
:: ClMgtModule dataModule("<your model name>");
</code>
+
:: /*
 +
::  * Initialize the module
 +
::  */
 +
:: dataModule.loadModule();
  
For MIB model:
+
====Initialize mapping between object instance and NETCONF/SNMP model====
<code>
+
/* Declare "network" module */
+
ClMgtModule        mibModule("<your mib module name>");
+
mibModule.loadModule();
+
</code>
+
  
8. Binding your object instance into YANG or MIB model with follow command:
+
*With NETCONF
  
<code>
+
:*Create object instance:
object.bindNetconf("<your yang model name>", "<your xpath model>");
+
</code>
+
or
+
<code>
+
object.bindSnmp("<your mib module name>", "<oid instance>");
+
</code>
+
  
9. Building your model:
+
:: yourclass objectInstance("<name of node tree object intend to create the mapping>")
 +
 
 +
::'''Example''':
 +
 
 +
:: /*
 +
::  * Should be defined at your main program or header file.
 +
::  */
 +
:: NetworkInterface    netif_eth0("interfaces");
 +
 
 +
:*Initialize the mapping for object instance:
 +
 
 +
:: objectInstance.bindNetconf("<your model name>", "<your xpath model>");
 +
 
 +
::'''Example''':
 +
:: /*
 +
::  * Bind the "active" network interface to
 +
::  * a "/ethernet/interfaces" subtree within
 +
::  * the "network" module.
 +
::  */
 +
::  netif_eth0.bindNetconf("network", "/ethernet/interfaces[name='eth0']");
 +
 
 +
*With SNMP
 +
 
 +
:Replace initialize mapping command with below API
 +
 
 +
:: object.bindSnmp("<your model name>", "<oid instance>");
 +
 
 +
::'''Example''':
 +
:: /*
 +
::  * Bind the "active" network interface to
 +
::  * a "/ethernet/interfaces" subtree within
 +
::  * the "network" module.
 +
::  */
 +
::  netif_eth0.bindSnmp("network", "1.3.6.1.4.1.99840.2.1.1");
 +
 
 +
====Implementation RPC====
 +
: '''This is only valid for NETCONF'''
 +
'''TODO'''
 +
 
 +
====Implementation Notification====
 +
* Create notification instance:
 +
    ClMgtNotify notiInstance("<notification name defined in Yang file>")
 +
    Example:
 +
      ClMgtNotify        addrFailoverNotify("AddressFailover");
 +
* Add notification parameters:
 +
    notiInstance.addLeaf("<leaf name>", "<default value>")
 +
    Example:
 +
      addrFailoverNotify.addLeaf("ipAddress", netif_eth0.IpAddress());
 +
* Add notification to module:
 +
    yangModule.addMgtNotify(&notiInstance)
 +
    Example:
 +
      yangModule.addMgtNotify(&addrFailoverNotify);
 +
* Send notification:
 +
    notiInstance.sendNotification()
 +
    Example:
 +
      addrFailoverNotify.sendNotification();
 +
 
 +
==Building your model:==
 
Right click project -> Build Project
 
Right click project -> Build Project
 +
<br>
  
10. Running your model: <model image>/etc/init.d/safplus start
+
==Deploying and running your model:==
 +
===To install===
 +
:This step is helping to automatically configure port 830 and netconf-subsystem for ssh daemon and define the super user for netconf server.
  
FAQ:
+
: root@test-pc:$<model image>/install.sh
Question:  
+
 
1. Cannot connect to NETCONF.
+
===To run the model===
Answer:
+
 
If you are running your model with non-root user, port 830 cannot being listening. Your should manual running the script at <model image>/etc/init.d/customerScript.sh with root privileges and test your connect with below command:
+
: root@test-pc:$<model image>/etc/init.d/safplus start
 +
 
 +
==Testing SET/GET command:==
 +
===Mgt CLI===
 +
root@openclovis:/root/SAFplus/ctrlI0# python bin/mgtcli.py
 +
 
 +
Management info cli -- OpenClovis, Inc., 2012
 +
---------------------------------------------
 +
Starting interactive prompt (type 'help' for help)
 +
[MgtCli]==> add element --host=127.0.0.1 --name=openclovis --user=root --password=clovis
 +
Connecting to openclovis
 +
Done!
 +
 
 +
 
 +
[MgtCli]==> ls openclovis/
 +
openclovis/arp        openclovis/ethernet    openclovis/interfaces 
 +
[MgtCli]==> ls openclovis/ethernet/
 +
interfaces:          {'name': 'eth0'}
 +
interfaces:          {'name': 'eth1'}
 +
 
 +
[MgtCli]==> ls openclovis/ethernet/interfaces
 +
openclovis/ethernet/interfaces[name=eth0]:
 +
  adminStatus:        false
 +
  bytesReceived:      705477592
 +
  bytesSent:          160825231
 +
  errorCount:          0
 +
  gateway:            0.0.0.0
 +
  ipAddress:          10.20.15.37
 +
  name:                eth0
 +
  netMask:            255.255.255.0
 +
 
 +
  openclovis/ethernet/interfaces[name=eth1]:
 +
  adminStatus:        false
 +
  bytesReceived:      0
 +
  bytesSent:          0
 +
  errorCount:          0
 +
  gateway:            0.0.0.0
 +
  ipAddress:          255.127.0.0
 +
  name:                eth1
 +
  netMask:            255.127.0.0
 +
 
 +
  [MgtCli]==>
 +
 
 +
 
 +
 
 +
===NETSNMP===
 +
root@openclovis:/root/SAFplus/ctrlI0# snmpwalk -v 2c -c clovis localhost:1610 1.3.6.1.4.1.99840.1
 +
SNMPv2-SMI::enterprises.99840.1.0 = Gauge32: 0
 +
root@openclovis:/root/SAFplus/ctrlI0# snmpset -v 2c -c clovis localhost:1610 1.3.6.1.4.1.99840.1.0 u 1
 +
SNMPv2-SMI::enterprises.99840.1.0 = Gauge32: 1
 +
root@openclovis:/root/SAFplus/ctrlI0# snmpwalk -v 2c -c clovis localhost:1610 1.3.6.1.4.1.99840.1
 +
SNMPv2-SMI::enterprises.99840.1.0 = Gauge32: 1
 +
root@openclovis:/root/SAFplus/ctrlI0#
 +
 
 +
 
 +
root@openclovis:/root/SAFplus/ctrlI0# snmpwalk -v 2c -c clovis localhost:1610 1.3.6.1.4.1.99840.2.1
 +
SNMPv2-SMI::enterprises.99840.2.1.1.1.4.101.116.104.48 = INTEGER: 0
 +
SNMPv2-SMI::enterprises.99840.2.1.1.1.4.101.116.104.49 = INTEGER: 0
 +
SNMPv2-SMI::enterprises.99840.2.1.1.2.4.101.116.104.48 = Hex-STRING: 65 74 68 30 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
SNMPv2-SMI::enterprises.99840.2.1.1.2.4.101.116.104.49 = Hex-STRING: 65 74 68 31 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
SNMPv2-SMI::enterprises.99840.2.1.1.3.4.101.116.104.48 = Hex-STRING: 31 30 2E 32 30 2E 31 35 2E 33 37 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
SNMPv2-SMI::enterprises.99840.2.1.1.3.4.101.116.104.49 = Hex-STRING: 32 35 35 2E 31 32 37 2E 30 2E 30 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
SNMPv2-SMI::enterprises.99840.2.1.1.4.4.101.116.104.48 = Hex-STRING: 32 35 35 2E 32 35 35 2E 32 35 35 2E 30 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
SNMPv2-SMI::enterprises.99840.2.1.1.4.4.101.116.104.49 = Hex-STRING: 32 35 35 2E 31 32 37 2E 30 2E 30 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
SNMPv2-SMI::enterprises.99840.2.1.1.5.4.101.116.104.48 = Hex-STRING: 30 2E 30 2E 30 2E 30 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
SNMPv2-SMI::enterprises.99840.2.1.1.5.4.101.116.104.49 = Hex-STRING: 30 2E 30 2E 30 2E 30 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 +
SNMPv2-SMI::enterprises.99840.2.1.1.6.4.101.116.104.48 = Gauge32: 0
 +
SNMPv2-SMI::enterprises.99840.2.1.1.6.4.101.116.104.49 = Gauge32: 0
 +
SNMPv2-SMI::enterprises.99840.2.1.1.7.4.101.116.104.48 = Gauge32: 160719241
 +
SNMPv2-SMI::enterprises.99840.2.1.1.7.4.101.116.104.49 = Gauge32: 0
 +
SNMPv2-SMI::enterprises.99840.2.1.1.8.4.101.116.104.48 = Gauge32: 705216763
 +
SNMPv2-SMI::enterprises.99840.2.1.1.8.4.101.116.104.49 = Gauge32: 0
 +
 
 +
===YUMA CLI===
 +
:Should be exporting YUMA_HOME locate in <SAFplus run directory>/share/netconf
 +
:'''Example''':
 +
root@openclovis:/root/SAFplus/ctrlI0# export YUMA_HOME=/root/SAFplus/ctrlI0/share/netconf
 +
root@openclovis:/root/SAFplus/ctrlI0# bin/yangcli
 +
 
 +
==FAQs:==
 +
===Question: NETCONF close your connection on both yumacli or mgtcli===
 +
 
 +
===Answer:===
 +
:This may cause by your sshd deamon Subsystem is still not running normal.
 +
:'''Hint:''' Go to step installing to make sure netconf-subsystem is listening on port 830.
 +
 
 +
===Question: NETSNMP respone with timeout for snmpwalk/snmpget/snmpset command===
 +
===Answer:===
 +
: The snmp master agent is listening on port 1610 and communication string is "clovis". Those params can be defined by your at <model>/src/config/snmpd.conf.
 +
 
 +
===Question: 3rdparty build failed at libssh2: Need OpenSSL or Libgcrypt (such as Fedora or Centos)===
 +
===Answer:===
 +
root@desktop:/# sudo yum install libgcrypt-devel
  
<code>
 
#sudo sh <model image>/etc/init.d/customerScript.sh start --> to start sshd listening
 
</code>
 
or
 
<code>
 
#sudo sh <model image>/etc/init.d/customerScript.sh stop  --> to stop sshd listening
 
</code>
 
  
  
 
[[Using Management CLI]]
 
[[Using Management CLI]]
 +
 +
[[C++ generator for YANG data]]

Latest revision as of 03:42, 26 March 2013

Contents

[edit] Download Framework via github

root@desktop:/# git clone https://github.com/OpenClovis/SAFplus-Mgt.git <path>

[edit] Building thirdparty library

root@desktop:/# cd <path>/3rdparty
root@desktop:<path>/3rdparty# make

[edit] Building CPP component on SAFplus Framework

This may be done in one of the following two ways:

[edit] Re-building SAFplus

root@desktop:/# cd <safplusdir>
root@desktop:/# mkdir -p prebuild
root@desktop:/# export BUILD_CPP=1 
root@desktop:/# <safplusdir>/src/SAFplus/configure --with-safplus-build
root@desktop:/# cd build/local
root@desktop:/# make

[edit] Building your model with extra configure

root@desktop:/# cd <project root>
root@desktop:<project root># export BUILD_CPP=1 
root@desktop:<project root># <safplusdir>/src/SAFplus/configure --with-safplus-build --with-model-name=<your model name> 
root@desktop:<project root># cd <your model name>/build/local
root@desktop:/# make

[edit] Development your source code

  • Using OpenClovis IDE:
File -> Import -> General -> Existing Projects into Workspace -> Next -> Locate <git checkout Framework path>/models -> Finish.
File:Import fw model.png

[edit] Defined your YANG model

Using vim, gedit or IDE to create your Yang model and put those models into <model>/src/extras/share/netconf/modules.
  • In case you would like to convert YANG model to MIB model, follow instruction at the link: Convert YANG to MIB model and also put the MIB model at <model>/src/extras/share/snmp/mibs.

[edit] Implementation your model

System provides a set of data modeling classes to build a flexible data model which have object-oriented relationships (containment, inheritance, association). User can implement his own C++ classes derived from the MGT base classes to match with the model defined in the input Yang file.
  • ClMgtModule
  • ClMgtObject
  • ClMgtContainer
  • ClMgtList
  • ClMgtIndex
  • ClMgtProvision
  • ClMgtStatistic
  • ClMgtHistoryStatistic
  • ClMgtRpc
  • ClMgtNotification

[edit] Example

class NetworkInterface : public ClMgtObjectContainer {
private:
   ClMgtIndex<string>        name;  // Interface name ex. "eth0".  This is also the index into this data.
   /*
    * "Prov" objects are "provisioned" -- that is, they are stored in the replicated database.
    * When "bind" is called, these object will be loaded from the database's "active" configuration.
    * Once bound when the database is modified via an incoming provisioning request, these objects are notified.
    * ClMgtProv is a template that wraps provisioning functionality around any fundamental type (by fundamental I mean
    * any type that is serializable via memcpy).
    */
   ClMgtProv<bool>          adminStatus;  // Administrative status.  If you want this to be "up" set it to "true". "False" = "down"
   ClMgtProv<ClIpAddress>   ipAddress;
   ClMgtProv<ClIpAddress>   netMask;
   ClMgtProv<ClIpAddress>   gateway;
   ClMgtStat<uint64_t>      errorCount;   // Cumulative count of errors
   /*
    * ClMgtHistoryStat is an in-ram statistic that returns cumulative count AND contains sub-nodes which are arrays of 10 values containing historical (starting now and extending into the past) data:
    * 5sec: the cumulative count within second 0-5, 5-10, 10-15, ...
    * 1min:
    * 5min:
    * 1hr:
    * 1day:
    * 1week:
    * 4weeks:
    * 1year:
    */
   ClMgtHistoryStat<uint64_t> bytesSent;
   ClMgtHistoryStat<uint64_t> bytesReceived;
public:
   NetworkInterface(const char* objName);
   virtual ~NetworkInterface();
   void initialize(std::string ifName, ClMgtObject* parent);
   void get(void **ppBuffer, ClUint64T *pBuffLen);
   void set(void *pBuffer, ClUint64T buffLen, ClTransaction& t = NO_TRANSACTION);
   string IpAddress();
};

[edit] Declare your YANG/MIB model:

/*
* Declare "<your model name>" module
* Should be defined at your main program or header file.
*/
ClMgtModule dataModule("<your model name>");
/*
* Initialize the module
*/
dataModule.loadModule();

[edit] Initialize mapping between object instance and NETCONF/SNMP model

  • With NETCONF
  • Create object instance:
yourclass objectInstance("<name of node tree object intend to create the mapping>")
Example:
/*
* Should be defined at your main program or header file.
*/
NetworkInterface netif_eth0("interfaces");
  • Initialize the mapping for object instance:
objectInstance.bindNetconf("<your model name>", "<your xpath model>");
Example:
/*
* Bind the "active" network interface to
* a "/ethernet/interfaces" subtree within
* the "network" module.
*/
netif_eth0.bindNetconf("network", "/ethernet/interfaces[name='eth0']");
  • With SNMP
Replace initialize mapping command with below API
object.bindSnmp("<your model name>", "<oid instance>");
Example:
/*
* Bind the "active" network interface to
* a "/ethernet/interfaces" subtree within
* the "network" module.
*/
netif_eth0.bindSnmp("network", "1.3.6.1.4.1.99840.2.1.1");

[edit] Implementation RPC

This is only valid for NETCONF
TODO

[edit] Implementation Notification

  • Create notification instance:
   ClMgtNotify notiInstance("<notification name defined in Yang file>") 
   Example:
     ClMgtNotify         addrFailoverNotify("AddressFailover");
  • Add notification parameters:
   notiInstance.addLeaf("<leaf name>", "<default value>")
   Example:
     addrFailoverNotify.addLeaf("ipAddress", netif_eth0.IpAddress());
  • Add notification to module:
   yangModule.addMgtNotify(&notiInstance)
   Example:
     yangModule.addMgtNotify(&addrFailoverNotify);
  • Send notification:
   notiInstance.sendNotification()
   Example:
     addrFailoverNotify.sendNotification();

[edit] Building your model:

Right click project -> Build Project

[edit] Deploying and running your model:

[edit] To install

This step is helping to automatically configure port 830 and netconf-subsystem for ssh daemon and define the super user for netconf server.
root@test-pc:$<model image>/install.sh

[edit] To run the model

root@test-pc:$<model image>/etc/init.d/safplus start

[edit] Testing SET/GET command:

[edit] Mgt CLI

root@openclovis:/root/SAFplus/ctrlI0# python bin/mgtcli.py

Management info cli -- OpenClovis, Inc., 2012
---------------------------------------------
Starting interactive prompt (type 'help' for help)
[MgtCli]==> add element --host=127.0.0.1 --name=openclovis --user=root --password=clovis
Connecting to openclovis
Done!


[MgtCli]==> ls openclovis/
openclovis/arp         openclovis/ethernet    openclovis/interfaces  
[MgtCli]==> ls openclovis/ethernet/
interfaces:          {'name': 'eth0'}
interfaces:          {'name': 'eth1'}
[MgtCli]==> ls openclovis/ethernet/interfaces
openclovis/ethernet/interfaces[name=eth0]:
 adminStatus:         false
 bytesReceived:       705477592
 bytesSent:           160825231
 errorCount:          0
 gateway:             0.0.0.0
 ipAddress:           10.20.15.37
 name:                eth0
 netMask:             255.255.255.0
 
 openclovis/ethernet/interfaces[name=eth1]:
  adminStatus:         false
  bytesReceived:       0
  bytesSent:           0
  errorCount:          0
  gateway:             0.0.0.0
  ipAddress:           255.127.0.0
  name:                eth1
  netMask:             255.127.0.0
  
  [MgtCli]==> 
  


[edit] NETSNMP

root@openclovis:/root/SAFplus/ctrlI0# snmpwalk -v 2c -c clovis localhost:1610 1.3.6.1.4.1.99840.1

SNMPv2-SMI::enterprises.99840.1.0 = Gauge32: 0
root@openclovis:/root/SAFplus/ctrlI0# snmpset -v 2c -c clovis localhost:1610 1.3.6.1.4.1.99840.1.0 u 1
SNMPv2-SMI::enterprises.99840.1.0 = Gauge32: 1
root@openclovis:/root/SAFplus/ctrlI0# snmpwalk -v 2c -c clovis localhost:1610 1.3.6.1.4.1.99840.1
SNMPv2-SMI::enterprises.99840.1.0 = Gauge32: 1
root@openclovis:/root/SAFplus/ctrlI0# 


root@openclovis:/root/SAFplus/ctrlI0# snmpwalk -v 2c -c clovis localhost:1610 1.3.6.1.4.1.99840.2.1
SNMPv2-SMI::enterprises.99840.2.1.1.1.4.101.116.104.48 = INTEGER: 0
SNMPv2-SMI::enterprises.99840.2.1.1.1.4.101.116.104.49 = INTEGER: 0
SNMPv2-SMI::enterprises.99840.2.1.1.2.4.101.116.104.48 = Hex-STRING: 65 74 68 30 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
SNMPv2-SMI::enterprises.99840.2.1.1.2.4.101.116.104.49 = Hex-STRING: 65 74 68 31 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
SNMPv2-SMI::enterprises.99840.2.1.1.3.4.101.116.104.48 = Hex-STRING: 31 30 2E 32 30 2E 31 35 2E 33 37 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
SNMPv2-SMI::enterprises.99840.2.1.1.3.4.101.116.104.49 = Hex-STRING: 32 35 35 2E 31 32 37 2E 30 2E 30 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
SNMPv2-SMI::enterprises.99840.2.1.1.4.4.101.116.104.48 = Hex-STRING: 32 35 35 2E 32 35 35 2E 32 35 35 2E 30 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
SNMPv2-SMI::enterprises.99840.2.1.1.4.4.101.116.104.49 = Hex-STRING: 32 35 35 2E 31 32 37 2E 30 2E 30 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
SNMPv2-SMI::enterprises.99840.2.1.1.5.4.101.116.104.48 = Hex-STRING: 30 2E 30 2E 30 2E 30 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
SNMPv2-SMI::enterprises.99840.2.1.1.5.4.101.116.104.49 = Hex-STRING: 30 2E 30 2E 30 2E 30 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
SNMPv2-SMI::enterprises.99840.2.1.1.6.4.101.116.104.48 = Gauge32: 0
SNMPv2-SMI::enterprises.99840.2.1.1.6.4.101.116.104.49 = Gauge32: 0
SNMPv2-SMI::enterprises.99840.2.1.1.7.4.101.116.104.48 = Gauge32: 160719241
SNMPv2-SMI::enterprises.99840.2.1.1.7.4.101.116.104.49 = Gauge32: 0
SNMPv2-SMI::enterprises.99840.2.1.1.8.4.101.116.104.48 = Gauge32: 705216763
SNMPv2-SMI::enterprises.99840.2.1.1.8.4.101.116.104.49 = Gauge32: 0

[edit] YUMA CLI

Should be exporting YUMA_HOME locate in <SAFplus run directory>/share/netconf
Example:
root@openclovis:/root/SAFplus/ctrlI0# export YUMA_HOME=/root/SAFplus/ctrlI0/share/netconf
root@openclovis:/root/SAFplus/ctrlI0# bin/yangcli

[edit] FAQs:

[edit] Question: NETCONF close your connection on both yumacli or mgtcli

[edit] Answer:

This may cause by your sshd deamon Subsystem is still not running normal.
Hint: Go to step installing to make sure netconf-subsystem is listening on port 830.

[edit] Question: NETSNMP respone with timeout for snmpwalk/snmpget/snmpset command

[edit] Answer:

The snmp master agent is listening on port 1610 and communication string is "clovis". Those params can be defined by your at <model>/src/config/snmpd.conf.

[edit] Question: 3rdparty build failed at libssh2: Need OpenSSL or Libgcrypt (such as Fedora or Centos)

[edit] Answer:

root@desktop:/# sudo yum install libgcrypt-devel


Using Management CLI

C++ generator for YANG data