Difference between revisions of "SAFplus Management Framework"

(Created page with "1. Git clone: git clone https://github.com/OpenClovis/SAFplus-Mgt.git <path> 2. cd <path>/3rdparty make 3. ./configure model 4. .make 5. make image 6. option - create ya...")
 
Line 6: Line 6:
 
make
 
make
  
3. ./configure model
+
3. Need to rebuild SAFplus SDK with environment variable BUILD_CPP=1
 +
$cd <safplusdir>
 +
$<safplusdir>/src/SAFplus/configure --with-safplus-build
 +
$export BUILD_CPP=1
 +
$cd build/local
 +
$make
  
4. .make
+
4. Launch OpenClovis IDE and Import Framework Model (i.e <path>/model)
  
5. make image
+
5. Defined your YANG model view at <model>/src/extras/share/netconf/modules
 +
(In case you would like to convert YANG model to MIB model, follow the link: [[Convert_YANG_TO_MIB]] and put your MIB model at <model>/src/extras/share/snmp/mibs
  
6. option - create yang model - convert to mib
+
6. Create your object implementor that derive from ClMgtObject mainly base class
 +
or ClMgtObjectContainer or ClMgtList.
  
7. running mgtcli
+
Example:
 +
<code>
 +
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();
 +
};
 +
</code>
 +
 
 +
7. Declare your YANG/MIB model:
 +
For YANG model:
 +
<code>
 +
/* Declare "network" module */
 +
ClMgtModule        yangModule("<your yang model name>");
 +
yangModule.loadModule();
 +
</code>
 +
 
 +
For MIB 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:
 +
 
 +
<code>
 +
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:
 +
Right click project -> Build Project
 +
 
 +
10. Running your model: <model image>/etc/init.d/safplus start
 +
 
 +
FAQ:
 +
Question:
 +
1. 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 prilivige 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

Revision as of 07:17, 21 January 2013

1. Git clone: git clone https://github.com/OpenClovis/SAFplus-Mgt.git <path>


2. cd <path>/3rdparty make

3. Need to rebuild SAFplus SDK with environment variable BUILD_CPP=1 $cd <safplusdir> $<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)

5. Defined your YANG model view at <model>/src/extras/share/netconf/modules (In case you would like to convert YANG model to MIB model, follow the link: Convert_YANG_TO_MIB and put your MIB model at <model>/src/extras/share/snmp/mibs

6. Create your object implementor that derive from ClMgtObject mainly base class or ClMgtObjectContainer or ClMgtList.

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

};

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

8. 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>");

9. Building your model: Right click project -> Build Project

10. Running your model: <model image>/etc/init.d/safplus start

FAQ: Question: 1. 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 prilivige and test your connect with below command:

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

or

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