Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed export data from db to xml issue and optimize code #168

Open
wants to merge 33 commits into
base: s7
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9bbf74f
fixed export data from db to xml issue and optimize code
thienluong Sep 4, 2015
4db6631
support multi db and improve iterator
thienluong Sep 14, 2015
f3c3a0c
merge source s7
thienluong Sep 14, 2015
00d67a0
Merge branch 's7' of https://github.com/OpenClovis/SAFplus-Availabili…
thienluong Sep 14, 2015
0345baa
fix wrong oder checking
thienluong Sep 15, 2015
e2b37c2
Merge branch 's7' of github.com:thienluong/SAFplus-Availability-Scala…
thienluong Sep 18, 2015
f57e408
store xpath key only instead of store key-value
thienluong Sep 18, 2015
db95c8f
Mgt Database will handle all opened DB
thienluong Sep 21, 2015
c507204
Merge branch 's7' of github.com:thienluong/SAFplus-Availability-Scala…
thienluong Sep 30, 2015
1fb9afc
Merge remote-tracking branch 'upstream/s7' into s7
thienluong Oct 7, 2015
c8999b7
fault enums + fault management
thienluong Oct 14, 2015
8988f9c
Merge remote-tracking branch 'upstream/s7' into s7
thienluong Oct 14, 2015
6689f0b
Merge remote-tracking branch 'upstream/s7' into s7
thienluong Oct 15, 2015
9d69411
Merge remote-tracking branch 'upstream/s7' into s7
thienluong Oct 16, 2015
1c02cc8
Merge branch 's7' of github.com:thienluong/SAFplus-Availability-Scala…
thienluong Oct 21, 2015
03d4067
redefine fault enums yang and apply to fault manager
thienluong Oct 23, 2015
36d611e
remove the RFC3877 fault enums
thienluong Oct 23, 2015
a1c2ffc
merge from s7
thienluong Oct 26, 2015
ef72c89
Notifications and YANG defined RPCs in cli
thienluong Oct 30, 2015
1c7734a
merge from upstream
thienluong Nov 6, 2015
bae5251
Update cli to send notifications and show Yang defined in RPCs
thienluong Nov 6, 2015
497f855
delete FaultState
thienluong Nov 6, 2015
925d5ea
optimize send fault notifications
thienluong Nov 18, 2015
ccfdcec
Merge remote-tracking branch 'upstream/s7' into s7
thienluong Nov 19, 2015
e641c73
Merge remote-tracking branch 'upstream/s7' into s7
thienluong Jan 6, 2016
27aaf71
revert
thienluong Jan 6, 2016
bfa8b7c
Add history command and move rpc & notification commands to netconfac…
thienluong Jan 6, 2016
ac92660
remove some stuff
thienluong Jan 14, 2016
e9328af
Work around to send rpc reset to myService app
thienluong Jan 22, 2016
fab4c92
update Rpc hanlder & add Rpc message handler
thienluong Jan 28, 2016
97afdf2
merge cli.py
thienluong Jan 28, 2016
2b294dc
fix clMgtNotify and add MGT_MSG_NOT_TYPE for notification message han…
thienluong Feb 19, 2016
8292b1f
merge from s7
thienluong Feb 19, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
599 changes: 599 additions & 0 deletions examples/eval/mgt/main.cxx

Large diffs are not rendered by default.

