Hi,
The AMF PR doc has been updated, it can be found here:
https://sourceforge.net/p/opensaf/tickets/_discuss/thread/e3e3fead/bdd7/attachment/OpenSAF_AMF_PR_2585.odt
If there's no more comments on the patch and document, I hope it can be
pushed soon.
Thanks,
Minh
On 05/10/17 12:40, Gary Lee wrote:
Hi
Ack (review only)
Thanks
Gary
-----Original Message-----
From: Minh Chau <[email protected]>
Date: Thursday, 28 September 2017 at 10:54 pm
To: <[email protected]>, gary <[email protected]>,
<[email protected]>, <[email protected]>
Cc: <[email protected]>, Minh Chau <[email protected]>
Subject: [PATCH 1/1] amf: Allow SI and SI Dependency object to be deleted in
same ccb [#2585]
CCB is allowed if:
. All SIs are in CCB must be unassigned
. CCB must include all safDepend that are related to all SIs
CCB is aborted if one of above conditions is not meet
---
src/amf/amfd/si.cc | 66
++++++++++++++++++++++++++++++++++++++++++++++----
src/amf/amfd/si.h | 2 ++
src/amf/amfd/si_dep.cc | 15 +++++++++---
3 files changed, 74 insertions(+), 9 deletions(-)
diff --git a/src/amf/amfd/si.cc b/src/amf/amfd/si.cc
index 74b465314..cf026d7b8 100644
--- a/src/amf/amfd/si.cc
+++ b/src/amf/amfd/si.cc
@@ -1091,11 +1091,40 @@ static SaAisErrorT
si_ccb_completed_cb(CcbUtilOperationData_t *opdata) {
goto done;
}
/* check for any SI-SI dependency configurations */
- if (0 != si->num_dependents || si->spons_si_list != nullptr) {
- report_ccb_validation_error(
- opdata, "Sponsors or Dependents Exist; Cannot delete '%s'",
- si->name.c_str());
- goto done;
+ if (si->num_dependents != 0) {
+ if (si->is_all_dependent_si_unassigned() == false) {
+ report_ccb_validation_error(
+ opdata, "Dependent SI still has assignment; Cannot delete
'%s'",
+ si->name.c_str());
+ goto done;
+ }
+ }
+ if (si->spons_si_list != nullptr) {
+ if (si->is_all_sponsor_si_unassigned() == false) {
+ report_ccb_validation_error(
+ opdata, "Sponsor SI still has assignment; Cannot delete
'%s'",
+ si->name.c_str());
+ goto done;
+ }
+ }
+ if (si->num_dependents != 0 || si->spons_si_list != nullptr) {
+ /* loop through sidep_db
+ * if any sidep can't be found in ccbutildata, reject
+ */
+ for (const auto &value : *sidep_db) {
+ const AVD_SI_DEP *sidep = value.second;
+ if (si == sidep->spons_si || si == sidep->dep_si) {
+ SaNameT sidepDn;
+ osaf_extended_name_lend(sidep->name.c_str(), &sidepDn);
+ if (ccbutil_getCcbOpDataByDN(opdata->ccbId, &sidepDn) ==
nullptr) {
+ report_ccb_validation_error(
+ opdata, "Dependency object '%s' must be deleted in same
ccb;"
+ " Cannot delete '%s'", sidep->name.c_str(),
+ si->name.c_str());
+ goto done;
+ }
+ }
+ }
}
rc = SA_AIS_OK;
opdata->userData = si; /* Save for later use in apply */
@@ -1573,6 +1602,33 @@ bool AVD_SI::is_sirank_valid(uint32_t newSiRank)
const {
}
/*
+ * @brief Check if all sponsor SIs are unassigned
+ * @return true if all are unassigned
+ */
+bool AVD_SI::is_all_sponsor_si_unassigned() const {
+ AVD_SPONS_SI_NODE *node;
+
+ for (node = spons_si_list; node; node = node->next) {
+ if (node->si->list_of_sisu != nullptr) return false;
+ }
+ return true;
+}
+
+/*
+ * @brief Check if all dependent SIs are unassigned
+ * @return true if all are unassigned
+ */
+bool AVD_SI::is_all_dependent_si_unassigned() const {
+ std::list<AVD_SI *> depsi_list;
+ get_dependent_si_list(name, depsi_list);
+ for (std::list<AVD_SI *>::const_iterator it = depsi_list.begin();
+ it != depsi_list.end(); ++it) {
+ if ((*it)->list_of_sisu != nullptr) return false;
+ }
+ return true;
+}
+
+/*
* @brief Update saAmfSIRank by new value of @newSiRank, and update the
* the si list which is hold by the sg
* @param [in] @newSiRank: rank of si to be updated
diff --git a/src/amf/amfd/si.h b/src/amf/amfd/si.h
index af14363b6..45b37cc33 100644
--- a/src/amf/amfd/si.h
+++ b/src/amf/amfd/si.h
@@ -153,6 +153,8 @@ class AVD_SI {
bool is_active() const;
SaAisErrorT si_swap_validate();
uint32_t count_sisu_with(SaAmfHAStateT ha);
+ bool is_all_sponsor_si_unassigned() const;
+ bool is_all_dependent_si_unassigned() const;
private:
bool is_assigned() const { return list_of_sisu ? true : false; }
diff --git a/src/amf/amfd/si_dep.cc b/src/amf/amfd/si_dep.cc
index 55fcb28cb..a4ccbe7c4 100644
--- a/src/amf/amfd/si_dep.cc
+++ b/src/amf/amfd/si_dep.cc
@@ -1230,6 +1230,7 @@ static AVD_SI_DEP *sidep_new(const std::string
&sidep_name,
sidep = new AVD_SI_DEP();
avd_sidep_indx_init(sidep_name, sidep);
+ sidep->name = sidep_name;
osafassert(sidep->dep_si != nullptr);
osafassert(sidep->spons_si != nullptr);
sidep_db->insert(make_pair(sidep->spons_name, sidep->dep_name), sidep);
@@ -1376,10 +1377,16 @@ static void
sidep_ccb_apply_cb(CcbUtilOperationData_t *opdata) {
sidep_spons_list_del(sidep);
sidep_db->erase(make_pair(sidep->spons_name, sidep->dep_name));
delete sidep;
- if (avd_cb->avail_state_avd == SA_AMF_HA_ACTIVE) {
- /* Update the SI according to its existing sponsors state */
- sidep_si_screen_si_dependencies(dep_si);
- sidep_si_take_action(dep_si);
+ /* Update the dependent SI according to its existing sponsors state
+ * if this dependent SI is not in this delete ccb
+ */
+ SaNameT depSiDn;
+ osaf_extended_name_lend(dep_si->name.c_str(), &depSiDn);
+ if (ccbutil_getCcbOpDataByDN(opdata->ccbId, &depSiDn) == nullptr) {
+ if (avd_cb->avail_state_avd == SA_AMF_HA_ACTIVE) {
+ sidep_si_screen_si_dependencies(dep_si);
+ sidep_si_take_action(dep_si);
+ }
}
break;
--
2.11.0
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel