Difference between revisions of "SAFplus Management Framework"

m (Defined your YANG model view at /src/extras/share/netconf/modules)
m (Create your object implementor that derive from ClMgtObject mainly base class)
Line 34: Line 34:
 
:*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.
 
:*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.
  
==Create your object implementor that derive from ClMgtObject mainly base class==
+
===Implementation your model===
or ClMgtObjectContainer or ClMgtList.
+
:Create your C++ classes that derive from ClMgtObject base class or ClMgtObjectContainer or ClMgtList depend on your yang model.
  
Example:
+
:*ClMgtObject: TODO
<br>
+
:*ClMgtObjectContainer: TODO
<code>
+
:*ClMgtList: TODO
class NetworkInterface : public ClMgtObjectContainer {
+
<br>
+
private:
+
  
 +
====Example====
 +
 +
class NetworkInterface : public ClMgtObjectContainer {
 +
private:
 
     ClMgtIndex<string>        name;  // Interface name ex. "eth0".  This is also the index into this data.
 
     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 57: Line 57:
 
     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 73: Line 71:
 
     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 80: Line 78:
 
     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>
+
  
 
==Declare your YANG/MIB model:==
 
==Declare your YANG/MIB model:==

Revision as of 06:32, 23 January 2013

Contents

Download Framework via github

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

Building thirdparty library

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

Build CPP component on SAFplus Framework

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

Rebuild 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

Build 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

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

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.

Implementation your model

Create your C++ classes that derive from ClMgtObject base class or ClMgtObjectContainer or ClMgtList depend on your yang model.
  • ClMgtObject: TODO
  • ClMgtObjectContainer: TODO
  • ClMgtList: TODO

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();
};

Declare your YANG/MIB model:

For YANG model:

/* Declare "network" module */ ClMgtModule yangModule("<your yang model name>"); yangModule.loadModule();

For MIB model:
/* Declare "network" module */ ClMgtModule mibModule("<your mib module name>"); mibModule.loadModule();

Binding your object instance into YANG or MIB model with follow command:


object.bindNetconf("<your yang model name>", "<your xpath model>");
or
object.bindSnmp("<your mib module name>", "<oid instance>");

Building your model:

Right click project -> Build Project

Running your model:

<model image>/etc/init.d/safplus start

FAQ:

Question: Cannot connect to NETCONF

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:
  • sudo sh <model image>/etc/init.d/customerScript.sh start --> to start sshd listening

or

  • sudo sh <model image>/etc/init.d/customerScript.sh stop --> to stop sshd listening

Question: Make 3rdparty failed at libssh2: Need OpenSSL or Libgcrypt (such as Fedora or Centos)

Answer:

  • sudo yum install libgcrypt-devel


Using Management CLI