111 changes: 111 additions & 0 deletions examples/eval/mgt/myService.yang
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
module myService
{
namespace "http://www.myCompany.com/ns/myService";
prefix "myService";
import SAFplusTypes { prefix "SAFplusTypes"; }

// Let's make a structure to track the subscribers to our fictious service:
list subscribers
{
key "name";
description "This list defines who can use this service";

leaf name
{
type string;
}
leaf active
{
type boolean;
description "True means this subscriber is in good standing, False means service is off";
default true;
}

leaf level
{
type enumeration
{
enum copper
{
value 0;
}
enum silver
{
value 1;
}
enum gold
{
value 2;
}
}
}

leaf limit
{
description "How much of the service this subscriber can use";
type int64;
default 10000;
}

leaf use
{
description "How much of the service this subscriber has used";
type int64;
//config false; // This would normally not be config but we want to be able to reset this for the sake of the demo
}
}

container serviceCfg
{
leaf port
{
description "What TCP port to listen on";
type uint16;
default 8080;
}
leaf homeLocation
{
description "What directory on the server contains the pages";
type string;
default "/srv/web";
}
}

container serviceStats
{
description "Statistics on the use of this service";
container accessCounts
{
description "How much is the service being used";
SAFplusTypes:c-existing "SAFplus::MgtHistoryStat<int>";
uses SAFplusTypes:intStatistic;
config false;
}
container bytesTransmitted
{
description "How many bytes are transmitted by the service";
SAFplusTypes:c-existing "SAFplus::MgtHistoryStat<int>";
uses SAFplusTypes:intStatistic;
config false;
}
}

rpc reset
{
description "Apply the setting changes. If no parameters are specified the current setting are applied, otherwise the passed parameters are applied and the data model is updated with these parameters";
input
{
leaf path
{
description "Location of the 'root' directory of the web server";
type string;
}
leaf port
{
description "The TCP port this web server should listen on (default is 80)";
type uint16;
}
}
}

}
46 changes: 46 additions & 0 deletions examples/eval/mgt/myService/MyServiceModule.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* File MyServiceModule.hxx
* This file has been auto-generated by Y2CPP, the
* plug-in of pyang.
*/

#pragma once
#ifndef MYSERVICEMODULE_HXX_
#define MYSERVICEMODULE_HXX_

#include "ServiceCfg.hxx"
#include "ServiceStats.hxx"
#include "reset.hxx"
#include "MgtFactory.hxx"
#include "clMgtModule.hxx"
#include "myServiceCommon.hxx"
#include "clMgtList.hxx"
#include <vector>

namespace myService
{

class MyServiceModule : public SAFplus::MgtModule {

/* Apply MGT object factory */
MGT_REGISTER(MyServiceModule);

public:
::myService::ServiceCfg serviceCfg;
::myService::ServiceStats serviceStats;
::myService::reset reset;

/*
* This list defines who can use this service
*/
SAFplus::MgtList<std::string> subscribersList;

public:
MyServiceModule();
std::vector<std::string>* getChildNames();
~MyServiceModule();

};
}
/* namespace ::myService */
#endif /* MYSERVICEMODULE_HXX_ */
138 changes: 138 additions & 0 deletions examples/eval/mgt/myService/reset.cxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
/*
* File reset.cxx
* This file has been auto-generated by Y2CPP, the
* plug-in of pyang.
*/

#include "MgtFactory.hxx"
#include "clMgtProv.hxx"
#include "clMgtContainer.hxx"
#include "clMgtRpc.hxx"
#include "clTransaction.hxx"
#include <string>
#include <boost/algorithm/string.hpp>
#include "myServiceCommon.hxx"
#include "MyServiceModule.hxx"
#include <cstdint>
#include <vector>
#include "reset.hxx"

extern void startHttpDaemon(int port);
extern void stopHttpDaemon(int port);
extern myService::MyServiceModule mgt;

namespace SAFplus
{
extern Handle myHandle;
};

namespace myService
{

/* Apply MGT object factory */
MGT_REGISTER_IMPL(reset, /myService/reset)

reset::reset(): SAFplus::MgtRpc("reset"), port("port"), homeLocation("homeLocation")
{
this->addChildObject(&port, "port");
this->addChildObject(&homeLocation, "homeLocation");
};

std::vector<std::string>* reset::getChildNames()
{
std::string childNames[] = { "port", "homeLocation" };
return new std::vector<std::string> (childNames, childNames + sizeof(childNames) / sizeof(childNames[0]));
};

/*
* XPATH: /myService/serviceCfg/port
*/
::uint16_t reset::getPort()
{
return this->port.value;
};

/*
* XPATH: /myService/serviceCfg/port
*/
void reset::setPort(::uint16_t portValue, SAFplus::Transaction &txn)
{
this->port.set(portValue,txn);
};

/*
* XPATH: /myService/serviceCfg/homeLocation
*/
std::string reset::getHomeLocation()
{
return this->homeLocation.value;
};

/*
* XPATH: /myService/serviceCfg/homeLocation
*/
void reset::setHomeLocation(std::string homeLocationValue, SAFplus::Transaction &txn)
{
this->homeLocation.set(homeLocationValue,txn);
};

ClRcT reset::validate(const std::string &attrs)
{
logInfo("APP","Reset","Validate the data !!!!", attrs.c_str());
return CL_OK;
}

ClRcT reset::invoke(const std::string &attrs)
{
logInfo("APP","Reset","invoke %s", attrs.c_str());
std::vector<std::string> strs;
boost::split(strs, attrs, boost::is_any_of(","));
//reset with the set port
if (strs.size() <= 0)
{
uint16_t new_port = mgt.serviceCfg.getPort();
uint16_t listening_port = getPort();
if (new_port != listening_port)
{
stopHttpDaemon(listening_port);
startHttpDaemon(new_port);
setPort(new_port);
}
}
else
{
for (auto attr : strs)
{
std::vector<std::string> s;
boost::split(s, attr, boost::is_any_of("="));
std::string key = s[0];
std::string value = s[1];

if (key == "port")
{
uint16_t new_port = atoi(value.c_str());
if (new_port && new_port != getPort())
{
stopHttpDaemon(getPort());
startHttpDaemon(new_port);
setPort(new_port);
mgt.serviceCfg.setPort(new_port);
}
}
}
}
return CL_OK;
}

ClRcT reset::postReply(const std::string &attrs)
{
logInfo("APP","Reset","post Reply %s", attrs.c_str());
return CL_OK;
}

reset::~reset()
{
};

}
/* namespace ::reset */
67 changes: 67 additions & 0 deletions examples/eval/mgt/myService/reset.hxx
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#pragma once
#ifndef RESET_HXX_
#define RESET_HXX_

#include "MgtFactory.hxx"
#include "clMgtProv.hxx"
#include "clMgtRpc.hxx"
#include "clTransaction.hxx"
#include <string>
#include "myServiceCommon.hxx"
#include <cstdint>
#include <vector>

namespace myService
{

class reset : public SAFplus::MgtRpc {

/* Apply MGT object factory */
MGT_REGISTER(reset);

public:

/*
* What TCP port to listen on
*/
SAFplus::MgtProv<::uint16_t> port;

/*
* What directory on the server contains the pages
*/
SAFplus::MgtProv<std::string> homeLocation;

public:
reset();
std::vector<std::string>* getChildNames();

/*
* XPATH: /myService/serviceCfg/port
*/
::uint16_t getPort();

/*
* XPATH: /myService/reset/port
*/
void setPort(::uint16_t portValue, SAFplus::Transaction &txn=SAFplus::NO_TXN);

/*
* XPATH: /myService/reset/homeLocation
*/
std::string getHomeLocation();

/*
* XPATH: /myService/reset/homeLocation
*/
void setHomeLocation(std::string homeLocationValue, SAFplus::Transaction &txn=SAFplus::NO_TXN);

virtual ClRcT validate(const std::string &attrs = "");
virtual ClRcT invoke(const std::string &attrs = "");
virtual ClRcT postReply(const std::string &attrs = "");

~reset();

};
}
/* namespace ::reset */
#endif /* RESET_HXX_ */
2 changes: 1 addition & 1 deletion src/amf/server/nPlusmAmfPolicy.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ namespace SAFplus
{
Handle compHdl = ::name.getHandle(comp->name);
// Actually it throws NameException: assert(compHdl != INVALID_HDL); // AMF MUST register this component before it does anything else with it so the name must exist.
fault->notify(compHdl,FaultEventData(AlarmState::ALARM_STATE_ASSERT,AlarmCategory::ALARM_CATEGORY_PROCESSING_ERROR,AlarmSeverity::ALARM_SEVERITY_MAJOR, AlarmProbableCause::ALARM_PROB_CAUSE_SOFTWARE_ERROR));
fault->notify(compHdl,FaultEventData(FaultEnums::FaultAlarmState::ALARM_STATE_ASSERT, FaultEnums::AlarmCategory::ALARM_CATEGORY_PROCESSING_ERROR, FaultEnums::FaultSeverity::ALARM_SEVERITY_MAJOR, FaultEnums::FaultProbableCause::ALARM_PROB_CAUSE_SOFTWARE_ERROR));
// TODO: it may be better to have the AMF react to fault manager's notification instead of doing it preemptively here
}
catch(NameException& ne)
Expand Down
Loading