Re: [devel] [PATCH 1/1] smf: Increase cbk count before post the evt to client [#2882]

2018-07-16 Thread Nguyen Luu

Hi Thuan,

Ack from me.

Just a suggestion for more correct comment (in case there's only one 
handle matching the callback label):


/* Descrease the cbk count */ => /* Remove the agent hdl from the cbk_list */

Thanks,
Nguyen

On 7/13/2018 10:52 AM, thuan.tran wrote:

Sometimes, callback agent dispatch and fail at saSmfReponse()
because cbk list is empty, agent by somehow handle evt before increase
cbk count. To avoid this, increase cbk count before post the evt.
---
  src/smf/agent/smfa_utils.c | 40 +-
  1 file changed, 22 insertions(+), 18 deletions(-)

diff --git a/src/smf/agent/smfa_utils.c b/src/smf/agent/smfa_utils.c
index fb31a9ae1..3436785cd 100644
--- a/src/smf/agent/smfa_utils.c
+++ b/src/smf/agent/smfa_utils.c
@@ -615,8 +615,8 @@ SMFA_CBK_HDL_LIST *smfa_inv_hdl_add(SaInvocationT inv_id, 
SaSmfHandleT hdl)
  }
  
  /***

-@brief : Match the filter. If matches, post the evt to the client MBX
- and increment the cbk count of the the corresponding hdl node.
+@brief : Match the filter. If matches, increment the cbk count of
+ the corresponding hdl node and post the evt to the client MBX.
  If for a client, more than one scope matches, then those many
  no of evts are posted to the MBX.
  @param[in]: client_info - For which filter match to be performed.
@@ -694,27 +694,31 @@ uint32_t smfa_cbk_filter_match(SMFA_CLIENT_INFO 
*client_info,
_evt->object_name),
>evt.cbk_evt.object_name);
  
-if (m_NCS_IPC_SEND(_info->cbk_mbx,

-  (NCSCONTEXT)evt,
-  NCS_IPC_PRIORITY_NORMAL)) {
-   /* Increment the cbk count.*/
-   if (NULL != hdl_list) {
-   /* There are two scope id
-* matching for the same hdl.*/
-   } else {
-   /* First scope id matching for
-* this hdl.*/
-   hdl_list = smfa_inv_hdl_add(
-   cbk_evt->inv_id,
-   client_info->client_hdl);
-   }
-   hdl_list->cnt++;
-   rc = NCSCC_RC_SUCCESS;
+   /* Increment the cbk count.*/
+   if (NULL != hdl_list) {
+   /* There are two scope id
+* matching for the same hdl.*/
} else {
+   /* First scope id matching for
+* this hdl.*/
+   hdl_list = smfa_inv_hdl_add(
+   cbk_evt->inv_id,
+   client_info->client_hdl);
+   }
+   hdl_list->cnt++;
+   rc = m_NCS_IPC_SEND(
+   _info->cbk_mbx,
+   (NCSCONTEXT)evt,
+   NCS_IPC_PRIORITY_NORMAL);
+   if (rc != NCSCC_RC_SUCCESS) {
LOG_ER(
"SMFA: Posting to MBX failed. hdl: %llu, 
scoe_id: %u",
client_info->client_hdl,
cbk_evt->scope_id);
+   /* Descrease the cbk count */
+   smfa_cbk_ok_resp_process(
+   client_info->client_hdl,
+   cbk_evt->inv_id);
}
  
  /* If one of the filter matches then go to the



--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


Re: [devel] [PATCH 1/1] smf: use cb_lock to sync cbk count access between threads [#2882]

2018-07-11 Thread Nguyen Luu

Hi Thuan,

I also agree with Gary about removing assert(). Other changes look fine.

Thanks,
Nguyen

On 7/11/2018 12:52 PM, Gary Lee wrote:

Hi Thuan

Looks OK to me, but I would remove the assert. We shouldn't do that in library 
code.

Thanks
Gary

On 10/7/18, 6:52 pm, "thuan.tran"  wrote:

 Sometimes, callback agent dispatch and fail at saSmfReponse()
 because cbk list is empty, agent by somehow handle evt before increase
 cbk count. To avoid this, use cb_lock to sync cbk count acess between 
threads.
 ---
  src/smf/agent/smfa_mds.c   | 7 ++-
  src/smf/agent/smfa_utils.c | 1 +
  2 files changed, 7 insertions(+), 1 deletion(-)
 
 diff --git a/src/smf/agent/smfa_mds.c b/src/smf/agent/smfa_mds.c

 index 3d288b5eb..ededbaa55 100644
 --- a/src/smf/agent/smfa_mds.c
 +++ b/src/smf/agent/smfa_mds.c
 @@ -243,7 +243,11 @@ uint32_t smfa_mds_rcv_cbk(MDS_CALLBACK_RECEIVE_INFO 
*rcv_evt)
return NCSCC_RC_SUCCESS;
}
  
 -	/* TODO: I need to take READ LOCK here. But in MDS thread ???*/

 +  if (m_NCS_LOCK(>cb_lock, NCS_LOCK_WRITE) != NCSCC_RC_SUCCESS) {
 +  LOG_ER("SMFA: Cb lock acquire FAILED.");
 +  TRACE_LEAVE();
 +  return NCSCC_RC_FAILURE;
 +  }
client_info = cb->smfa_client_info_list;
while (NULL != client_info) {
/* If filter matches, post the evt to the corresponding MBX.*/
 @@ -252,6 +256,7 @@ uint32_t smfa_mds_rcv_cbk(MDS_CALLBACK_RECEIVE_INFO 
*rcv_evt)
filter_match = true;
client_info = client_info->next_client;
}
 +  m_NCS_UNLOCK(>cb_lock, NCS_LOCK_WRITE);
  
  	/* If filters dont match, respond to ND as SA_AIS_OK*/

if (false == filter_match) {
 diff --git a/src/smf/agent/smfa_utils.c b/src/smf/agent/smfa_utils.c
 index fb31a9ae1..b250e9bc2 100644
 --- a/src/smf/agent/smfa_utils.c
 +++ b/src/smf/agent/smfa_utils.c
 @@ -715,6 +715,7 @@ uint32_t smfa_cbk_filter_match(SMFA_CLIENT_INFO 
*client_info,
"SMFA: Posting to MBX failed. hdl: %llu, 
scoe_id: %u",
client_info->client_hdl,
cbk_evt->scope_id);
 +  osafassert(0);
}
  
  /* If one of the filter matches then go to the

 --
 2.18.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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


Re: [devel] [PATCH 1/1] smf: Increase cbk count before post the evt to client [#2882]

2018-07-09 Thread Nguyen Luu

Hi,

You are right about the behavior according to SMF spec. I misinterpreted 
the code.
I have no further comments regarding assert(). You can wait for comments 
from Lennart and Gary.


Thanks,
Nguyen

On 7/9/2018 8:43 AM, Tran Thuan wrote:

Hi Nguyen,

SMF spec describe:
"Also, if a registered process fails to respond within the time limit specified 
for the callback in the campaign
specification, this timeout does not cause the upgrade step or the upgrade 
campaign
to fail. This approach was taken because the upgrade-awareness is not a basic
requirement for software upgrades"

In this situation, posting event fail mean callback is not triggered execution,
but don't assert() then SMFND treat it as non-response callback after timeout
and continue upgrade, it will cause more trouble, I think.

@Lennart, Gary: do you have any idea? Should assert() or not?

Best Regards,
Thuan (UFO – Unique FBI Opensaf)
CoreMW Maintenance, DEK VietNam

-Original Message-----
From: Nguyen Luu 
Sent: Friday, July 6, 2018 5:34 PM
To: Tran Thuan ; lennart.l...@ericsson.com; 'Gary Lee' 

Cc: opensaf-devel@lists.sourceforge.net
Subject: Re: [devel] [PATCH 1/1] smf: Increase cbk count before post the evt to 
client [#2882]

Hi,

A failed calloc() breaks the main flow and intended purpose of the function, 
and perhaps the original author saw no better way to gracefully handle and 
signify the failure except to assert. In our case, the failure can be 
gracefully handled and signified as a failed campaign. Again, it's just a 
matter of opinion whether to use assert. In case SMF is not told in the 
campaign to wait for callback response from the client, why crashing the client 
if it misses a callback whose response is not important to the upgrade progress?

I guess the agent you mentioned is the cbk_util thread of SMFD. If it crashes, 
no rollback will be triggered, and the campaign will fail.

Thanks,
Nguyen

On 7/6/2018 3:04 PM, Tran Thuan wrote:

Hi Nguyen,

In that function, some osafassert(0) is used when fail calloc(), why don't just 
ignore as your idea?
Just wonder one point:
Agent is a thread of SMFD, it crash mean SMFD crash (node reboot?), is there 
any rollback trigger after that?
If it cannot, then I should handle posting fail as your comment.

Best Regards,
Thuan

-Original Message-----
From: Nguyen Luu 
Sent: Thursday, July 5, 2018 8:00 PM
To: Tran Thuan ; lennart.l...@ericsson.com;
Gary Lee 
Cc: opensaf-devel@lists.sourceforge.net
Subject: Re: [devel] [PATCH 1/1] smf: Increase cbk count before post
the evt to client [#2882]

Hi Thuan,

I think it's not a good idea and also not that critical to crash the SMF client 
just because of the agent failing to send a callback message. It also depends 
on whether the client expects SMF to wait for its response on callback in order 
to proceed with the upgrade or not, which behavior is specified by the callback 
timeout value in the campaign file.

With the current handling, SMF will not wait for the client response on 
callback if the timeout is '0', and will just continue executing the campaign; 
otherwise it will wait for as long as the specified timeout and will fail the 
campaign if not receiving the callback response within that period. A failed 
campaign and an error message in the log should be good enough for SMF to 
communicate the failure in this situation. It's not that severe to call abort() 
and generate core dump in this case.

Perhaps Lennart and Gary can have further comments/ideas on this solution.

Thanks,
Nguyen

On 7/5/2018 4:11 PM, Tran Thuan wrote:

Hi Nguyen,

Thanks for your comments. I agree with general comment.
About the patch (new flow), when posting to the client mailbox fail, 
osafassert(0) is called.
I think the posting fail is critical problem since agent will miss a callback.
Also avoid smfnd is keeping waiting for agent response for that callback.
Please correct if I was wrong.

Best Regards,
Thuan (UFO – Unique FBI Opensaf)
CoreMW Maintenance, DEK VietNam

-Original Message-----
From: Nguyen Luu 
Sent: Wednesday, July 4, 2018 5:08 PM
To: thuan.tran ; lennart.l...@ericsson.com
Cc: opensaf-devel@lists.sourceforge.net
Subject: Re: [devel] [PATCH 1/1] smf: Increase cbk count before post
the evt to client [#2882]

Hi,

One comment from me for the patch: With the new flow, the matched hdl should be 
removed from the cbk_list if posting the message to the client mailbox fails.

A general comment: The original issue happened because of a race condition in 
which the smfa_cb was used in different threads without proper use of mutex. 
This patch may solve the issue, but the agent code should be improved to use 
the mutex better, to avoid any other hidden race conditions. Perhaps a future 
enhancement.

Thanks,
Nguyen

On 6/26/2018 11:32 AM, thuan.tran wrote:

Sometimes, callback agent dispatch and fail at saSmfReponse()
because cbk list is empty, agent by somehow handle evt before
increase cbk count. To avoid this, increase

Re: [devel] [PATCH 1/1] smf: Increase cbk count before post the evt to client [#2882]

2018-07-06 Thread Nguyen Luu

Hi,

A failed calloc() breaks the main flow and intended purpose of the 
function, and perhaps the original author saw no better way to 
gracefully handle and signify the failure except to assert. In our case, 
the failure can be gracefully handled and signified as a failed 
campaign. Again, it's just a matter of opinion whether to use assert. In 
case SMF is not told in the campaign to wait for callback response from 
the client, why crashing the client if it misses a callback whose 
response is not important to the upgrade progress?


I guess the agent you mentioned is the cbk_util thread of SMFD. If it 
crashes, no rollback will be triggered, and the campaign will fail.


Thanks,
Nguyen

On 7/6/2018 3:04 PM, Tran Thuan wrote:

Hi Nguyen,

In that function, some osafassert(0) is used when fail calloc(), why don't just 
ignore as your idea?
Just wonder one point:
Agent is a thread of SMFD, it crash mean SMFD crash (node reboot?), is there 
any rollback trigger after that?
If it cannot, then I should handle posting fail as your comment.

Best Regards,
Thuan

-Original Message-
From: Nguyen Luu 
Sent: Thursday, July 5, 2018 8:00 PM
To: Tran Thuan ; lennart.l...@ericsson.com; Gary Lee 

Cc: opensaf-devel@lists.sourceforge.net
Subject: Re: [devel] [PATCH 1/1] smf: Increase cbk count before post the evt to 
client [#2882]

Hi Thuan,

I think it's not a good idea and also not that critical to crash the SMF client 
just because of the agent failing to send a callback message. It also depends 
on whether the client expects SMF to wait for its response on callback in order 
to proceed with the upgrade or not, which behavior is specified by the callback 
timeout value in the campaign file.

With the current handling, SMF will not wait for the client response on 
callback if the timeout is '0', and will just continue executing the campaign; 
otherwise it will wait for as long as the specified timeout and will fail the 
campaign if not receiving the callback response within that period. A failed 
campaign and an error message in the log should be good enough for SMF to 
communicate the failure in this situation. It's not that severe to call abort() 
and generate core dump in this case.

Perhaps Lennart and Gary can have further comments/ideas on this solution.

Thanks,
Nguyen

On 7/5/2018 4:11 PM, Tran Thuan wrote:

Hi Nguyen,

Thanks for your comments. I agree with general comment.
About the patch (new flow), when posting to the client mailbox fail, 
osafassert(0) is called.
I think the posting fail is critical problem since agent will miss a callback.
Also avoid smfnd is keeping waiting for agent response for that callback.
Please correct if I was wrong.

Best Regards,
Thuan (UFO – Unique FBI Opensaf)
CoreMW Maintenance, DEK VietNam

-Original Message-
From: Nguyen Luu 
Sent: Wednesday, July 4, 2018 5:08 PM
To: thuan.tran ; lennart.l...@ericsson.com
Cc: opensaf-devel@lists.sourceforge.net
Subject: Re: [devel] [PATCH 1/1] smf: Increase cbk count before post
the evt to client [#2882]

Hi,

One comment from me for the patch: With the new flow, the matched hdl should be 
removed from the cbk_list if posting the message to the client mailbox fails.

A general comment: The original issue happened because of a race condition in 
which the smfa_cb was used in different threads without proper use of mutex. 
This patch may solve the issue, but the agent code should be improved to use 
the mutex better, to avoid any other hidden race conditions. Perhaps a future 
enhancement.

Thanks,
Nguyen

On 6/26/2018 11:32 AM, thuan.tran wrote:

Sometimes, callback agent dispatch and fail at saSmfReponse() because
cbk list is empty, agent by somehow handle evt before increase cbk
count. To avoid this, increase cbk count before post the evt.
---
src/smf/agent/smfa_utils.c | 38 --
1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/src/smf/agent/smfa_utils.c b/src/smf/agent/smfa_utils.c
index fb31a9a..917b6b8 100644
--- a/src/smf/agent/smfa_utils.c
+++ b/src/smf/agent/smfa_utils.c
@@ -615,8 +615,8 @@ SMFA_CBK_HDL_LIST *smfa_inv_hdl_add(SaInvocationT inv_id, 
SaSmfHandleT hdl)
}

/***

-@brief : Match the filter. If matches, post the evt to the client MBX
- and increment the cbk count of the the corresponding hdl node.
+@brief : Match the filter. If matches, increment the cbk count of
+ the corresponding hdl node and post the evt to the client MBX.
  If for a client, more than one scope matches, then those many
  no of evts are posted to the MBX.
@param[in]  : client_info - For which filter match to be performed.
@@ -694,27 +694,29 @@ uint32_t smfa_cbk_filter_match(SMFA_CLIENT_INFO 
*client_info,
_evt->object_n

Re: [devel] [PATCH 1/1] smf: Increase cbk count before post the evt to client [#2882]

2018-07-05 Thread Nguyen Luu

Hi Thuan,

I think it's not a good idea and also not that critical to crash the SMF 
client just because of the agent failing to send a callback message. It 
also depends on whether the client expects SMF to wait for its response 
on callback in order to proceed with the upgrade or not, which behavior 
is specified by the callback timeout value in the campaign file.


With the current handling, SMF will not wait for the client response on 
callback if the timeout is '0', and will just continue executing the 
campaign; otherwise it will wait for as long as the specified timeout 
and will fail the campaign if not receiving the callback response within 
that period. A failed campaign and an error message in the log should be 
good enough for SMF to communicate the failure in this situation. It's 
not that severe to call abort() and generate core dump in this case.


Perhaps Lennart and Gary can have further comments/ideas on this solution.

Thanks,
Nguyen

On 7/5/2018 4:11 PM, Tran Thuan wrote:

Hi Nguyen,

Thanks for your comments. I agree with general comment.
About the patch (new flow), when posting to the client mailbox fail, 
osafassert(0) is called.
I think the posting fail is critical problem since agent will miss a callback.
Also avoid smfnd is keeping waiting for agent response for that callback.
Please correct if I was wrong.

Best Regards,
Thuan (UFO – Unique FBI Opensaf)
CoreMW Maintenance, DEK VietNam

-Original Message-
From: Nguyen Luu 
Sent: Wednesday, July 4, 2018 5:08 PM
To: thuan.tran ; lennart.l...@ericsson.com
Cc: opensaf-devel@lists.sourceforge.net
Subject: Re: [devel] [PATCH 1/1] smf: Increase cbk count before post the evt to 
client [#2882]

Hi,

One comment from me for the patch: With the new flow, the matched hdl should be 
removed from the cbk_list if posting the message to the client mailbox fails.

A general comment: The original issue happened because of a race condition in 
which the smfa_cb was used in different threads without proper use of mutex. 
This patch may solve the issue, but the agent code should be improved to use 
the mutex better, to avoid any other hidden race conditions. Perhaps a future 
enhancement.

Thanks,
Nguyen

On 6/26/2018 11:32 AM, thuan.tran wrote:

Sometimes, callback agent dispatch and fail at saSmfReponse() because
cbk list is empty, agent by somehow handle evt before increase cbk
count. To avoid this, increase cbk count before post the evt.
---
   src/smf/agent/smfa_utils.c | 38 --
   1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/src/smf/agent/smfa_utils.c b/src/smf/agent/smfa_utils.c
index fb31a9a..917b6b8 100644
--- a/src/smf/agent/smfa_utils.c
+++ b/src/smf/agent/smfa_utils.c
@@ -615,8 +615,8 @@ SMFA_CBK_HDL_LIST *smfa_inv_hdl_add(SaInvocationT inv_id, 
SaSmfHandleT hdl)
   }
   
   /***

-@brief : Match the filter. If matches, post the evt to the client MBX
- and increment the cbk count of the the corresponding hdl node.
+@brief : Match the filter. If matches, increment the cbk count of
+ the corresponding hdl node and post the evt to the client MBX.
  If for a client, more than one scope matches, then those many
  no of evts are posted to the MBX.
   @param[in]   : client_info - For which filter match to be performed.
@@ -694,27 +694,29 @@ uint32_t smfa_cbk_filter_match(SMFA_CLIENT_INFO 
*client_info,
_evt->object_name),
>evt.cbk_evt.object_name);
   
-if (m_NCS_IPC_SEND(_info->cbk_mbx,

-  (NCSCONTEXT)evt,
-  NCS_IPC_PRIORITY_NORMAL)) {
-   /* Increment the cbk count.*/
-   if (NULL != hdl_list) {
-   /* There are two scope id
-* matching for the same hdl.*/
-   } else {
-   /* First scope id matching for
-* this hdl.*/
-   hdl_list = smfa_inv_hdl_add(
-   cbk_evt->inv_id,
-   client_info->client_hdl);
-   }
-   hdl_list->cnt++;
-   rc = NCSCC_RC_SUCCESS;
+   /* Increment the cbk count.*/
+   if (NULL != hdl_list) {
+   /* There are two scope id
+* matchin

Re: [devel] [PATCH 1/1] smf: Increase cbk count before post the evt to client [#2882]

2018-07-04 Thread Nguyen Luu

Hi,

One comment from me for the patch: With the new flow, the matched hdl 
should be removed from the cbk_list if posting the message to the client 
mailbox fails.


A general comment: The original issue happened because of a race 
condition in which the smfa_cb was used in different threads without 
proper use of mutex. This patch may solve the issue, but the agent code 
should be improved to use the mutex better, to avoid any other hidden 
race conditions. Perhaps a future enhancement.


Thanks,
Nguyen

On 6/26/2018 11:32 AM, thuan.tran wrote:

Sometimes, callback agent dispatch and fail at saSmfReponse()
because cbk list is empty, agent by somehow handle evt before increase
cbk count. To avoid this, increase cbk count before post the evt.
---
  src/smf/agent/smfa_utils.c | 38 --
  1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/src/smf/agent/smfa_utils.c b/src/smf/agent/smfa_utils.c
index fb31a9a..917b6b8 100644
--- a/src/smf/agent/smfa_utils.c
+++ b/src/smf/agent/smfa_utils.c
@@ -615,8 +615,8 @@ SMFA_CBK_HDL_LIST *smfa_inv_hdl_add(SaInvocationT inv_id, 
SaSmfHandleT hdl)
  }
  
  /***

-@brief : Match the filter. If matches, post the evt to the client MBX
- and increment the cbk count of the the corresponding hdl node.
+@brief : Match the filter. If matches, increment the cbk count of
+ the corresponding hdl node and post the evt to the client MBX.
  If for a client, more than one scope matches, then those many
  no of evts are posted to the MBX.
  @param[in]: client_info - For which filter match to be performed.
@@ -694,27 +694,29 @@ uint32_t smfa_cbk_filter_match(SMFA_CLIENT_INFO 
*client_info,
_evt->object_name),
>evt.cbk_evt.object_name);
  
-if (m_NCS_IPC_SEND(_info->cbk_mbx,

-  (NCSCONTEXT)evt,
-  NCS_IPC_PRIORITY_NORMAL)) {
-   /* Increment the cbk count.*/
-   if (NULL != hdl_list) {
-   /* There are two scope id
-* matching for the same hdl.*/
-   } else {
-   /* First scope id matching for
-* this hdl.*/
-   hdl_list = smfa_inv_hdl_add(
-   cbk_evt->inv_id,
-   client_info->client_hdl);
-   }
-   hdl_list->cnt++;
-   rc = NCSCC_RC_SUCCESS;
+   /* Increment the cbk count.*/
+   if (NULL != hdl_list) {
+   /* There are two scope id
+* matching for the same hdl.*/
} else {
+   /* First scope id matching for
+* this hdl.*/
+   hdl_list = smfa_inv_hdl_add(
+   cbk_evt->inv_id,
+   client_info->client_hdl);
+   }
+   hdl_list->cnt++;
+   rc = NCSCC_RC_SUCCESS;
+   if (m_NCS_IPC_SEND(
+   _info->cbk_mbx,
+   (NCSCONTEXT)evt,
+   NCS_IPC_PRIORITY_NORMAL)
+   != NCSCC_RC_SUCCESS) {
LOG_ER(
"SMFA: Posting to MBX failed. hdl: %llu, 
scoe_id: %u",
client_info->client_hdl,
cbk_evt->scope_id);
+   osafassert(0);
}
  
  /* If one of the filter matches then go to the



--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 1/1] smf: Fix failed rollback of DELETE/MODIFY CCB with originally empty attributes [#2877]

2018-06-21 Thread Nguyen Luu
Currently, if an upgrade DELETE or MODIFY CCB contains empty-value
attributes, SMF will create rollback data for those attributes with
the hard-coded "<_empty_>" string value. However, this hard-coded
string will actually make the later rollback fail, especially for
numeric-type attributes, when trying to convert "<_empty_>" to the
real numeric type, which is considered an invalid conversion.

This commit fixes that kind of rollback issue by:
- Not re-create any originally empty-value attributes when rolling
  back DELETE CCBs.
- Check for the hard-coded marker string "<_empty_>" and not add it
  to an attribute descriptor when rolling back empty attributes that
  got added with values by MODIFY CCBs in the upgrade.

This commit also fixes a few semantic errors in the code, and improve
some log/trace printouts.
---
 src/smf/smfd/SmfImmOperation.cc|  5 ++---
 src/smf/smfd/SmfImmOperation.h |  3 ++-
 src/smf/smfd/SmfRollback.cc|  2 +-
 src/smf/smfd/imm_modify_config/add_operation_to_ccb.cc | 13 -
 src/smf/smfd/imm_modify_config/attribute.cc| 10 +++---
 src/smf/smfd/imm_modify_config/immccb.cc   |  6 +++---
 6 files changed, 23 insertions(+), 16 deletions(-)

diff --git a/src/smf/smfd/SmfImmOperation.cc b/src/smf/smfd/SmfImmOperation.cc
index a8e65c5..fc127fa 100644
--- a/src/smf/smfd/SmfImmOperation.cc
+++ b/src/smf/smfd/SmfImmOperation.cc
@@ -275,9 +275,8 @@ SaAisErrorT SmfImmDeleteOperation::PrepareRollback(
 
 if (saveAttribute == true) {
   if (attr->attrValuesNumber == 0) {
-o_rollbackData->addAttrValue(attr->attrName,
- smf_immTypeToString(attr->attrValueType),
- "<_empty_>");
+// No need to re-create originally empty attribute
+continue;
   } else {
 for (unsigned int j = 0; j < attr->attrValuesNumber; j++) {
   o_rollbackData->addAttrValue(
diff --git a/src/smf/smfd/SmfImmOperation.h b/src/smf/smfd/SmfImmOperation.h
index fc855d4..bc91431 100644
--- a/src/smf/smfd/SmfImmOperation.h
+++ b/src/smf/smfd/SmfImmOperation.h
@@ -49,7 +49,8 @@ class SmfImmAttribute {
   // Note: More than one value can be added (multi-value)
   void AddAttributeValue(const std::string& i_value) {
 m_values.push_back(i_value);
-attribute_.AddValue(i_value);
+if (i_value.compare("<_empty_>") != 0)
+  attribute_.AddValue(i_value);
   }
 
   // Note: This is the legacy function that returns a list of strings. Is kept
diff --git a/src/smf/smfd/SmfRollback.cc b/src/smf/smfd/SmfRollback.cc
index 5aedd62..299a1cb 100644
--- a/src/smf/smfd/SmfRollback.cc
+++ b/src/smf/smfd/SmfRollback.cc
@@ -408,7 +408,7 @@ SaAisErrorT SmfRollbackData::rollbackModifyOperation(
   SmfImmModifyOperation* immOp = new (std::nothrow) SmfImmModifyOperation();
   if (immOp == NULL) {
 LOG_ER(
-"SmfRollbackData::rollbackModifyOperation, could not create 
SmfImmCreateOperation");
+"SmfRollbackData::rollbackModifyOperation, could not create 
SmfImmModifyOperation");
 return SA_AIS_ERR_FAILED_OPERATION;
   }
 
diff --git a/src/smf/smfd/imm_modify_config/add_operation_to_ccb.cc 
b/src/smf/smfd/imm_modify_config/add_operation_to_ccb.cc
index 44373cd..e9dea79 100644
--- a/src/smf/smfd/imm_modify_config/add_operation_to_ccb.cc
+++ b/src/smf/smfd/imm_modify_config/add_operation_to_ccb.cc
@@ -284,12 +284,15 @@ int AddModifyToCcb(const SaImmCcbHandleT& ccb_handle,
 ais_error_ = ais_rc;
 break;
   }
+} else {
+// Unrecoverable Fail
+LOG_NO("%s: AddObjectModifyToCcb() Fail, %s", __FUNCTION__,
+   saf_error(ais_rc));
+recovery_info = kFail;
+api_name_ = "saImmOmCcbObjectModify_2";
+ais_error_ = ais_rc;
+break;
 }
-  } else {
-// Unrecoverable Fail
-recovery_info = kFail;
-api_name_ = "saImmOmCcbObjectModify_2";
-ais_error_ = ais_rc;
   }
 
   // Add Modify to CCB Success
diff --git a/src/smf/smfd/imm_modify_config/attribute.cc 
b/src/smf/smfd/imm_modify_config/attribute.cc
index 9329110..d31524f 100644
--- a/src/smf/smfd/imm_modify_config/attribute.cc
+++ b/src/smf/smfd/imm_modify_config/attribute.cc
@@ -88,10 +88,10 @@ static bool StringToNumericValue(const std::string& 
str_value,
   }
 }
   } catch(std::invalid_argument& e) {
-LOG_NO("%s: Invalid argument", __FUNCTION__);
+LOG_NO("%s Fail: Invalid argument", __FUNCTION__);
 rc = false;
   } catch(std::out_of_range& e) {
-LOG_NO("%s: Out of range", __FUNCTION__);
+LOG_NO("%s Fail: Out of range", __FUNCTION__);
 rc = false;
   }
 
@@ -140,6 +140,9 @@ bool AttributeHandler::AddAttributesForModification(const 
ModifyDescriptor&
 rc = false;
 break;
 }
+// break out of the 'for' loop if a 'switch case' fails
+if 

[devel] [PATCH 0/1] Review Request for smf: Fix failed rollback of DELETE, MODIFY CCBs with originally empty attributes [#2877]

2018-06-21 Thread Nguyen Luu
Summary: smf: Fix failed rollback of DELETE/MODIFY CCB with originally empty 
attributes [#2877]
Review request for Ticket(s): 2877
Peer Reviewer(s): Lennart Lund
Pull request to: Lennart Lund
Affected branch(es): develop
Development branch: ticket-2877
Base revision: 9df337b030ff51c05e5d9d95eca15efeb8641a0a
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n

NOTE: Patch(es) contain lines longer than 80 characers

Comments (indicate scope for each "y" above):
-
revision 3d1d6e45cd49fabddcdab00ad998af7583090a20
Author: Nguyen Luu 
Date:   Thu, 21 Jun 2018 19:46:55 +0700

smf: Fix failed rollback of DELETE/MODIFY CCB with originally empty attributes 
[#2877]

Currently, if an upgrade DELETE or MODIFY CCB contains empty-value
attributes, SMF will create rollback data for those attributes with
the hard-coded "<_empty_>" string value. However, this hard-coded
string will actually make the later rollback fail, especially for
numeric-type attributes, when trying to convert "<_empty_>" to the
real numeric type, which is considered an invalid conversion.

This commit fixes that kind of rollback issue by:
- Not re-create any originally empty-value attributes when rolling
  back DELETE CCBs.
- Check for the hard-coded marker string "<_empty_>" and not add it
  to an attribute descriptor when rolling back empty attributes that
  got added with values by MODIFY CCBs in the upgrade.

This commit also fixes a few semantic errors in the code, and improve
some log/trace printouts.



Complete diffstat:
--
 src/smf/smfd/SmfImmOperation.cc|  5 ++---
 src/smf/smfd/SmfImmOperation.h |  3 ++-
 src/smf/smfd/SmfRollback.cc|  2 +-
 src/smf/smfd/imm_modify_config/add_operation_to_ccb.cc | 13 -
 src/smf/smfd/imm_modify_config/attribute.cc| 10 +++---
 src/smf/smfd/imm_modify_config/immccb.cc   |  6 +++---
 6 files changed, 23 insertions(+), 16 deletions(-)


Testing Commands:
-
Testing steps as described in the ticket.


Testing, Expected Results:
--
- The upgrade campaign is successfully rollbacked.
- Any empty attributes that got added with values in the upgrade
  are back to empty after the rollback.


Conditions of Submission:
-
Ack from Lennart.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all 

[devel] [PATCH 0/1] Review Request for smf: Fix failed rollback of DELETE, MODIFY CCBs with originally empty attributes [#2877]

2018-06-20 Thread Nguyen Luu
Summary: smf: Fix failed rollback of DELETE/MODIFY CCB with originally empty 
attributes [#2877]
Review request for Ticket(s): 2877
Peer Reviewer(s): Lennart Lund
Pull request to: Lennart Lund
Affected branch(es): develop
Development branch: ticket-2877
Base revision: b43856b6227e989fa6583edfceea10c0849c130d
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n

NOTE: Patch(es) contain lines longer than 80 characers

Comments (indicate scope for each "y" above):
-
revision 6a3ea7621b35c4562571f8dd6156ad03c1cd8a2e
Author: Nguyen Luu 
Date:   Wed, 20 Jun 2018 17:30:42 +0700

smf: Fix failed rollback of DELETE/MODIFY CCB with originally empty attributes 
[#2877]

Currently, if an upgrade DELETE or MODIFY CCB contains empty-value
attributes, SMF will create rollback data for those attributes with
the hard-coded "<_empty_>" string value. However, this hard-coded
string will actually make the later rollback fail, especially for
numeric-type attributes, when trying to convert "<_empty_>" to the
real numeric type, which is considered an invalid conversion.

This commit fixes that kind of rollback issue by:
- Not re-creating any originally empty-value attributes when rolling
  back DELETE CCBs.
- Saving an actual empty string instead of the hard-coded "<_empty_>"
  string for later rollback of empty attributes that are going to be
  added with values by MODIFY CCBs in the upgrade.

This commit also fixes a few semantic errors in the code, and improve
some log/trace printouts.



Complete diffstat:
--
 src/smf/smfd/SmfImmOperation.cc|  8 
 src/smf/smfd/SmfImmOperation.h |  3 ++-
 src/smf/smfd/SmfRollback.cc|  2 +-
 src/smf/smfd/imm_modify_config/add_operation_to_ccb.cc | 13 -
 src/smf/smfd/imm_modify_config/attribute.cc| 10 +++---
 src/smf/smfd/imm_modify_config/immccb.cc   |  6 +++---
 6 files changed, 25 insertions(+), 17 deletions(-)


Testing Commands:
-
Testing steps as described in the ticket.


Testing, Expected Results:
--
- The upgrade campaign is successfully rollbacked.
- Any empty attributes that got added with values in the upgrade
  are back to empty after the rollback.


Conditions of Submission:
-
Ack from Lennart.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all 

[devel] [PATCH 1/1] smf: Fix failed rollback of DELETE/MODIFY CCB with originally empty attributes [#2877]

2018-06-20 Thread Nguyen Luu
Currently, if an upgrade DELETE or MODIFY CCB contains empty-value
attributes, SMF will create rollback data for those attributes with
the hard-coded "<_empty_>" string value. However, this hard-coded
string will actually make the later rollback fail, especially for
numeric-type attributes, when trying to convert "<_empty_>" to the
real numeric type, which is considered an invalid conversion.

This commit fixes that kind of rollback issue by:
- Not re-creating any originally empty-value attributes when rolling
  back DELETE CCBs.
- Saving an actual empty string instead of the hard-coded "<_empty_>"
  string for later rollback of empty attributes that are going to be
  added with values by MODIFY CCBs in the upgrade.

This commit also fixes a few semantic errors in the code, and improve
some log/trace printouts.
---
 src/smf/smfd/SmfImmOperation.cc|  8 
 src/smf/smfd/SmfImmOperation.h |  3 ++-
 src/smf/smfd/SmfRollback.cc|  2 +-
 src/smf/smfd/imm_modify_config/add_operation_to_ccb.cc | 13 -
 src/smf/smfd/imm_modify_config/attribute.cc| 10 +++---
 src/smf/smfd/imm_modify_config/immccb.cc   |  6 +++---
 6 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/src/smf/smfd/SmfImmOperation.cc b/src/smf/smfd/SmfImmOperation.cc
index a8e65c5..d482870 100644
--- a/src/smf/smfd/SmfImmOperation.cc
+++ b/src/smf/smfd/SmfImmOperation.cc
@@ -275,9 +275,8 @@ SaAisErrorT SmfImmDeleteOperation::PrepareRollback(
 
 if (saveAttribute == true) {
   if (attr->attrValuesNumber == 0) {
-o_rollbackData->addAttrValue(attr->attrName,
- smf_immTypeToString(attr->attrValueType),
- "<_empty_>");
+// No need to re-create originally empty attribute
+continue;
   } else {
 for (unsigned int j = 0; j < attr->attrValuesNumber; j++) {
   o_rollbackData->addAttrValue(
@@ -385,9 +384,10 @@ SaAisErrorT SmfImmModifyOperation::PrepareRollback(
 while ((attr = attributes[i++]) != NULL) {
   if (!strcmp((elem).m_name.c_str(), attr->attrName)) {
 if (attr->attrValuesNumber == 0) {
+  // Save an empty string as rollback value for empty attribute
   o_rollbackData->addAttrValue(attr->attrName,

smf_immTypeToString(attr->attrValueType),
-   "<_empty_>");
+   "");
 } else {
   for (unsigned int j = 0; j < attr->attrValuesNumber; j++) {
 o_rollbackData->addAttrValue(
diff --git a/src/smf/smfd/SmfImmOperation.h b/src/smf/smfd/SmfImmOperation.h
index fc855d4..d14ea10 100644
--- a/src/smf/smfd/SmfImmOperation.h
+++ b/src/smf/smfd/SmfImmOperation.h
@@ -49,7 +49,8 @@ class SmfImmAttribute {
   // Note: More than one value can be added (multi-value)
   void AddAttributeValue(const std::string& i_value) {
 m_values.push_back(i_value);
-attribute_.AddValue(i_value);
+if (!i_value.empty())
+  attribute_.AddValue(i_value);
   }
 
   // Note: This is the legacy function that returns a list of strings. Is kept
diff --git a/src/smf/smfd/SmfRollback.cc b/src/smf/smfd/SmfRollback.cc
index 5aedd62..299a1cb 100644
--- a/src/smf/smfd/SmfRollback.cc
+++ b/src/smf/smfd/SmfRollback.cc
@@ -408,7 +408,7 @@ SaAisErrorT SmfRollbackData::rollbackModifyOperation(
   SmfImmModifyOperation* immOp = new (std::nothrow) SmfImmModifyOperation();
   if (immOp == NULL) {
 LOG_ER(
-"SmfRollbackData::rollbackModifyOperation, could not create 
SmfImmCreateOperation");
+"SmfRollbackData::rollbackModifyOperation, could not create 
SmfImmModifyOperation");
 return SA_AIS_ERR_FAILED_OPERATION;
   }
 
diff --git a/src/smf/smfd/imm_modify_config/add_operation_to_ccb.cc 
b/src/smf/smfd/imm_modify_config/add_operation_to_ccb.cc
index 44373cd..e9dea79 100644
--- a/src/smf/smfd/imm_modify_config/add_operation_to_ccb.cc
+++ b/src/smf/smfd/imm_modify_config/add_operation_to_ccb.cc
@@ -284,12 +284,15 @@ int AddModifyToCcb(const SaImmCcbHandleT& ccb_handle,
 ais_error_ = ais_rc;
 break;
   }
+} else {
+// Unrecoverable Fail
+LOG_NO("%s: AddObjectModifyToCcb() Fail, %s", __FUNCTION__,
+   saf_error(ais_rc));
+recovery_info = kFail;
+api_name_ = "saImmOmCcbObjectModify_2";
+ais_error_ = ais_rc;
+break;
 }
-  } else {
-// Unrecoverable Fail
-recovery_info = kFail;
-api_name_ = "saImmOmCcbObjectModify_2";
-ais_error_ = ais_rc;
   }
 
   // Add Modify to CCB Success
diff --git a/src/smf/smfd/imm_modify_config/attribute.cc 
b/src/smf/smfd/imm_modify_config/attribute.cc
index 9329110..d31524f 100644
--- a/src/smf/smfd/imm_modify_config/attribute.cc
+++ 

Re: [devel] [PATCH 1/1] imm: fix failure to import file containing existing long dn object [#2874]

2018-06-19 Thread Nguyen Luu

Hi Lennart,

Looks like you have by mistake commented on the wrong mail thread. 
Thanks for the comments and suggestion anyway. I will consider them and 
work on a new fix.


Thanks,
Nguyen

On 6/19/2018 9:30 PM, Lennart Lund wrote:

Hi Nguyen

The main issue that I saw is that you have added some checking of <_empy_> tag 
in the ccb handler (in imm_modify_config). This is not allowed. The ccb handler is 
supposed to be generic and completely independent of SMF. For now it is housed within 
the SMF src directories but it could be made a library and be used by other services. 
Let's not destroy that possibility. The ccb handler is also already used in other 
places that are not related to smfImmOperation (exec control object handling and node 
groups for lock operations).

Instead add a check <_empty_> before adding a value to an attribute descriptor. If the 
value is <_empty_>, don't add it. The legacy attribute handling classes still have the 
original attribute vectors and there it is ok to add <_empty_> as before. I have written 
some comments in the code as well to clarify.

See attached patch (can be applied on your review branch)

Thanks
Lennart


-Original Message-
From: Vu Minh Nguyen 
Sent: den 19 juni 2018 10:50
To: Lennart Lund ; Hans Nordebäck
; Gary Lee 
Cc: opensaf-devel@lists.sourceforge.net; Vu Minh Nguyen

Subject: [PATCH 1/1] imm: fix failure to import file containing existing long dn
object [#2874]

The original object name `state->objectName` was copied using the function
osaf_extended_name_lend(state->objectName, ).

In case of long dn object, the `objectName` contained a reference to the
string
which was stored in `state->objectName`, any change to `state-

objectName`,

in this case it was the code line `state->objectName[DNlen] = '\0',
would impact the backup `objectName`.

As the `objectName` had been changed unintentionally to non-existing
object dn,
`saImmOmAccessorGet_2` returned `SA_AIS_ERR_NOT_EXIST`
unexpectedly.

With this fix, using C++ string to copy the `state->objectName` value.
Extracting parent DN, and object RDN are operating on C++ string, don't
change the original value.
---
  src/imm/tools/imm_import.cc | 39 +++
  1 file changed, 19 insertions(+), 20 deletions(-)

diff --git a/src/imm/tools/imm_import.cc b/src/imm/tools/imm_import.cc
index 5397c67..e2bdcba 100644
--- a/src/imm/tools/imm_import.cc
+++ b/src/imm/tools/imm_import.cc
@@ -182,6 +182,7 @@ static SaImmValueTypeT
getClassAttrValueType(ParserState *, const char *,
   const char *);
  static void saveRDNAttribute(ParserState *parserState);
  static void getDNForClass(ParserState *, const SaImmClassNameT,
+  const std::string&,
SaImmAttrValuesT_2 *);
  static int charsToValueHelper(SaImmAttrValueT *, SaImmValueTypeT, const
char *,
bool strictParse);
@@ -633,7 +634,8 @@ static void createImmObject(ParserState *state) {
SaAisErrorT errorCode = SA_AIS_OK;
int i = 0;
size_t DNlen;
-  SaNameT objectName;
+  const char *parent = nullptr;
+  std::string rdn;
std::list::iterator it;

TRACE_8("CREATE IMM OBJECT %s, %s", state->objectClass, state-

objectName);

@@ -645,23 +647,21 @@ static void createImmObject(ParserState *state) {

/* Set the parent name */
osaf_extended_name_clear();
-  if (state->objectName != NULL) {
-char *parent;
-osaf_extended_name_lend(state->objectName, );
-
+  if (state->objectName != nullptr) {
+rdn = std::string{state->objectName};
  /* ',' is the delimeter */
  /* but '\' is the escape character, used for association objects */
-parent = state->objectName;
+parent = rdn.c_str();
  do {
parent = strchr(parent, ',');
TRACE_8("PARENT: %s", parent);
  } while (parent && (*((++parent) - 2)) == '\\');

  if (parent && strlen(parent) <= 1) {
-  parent = NULL;
+  parent = nullptr;
  }

-if (parent != NULL) osaf_extended_name_lend(parent, );
+if (parent != nullptr) osaf_extended_name_lend(parent, );
} else {
  LOG_ER("Empty DN for object");
  stopParser(state);
@@ -675,19 +675,13 @@ static void createImmObject(ParserState *state) {

if (state->ctxt->instate == XML_PARSER_EOF) return;

-#ifdef TRACE_8
/* Get the length of the DN and truncate state->objectName */
if (!osaf_is_extended_name_empty()) {
  DNlen = strlen(state->objectName) -
  (strlen(osaf_extended_name_borrow()) + 1);
-  } else {
-DNlen = strlen(state->objectName);
+rdn[DNlen] = '\0';
}

-  state->objectName[DNlen] = '\0';
-  TRACE_8("OBJECT NAME: %s", state->objectName);
-#endif
-
if (!state->validation) {
  /* Set the attribute values array, add space for the rdn attribute
   * and a NULL terminator */
@@ -717,17 +711,19 @@ static void createImmObject(ParserState *state) {

  /* Do the actual 

Re: [devel] [PATCH 1/1] smf: Validation error for rollback CCB and a related core dump [#2858]

2018-06-07 Thread Nguyen Luu

Hi Lennart,

If you think the flag will be useful later, then it's good to keep it as 
is. Then there's no more comment from me.


Thanks,
Nguyen

On 6/7/2018 6:22 PM, Lennart Lund wrote:


Hi Nguyen,

It is correct that it is not used in SMF any longer. However the CCB 
handler is generic and could in the future be moved to become OpenSAF 
common code and the possibility to ignore if an object to be created 
already exist may be useful. The only reason why it could not be used 
in SMF is that doImmOperation() is also contains rollback handling 
(creation of additional data stores that has to be deleted).


Thanks

Lennart

*From:*Nguyen Luu 
*Sent:* den 7 juni 2018 07:19
*To:* Lennart Lund 
*Cc:* opensaf-devel@lists.sourceforge.net
*Subject:* Re: [PATCH 1/1] smf: Validation error for rollback CCB and 
a related core dump [#2858]


Hi Lennart,

Ack from me for this new patch. Code review only, no re-test.

Just a minor comment below for you to consider.

Since we will now not add the CreateDescriptorfor an object to the CCB 
if it already exists (CheckObjectExist::IsExisting() == 
CheckObjectExist::ReturnCode::kOk), do we still need to keep the flag 
ignore_ais_err_existof CreateDescriptor for any use? It is currently 
only used for testing purpose in the test_ccbhdldemo.


Thanks,
Nguyen

On 6/5/2018 2:41 PM, Lennart Lund wrote:

SMF imm operation lists may contain duplicate create operations.

Fix, rollback data shall not be stored for duplicate operations and

duplicate operations shall not be added to the CCB.

Fix, crash in SmfUtil::doImmoperation if the CCB fails

---

  opensaf.spec.in|3 +-

  src/smf/Makefile.am|42 ++-

  src/smf/smfd/SmfRollback.h|11 -

  src/smf/smfd/SmfUtils.cc|73 -

  src/smf/smfd/SmfUtils_ObjExist.cc| 297 ++

  src/smf/smfd/SmfUtils_ObjExist.h|67 

  .../imm_modify_config/add_operation_to_ccb.cc |7 +-

  src/smf/smfd/imm_modify_config/attribute.cc|6 +

  src/smf/smfd/imm_modify_config/immccb.h|53 +++-

  src/smf/smfd/imm_modify_demo/Makefile|3 +-

  src/smf/smfd/imm_modify_demo/README|10 +-

  src/smf/smfd/imm_modify_demo/common.cc|4 +-

  src/smf/smfd/imm_modify_demo/common.h|3 +

  .../{ccbhdl_test.cc => test_ccbhdl.cc}|45 ++-

  src/smf/smfd/imm_modify_demo/test_objexist.cc | 127 

  15 files changed, 681 insertions(+), 70 deletions(-)

  create mode 100644 src/smf/smfd/SmfUtils_ObjExist.cc

  create mode 100644 src/smf/smfd/SmfUtils_ObjExist.h

  rename src/smf/smfd/imm_modify_demo/{ccbhdl_test.cc => test_ccbhdl.cc} 
(95%)

  create mode 100644 src/smf/smfd/imm_modify_demo/test_objexist.cc

diff --git a/opensaf.spec.in b/opensaf.spec.in

index 3d7ac28a9..5ae2070d4 100644

--- a/opensaf.spec.in

+++ b/opensaf.spec.in

@@ -1538,7 +1538,8 @@ fi

  %{_bindir}/ccbdemo_create

  %{_bindir}/ccbdemo_delete

  %{_bindir}/ccbdemo_modify

-%{_bindir}/ccbhdl_test

+%{_bindir}/test_ccbhdl

+%{_bindir}/test_objexist

  %endif

  %if %is_ais_ckpt

  %{_bindir}/ckpttest

diff --git a/src/smf/Makefile.am b/src/smf/Makefile.am

index 3502f1546..5eed2e683 100644

--- a/src/smf/Makefile.am

+++ b/src/smf/Makefile.am

@@ -106,6 +106,7 @@ noinst_HEADERS += \

  src/smf/smfd/SmfUpgradeProcedure.h \

  src/smf/smfd/SmfUpgradeStep.h \

  src/smf/smfd/SmfUtils.h \

+src/smf/smfd/SmfUtils_ObjExist.h \

  src/smf/smfd/smfd.h \

  src/smf/smfd/smfd_cb.h \

  src/smf/smfd/smfd_evt.h \

@@ -198,6 +199,7 @@ bin_osafsmfd_SOURCES = \

  src/smf/smfd/SmfUpgradeProcedure.cc \

  src/smf/smfd/SmfUpgradeStep.cc \

  src/smf/smfd/SmfUtils.cc \

+src/smf/smfd/SmfUtils_ObjExist.cc \

  src/smf/smfd/smfd_amf.cc \

  src/smf/smfd/smfd_campaign_oi.cc \

  src/smf/smfd/smfd_evt.c \

@@ -261,7 +263,12 @@ endif

  # Demos and test

  if ENABLE_TESTS

  


-bin_PROGRAMS += bin/ccbdemo_create bin/ccbdemo_delete bin/ccbdemo_modify 
bin/ccbhdl_test

+bin_PROGRAMS += \

+bin/ccbdemo_create \

+bin/ccbdemo_delete \

+bin/ccbdemo_modify \

+bin/test_ccbhdl \

+bin/test_objexist

  


dist_pkgimmxml_svc_DATA += \

  src/smf/smfd/imm_modify_demo/democlass.xml

@@ -377,26 +384,26 @@ bin_ccbdemo_modify_LDADD = \

  lib/libSaImmOm.la \

  lib/libopensaf_core.la

  


-# CCBHDL Test

+# Test CCBHDL

  # ---

-bin_ccbhdl_test_CFLAGS = $(AM_CFLAGS) -Wformat=1

+bin_test_ccbhdl_CFLAGS = $(AM_CFLAGS) -Wformat=1

  


-bin_ccbhdl_test_CPPFLAGS = \

+bin_test_ccbhdl_CPPFLAGS = \

  -DSA_EXTENDED_NAME_SOURCE \

  $(AM_CPPFLAGS)

  


-bin_ccbhdl_test_SOURCES = \

+bin_test_ccbhdl_SOURCES = \

  src/smf/smfd/imm_modify_demo/common.cc \

-src/smf/smfd/imm_modify_demo/ccbhdl_test.cc

+src/smf/smfd/imm_modify_demo/test_ccb

Re: [devel] [PATCH 1/1] smf: Validation error for rollback CCB and a related core dump [#2858]

2018-06-06 Thread Nguyen Luu

Hi Lennart,

Ack from me for this new patch. Code review only, no re-test.

Just a minor comment below for you to consider.

Since we will now not add the CreateDescriptor for an object to the CCB 
if it already exists (CheckObjectExist::IsExisting() == 
CheckObjectExist::ReturnCode::kOk), do we still need to keep the flag 
ignore_ais_err_exist of CreateDescriptor for any use? It is currently 
only used for testing purpose in the test_ccbhdl demo.


Thanks,
Nguyen

On 6/5/2018 2:41 PM, Lennart Lund wrote:

SMF imm operation lists may contain duplicate create operations.
Fix, rollback data shall not be stored for duplicate operations and
duplicate operations shall not be added to the CCB.
Fix, crash in SmfUtil::doImmoperation if the CCB fails
---
  opensaf.spec.in   |   3 +-
  src/smf/Makefile.am   |  42 ++-
  src/smf/smfd/SmfRollback.h|  11 -
  src/smf/smfd/SmfUtils.cc  |  73 -
  src/smf/smfd/SmfUtils_ObjExist.cc | 297 ++
  src/smf/smfd/SmfUtils_ObjExist.h  |  67 
  .../imm_modify_config/add_operation_to_ccb.cc |   7 +-
  src/smf/smfd/imm_modify_config/attribute.cc   |   6 +
  src/smf/smfd/imm_modify_config/immccb.h   |  53 +++-
  src/smf/smfd/imm_modify_demo/Makefile |   3 +-
  src/smf/smfd/imm_modify_demo/README   |  10 +-
  src/smf/smfd/imm_modify_demo/common.cc|   4 +-
  src/smf/smfd/imm_modify_demo/common.h |   3 +
  .../{ccbhdl_test.cc => test_ccbhdl.cc}|  45 ++-
  src/smf/smfd/imm_modify_demo/test_objexist.cc | 127 
  15 files changed, 681 insertions(+), 70 deletions(-)
  create mode 100644 src/smf/smfd/SmfUtils_ObjExist.cc
  create mode 100644 src/smf/smfd/SmfUtils_ObjExist.h
  rename src/smf/smfd/imm_modify_demo/{ccbhdl_test.cc => test_ccbhdl.cc} (95%)
  create mode 100644 src/smf/smfd/imm_modify_demo/test_objexist.cc

diff --git a/opensaf.spec.in b/opensaf.spec.in
index 3d7ac28a9..5ae2070d4 100644
--- a/opensaf.spec.in
+++ b/opensaf.spec.in
@@ -1538,7 +1538,8 @@ fi
  %{_bindir}/ccbdemo_create
  %{_bindir}/ccbdemo_delete
  %{_bindir}/ccbdemo_modify
-%{_bindir}/ccbhdl_test
+%{_bindir}/test_ccbhdl
+%{_bindir}/test_objexist
  %endif
  %if %is_ais_ckpt
  %{_bindir}/ckpttest
diff --git a/src/smf/Makefile.am b/src/smf/Makefile.am
index 3502f1546..5eed2e683 100644
--- a/src/smf/Makefile.am
+++ b/src/smf/Makefile.am
@@ -106,6 +106,7 @@ noinst_HEADERS += \
src/smf/smfd/SmfUpgradeProcedure.h \
src/smf/smfd/SmfUpgradeStep.h \
src/smf/smfd/SmfUtils.h \
+   src/smf/smfd/SmfUtils_ObjExist.h \
src/smf/smfd/smfd.h \
src/smf/smfd/smfd_cb.h \
src/smf/smfd/smfd_evt.h \
@@ -198,6 +199,7 @@ bin_osafsmfd_SOURCES = \
src/smf/smfd/SmfUpgradeProcedure.cc \
src/smf/smfd/SmfUpgradeStep.cc \
src/smf/smfd/SmfUtils.cc \
+   src/smf/smfd/SmfUtils_ObjExist.cc \
src/smf/smfd/smfd_amf.cc \
src/smf/smfd/smfd_campaign_oi.cc \
src/smf/smfd/smfd_evt.c \
@@ -261,7 +263,12 @@ endif
  # Demos and test
  if ENABLE_TESTS
  
-bin_PROGRAMS += bin/ccbdemo_create bin/ccbdemo_delete bin/ccbdemo_modify bin/ccbhdl_test

+bin_PROGRAMS += \
+   bin/ccbdemo_create \
+   bin/ccbdemo_delete \
+   bin/ccbdemo_modify \
+   bin/test_ccbhdl \
+   bin/test_objexist
  
  dist_pkgimmxml_svc_DATA += \

src/smf/smfd/imm_modify_demo/democlass.xml
@@ -377,26 +384,26 @@ bin_ccbdemo_modify_LDADD = \
lib/libSaImmOm.la \
lib/libopensaf_core.la
  
-# CCBHDL Test

+# Test CCBHDL
  # ---
-bin_ccbhdl_test_CFLAGS = $(AM_CFLAGS) -Wformat=1
+bin_test_ccbhdl_CFLAGS = $(AM_CFLAGS) -Wformat=1
  
-bin_ccbhdl_test_CPPFLAGS = \

+bin_test_ccbhdl_CPPFLAGS = \
-DSA_EXTENDED_NAME_SOURCE \
$(AM_CPPFLAGS)
  
-bin_ccbhdl_test_SOURCES = \

+bin_test_ccbhdl_SOURCES = \
src/smf/smfd/imm_modify_demo/common.cc \
-   src/smf/smfd/imm_modify_demo/ccbhdl_test.cc
+   src/smf/smfd/imm_modify_demo/test_ccbhdl.cc
  
  # IMM configuration modifier

-bin_ccbhdl_test_SOURCES += \
+bin_test_ccbhdl_SOURCES += \
src/smf/smfd/imm_modify_config/attribute.cc \
src/smf/smfd/imm_modify_config/add_operation_to_ccb.cc \
src/smf/smfd/imm_modify_config/immccb.cc
  
  # IMM OM C++ APIs

-bin_ccbhdl_test_SOURCES += \
+bin_test_ccbhdl_SOURCES += \
src/smf/smfd/imm_om_ccapi/common/common.cc \
src/smf/smfd/imm_om_ccapi/common/imm_attribute.cc \
src/smf/smfd/imm_om_ccapi/om_admin_owner_clear.cc \
@@ -408,7 +415,24 @@ bin_ccbhdl_test_SOURCES += \
src/smf/smfd/imm_om_ccapi/om_ccb_object_modify.cc \
src/smf/smfd/imm_om_ccapi/om_handle.cc
  
-bin_ccbhdl_test_LDADD = \

+bin_test_ccbhdl_LDADD = \
+   lib/libosaf_common.la \
+   lib/libSaImmOm.la \
+   lib/libopensaf_core.la
+
+# Test OBJEXIST
+# -
+bin_test_objexist_CFLAGS = $(AM_CFLAGS) -Wformat=1
+

Re: [devel] [PATCH 0/1] Review Request for smf: Validation error for rollback CCB and a related core dump [#2858]

2018-06-01 Thread Nguyen Luu

Hi Lennart,

I've run *test_ccbhdl* in OpenSAF UML cluster and the same core dump was 
still generated as described in my previous mail.
My UML cluster was built and installed with the latest OpenSAF develop 
commit (*5d8d104 rded: run controller promotion code in new thread 
[#2857]*), and with your patch applied on top.


I debugged a little by removing the creation of the long-value 
SA_IMM_ATTR_SANAMET attribute from the test (below code, at two places 
in the test), and the test passed successfully with no core dump.


  // Add a long name and a third short name
  char long_name[300];
  for (size_t i = 0; i < 299; i++) {
    long_name[i] = 'a';
  }
  long_name[299] = '\0';
  osaf_extended_name_lend(long_name, _name);
  attribute.AddValue(modelmodify::SaNametToString(_name));

Testing further, I tried running a test campaign which included the 
creation of a long-dn object, and the campaign also failed at such 
creation (I did enable longDnsAllowed beforehand). Then, I tried testing 
the same campaign after *reverting your 2nd increment for ticket #1398* 
and the campaign completed successfully with the long-dn object created. 
So I've doubted that the 2nd increment of #1398 might have introduced 
the issue here.


Can you check/verify the patch again in consideration of my testing and 
observation?


Thanks,
Nguyen

On 5/31/2018 7:33 PM, Lennart Lund wrote:


Hi Nguyen,

I have tried to reproduce the coredump but I have not succeeded. Did 
you just run test_ccbhdl without any special settings?


I am testing in an OpenSAF UML cluster that is built and started using 
the tools in …/tools/cluster_sim_uml/


I have also tested when the test class is not in the IMM model. The 
test of course fail but no coredump. The fail happen in a controlled 
and predictable way.


What kind of system are you using?

Thanks

Lennart

*From:*Nguyen Luu 
*Sent:* den 31 maj 2018 11:10
*To:* Lennart Lund 
*Cc:* opensaf-devel@lists.sourceforge.net
*Subject:* Re: [PATCH 0/1] Review Request for smf: Validation error 
for rollback CCB and a related core dump [#2858]


Hi Lennart,

I've reviewed and tested your patch.
- For the code review, please check comments in the attached diff file.
- For the testing, a core dump occurred when executing *test_ccbhdl* 
(always reproducible). Test printouts, core dump backtrace, and syslog 
as shown below. Looks like some issue with setting an extended-name 
attribute of type SA_IMM_ATTR_SANAMET. Has this test passed in your 
last run?


-Terminal printouts-
root@SC-1:~# test_ccbhdl
ccbhdl_test
IMM class used for test: ImmTestValuesConfig
Creating: Test1=1,safApp=safSmfService
Aborted (core dumped)

-System logs-
2018-05-31 16:02:35.873 SC-1 osafimmpbed: IN Create of class 
ImmTestValuesConfig committing with ccbId:10004
2018-05-31 16:02:35.889 SC-1 osafimmnd[207]: NO Create of class 
ImmTestValuesConfig is PERSISTENT.
2018-05-31 16:02:35.908 SC-1 osafimmpbed: NO PBE allowing modification 
to object opensafImm=opensafImm,safApp=safImmService
2018-05-31 16:02:35.922 SC-1 osafimmnd[207]: NO Ccb 2 COMMITTED 
(immcfg_SC-1_487)
2018-05-31 16:02:35.934 SC-1 test_ccbhdl: 
src/base/osaf_extended_name.c:144: osaf_extended_name_length: 
Assertion 'osaf_extended_names_enabled && length >= 
SA_MAX_UNEXTENDED_NAME_LENGTH' failed.


-Core dump backtrace-
(gdb) bt
#0  0x7faf97b83428 in __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:54

#1  0x7faf97b8502a in __GI_abort () at abort.c:89
#2  0x7faf987034ab in __osafassert_fail 
(__file=__file@entry=0x7faf9873275d "src/base/osaf_extended_name.c",
    __line=__line@entry=144, __func=__func@entry=0x7faf987327f0 
<__FUNCTION__.3368> "osaf_extended_name_length",
    __assertion=__assertion@entry=0x7faf987327a8 
"osaf_extended_names_enabled && length >= SA_MAX_UNEXTENDED_NAME_LENGTH")

    at src/base/sysf_def.c:286
#3  0x7faf986fef89 in osaf_extended_name_length 
(name=0x564decae3796) at src/base/osaf_extended_name.c:143
#4  0x7faf9895ef1d in imma_copyAttrValue 
(p=p@entry=0x564decae2d00, attrValueType=SA_IMM_ATTR_SANAMET,

    attrValue=0x564decae3796) at src/imm/agent/imma_init.cc:434
#5  0x7faf9896b140 in ccb_object_create_common 
(ccbHandle=1527757355930828673, className=,
    parentName=0x7ffefbb72e20, objectName=, 
objectName@entry=0x0, attrValues=attrValues@entry=0x7ffefbb72cf0)

    at src/imm/agent/imma_om_api.cc:2079
#6  0x7faf9896d8cf in saImmOmCcbObjectCreate_2 
(ccbHandle=, className=,
    parentName=, 
attrValues=attrValues@entry=0x7ffefbb72cf0) at 
src/imm/agent/imma_om_api.cc:1660
#7  0x564dea9df953 in 
immom::ImmOmCcbObjectCreate::AddObjectCreateToCcb 
(this=this@entry=0x7ffefbb72ff0)

    at src/smf/smfd/imm_om_ccapi/om_ccb_object_create.cc:61
#8  0x564dea9d8d54 in modelmodify::AddCreateToCcb 
(ccb_handle=@0x7ffefbb730c8: 1527757355930828673, create_descriptor=...)

    at src/smf/smfd/imm_mod

Re: [devel] [PATCH 0/1] Review Request for smf: Validation error for rollback CCB and a related core dump [#2858]

2018-05-31 Thread Nguyen Luu

Hi Lennart,

Thanks for your answers to my comments. I agree with most of the major 
points.
So Ack from me for the diff file. I can do a double-check review if you 
will send out a new patch (with comments removed).


Thanks,
Nguyen

On 5/31/2018 10:48 PM, Lennart Lund wrote:


Hi Nguyen,

Attached is a diff with your comments still in there and my answers 
tagged [Lennart].


I have also kept your uncommented fixes.

If you ack this I will use the patch with review comments removed.

Thanks

Lennart

*From:*Nguyen Luu 
*Sent:* den 31 maj 2018 11:10
*To:* Lennart Lund 
*Cc:* opensaf-devel@lists.sourceforge.net
*Subject:* Re: [PATCH 0/1] Review Request for smf: Validation error 
for rollback CCB and a related core dump [#2858]


Hi Lennart,

I've reviewed and tested your patch.
- For the code review, please check comments in the attached diff file.
- For the testing, a core dump occurred when executing *test_ccbhdl* 
(always reproducible). Test printouts, core dump backtrace, and syslog 
as shown below. Looks like some issue with setting an extended-name 
attribute of type SA_IMM_ATTR_SANAMET. Has this test passed in your 
last run?


-Terminal printouts-
root@SC-1:~# test_ccbhdl
ccbhdl_test
IMM class used for test: ImmTestValuesConfig
Creating: Test1=1,safApp=safSmfService
Aborted (core dumped)

-System logs-
2018-05-31 16:02:35.873 SC-1 osafimmpbed: IN Create of class 
ImmTestValuesConfig committing with ccbId:10004
2018-05-31 16:02:35.889 SC-1 osafimmnd[207]: NO Create of class 
ImmTestValuesConfig is PERSISTENT.
2018-05-31 16:02:35.908 SC-1 osafimmpbed: NO PBE allowing modification 
to object opensafImm=opensafImm,safApp=safImmService
2018-05-31 16:02:35.922 SC-1 osafimmnd[207]: NO Ccb 2 COMMITTED 
(immcfg_SC-1_487)
2018-05-31 16:02:35.934 SC-1 test_ccbhdl: 
src/base/osaf_extended_name.c:144: osaf_extended_name_length: 
Assertion 'osaf_extended_names_enabled && length >= 
SA_MAX_UNEXTENDED_NAME_LENGTH' failed.


-Core dump backtrace-
(gdb) bt
#0  0x7faf97b83428 in __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:54

#1  0x7faf97b8502a in __GI_abort () at abort.c:89
#2  0x7faf987034ab in __osafassert_fail 
(__file=__file@entry=0x7faf9873275d "src/base/osaf_extended_name.c",
    __line=__line@entry=144, __func=__func@entry=0x7faf987327f0 
<__FUNCTION__.3368> "osaf_extended_name_length",
    __assertion=__assertion@entry=0x7faf987327a8 
"osaf_extended_names_enabled && length >= SA_MAX_UNEXTENDED_NAME_LENGTH")

    at src/base/sysf_def.c:286
#3  0x7faf986fef89 in osaf_extended_name_length 
(name=0x564decae3796) at src/base/osaf_extended_name.c:143
#4  0x7faf9895ef1d in imma_copyAttrValue 
(p=p@entry=0x564decae2d00, attrValueType=SA_IMM_ATTR_SANAMET,

    attrValue=0x564decae3796) at src/imm/agent/imma_init.cc:434
#5  0x7faf9896b140 in ccb_object_create_common 
(ccbHandle=1527757355930828673, className=,
    parentName=0x7ffefbb72e20, objectName=, 
objectName@entry=0x0, attrValues=attrValues@entry=0x7ffefbb72cf0)

    at src/imm/agent/imma_om_api.cc:2079
#6  0x7faf9896d8cf in saImmOmCcbObjectCreate_2 
(ccbHandle=, className=,
    parentName=, 
attrValues=attrValues@entry=0x7ffefbb72cf0) at 
src/imm/agent/imma_om_api.cc:1660
#7  0x564dea9df953 in 
immom::ImmOmCcbObjectCreate::AddObjectCreateToCcb 
(this=this@entry=0x7ffefbb72ff0)

    at src/smf/smfd/imm_om_ccapi/om_ccb_object_create.cc:61
#8  0x564dea9d8d54 in modelmodify::AddCreateToCcb 
(ccb_handle=@0x7ffefbb730c8: 1527757355930828673, create_descriptor=...)

    at src/smf/smfd/imm_modify_config/add_operation_to_ccb.cc:103
#9  0x564dea9db26c in modelmodify::ModelModification::AddCreate 
(this=this@entry=0x7ffefbb73870, create_descriptor=...)

    at src/smf/smfd/imm_modify_config/immccb.cc:482
#10 0x564dea9dca8b in modelmodify::ModelModification::AddCreates 
(this=this@entry=0x7ffefbb73870,
    create_descriptors=std::vector of length 1, capacity 1 = {...}) at 
src/smf/smfd/imm_modify_config/immccb.cc:455
#11 0x564dea9dce67 in 
modelmodify::ModelModification::DoModelModification 
(this=0x7ffefbb73870, modifications=...)

    at src/smf/smfd/imm_modify_config/immccb.cc:107
#12 0x564dea9c61af in CreateOneObject () at 
src/smf/smfd/imm_modify_demo/test_ccbhdl.cc:141
#13 0x564dea9bd36c in main () at 
src/smf/smfd/imm_modify_demo/test_ccbhdl.cc:244


Thanks,
Nguyen

On 5/29/2018 9:40 PM, Lennart Lund wrote:

Summary: smf: Validation error for rollback CCB and a related core dump 
[#2858]

Review request for Ticket(s): 2858

Peer Reviewer(s):nguyen.tk@dektech.com.au 
<mailto:nguyen.tk@dektech.com.au>

Pull request to: *** LIST THE PERSON WITH PUSH ACCESS HERE ***

Affected branch(es): develop

Development branch: ticket-2858

Base revision: 1c4c6ad57fdf44b228ec83f777ae957e878f1d61

Personal repository: git://git.code.sf.net/u/elunlen/review

 

Re: [devel] [PATCH 0/1] Review Request for smf: Validation error for rollback CCB and a related core dump [#2858]

2018-05-31 Thread Nguyen Luu

Hi Lennart,

I've reviewed and tested your patch.
- For the code review, please check comments in the attached diff file.
- For the testing, a core dump occurred when executing *test_ccbhdl* 
(always reproducible). Test printouts, core dump backtrace, and syslog 
as shown below. Looks like some issue with setting an extended-name 
attribute of type SA_IMM_ATTR_SANAMET. Has this test passed in your last 
run?


-Terminal printouts-
root@SC-1:~# test_ccbhdl
ccbhdl_test
IMM class used for test: ImmTestValuesConfig
Creating: Test1=1,safApp=safSmfService
Aborted (core dumped)

-System logs-
2018-05-31 16:02:35.873 SC-1 osafimmpbed: IN Create of class 
ImmTestValuesConfig committing with ccbId:10004
2018-05-31 16:02:35.889 SC-1 osafimmnd[207]: NO Create of class 
ImmTestValuesConfig is PERSISTENT.
2018-05-31 16:02:35.908 SC-1 osafimmpbed: NO PBE allowing modification 
to object opensafImm=opensafImm,safApp=safImmService
2018-05-31 16:02:35.922 SC-1 osafimmnd[207]: NO Ccb 2 COMMITTED 
(immcfg_SC-1_487)
2018-05-31 16:02:35.934 SC-1 test_ccbhdl: 
src/base/osaf_extended_name.c:144: osaf_extended_name_length: Assertion 
'osaf_extended_names_enabled && length >= SA_MAX_UNEXTENDED_NAME_LENGTH' 
failed.


-Core dump backtrace-
(gdb) bt
#0  0x7faf97b83428 in __GI_raise (sig=sig@entry=6) at 
../sysdeps/unix/sysv/linux/raise.c:54

#1  0x7faf97b8502a in __GI_abort () at abort.c:89
#2  0x7faf987034ab in __osafassert_fail 
(__file=__file@entry=0x7faf9873275d "src/base/osaf_extended_name.c",
    __line=__line@entry=144, __func=__func@entry=0x7faf987327f0 
<__FUNCTION__.3368> "osaf_extended_name_length",
    __assertion=__assertion@entry=0x7faf987327a8 
"osaf_extended_names_enabled && length >= SA_MAX_UNEXTENDED_NAME_LENGTH")

    at src/base/sysf_def.c:286
#3  0x7faf986fef89 in osaf_extended_name_length 
(name=0x564decae3796) at src/base/osaf_extended_name.c:143
#4  0x7faf9895ef1d in imma_copyAttrValue (p=p@entry=0x564decae2d00, 
attrValueType=SA_IMM_ATTR_SANAMET,

    attrValue=0x564decae3796) at src/imm/agent/imma_init.cc:434
#5  0x7faf9896b140 in ccb_object_create_common 
(ccbHandle=1527757355930828673, className=,
    parentName=0x7ffefbb72e20, objectName=, 
objectName@entry=0x0, attrValues=attrValues@entry=0x7ffefbb72cf0)

    at src/imm/agent/imma_om_api.cc:2079
#6  0x7faf9896d8cf in saImmOmCcbObjectCreate_2 (ccbHandle=out>, className=,
    parentName=, 
attrValues=attrValues@entry=0x7ffefbb72cf0) at 
src/imm/agent/imma_om_api.cc:1660
#7  0x564dea9df953 in 
immom::ImmOmCcbObjectCreate::AddObjectCreateToCcb 
(this=this@entry=0x7ffefbb72ff0)

    at src/smf/smfd/imm_om_ccapi/om_ccb_object_create.cc:61
#8  0x564dea9d8d54 in modelmodify::AddCreateToCcb 
(ccb_handle=@0x7ffefbb730c8: 1527757355930828673, create_descriptor=...)

    at src/smf/smfd/imm_modify_config/add_operation_to_ccb.cc:103
#9  0x564dea9db26c in modelmodify::ModelModification::AddCreate 
(this=this@entry=0x7ffefbb73870, create_descriptor=...)

    at src/smf/smfd/imm_modify_config/immccb.cc:482
#10 0x564dea9dca8b in modelmodify::ModelModification::AddCreates 
(this=this@entry=0x7ffefbb73870,
    create_descriptors=std::vector of length 1, capacity 1 = {...}) at 
src/smf/smfd/imm_modify_config/immccb.cc:455
#11 0x564dea9dce67 in 
modelmodify::ModelModification::DoModelModification 
(this=0x7ffefbb73870, modifications=...)

    at src/smf/smfd/imm_modify_config/immccb.cc:107
#12 0x564dea9c61af in CreateOneObject () at 
src/smf/smfd/imm_modify_demo/test_ccbhdl.cc:141
#13 0x564dea9bd36c in main () at 
src/smf/smfd/imm_modify_demo/test_ccbhdl.cc:244


Thanks,
Nguyen

On 5/29/2018 9:40 PM, Lennart Lund wrote:

Summary: smf: Validation error for rollback CCB and a related core dump [#2858]
Review request for Ticket(s): 2858
Peer Reviewer(s): nguyen.tk@dektech.com.au
Pull request to: *** LIST THE PERSON WITH PUSH ACCESS HERE ***
Affected branch(es): develop
Development branch: ticket-2858
Base revision: 1c4c6ad57fdf44b228ec83f777ae957e878f1d61
Personal repository: git://git.code.sf.net/u/elunlen/review


Impacted area   Impact y/n

  Docsn
  Build systemn
  RPM/packaging   n
  Configuration files n
  Startup scripts n
  SAF servicesy
  OpenSAF servicesn
  Core libraries  n
  Samples n
  Tests   n
  Other   n


Comments (indicate scope for each "y" above):
-
The lists of IMM operations that are created in many places may contain object
create operations for objects that already exists in the IMM model.
  The lists may also contain more than one create operation for the same 
object. If
a create operation for any of the duplicates is added to the CCB, ERR_EXSIST 
will
be returned. To avoid this it must be checked for each create operation if 

Re: [devel] [PATCH 1/1] smf: Add capability to redo CCBs that fail [#1398]

2018-05-15 Thread Nguyen Luu

Hi Lennart,

I've looked at your changes in the .diff file. They look good overall.

- Nevertheless, I think some updates, mostly regarding comments and 
log/trace printouts, are needed to make the changes consistent. You can 
find the places to update in the attached .diff file which can be 
applied onto your review repository.


- Regarding renaming legacy function names in /SmfImmOperation.h/, you 
missed to change two legacy functions of /SmfImmDeleteOperation/ class. 
Please see the attached .diff file for details and double-check my 
suggested update.


- About refactoring SMF TRY_AGAIN handling for IMM operations, I agree 
that it should be done in a new ticket.


(I have removed the original patch from the mail thread to reduce the 
message size)


Thanks,
Nguyen

On 5/14/2018 8:13 PM, Lennart Lund wrote:

Hi Nguyen,

Attached patch contains all fixes. Can be applied on the review request. I will 
not send out a new review request unless Hans will find something that requires 
significant changes.

This is how I have handled your comments:

SmfAdminState.cc
I have added most of your comments. Thanks for going through all comments and 
finding the mismatches between comments and variable names etc. that was wrong.
A few of the suggested changes are not added.

SmfCampState.*
I have not changed the order of #include as suggested. The reason is that it 
cannot easily be done since there are problems with .h files that does not have 
all needed includes and circular dependencies. I tried to fix this in some 
parts of the code but run into huge problems so I skipped that in the legacy 
code.

SmfCampaignWrapup.cc
Your comment ...
   // [Nguyen] smfCreateRollbackElement eventually calls 
immutil_saImmOiRtObjectCreate_2()
   // which already handles TRY_AGAIN. Should we remove the TRY_AGAIN handling 
here?
   // I've also looked at the smfCreateRollbackElement part of other campaign 
stages and
   // found no use of such doImmOpTimer.
... is correct regarding the try again loop. This "outer loop" adds a timed 
loop with a timeout of 60 sec which is completely useless since the setting for immutil 
set by smf is to always use 600 X 1000 ms which is not at all correct. However I will not 
change any of this since it is not within scope of this ticket. Maybe create a new ticket 
for this?

SmfImmOperation.h:
   // [Nguyen] The naming of class methods in this file is not consistent,
   // i.e some with capitalized initial letter, some with uncapitalized initial 
letter
   // Should we capitalize all initial letter for consistency?
   // getClassName() -> GetClassName()
This again is legacy code. I have not renamed all legacy functions according to 
Google style guide so there may be a mix in some classes. However this file is 
fixed.

SmfUtils.cc:
lldtest_delete is test code that should have been removed. Fixed

Thanks
Lennart




-Original Message-
From: Nguyen Luu [mailto:nguyen.tk@dektech.com.au]
Sent: den 10 maj 2018 09:46
To: Lennart Lund <lennart.l...@ericsson.com>; Hans Nordebäck
<hans.nordeb...@ericsson.com>
Cc: opensaf-devel@lists.sourceforge.net
Subject: Re: [devel] [PATCH 1/1] smf: Add capability to redo CCBs that fail
[#1398]

Hi Lennart,

I've reviewed your patch. Code review only, not tested yet.
Please see my comments in the attached diff file which was generated on
top of the changes in your patch.

Regards,
Nguyen


---
 src/smf/smfd/SmfAdminState.cc   |  3 +--
 src/smf/smfd/SmfCampState.cc|  4 +--
 src/smf/smfd/SmfImmOperation.cc | 54 ++---
 src/smf/smfd/SmfImmOperation.h  | 12 -
 src/smf/smfd/SmfUpgradeProcedure.cc |  2 +-
 5 files changed, 37 insertions(+), 38 deletions(-)

diff --git a/src/smf/smfd/SmfAdminState.cc b/src/smf/smfd/SmfAdminState.cc
index 3b8dbbf..0c0115b 100644
--- a/src/smf/smfd/SmfAdminState.cc
+++ b/src/smf/smfd/SmfAdminState.cc
@@ -520,7 +520,6 @@ bool 
SmfAdminStateHandler::changeAdminState(SaAmfAdminStateT fromState,
   }
 
   // Set admin state for SUs
-  // [Nguyen] just my suggestion to use suList_.empty()
   if ((rc == true) && (!suList_.empty())) {
 TRACE("%s: Use serialized for SUs", __FUNCTION__);
 // Do only if setting admin state for nodes did not fail
@@ -728,7 +727,7 @@ done:
 }
 
 /// Create a SmfAdminStateHandler instance node group with the nodes in
-/// the nodeList.
+/// the nodeList_.
 /// The saAmfNGAdminState attribute will be given fromState. The initState
 /// must be set to a state so that a state change to the wanted state for the
 /// nodes can be done.
diff --git a/src/smf/smfd/SmfCampState.cc b/src/smf/smfd/SmfCampState.cc
index 2e09f41..8f62fb0 100644
--- a/src/smf/smfd/SmfCampState.cc
+++ b/src/smf/smfd/SmfCampState.cc
@@ -145,13 +145,13 @@ SaAisErrorT SmfCampState::verify(SmfUpgradeCampaign 
*i_camp,
 }
 
 
//--
-//

[devel] [PATCH 1/1] smfd: Remove duplicate DU/AU on SU/comp level in one-step upgrade [#2227]

2018-05-12 Thread Nguyen Luu
This fix extends, and also improves the previous one of #2209 which was
done for node level DU/AU. In particular, it eliminates any duplicate AU/DU
on SU and component level when merging forAddRemove and forModify/Rolling
procedures into a single-step procedure for one-step upgrade execution mode.

Improvement is made to remove units that have duplicates within the
forAddRemoveDU/AU lists themselves, but not having duplicate in the merged
symmetric DU/AU lists, which is the case that #2209 failed to consider.
---
 src/smf/smfd/SmfUpgradeProcedure.cc | 104 +++-
 src/smf/smfd/SmfUpgradeStep.h   |   5 ++
 2 files changed, 49 insertions(+), 60 deletions(-)

diff --git a/src/smf/smfd/SmfUpgradeProcedure.cc 
b/src/smf/smfd/SmfUpgradeProcedure.cc
index 2937c70..598edcc 100644
--- a/src/smf/smfd/SmfUpgradeProcedure.cc
+++ b/src/smf/smfd/SmfUpgradeProcedure.cc
@@ -1,6 +1,7 @@
 /*
  *
  * (C) Copyright 2009 The OpenSAF Foundation
+ * Copyright (C) 2018 Ericsson AB. All Rights Reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -1295,11 +1296,18 @@ bool 
SmfUpgradeProcedure::mergeStepIntoSingleStep(SmfUpgradeProcedure *i_proc,
 getCallbackList((*proc_elem).getUpgradeMethod());
   }
 
-  // Remove DU duplicates
-  LOG_NO("Remove duplicates from the merged DU list");
+  // Remove duplicates from tmpDU list
+  LOG_NO("Remove duplicates from the merged symmetric DU/AU list");
   tmpDU.sort(compare_du_part);
   tmpDU.unique(unique_du_part);
 
+  // Remove duplicates from forAddRemoveDU/AU lists
+  LOG_NO("Remove duplicates from the forAddRemoveDU/AU lists");
+  forAddRemoveDU.sort(compare_du_part);
+  forAddRemoveDU.unique(unique_du_part);
+  forAddRemoveAU.sort(compare_du_part);
+  forAddRemoveAU.unique(unique_du_part);
+
   // Reduce the DU list, check if smaller scope is within bigger scope.
   LOG_NO("Optimize AU/DU");
   std::pair::iterator,
@@ -1382,67 +1390,43 @@ bool 
SmfUpgradeProcedure::mergeStepIntoSingleStep(SmfUpgradeProcedure *i_proc,
 }
   }
 
-  // For forAddRemove AU/DU the node level AU/DU will be optimized with other
-  // rolling/formodify proceduers. Because node will never be optimized away.
-  // But AU/DU at SU/Comp will not be optimized for AddRemove and will be as 
is,
-  // because there is a chance that Su/comp can be removed if they are in the
-  // scope of the node/Su.
-
-  std::list::iterator addRemoveUnit_iter, nodeLevel_iter;
-  for (addRemoveUnit_iter = forAddRemoveAU.begin();
-   addRemoveUnit_iter != forAddRemoveAU.end();) {
-for (nodeLevel_iter = nodeLevelDU.begin();
- nodeLevel_iter != nodeLevelDU.end(); ++nodeLevel_iter) {
-  if ((*addRemoveUnit_iter).name == (*nodeLevel_iter).name) {
-// if item is already presented in nodeLevelDU, erase it from the
-// forAddRemove list
-LOG_NO(
-"[%s] is already presented in the merged DU list, remove it from 
forAddRemoveAU list",
-(*addRemoveUnit_iter).name.c_str());
-addRemoveUnit_iter = forAddRemoveAU.erase(addRemoveUnit_iter);
-break;
-  }
-}
-if (nodeLevel_iter == nodeLevelDU.end()) {
-  ++addRemoveUnit_iter;
-}
-  }
-
-  for (addRemoveUnit_iter = forAddRemoveDU.begin();
-   addRemoveUnit_iter != forAddRemoveDU.end();) {
-for (nodeLevel_iter = nodeLevelDU.begin();
- nodeLevel_iter != nodeLevelDU.end(); ++nodeLevel_iter) {
-  if ((*addRemoveUnit_iter).name == (*nodeLevel_iter).name) {
-// if item is already presented in nodeLevelDU, erase it from the
-// forAddRemove list
-LOG_NO(
-"[%s] is already presented in the merged DU list, remove it from 
forAddRemoveDU list",
-(*addRemoveUnit_iter).name.c_str());
-addRemoveUnit_iter = forAddRemoveDU.erase(addRemoveUnit_iter);
-break;
-  }
-}
-if (nodeLevel_iter == nodeLevelDU.end()) {
-  ++addRemoveUnit_iter;
-}
-  }
-
-  newStep->addDeactivationUnits(nodeLevelDU);  // Add the node level DU
-  newStep->addDeactivationUnits(suLevelDU);// Add the SU level DU
-  newStep->addDeactivationUnits(tmpDU);// Add the comp level DU
-  newStep->addActivationUnits(nodeLevelDU);// Rolling and forModify are
- // symetric, add the node level DU
-  newStep->addActivationUnits(
-  suLevelDU);  // Rolling and forModify are symetric, Add the SU level DU
-  newStep->addActivationUnits(
-  tmpDU);  // Rolling and forModify are symetric, Add the comp level DU
-
-  // Copy the forAddRemove AU/DU(except the optimized nodes) into the lists as
-  // is. They must be run as specified in the campaign.
+  // Compile all the optimized symmetric DU lists on Node, SU, Comp levels
+  // into one single merged symmetric DU list
+  //
+  // Copy nodeLevelDU list first, 

[devel] [PATCH 0/1] Review Request for smfd: Remove duplicate DU, AU on SU or comp level in one-step upgrade V3 [#2227]

2018-05-12 Thread Nguyen Luu
Summary: smfd: Remove duplicate DU/AU on SU/comp level in one-step upgrade 
[#2227]
Review request for Ticket(s): 2227
Peer Reviewer(s): Lennart Lund
Pull request to: Lennart Lund
Affected branch(es): develop
Development branch: ticket-2227
Base revision: 93e2808fb0bd3143a77e31dd2f0115a6596479ed
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
revision 60bc0f9f9b54b86b06bfe36cb2686c168ea43f78
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Sun, 13 May 2018 11:37:53 +0700

smfd: Remove duplicate DU/AU on SU/comp level in one-step upgrade [#2227]

This fix extends, and also improves the previous one of #2209 which was
done for node level DU/AU. In particular, it eliminates any duplicate AU/DU
on SU and component level when merging forAddRemove and forModify/Rolling
procedures into a single-step procedure for one-step upgrade execution mode.

Improvement is made to remove units that have duplicates within the
forAddRemoveDU/AU lists themselves, but not having duplicate in the merged
symmetric DU/AU lists, which is the case that #2209 failed to consider.



Complete diffstat:
--
 src/smf/smfd/SmfUpgradeProcedure.cc | 104 +++-
 src/smf/smfd/SmfUpgradeStep.h   |   5 ++
 2 files changed, 49 insertions(+), 60 deletions(-)


Testing Commands:
-
1. Install the AmfDemo sample app on PL-3, PL-4.
(could use the campaign_install_amfdemo.xml attached in the ticket;
amf_demo binary and clc script can be built and got from opensaf samples dir)
2. Run either or both of the attached campaign_one_step_<su|comp>_level.xml
in one-step upgrade execution mode.


Testing, Expected Results:
--
- The one-step upgrade should complete successfully.
(verify that the AmfDemo model changes designated in the campaign have actually
taken effect)
- Another way to examine the result is to search for the upgrade runtime objects
safSmf<Du|Au>=...,safSmfCampaign=...,safApp=safSmfService (before committing the
upgrade campaign) and to look at the corresponding attributes 
saSmf<Du|Au>ActedOn
=> No duplicate DU/AU should be found.
(Without the fix, duplicate SU or component DU/AU would result)


Conditions of Submission:
-
Ack from SMF maintainer.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed

Re: [devel] [PATCH 0/1] Review Request for smfd: Remove duplicate DU, AU on SU or comp level in one-step upgrade V2 [#2227]

2018-05-10 Thread Nguyen Luu

Hi Lennart,

Thank you for comments. I will send out V3 of the patch with the new 
implementation based on your comments.


Thanks,
Nguyen

On 5/8/2018 8:53 PM, Lennart Lund wrote:

Hi Nguyen

See my comments [Lennart] in the attached diff file. Can be applied on your 
review repository.

Thanks
Lennart


-Original Message-
From: Nguyen Luu [mailto:nguyen.tk@dektech.com.au]
Sent: den 8 maj 2018 04:19
To: Lennart Lund <lennart.l...@ericsson.com>; syam.tall...@oracle.com
Cc: opensaf-devel@lists.sourceforge.net; Nguyen Tran Khoi Luu
<nguyen.tk@dektech.com.au>
Subject: [PATCH 0/1] Review Request for smfd: Remove duplicate DU, AU on
SU or comp level in one-step upgrade V2 [#2227]

Summary: smfd: Remove duplicate DU/AU on SU/comp level in one-step
upgrade [#2227]
Review request for Ticket(s): 2227
Peer Reviewer(s): Lennart Lund, Syam Prasad Talluri
Pull request to: Lennart Lund
Affected branch(es): develop
Development branch: ticket-2227
Base revision: c44d5c9f076bdfbc9bd5fded69bcbb30e65d0f14
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

  Docsn
  Build systemn
  RPM/packaging   n
  Configuration files n
  Startup scripts n
  SAF servicesy
  OpenSAF servicesn
  Core libraries  n
  Samples n
  Tests   n
  Other   n


Comments (indicate scope for each "y" above):
-
revision dae399f6d30c7cac041282d8d3c5510838fdc3cd
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Tue, 8 May 2018 08:57:12 +0700

smfd: Remove duplicate DU/AU on SU/comp level in one-step upgrade
[#2227]

This fix extends the previous one of #2209 which was on node level.
In particular, it is to eliminate any duplicate DU/AU on SU or component
level when merging forAddRemove and forModify/rolling procedures into a
single-step procedure for one-step upgrade execution mode.



Complete diffstat:
--
  src/smf/smfd/SmfUpgradeProcedure.cc | 83
+++--
  1 file changed, 71 insertions(+), 12 deletions(-)


Testing Commands:
-
1. Install the AmfDemo sample app on PL-3, PL-4.
(could use the campaign_install_amfdemo.xml attached in the ticket;
amf_demo binary and clc script can be built and got from opensaf samples
dir)
2. Run either or both of the attached
campaign_one_step_<su|comp>_level.xml
in one-step upgrade execution mode.


Testing, Expected Results:
--
- The one-step upgrade should complete successfully.
(verify that the AmfDemo model changes designated in the campaign have
actually
taken effect)
- Another way to examine the result is to search for the upgrade runtime
objects
safSmf<Du|Au>=...,safSmfCampaign=...,safApp=safSmfService (before
committing the
upgrade campaign) and to look at the corresponding attributes
saSmf<Du|Au>ActedOn
=> No duplicate DU/AU should be found.
(Without the fix, duplicate SU or component DU/AU would result)


Conditions of Submission:
-
Ack from the reviewers.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
 that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your
headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
 (i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
 Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
 like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
 cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
 too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never h

[devel] [PATCH 1/1] smfd: Remove duplicate DU/AU on SU/comp level in one-step upgrade [#2227]

2018-05-07 Thread Nguyen Luu
This fix extends the previous one of #2209 which was on node level.
In particular, it is to eliminate any duplicate DU/AU on SU or component
level when merging forAddRemove and forModify/rolling procedures into a
single-step procedure for one-step upgrade execution mode.
---
 src/smf/smfd/SmfUpgradeProcedure.cc | 83 +++--
 1 file changed, 71 insertions(+), 12 deletions(-)

diff --git a/src/smf/smfd/SmfUpgradeProcedure.cc 
b/src/smf/smfd/SmfUpgradeProcedure.cc
index 2937c70..8d527d3 100644
--- a/src/smf/smfd/SmfUpgradeProcedure.cc
+++ b/src/smf/smfd/SmfUpgradeProcedure.cc
@@ -1,6 +1,7 @@
 /*
  *
  * (C) Copyright 2009 The OpenSAF Foundation
+ * Copyright (C) 2018 Ericsson AB. All Rights Reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -1359,7 +1360,7 @@ bool 
SmfUpgradeProcedure::mergeStepIntoSingleStep(SmfUpgradeProcedure *i_proc,
   for (unit_iter = tmpDU.begin(); unit_iter != tmpDU.end();) {
 if ((*unit_iter).name.find("safSu=") == 0) {  // DU is a SU
   suLevelDU.push_back(
-  *unit_iter);  // A node will never be optimized away, save it
+  *unit_iter);
   unit_iter = tmpDU.erase(unit_iter);  // Remove the SU and update iterator
 } else {
   ++unit_iter;
@@ -1388,41 +1389,99 @@ bool 
SmfUpgradeProcedure::mergeStepIntoSingleStep(SmfUpgradeProcedure *i_proc,
   // because there is a chance that Su/comp can be removed if they are in the
   // scope of the node/Su.
 
-  std::list::iterator addRemoveUnit_iter, nodeLevel_iter;
+  std::list::iterator addRemoveUnit_iter, mergedUnit_iter;
   for (addRemoveUnit_iter = forAddRemoveAU.begin();
addRemoveUnit_iter != forAddRemoveAU.end();) {
-for (nodeLevel_iter = nodeLevelDU.begin();
- nodeLevel_iter != nodeLevelDU.end(); ++nodeLevel_iter) {
-  if ((*addRemoveUnit_iter).name == (*nodeLevel_iter).name) {
+for (mergedUnit_iter = nodeLevelDU.begin();
+ mergedUnit_iter != nodeLevelDU.end(); ++mergedUnit_iter) {
+  if ((*addRemoveUnit_iter).name == (*mergedUnit_iter).name) {
 // if item is already presented in nodeLevelDU, erase it from the
 // forAddRemove list
 LOG_NO(
-"[%s] is already presented in the merged DU list, remove it from 
forAddRemoveAU list",
+"[%s] is already present in the merged AU list, "
+"remove it from forAddRemoveAU list",
 (*addRemoveUnit_iter).name.c_str());
 addRemoveUnit_iter = forAddRemoveAU.erase(addRemoveUnit_iter);
 break;
   }
 }
-if (nodeLevel_iter == nodeLevelDU.end()) {
+// Find and remove any duplicate SU-level AU between suLevelDU
+// and forAddRemoveAU lists
+if (mergedUnit_iter == nodeLevelDU.end()) {
+  for (mergedUnit_iter = suLevelDU.begin();
+   mergedUnit_iter != suLevelDU.end(); ++mergedUnit_iter) {
+if ((*addRemoveUnit_iter).name == (*mergedUnit_iter).name) {
+  LOG_NO("[%s] is already present in the merged AU list, "
+ "remove it from forAddRemoveAU list",
+ (*addRemoveUnit_iter).name.c_str());
+  addRemoveUnit_iter = forAddRemoveAU.erase(addRemoveUnit_iter);
+  break;
+}
+  }
+}
+// Find and remove any duplicate comp-level AU between tmpDU
+// and forAddRemoveAU lists
+if (mergedUnit_iter == suLevelDU.end()) {
+  for (mergedUnit_iter = tmpDU.begin();
+   mergedUnit_iter != tmpDU.end(); ++mergedUnit_iter) {
+if ((*addRemoveUnit_iter).name == (*mergedUnit_iter).name) {
+  LOG_NO("[%s] is already present in the merged AU list, "
+ "remove it from forAddRemoveAU list",
+ (*addRemoveUnit_iter).name.c_str());
+  addRemoveUnit_iter = forAddRemoveAU.erase(addRemoveUnit_iter);
+  break;
+}
+  }
+}
+if (mergedUnit_iter == tmpDU.end()) {
   ++addRemoveUnit_iter;
 }
   }
 
   for (addRemoveUnit_iter = forAddRemoveDU.begin();
addRemoveUnit_iter != forAddRemoveDU.end();) {
-for (nodeLevel_iter = nodeLevelDU.begin();
- nodeLevel_iter != nodeLevelDU.end(); ++nodeLevel_iter) {
-  if ((*addRemoveUnit_iter).name == (*nodeLevel_iter).name) {
+for (mergedUnit_iter = nodeLevelDU.begin();
+ mergedUnit_iter != nodeLevelDU.end(); ++mergedUnit_iter) {
+  if ((*addRemoveUnit_iter).name == (*mergedUnit_iter).name) {
 // if item is already presented in nodeLevelDU, erase it from the
 // forAddRemove list
 LOG_NO(
-"[%s] is already presented in the merged DU list, remove it from 
forAddRemoveDU list",
+"[%s] is already present in the merged DU list, "
+"remove it from forAddRemoveDU list",
 (*addRemoveUnit_iter).name.c_str());
 addRemoveUnit_iter = forAddRemoveDU.erase(addRemoveUnit_iter);

[devel] [PATCH 0/1] Review Request for smfd: Remove duplicate DU, AU on SU or comp level in one-step upgrade V2 [#2227]

2018-05-07 Thread Nguyen Luu
Summary: smfd: Remove duplicate DU/AU on SU/comp level in one-step upgrade 
[#2227]
Review request for Ticket(s): 2227
Peer Reviewer(s): Lennart Lund, Syam Prasad Talluri
Pull request to: Lennart Lund
Affected branch(es): develop
Development branch: ticket-2227
Base revision: c44d5c9f076bdfbc9bd5fded69bcbb30e65d0f14
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
revision dae399f6d30c7cac041282d8d3c5510838fdc3cd
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Tue, 8 May 2018 08:57:12 +0700

smfd: Remove duplicate DU/AU on SU/comp level in one-step upgrade [#2227]

This fix extends the previous one of #2209 which was on node level.
In particular, it is to eliminate any duplicate DU/AU on SU or component
level when merging forAddRemove and forModify/rolling procedures into a
single-step procedure for one-step upgrade execution mode.



Complete diffstat:
--
 src/smf/smfd/SmfUpgradeProcedure.cc | 83 +++--
 1 file changed, 71 insertions(+), 12 deletions(-)


Testing Commands:
-
1. Install the AmfDemo sample app on PL-3, PL-4.
(could use the campaign_install_amfdemo.xml attached in the ticket;
amf_demo binary and clc script can be built and got from opensaf samples dir)
2. Run either or both of the attached campaign_one_step_<su|comp>_level.xml
in one-step upgrade execution mode.


Testing, Expected Results:
--
- The one-step upgrade should complete successfully.
(verify that the AmfDemo model changes designated in the campaign have actually
taken effect)
- Another way to examine the result is to search for the upgrade runtime objects
safSmf<Du|Au>=...,safSmfCampaign=...,safApp=safSmfService (before committing the
upgrade campaign) and to look at the corresponding attributes 
saSmf<Du|Au>ActedOn
=> No duplicate DU/AU should be found.
(Without the fix, duplicate SU or component DU/AU would result)


Conditions of Submission:
-
Ack from the reviewers.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results

[devel] [PATCH 0/1] Review Request for smfd: Remove duplicate DU, AU on SU or comp level in one-step upgrade [#2227]

2018-05-02 Thread Nguyen Luu
Summary: smfd: Remove duplicate DU/AU on SU/comp level in one-step upgrade 
[#2227]
Review request for Ticket(s): 2227
Peer Reviewer(s): Lennart Lund, Syam Prasad Talluri 
Pull request to: Lennart Lund
Affected branch(es): develop
Development branch: ticket-2227
Base revision: 46181161a4b4afbf1f269d601914951da97265ef
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
revision 99484e9ba2fce28b997cfd6a0af571c99c876804
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Thu, 3 May 2018 09:47:12 +0700

smfd: Remove duplicate DU/AU on SU/comp level in one-step upgrade [#2227]

This fix extends the previous one of #2209 which was on node level.
In particular, it is to eliminate any duplicate DU/AU on SU or component
level when merging forAddRemove and forModify/rolling procedures into a
single-step procedure for one-step upgrade execution mode.
The fix also corrects return value handling of 
SmfImmUtils::callAdminOperation().



Complete diffstat:
--
 src/smf/smfd/SmfUpgradeProcedure.cc | 83 +++--
 src/smf/smfd/SmfUtils.cc| 11 +++--
 2 files changed, 78 insertions(+), 16 deletions(-)


Testing Commands:
-
1. Install the AmfDemo app on PL-3, PL-4.
(could use the campaign_install_amfdemo.xml attached in the ticket;
amf_demo binary and clc script can be built and got from opensaf samples dir)
2. Run either or both of the attached campaign_one_step_<su|comp>_level.xml
in one-step upgrade execution mode. 


Testing, Expected Results:
--
- The one-step upgrade should complete successfully.
(verify that the AmfDemo model changes designated in the campaign have actually
taken effect)
- Another way to examine the result is to search for the upgrade runtime objects
safSmf<Du|Au>=...,safSmfCampaign=...,safApp=safSmfService (before committing the
upgrade campaign) and to look at the corresponding attributes 
saSmf<Du|Au>ActedOn
=> No duplicate DU/AU should be found.
(Without the fix, duplicate SU or component DU/AU would result)


Conditions of Submission:
-
Ack from the reviewers.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badl

[devel] [PATCH 1/1] smfd: Remove duplicate DU/AU on SU/comp level in one-step upgrade [#2227]

2018-05-02 Thread Nguyen Luu
This fix extends the previous one of #2209 which was on node level.
In particular, it is to eliminate any duplicate DU/AU on SU or component
level when merging forAddRemove and forModify/rolling procedures into a
single-step procedure for one-step upgrade execution mode.
The fix also corrects return value handling of 
SmfImmUtils::callAdminOperation().
---
 src/smf/smfd/SmfUpgradeProcedure.cc | 83 +++--
 src/smf/smfd/SmfUtils.cc| 11 +++--
 2 files changed, 78 insertions(+), 16 deletions(-)

diff --git a/src/smf/smfd/SmfUpgradeProcedure.cc 
b/src/smf/smfd/SmfUpgradeProcedure.cc
index 2937c70..8d527d3 100644
--- a/src/smf/smfd/SmfUpgradeProcedure.cc
+++ b/src/smf/smfd/SmfUpgradeProcedure.cc
@@ -1,6 +1,7 @@
 /*
  *
  * (C) Copyright 2009 The OpenSAF Foundation
+ * Copyright (C) 2018 Ericsson AB. All Rights Reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -1359,7 +1360,7 @@ bool 
SmfUpgradeProcedure::mergeStepIntoSingleStep(SmfUpgradeProcedure *i_proc,
   for (unit_iter = tmpDU.begin(); unit_iter != tmpDU.end();) {
 if ((*unit_iter).name.find("safSu=") == 0) {  // DU is a SU
   suLevelDU.push_back(
-  *unit_iter);  // A node will never be optimized away, save it
+  *unit_iter);
   unit_iter = tmpDU.erase(unit_iter);  // Remove the SU and update iterator
 } else {
   ++unit_iter;
@@ -1388,41 +1389,99 @@ bool 
SmfUpgradeProcedure::mergeStepIntoSingleStep(SmfUpgradeProcedure *i_proc,
   // because there is a chance that Su/comp can be removed if they are in the
   // scope of the node/Su.
 
-  std::list::iterator addRemoveUnit_iter, nodeLevel_iter;
+  std::list::iterator addRemoveUnit_iter, mergedUnit_iter;
   for (addRemoveUnit_iter = forAddRemoveAU.begin();
addRemoveUnit_iter != forAddRemoveAU.end();) {
-for (nodeLevel_iter = nodeLevelDU.begin();
- nodeLevel_iter != nodeLevelDU.end(); ++nodeLevel_iter) {
-  if ((*addRemoveUnit_iter).name == (*nodeLevel_iter).name) {
+for (mergedUnit_iter = nodeLevelDU.begin();
+ mergedUnit_iter != nodeLevelDU.end(); ++mergedUnit_iter) {
+  if ((*addRemoveUnit_iter).name == (*mergedUnit_iter).name) {
 // if item is already presented in nodeLevelDU, erase it from the
 // forAddRemove list
 LOG_NO(
-"[%s] is already presented in the merged DU list, remove it from 
forAddRemoveAU list",
+"[%s] is already present in the merged AU list, "
+"remove it from forAddRemoveAU list",
 (*addRemoveUnit_iter).name.c_str());
 addRemoveUnit_iter = forAddRemoveAU.erase(addRemoveUnit_iter);
 break;
   }
 }
-if (nodeLevel_iter == nodeLevelDU.end()) {
+// Find and remove any duplicate SU-level AU between suLevelDU
+// and forAddRemoveAU lists
+if (mergedUnit_iter == nodeLevelDU.end()) {
+  for (mergedUnit_iter = suLevelDU.begin();
+   mergedUnit_iter != suLevelDU.end(); ++mergedUnit_iter) {
+if ((*addRemoveUnit_iter).name == (*mergedUnit_iter).name) {
+  LOG_NO("[%s] is already present in the merged AU list, "
+ "remove it from forAddRemoveAU list",
+ (*addRemoveUnit_iter).name.c_str());
+  addRemoveUnit_iter = forAddRemoveAU.erase(addRemoveUnit_iter);
+  break;
+}
+  }
+}
+// Find and remove any duplicate comp-level AU between tmpDU
+// and forAddRemoveAU lists
+if (mergedUnit_iter == suLevelDU.end()) {
+  for (mergedUnit_iter = tmpDU.begin();
+   mergedUnit_iter != tmpDU.end(); ++mergedUnit_iter) {
+if ((*addRemoveUnit_iter).name == (*mergedUnit_iter).name) {
+  LOG_NO("[%s] is already present in the merged AU list, "
+ "remove it from forAddRemoveAU list",
+ (*addRemoveUnit_iter).name.c_str());
+  addRemoveUnit_iter = forAddRemoveAU.erase(addRemoveUnit_iter);
+  break;
+}
+  }
+}
+if (mergedUnit_iter == tmpDU.end()) {
   ++addRemoveUnit_iter;
 }
   }
 
   for (addRemoveUnit_iter = forAddRemoveDU.begin();
addRemoveUnit_iter != forAddRemoveDU.end();) {
-for (nodeLevel_iter = nodeLevelDU.begin();
- nodeLevel_iter != nodeLevelDU.end(); ++nodeLevel_iter) {
-  if ((*addRemoveUnit_iter).name == (*nodeLevel_iter).name) {
+for (mergedUnit_iter = nodeLevelDU.begin();
+ mergedUnit_iter != nodeLevelDU.end(); ++mergedUnit_iter) {
+  if ((*addRemoveUnit_iter).name == (*mergedUnit_iter).name) {
 // if item is already presented in nodeLevelDU, erase it from the
 // forAddRemove list
 LOG_NO(
-"[%s] is already presented in the merged DU list, remove it from 
forAddRemoveDU list",
+"[%s] is already present in the merged DU list, "
+"remove it from forAddRemoveDU 

Re: [devel] [PATCH 1/1] smfd: Fix incorrect handling of SMFND NCSMDS_UP/DOWN events [#2821]

2018-04-08 Thread Nguyen Luu

Hi,

I intend to push this patch by the end of today if there are no more 
comments.


Thanks,
Nguyen

On 4/6/2018 10:54 AM, Nguyen Luu wrote:

Hi Lennart,

Thank you for your comment.

You suggested that the changed files be reformatted following Google 
Coding Style (i.e space-indented); but according to OpenSAF Coding 
Rules <https://sourceforge.net/p/opensaf/wiki/Coding%20Rules/>, C code 
shall follow Linux kernel Coding Style (i.e tab-indented).
It seems that the old code line used mixed tabs and spaces, so that's 
probably why you see my new code line as incorrectly indented. I used 
'tabs' actually.


Can you check again and confirm the coding style?

Thanks,
Nguyen

On 4/5/2018 8:38 PM, Lennart Lund wrote:

Hi Nguyen,

Ack with comments. See below [Lennart]

Thanks
Lennart


-Original Message-
From: Nguyen Luu [mailto:nguyen.tk@dektech.com.au]
Sent: den 28 mars 2018 10:08
To: Lennart Lund <lennart.l...@ericsson.com>; vijay@oracle.com
Cc: opensaf-devel@lists.sourceforge.net; Nguyen Tran Khoi Luu
<nguyen.tk@dektech.com.au>
Subject: [PATCH 1/1] smfd: Fix incorrect handling of SMFND
NCSMDS_UP/DOWN events [#2821]

Current handling of SMFND DOWN event does not take into account failed
SMFND UP event, which could eventually result in an inexact view of the
actual number of SMFND nodes in the cluster if, for example, a node
happened to be DOWN and UP twice, and the first UP event somehow
failed.
---
  src/smf/smfd/smfd_evt.c   | 7 ---
  src/smf/smfd/smfd_smfnd.c | 9 +
  2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/smf/smfd/smfd_evt.c b/src/smf/smfd/smfd_evt.c
index 32f83fd..6f60c13 100644
--- a/src/smf/smfd/smfd_evt.c
+++ b/src/smf/smfd/smfd_evt.c
@@ -1,6 +1,7 @@
  /*  -*- OpenSAF  -*-
   *
   * (C) Copyright 2008 The OpenSAF Foundation
+ * Copyright (C) 2018 Ericsson AB. All Rights Reserved.
   *
   * This program is distributed in the hope that it will be useful, 
but

   * WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY
@@ -86,7 +87,7 @@ static void proc_mds_info(smfd_cb_t *cb, SMFSV_EVT
*evt)

  if (mds_info->svc_id == NCSMDS_SVC_ID_SMFND) {
  if (smfnd_up(mds_info->node_id, mds_info->dest,
- mds_info->rem_svc_pvt_ver) ==
SA_AIS_OK)
[Lennart] Format: The following line has incorrect indentation and is 
probably too long. It is Ok to reformat this file according to Google 
style guide

+    mds_info-

rem_svc_pvt_ver) == NCSCC_RC_SUCCESS)

  cb->no_of_smfnd++;
  else
  LOG_WA("%s: SMFND UP failed",
__FUNCTION__);
@@ -100,8 +101,8 @@ static void proc_mds_info(smfd_cb_t *cb,
SMFSV_EVT *evt)
  }

  if (mds_info->svc_id == NCSMDS_SVC_ID_SMFND) {
-    smfnd_down(mds_info->node_id);
-    cb->no_of_smfnd--;
+    if (smfnd_down(mds_info->node_id) ==
NCSCC_RC_SUCCESS)
+    cb->no_of_smfnd--;
  }
  break;

diff --git a/src/smf/smfd/smfd_smfnd.c b/src/smf/smfd/smfd_smfnd.c
index c48adb2..5a64507 100644
--- a/src/smf/smfd/smfd_smfnd.c
+++ b/src/smf/smfd/smfd_smfnd.c
@@ -1,6 +1,7 @@
  /*  OpenSAF
   *
   * (C) Copyright 2008 The OpenSAF Foundation
+ * Copyright (C) 2018 Ericsson AB. All Rights Reserved.
   *
   * This program is distributed in the hope that it will be useful, 
but

   * WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY
@@ -212,6 +213,14 @@ uint32_t smfnd_down(SaClmNodeIdT i_node_id)
  /* Update the node info */
  while (smfnd != NULL) {
  if (smfnd->clmInfo.nodeId == i_node_id) {
+    /* Check if the node state was already Down,
+ * probably due to previous failed SMFND UP event
+ */
+    if (smfnd->nd_state == ndDown) {
[Lennart] Formatting: The following line is too long. It is Ok to 
reformat this file to follow Google style guide

+    TRACE("SMFND node state was already
Down. No update needed");
+    pthread_mutex_unlock(_list_lock);
+    return NCSCC_RC_FAILURE;
+    }
  /* Store the nd state */
  TRACE(
  "SMFND state updated for node [%s], id [%x]",
--
2.7.4


-- 


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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel



--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
___
Opensaf-

Re: [devel] [PATCH 1/1] smfd: Fix incorrect handling of SMFND NCSMDS_UP/DOWN events [#2821]

2018-04-05 Thread Nguyen Luu

Hi Lennart,

Thank you for your comment.

You suggested that the changed files be reformatted following Google 
Coding Style (i.e space-indented); but according to OpenSAF Coding Rules 
<https://sourceforge.net/p/opensaf/wiki/Coding%20Rules/>, C code shall 
follow Linux kernel Coding Style (i.e tab-indented).
It seems that the old code line used mixed tabs and spaces, so that's 
probably why you see my new code line as incorrectly indented. I used 
'tabs' actually.


Can you check again and confirm the coding style?

Thanks,
Nguyen

On 4/5/2018 8:38 PM, Lennart Lund wrote:

Hi Nguyen,

Ack with comments. See below [Lennart]

Thanks
Lennart


-Original Message-
From: Nguyen Luu [mailto:nguyen.tk@dektech.com.au]
Sent: den 28 mars 2018 10:08
To: Lennart Lund <lennart.l...@ericsson.com>; vijay@oracle.com
Cc: opensaf-devel@lists.sourceforge.net; Nguyen Tran Khoi Luu
<nguyen.tk@dektech.com.au>
Subject: [PATCH 1/1] smfd: Fix incorrect handling of SMFND
NCSMDS_UP/DOWN events [#2821]

Current handling of SMFND DOWN event does not take into account failed
SMFND UP event, which could eventually result in an inexact view of the
actual number of SMFND nodes in the cluster if, for example, a node
happened to be DOWN and UP twice, and the first UP event somehow
failed.
---
  src/smf/smfd/smfd_evt.c   | 7 ---
  src/smf/smfd/smfd_smfnd.c | 9 +
  2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/smf/smfd/smfd_evt.c b/src/smf/smfd/smfd_evt.c
index 32f83fd..6f60c13 100644
--- a/src/smf/smfd/smfd_evt.c
+++ b/src/smf/smfd/smfd_evt.c
@@ -1,6 +1,7 @@
  /*  -*- OpenSAF  -*-
   *
   * (C) Copyright 2008 The OpenSAF Foundation
+ * Copyright (C) 2018 Ericsson AB. All Rights Reserved.
   *
   * This program is distributed in the hope that it will be useful, but
   * WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY
@@ -86,7 +87,7 @@ static void proc_mds_info(smfd_cb_t *cb, SMFSV_EVT
*evt)

if (mds_info->svc_id == NCSMDS_SVC_ID_SMFND) {
if (smfnd_up(mds_info->node_id, mds_info->dest,
-mds_info->rem_svc_pvt_ver) ==
SA_AIS_OK)

[Lennart] Format: The following line has incorrect indentation and is probably 
too long. It is Ok to reformat this file according to Google style guide

+   mds_info-

rem_svc_pvt_ver) == NCSCC_RC_SUCCESS)

cb->no_of_smfnd++;
else
LOG_WA("%s: SMFND UP failed",
__FUNCTION__);
@@ -100,8 +101,8 @@ static void proc_mds_info(smfd_cb_t *cb,
SMFSV_EVT *evt)
}

if (mds_info->svc_id == NCSMDS_SVC_ID_SMFND) {
-   smfnd_down(mds_info->node_id);
-   cb->no_of_smfnd--;
+   if (smfnd_down(mds_info->node_id) ==
NCSCC_RC_SUCCESS)
+   cb->no_of_smfnd--;
}
break;

diff --git a/src/smf/smfd/smfd_smfnd.c b/src/smf/smfd/smfd_smfnd.c
index c48adb2..5a64507 100644
--- a/src/smf/smfd/smfd_smfnd.c
+++ b/src/smf/smfd/smfd_smfnd.c
@@ -1,6 +1,7 @@
  /*  OpenSAF
   *
   * (C) Copyright 2008 The OpenSAF Foundation
+ * Copyright (C) 2018 Ericsson AB. All Rights Reserved.
   *
   * This program is distributed in the hope that it will be useful, but
   * WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY
@@ -212,6 +213,14 @@ uint32_t smfnd_down(SaClmNodeIdT i_node_id)
/* Update the node info */
while (smfnd != NULL) {
if (smfnd->clmInfo.nodeId == i_node_id) {
+   /* Check if the node state was already Down,
+* probably due to previous failed SMFND UP event
+*/
+   if (smfnd->nd_state == ndDown) {

[Lennart] Formatting: The following line is too long. It is Ok to reformat this 
file to follow Google style guide

+   TRACE("SMFND node state was already
Down. No update needed");
+   pthread_mutex_unlock(_list_lock);
+   return NCSCC_RC_FAILURE;
+   }
/* Store the nd state */
TRACE(
"SMFND state updated for node [%s], id [%x]",
--
2.7.4


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


Re: [devel] [PATCH 1/1] smfd: Fix incorrect handling of SMFND NCSMDS_UP/DOWN events [#2821]

2018-04-04 Thread Nguyen Luu

Hi Lennart, Vijay,

Please help me review this patch whenever possible for you.

Thanks,
Nguyen

On 3/28/2018 3:07 PM, Nguyen Luu wrote:

Current handling of SMFND DOWN event does not take into account failed
SMFND UP event, which could eventually result in an inexact view of the
actual number of SMFND nodes in the cluster if, for example, a node
happened to be DOWN and UP twice, and the first UP event somehow failed.
---
  src/smf/smfd/smfd_evt.c   | 7 ---
  src/smf/smfd/smfd_smfnd.c | 9 +
  2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/smf/smfd/smfd_evt.c b/src/smf/smfd/smfd_evt.c
index 32f83fd..6f60c13 100644
--- a/src/smf/smfd/smfd_evt.c
+++ b/src/smf/smfd/smfd_evt.c
@@ -1,6 +1,7 @@
  /*  -*- OpenSAF  -*-
   *
   * (C) Copyright 2008 The OpenSAF Foundation
+ * Copyright (C) 2018 Ericsson AB. All Rights Reserved.
   *
   * This program is distributed in the hope that it will be useful, but
   * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -86,7 +87,7 @@ static void proc_mds_info(smfd_cb_t *cb, SMFSV_EVT *evt)
  
  		if (mds_info->svc_id == NCSMDS_SVC_ID_SMFND) {

if (smfnd_up(mds_info->node_id, mds_info->dest,
-mds_info->rem_svc_pvt_ver) == SA_AIS_OK)
+   mds_info->rem_svc_pvt_ver) == 
NCSCC_RC_SUCCESS)
cb->no_of_smfnd++;
else
LOG_WA("%s: SMFND UP failed", __FUNCTION__);
@@ -100,8 +101,8 @@ static void proc_mds_info(smfd_cb_t *cb, SMFSV_EVT *evt)
}
  
  		if (mds_info->svc_id == NCSMDS_SVC_ID_SMFND) {

-   smfnd_down(mds_info->node_id);
-   cb->no_of_smfnd--;
+   if (smfnd_down(mds_info->node_id) == NCSCC_RC_SUCCESS)
+   cb->no_of_smfnd--;
}
break;
  
diff --git a/src/smf/smfd/smfd_smfnd.c b/src/smf/smfd/smfd_smfnd.c

index c48adb2..5a64507 100644
--- a/src/smf/smfd/smfd_smfnd.c
+++ b/src/smf/smfd/smfd_smfnd.c
@@ -1,6 +1,7 @@
  /*  OpenSAF
   *
   * (C) Copyright 2008 The OpenSAF Foundation
+ * Copyright (C) 2018 Ericsson AB. All Rights Reserved.
   *
   * This program is distributed in the hope that it will be useful, but
   * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -212,6 +213,14 @@ uint32_t smfnd_down(SaClmNodeIdT i_node_id)
/* Update the node info */
while (smfnd != NULL) {
if (smfnd->clmInfo.nodeId == i_node_id) {
+   /* Check if the node state was already Down,
+* probably due to previous failed SMFND UP event
+*/
+   if (smfnd->nd_state == ndDown) {
+   TRACE("SMFND node state was already Down. No update 
needed");
+   pthread_mutex_unlock(_list_lock);
+   return NCSCC_RC_FAILURE;
+   }
/* Store the nd state */
TRACE(
"SMFND state updated for node [%s], id [%x]",



--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 1/1] smfd: Fix incorrect handling of SMFND NCSMDS_UP/DOWN events [#2821]

2018-03-28 Thread Nguyen Luu
Current handling of SMFND DOWN event does not take into account failed
SMFND UP event, which could eventually result in an inexact view of the
actual number of SMFND nodes in the cluster if, for example, a node
happened to be DOWN and UP twice, and the first UP event somehow failed.
---
 src/smf/smfd/smfd_evt.c   | 7 ---
 src/smf/smfd/smfd_smfnd.c | 9 +
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/smf/smfd/smfd_evt.c b/src/smf/smfd/smfd_evt.c
index 32f83fd..6f60c13 100644
--- a/src/smf/smfd/smfd_evt.c
+++ b/src/smf/smfd/smfd_evt.c
@@ -1,6 +1,7 @@
 /*  -*- OpenSAF  -*-
  *
  * (C) Copyright 2008 The OpenSAF Foundation
+ * Copyright (C) 2018 Ericsson AB. All Rights Reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -86,7 +87,7 @@ static void proc_mds_info(smfd_cb_t *cb, SMFSV_EVT *evt)
 
if (mds_info->svc_id == NCSMDS_SVC_ID_SMFND) {
if (smfnd_up(mds_info->node_id, mds_info->dest,
-mds_info->rem_svc_pvt_ver) == SA_AIS_OK)
+   mds_info->rem_svc_pvt_ver) == 
NCSCC_RC_SUCCESS)
cb->no_of_smfnd++;
else
LOG_WA("%s: SMFND UP failed", __FUNCTION__);
@@ -100,8 +101,8 @@ static void proc_mds_info(smfd_cb_t *cb, SMFSV_EVT *evt)
}
 
if (mds_info->svc_id == NCSMDS_SVC_ID_SMFND) {
-   smfnd_down(mds_info->node_id);
-   cb->no_of_smfnd--;
+   if (smfnd_down(mds_info->node_id) == NCSCC_RC_SUCCESS)
+   cb->no_of_smfnd--;
}
break;
 
diff --git a/src/smf/smfd/smfd_smfnd.c b/src/smf/smfd/smfd_smfnd.c
index c48adb2..5a64507 100644
--- a/src/smf/smfd/smfd_smfnd.c
+++ b/src/smf/smfd/smfd_smfnd.c
@@ -1,6 +1,7 @@
 /*  OpenSAF
  *
  * (C) Copyright 2008 The OpenSAF Foundation
+ * Copyright (C) 2018 Ericsson AB. All Rights Reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -212,6 +213,14 @@ uint32_t smfnd_down(SaClmNodeIdT i_node_id)
/* Update the node info */
while (smfnd != NULL) {
if (smfnd->clmInfo.nodeId == i_node_id) {
+   /* Check if the node state was already Down,
+* probably due to previous failed SMFND UP event
+*/
+   if (smfnd->nd_state == ndDown) {
+   TRACE("SMFND node state was already Down. No 
update needed");
+   pthread_mutex_unlock(_list_lock);
+   return NCSCC_RC_FAILURE;
+   }
/* Store the nd state */
TRACE(
"SMFND state updated for node [%s], id [%x]",
-- 
2.7.4


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


Re: [devel] [PATCH 1/1] amfa: Fix api internal check to avoid fatal mutex unlock [#2548]

2018-03-11 Thread Nguyen Luu

Hi Hans,

Thanks for reviewing the patch. I've made the necessary changes based on 
your comments before having the patch pushed.


Regards,
Nguyen

On 3/9/2018 4:58 PM, Hans Nordebäck wrote:

ack, review only. Some comments below marked with [HansN].

/Thanks HansN


On 03/06/2018 07:39 AM, Nguyen Luu wrote:

Current check for the required setting of the SA_AMF_COMPONENT_NAME
env variable in some amf api's (ComponentRegister, QuiescingComplete)
would crash the invoking process if that env variable was missed
to be set for some reason, as the agent lib tries, during cleanup,
to unlock a mutex which it has not previously locked yet.
---
  src/amf/agent/amf_agent.cc | 51 
--

  1 file changed, 31 insertions(+), 20 deletions(-)

diff --git a/src/amf/agent/amf_agent.cc b/src/amf/agent/amf_agent.cc
index f0ed7a8..a162af1 100644
--- a/src/amf/agent/amf_agent.cc
+++ b/src/amf/agent/amf_agent.cc
@@ -2,6 +2,7 @@
   *
   * (C) Copyright 2008 The OpenSAF Foundation
   * Copyright (C) 2017, Oracle and/or its affiliates. All rights 
reserved.

+ * Copyright (C) 2018 Ericsson AB. All Rights Reserved.
   *
   * This program is distributed in the hope that it will be useful, but
   * WITHOUT ANY WARRANTY; without even the implied warranty of 
MERCHANTABILITY

@@ -13,6 +14,7 @@
   * licensing terms.
   *
   * Author(s): Emerson Network Power
+ *    Ericsson
   *
   */
  @@ -272,7 +274,7 @@ SaAisErrorT AmfAgent::Dispatch(SaAmfHandleT 
hdl, SaDispatchFlagsT flags) {

  rc = SA_AIS_ERR_LIBRARY;
  goto done;
    }
-  /* acquire cb read lock */
+  /* acquire cb write lock */
    m_NCS_LOCK(>lock, NCS_LOCK_WRITE);
    /* retrieve hdl rec */
    if (!(hdl_rec = (AVA_HDL_REC *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, 
hdl))) {
@@ -293,7 +295,7 @@ SaAisErrorT AmfAgent::Dispatch(SaAmfHandleT hdl, 
SaDispatchFlagsT flags) {

    pend_fin = cb->pend_fin;
    done:
-  /* release cb read lock and return handles */
+  /* release cb write lock and return handles */
    if (cb) {
  m_NCS_UNLOCK(>lock, NCS_LOCK_WRITE);
  ncshm_give_hdl(gl_ava_hdl);
@@ -356,7 +358,7 @@ SaAisErrorT AmfAgent::Finalize(SaAmfHandleT hdl) {
  uninstall_osafAmfSCStatusChangeCallback();
    }
  -  /* acquire cb read lock */
+  /* acquire cb write lock */
    m_NCS_LOCK(>lock, NCS_LOCK_WRITE);
      /* retrieve hdl rec */
@@ -394,7 +396,7 @@ SaAisErrorT AmfAgent::Finalize(SaAmfHandleT hdl) {
  cb->pend_fin++;
    done:
-  /* release cb read lock and return handles */
+  /* release cb read write and return handles */
    if (cb) {
  m_NCS_UNLOCK(>lock, NCS_LOCK_WRITE);
  ncshm_give_hdl(gl_ava_hdl);
@@ -457,8 +459,7 @@ SaAisErrorT 
AmfAgent::ComponentRegister(SaAmfHandleT hdl,

  goto done;
    }
    /* retrieve AvA CB */
-  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, 
gl_ava_hdl)) ||

-  !m_AVA_FLAG_IS_COMP_NAME(cb)) {
+  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, 
gl_ava_hdl))) {
[HansN] the agent is c++, so use if (!(cb = static_cast*>(ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl {

  TRACE_4("SA_AIS_ERR_LIBRARY: Unable to retrieve cb handle");
  rc = SA_AIS_ERR_LIBRARY;
  goto done;
@@ -627,8 +628,7 @@ SaAisErrorT 
AmfAgent::ComponentUnregister(SaAmfHandleT hdl,

  goto done;
    }
    /* retrieve AvA CB */
-  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, 
gl_ava_hdl)) ||

-  !m_AVA_FLAG_IS_COMP_NAME(cb)) {
+  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, 
gl_ava_hdl))) {
[HansN] if (!(cb = static_cast*>(ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl {

  TRACE_4("SA_AIS_ERR_LIBRARY: Unable to retrieve cb handle");
  rc = SA_AIS_ERR_LIBRARY;
  goto done;
@@ -636,6 +636,13 @@ SaAisErrorT 
AmfAgent::ComponentUnregister(SaAmfHandleT hdl,

      /* acquire cb read lock */
    m_NCS_LOCK(>lock, NCS_LOCK_READ);
+
+  if (!m_AVA_FLAG_IS_COMP_NAME(cb)) {
+    TRACE_2("The SA_AMF_COMPONENT_NAME environment variable is NULL");
+    rc = SA_AIS_ERR_LIBRARY;
+    goto done;
+  }
+
    /* Version is previously set in in initialize function */
    if (ava_B4_ver_used(cb)) {
  TRACE_2("Invalid AMF version, B 4.1");
@@ -1373,14 +1380,20 @@ SaAisErrorT 
AmfAgent::CSIQuiescingComplete(SaAmfHandleT hdl, SaInvocationT inv,

  goto done;
    }
    /* retrieve AvA CB */
-  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, 
gl_ava_hdl)) ||

-  !m_AVA_FLAG_IS_COMP_NAME(cb)) {
+  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, 
gl_ava_hdl))) {

  TRACE_4("SA_AIS_ERR_LIBRARY: Unable to retrieve cb handle");
  rc = SA_AIS_ERR_LIBRARY;
  goto done;
    }
    /* acquire cb read lock */
    m_NCS_LOCK(>lock, NCS_LOCK_READ);
+
+  if (!m_AVA_FLAG_IS_COMP_NAME(cb)) {
+    TRACE_2("The SA_AMF_COMPONENT_NAME environment variable is NULL");
+    rc = SA_AIS_ERR_LIBRARY;
+    goto done;
+  }
+
    /* retr

Re: [devel] [PATCH 1/1] pyosaf: Refactor NTF samples to make use of new pyosaf utils [#2707]

2018-03-05 Thread Nguyen Luu

Hi Hans,

Please help me review this patch whenever possible for you. It has been 
on review for months.


Thanks,
Nguyen

On 12/20/2017 3:31 PM, Nguyen Luu wrote:

- Refactor the ntfsend and ntfsubscribe python samples to make use of
   the new pyosaf utils implementation of enhancement ticket #2602.
- Add a new ntfread sample to demonstrate usage of the new NtfReader
   utils.
---
  python/samples/ntfread  | 411 
  python/samples/ntfsend  | 922 
  python/samples/ntfsubscribe | 795 --
  3 files changed, 1591 insertions(+), 537 deletions(-)
  create mode 100755 python/samples/ntfread
  mode change 100644 => 100755 python/samples/ntfsend
  mode change 100644 => 100755 python/samples/ntfsubscribe

diff --git a/python/samples/ntfread b/python/samples/ntfread
new file mode 100755
index 000..a70552b
--- /dev/null
+++ b/python/samples/ntfread
@@ -0,0 +1,411 @@
+#! /usr/bin/env python
+
+#
+# (C) Copyright 2017 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson
+#
+
+# pylint: disable=unused-argument
+"""
+ntfread tool used to read alarm and/or security alarm notifications from NTF
+
+Run ntfread --help/-h for more detail on usage
+"""
+from __future__ import print_function
+import sys
+import argparse
+from datetime import datetime, tzinfo, timedelta
+
+from pyosaf import saNtf
+from pyosaf.saAis import eSaAisErrorT
+from pyosaf.utils.ntf.reader import NtfReader
+
+
+class UTCOffsetTZ(tzinfo):
+""" Time zone represented as UTC hour-offset """
+def __init__(self, hour_offset):
+""" UTCOffsetTZ constructor """
+self._hour_offset = hour_offset
+super(UTCOffsetTZ, self).__init__()
+
+def utcoffset(self, dt):
+""" Return offset of local time from UTC, in minutes east of UTC """
+return timedelta(hours=self._hour_offset)
+
+def dst(self, dt):
+""" Return the daylight saving time (DST) adjustment, in minutes east
+of UTC, or None if DST information isn't known
+"""
+return timedelta(0)
+
+def tzname(self, dt):
+""" Return the time zone name represented in UTC hour-offset format as
+'UTC+/-offset'
+"""
+if self._hour_offset > 0:
+tzname = "UTC+%02d:00" % self._hour_offset
+elif self._hour_offset < 0:
+tzname = "UTC-%02d:00" % self._hour_offset
+else:  # hour_offset = 0
+tzname = "UTC"
+
+return tzname
+
+
+def satime_to_readable_datetime(sa_time, format_str=None):
+""" Convert the given SaTimeT time value to readable datetime string
+representation in ISO 8601 format
+
+Args:
+sa_time (SaTimeT): SaTimeT time value
+format_str (str): Format string for datetime output representation
+
+Returns:
+str: Datetime representation in format specified by format_str, or in
+ ISO 8601 format '-MM-DDTHH:MM:SS' if format_str not provided
+"""
+time_sec = sa_time / 10**9  # Convert the time from nsec to sec 10
+
+# Calculate the UTC offset for time zone information
+naive_dt = datetime.fromtimestamp(time_sec)
+utc_offset = (naive_dt - datetime.utcfromtimestamp(time_sec))
+hour_offset = utc_offset.total_seconds() // 3600
+utc_offset_tz = UTCOffsetTZ(hour_offset)
+
+aware_dt = naive_dt.replace(tzinfo=utc_offset_tz)
+
+if format_str is not None:
+return aware_dt.strftime(format_str)
+
+return aware_dt.isoformat(' ')
+
+
+def _validate_ntf_class_id(arg):
+""" Validate the input NtfClassId with format 'VENDOR_ID.MAJOR_ID.MINOR_ID'
+
+Args:
+arg (str): The NtfClassId to validate
+
+Returns:
+SaNtfClassIdT: The validated NtfClassId
+"""
+if arg.count('.') != 2:
+msg = "%r is not in correct format 'VENDOR_ID.MAJOR_ID.MINOR_ID'" % arg
+raise argparse.ArgumentTypeError(msg)
+if not arg.split('.')[0] or not arg.split('.')[1] or not arg.s

[devel] [PATCH 1/1] amfa: Fix api internal check to avoid fatal mutex unlock [#2548]

2018-03-05 Thread Nguyen Luu
Current check for the required setting of the SA_AMF_COMPONENT_NAME
env variable in some amf api's (ComponentRegister, QuiescingComplete)
would crash the invoking process if that env variable was missed
to be set for some reason, as the agent lib tries, during cleanup,
to unlock a mutex which it has not previously locked yet.
---
 src/amf/agent/amf_agent.cc | 51 --
 1 file changed, 31 insertions(+), 20 deletions(-)

diff --git a/src/amf/agent/amf_agent.cc b/src/amf/agent/amf_agent.cc
index f0ed7a8..a162af1 100644
--- a/src/amf/agent/amf_agent.cc
+++ b/src/amf/agent/amf_agent.cc
@@ -2,6 +2,7 @@
  *
  * (C) Copyright 2008 The OpenSAF Foundation
  * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (C) 2018 Ericsson AB. All Rights Reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -13,6 +14,7 @@
  * licensing terms.
  *
  * Author(s): Emerson Network Power
+ *Ericsson
  *
  */
 
@@ -272,7 +274,7 @@ SaAisErrorT AmfAgent::Dispatch(SaAmfHandleT hdl, 
SaDispatchFlagsT flags) {
 rc = SA_AIS_ERR_LIBRARY;
 goto done;
   }
-  /* acquire cb read lock */
+  /* acquire cb write lock */
   m_NCS_LOCK(>lock, NCS_LOCK_WRITE);
   /* retrieve hdl rec */
   if (!(hdl_rec = (AVA_HDL_REC *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, hdl))) {
@@ -293,7 +295,7 @@ SaAisErrorT AmfAgent::Dispatch(SaAmfHandleT hdl, 
SaDispatchFlagsT flags) {
   pend_fin = cb->pend_fin;
 
 done:
-  /* release cb read lock and return handles */
+  /* release cb write lock and return handles */
   if (cb) {
 m_NCS_UNLOCK(>lock, NCS_LOCK_WRITE);
 ncshm_give_hdl(gl_ava_hdl);
@@ -356,7 +358,7 @@ SaAisErrorT AmfAgent::Finalize(SaAmfHandleT hdl) {
 uninstall_osafAmfSCStatusChangeCallback();
   }
 
-  /* acquire cb read lock */
+  /* acquire cb write lock */
   m_NCS_LOCK(>lock, NCS_LOCK_WRITE);
 
   /* retrieve hdl rec */
@@ -394,7 +396,7 @@ SaAisErrorT AmfAgent::Finalize(SaAmfHandleT hdl) {
 cb->pend_fin++;
 
 done:
-  /* release cb read lock and return handles */
+  /* release cb read write and return handles */
   if (cb) {
 m_NCS_UNLOCK(>lock, NCS_LOCK_WRITE);
 ncshm_give_hdl(gl_ava_hdl);
@@ -457,8 +459,7 @@ SaAisErrorT AmfAgent::ComponentRegister(SaAmfHandleT hdl,
 goto done;
   }
   /* retrieve AvA CB */
-  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl)) ||
-  !m_AVA_FLAG_IS_COMP_NAME(cb)) {
+  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl))) {
 TRACE_4("SA_AIS_ERR_LIBRARY: Unable to retrieve cb handle");
 rc = SA_AIS_ERR_LIBRARY;
 goto done;
@@ -627,8 +628,7 @@ SaAisErrorT AmfAgent::ComponentUnregister(SaAmfHandleT hdl,
 goto done;
   }
   /* retrieve AvA CB */
-  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl)) ||
-  !m_AVA_FLAG_IS_COMP_NAME(cb)) {
+  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl))) {
 TRACE_4("SA_AIS_ERR_LIBRARY: Unable to retrieve cb handle");
 rc = SA_AIS_ERR_LIBRARY;
 goto done;
@@ -636,6 +636,13 @@ SaAisErrorT AmfAgent::ComponentUnregister(SaAmfHandleT hdl,
 
   /* acquire cb read lock */
   m_NCS_LOCK(>lock, NCS_LOCK_READ);
+
+  if (!m_AVA_FLAG_IS_COMP_NAME(cb)) {
+TRACE_2("The SA_AMF_COMPONENT_NAME environment variable is NULL");
+rc = SA_AIS_ERR_LIBRARY;
+goto done;
+  }
+
   /* Version is previously set in in initialize function */
   if (ava_B4_ver_used(cb)) {
 TRACE_2("Invalid AMF version, B 4.1");
@@ -1373,14 +1380,20 @@ SaAisErrorT AmfAgent::CSIQuiescingComplete(SaAmfHandleT 
hdl, SaInvocationT inv,
 goto done;
   }
   /* retrieve AvA CB */
-  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl)) ||
-  !m_AVA_FLAG_IS_COMP_NAME(cb)) {
+  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl))) {
 TRACE_4("SA_AIS_ERR_LIBRARY: Unable to retrieve cb handle");
 rc = SA_AIS_ERR_LIBRARY;
 goto done;
   }
   /* acquire cb read lock */
   m_NCS_LOCK(>lock, NCS_LOCK_READ);
+
+  if (!m_AVA_FLAG_IS_COMP_NAME(cb)) {
+TRACE_2("The SA_AMF_COMPONENT_NAME environment variable is NULL");
+rc = SA_AIS_ERR_LIBRARY;
+goto done;
+  }
+
   /* retrieve hdl rec */
   if (!(hdl_rec = (AVA_HDL_REC *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, hdl))) {
 rc = SA_AIS_ERR_BAD_HANDLE;
@@ -1591,7 +1604,7 @@ SaAisErrorT AmfAgent::ProtectionGroupTrack(
 goto done;
   }
   /* acquire cb read lock */
-  m_NCS_LOCK(>lock, NCS_LOCK_WRITE);
+  m_NCS_LOCK(>lock, NCS_LOCK_READ);
   /* retrieve hdl rec */
   if (!(hdl_rec = (AVA_HDL_REC *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, hdl))) {
 rc = SA_AIS_ERR_BAD_HANDLE;
@@ -1702,7 +1715,7 @@ SaAisErrorT AmfAgent::ProtectionGroupTrack(
 done:
   /* release cb read lock and return handles */
   if (cb) {
-m_NCS_UNLOCK(>lock, NCS_LOCK_WRITE);
+m_NCS_UNLOCK(>lock, NCS_LOCK_READ);
 

[devel] [PATCH 0/1] Review Request for amfa: Fix api internal check to avoid fatal mutex unlock [#2548]

2018-03-05 Thread Nguyen Luu
Summary: amfa: Fix api internal check to avoid fatal mutex unlock [#2548]
Review request for Ticket(s): 2548
Peer Reviewer(s): AMF maintainers
Pull request to: Gary Lee, Hans Nordeback
Affected branch(es): develop, release
Development branch: ticket-2548
Base revision: b2ae7671b009e97117bdee3aa21c5242d4d061a9
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
revision cbe183d7927cd53d6928611b91f5fcda5d939eee
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Tue, 6 Mar 2018 13:14:52 +0700

amfa: Fix api internal check to avoid fatal mutex unlock [#2548]

Current check for the required setting of the SA_AMF_COMPONENT_NAME
env variable in some amf api's (ComponentRegister, QuiescingComplete)
would crash the invoking process if that env variable was missed
to be set for some reason, as the agent lib tries, during cleanup,
to unlock a mutex which it has not previously locked yet.



Complete diffstat:
--
 src/amf/agent/amf_agent.cc | 51 --
 1 file changed, 31 insertions(+), 20 deletions(-)


Testing Commands:
-
First call saAmfInitialize, then call saAmfComponentRegister without having
previously set the environment variable SA_AMF_COMPONENT_NAME.


Testing, Expected Results:
--
saAmfComponentRegister should return SA_AIS_ERR_LIBRARY.


Conditions of Submission:
-
Ack from an AMF maintainer.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 1/1] amf: Validate env variable format set in comptype/comp objects [#2409]

2018-02-12 Thread Nguyen Luu
Valid environment variable should have the format 'var=value'.
This validation shall now be done by AMF during CCB operations
on SaAmfCompType (CREATE) and SaAmfComp (CREATE/MODIFY) objects
regarding the saAmfxxxCmdEnv attribute.
---
 src/amf/amfd/comp.cc | 59 +++-
 src/amf/amfd/comp.h  |  2 ++
 src/amf/amfd/comptype.cc | 27 +++---
 3 files changed, 84 insertions(+), 4 deletions(-)

diff --git a/src/amf/amfd/comp.cc b/src/amf/amfd/comp.cc
index 482322d..10fb1c3 100644
--- a/src/amf/amfd/comp.cc
+++ b/src/amf/amfd/comp.cc
@@ -1,7 +1,7 @@
 /*  -*- OpenSAF  -*-
  *
  * (C) Copyright 2008 The OpenSAF Foundation
- * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
+ * (C) Copyright 2017, 2018 Ericsson AB. All rights reserved.
  * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
  *
  * This program is distributed in the hope that it will be useful, but
@@ -328,6 +328,26 @@ done:
   TRACE_LEAVE();
 }
 
+/*
+ * Validate the component CmdEnv attribute
+ *
+ * @param const std::string
+ *
+ * @return bool
+ */
+bool is_cmd_env_valid(const std::string _env_var) {
+  /* following environment variable format is considered as invalid:
+   * - containing 'whitespace'
+   * - having none or more than one '='
+   */
+  if ((cmd_env_var.find_first_of(' ') != std::string::npos) ||
+  (std::count(cmd_env_var.begin(), cmd_env_var.end(), '=') != 1)) {
+return false;
+  }
+
+  return true;
+}
+
 /**
  * Validate configuration attributes for an AMF Comp object
  * @param comp
@@ -339,6 +359,7 @@ static int is_config_valid(const std::string ,
CcbUtilOperationData_t *opdata) {
   SaAisErrorT rc;
   SaNameT aname;
+  unsigned int num_of_cmd_env;
   std::string::size_type pos;
   SaUint32T value;
 
@@ -399,6 +420,27 @@ static int is_config_valid(const std::string ,
 return 0;
   }
 
+  if 
((immutil_getAttrValuesNumber(const_cast("saAmfCompCmdEnv")
+   ,attributes, _of_cmd_env)) == SA_AIS_OK)
+  {
+for (unsigned int i = 0; i < num_of_cmd_env; i++) {
+  std::string cmd_env = immutil_getStringAttr(attributes,
+  "saAmfCompCmdEnv", i);
+
+  if (!is_cmd_env_valid(cmd_env)) {
+report_ccb_validation_error(opdata, "Unknown environment variable"
+" format '%s' for '%s'."
+" Should be 'var=value'",
+cmd_env.c_str(), dn.c_str());
+/* NOTE: We shall only fail the env variable format validation at CCB-
+ * CREATE operation, but not during initial config read, so as to avoid
+ * breaking systems with invalid env variables pre-existing in IMM */
+if (opdata != nullptr)
+  return 0;
+  }
+} // for (...; i < num_of_cmd_env;...)
+  }
+
 #if 0
 if ((comp->comp_info.category == AVSV_COMP_TYPE_SA_AWARE) && 
(comp->comp_info.init_len == 0)) {
 LOG_ER("Sa Aware Component: instantiation command not 
configured");
@@ -1038,6 +1080,21 @@ static SaAisErrorT 
ccb_completed_modify_hdlr(CcbUtilOperationData_t *opdata) {
 opdata, "Modification of saAmfCompCmdEnv failed, nullptr arg");
 goto done;
   }
+  for (unsigned index = 0; index < attribute->attrValuesNumber; index++) {
+std::string mod_comp_env = *(static_cast(attribute->
+  attrValues[index]));
+
+if (!is_cmd_env_valid(mod_comp_env)) {
+  report_ccb_validation_error(opdata, "Modification of saAmfCompCmdEnv"
+  " failed. Unknown environment variable"
+  " format '%s' for '%s'."
+  " Should be 'var=value'",
+  mod_comp_env.c_str(),
+  osaf_extended_name_borrow(>
+objectName));
+  goto done;
+}
+  }
 } else if (!strcmp(attribute->attrName, "saAmfCompInstantiateCmdArgv")) {
   if (value_is_deleted == true) continue;
   char *param_val = *((char **)value);
diff --git a/src/amf/amfd/comp.h b/src/amf/amfd/comp.h
index 1493d71..3544a3a 100644
--- a/src/amf/amfd/comp.h
+++ b/src/amf/amfd/comp.h
@@ -1,6 +1,7 @@
 /*  -*- OpenSAF  -*-
  *
  * (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017, 2018 Ericsson AB. All rights reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -295,4 +296,5 @@ extern SaAisErrorT check_comp_stability(const AVD_COMP *);
 extern AVD_CTCS_TYPE *get_ctcstype(const std::string _name,
const std::string _name);
 extern void 

[devel] [PATCH 0/1] Review Request for amf: validate env variable format set in comptype and comp objects [#2409] V4

2018-02-12 Thread Nguyen Luu
Summary: amf: Validate env variable format set in comptype/comp objects [#2409]
Review request for Ticket(s): 2409
Peer Reviewer(s): AMF maintainers
Pull request to: Gary Lee, Hans Nordeback
Affected branch(es): develop, release
Development branch: ticket-2409
Base revision: e61e96acac6428f53545ad9b6f4203f3032a51c3
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
revision de870ceadd4d59cacbacfad3cfed29b6e5fec615
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Tue, 13 Feb 2018 10:51:49 +0700

amf: Validate env variable format set in comptype/comp objects [#2409]

Valid environment variable should have the format 'var=value'.
This validation shall now be done by AMF during CCB operations
on SaAmfCompType (CREATE) and SaAmfComp (CREATE/MODIFY) objects
regarding the saAmfxxxCmdEnv attribute.


Complete diffstat:
--
 src/amf/amfd/comp.cc | 59 +++-
 src/amf/amfd/comp.h  |  2 ++
 src/amf/amfd/comptype.cc | 27 +++---
 3 files changed, 84 insertions(+), 4 deletions(-)


Testing Commands:
-
1) Create SaAmfCompType/SaAmfComp objects with invalid env variable format
in attributes saAmfCtDefCmdEnv/saAmfCompCmdEnv (e.g 'var = value', 
'var==value').
2) Modify attribute saAmfCompCmdEnv of SaAmfComp object with invalid env
variable format.


Testing, Expected Results:
--
AMFD will reject CREATE/MODIFY CCBs with invalid env variable format.


Conditions of Submission:
-
Ack from an AMF maintainer.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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 li

Re: [devel] [PATCH 1/1] amf: validate env variable format set in comptype/comp objects [#2409]

2018-02-08 Thread Nguyen Luu

Hi Gary,

Thank you for your comments. Please see my corresponding answers below, 
marked with [Nguyen].


Thanks,
Nguyen

On 2/7/2018 11:30 AM, Gary Lee wrote:

Hi Nguyen

Some comments below marked with [GL].

Thanks
Gary

On 6/2/18, 6:35 pm, "Nguyen Luu" <nguyen.tk@dektech.com.au> wrote:

 Valid environment variable should have the format 'var=value'.
 
 AMF currently does not validate this format during CREATE CCBs

 for comptype and comp objects (MODIFY allowed for comp after #2255)
 related to saAmfxxxCmdEnv attribute.
 Besides, the existing validation in avnd_comp_clc_cmd_execute()
 is not good enough. This results in invalid env variables getting
 printed with weird output.
 
 Also, there is currently no check for duplicate env variables set

 in both comptype and comp, so they get printed twice in trace.
 
 This ticket fixes the above issues:

 - Validate env variable format during comp[type] CREATE, MODIFY CCBs.
 - Overwrite env variable set in comptype if it is also set in comp.
 ---
  src/amf/amfd/comp.cc | 54 
+++-
  src/amf/amfd/comp.h  |  2 ++
  src/amf/amfd/comptype.cc | 22 +---
  src/amf/amfnd/clc.cc |  7 +--
  src/amf/amfnd/compdb.cc  | 42 ++---
  5 files changed, 110 insertions(+), 17 deletions(-)
 
 diff --git a/src/amf/amfd/comp.cc b/src/amf/amfd/comp.cc

 index 482322d..8805029 100644
 --- a/src/amf/amfd/comp.cc
 +++ b/src/amf/amfd/comp.cc
 @@ -1,7 +1,7 @@
  /*  -*- OpenSAF  -*-
   *
   * (C) Copyright 2008 The OpenSAF Foundation
 - * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
 + * (C) Copyright 2017, 2018 Ericsson AB. All rights reserved.
   * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
   *
   * This program is distributed in the hope that it will be useful, but
 @@ -328,6 +328,26 @@ done:
TRACE_LEAVE();
  }
  
 +/*

 + * Validate the component CmdEnv attribute
 + *
 + * @param const std::string
 + *
 + * @return bool
 + */
 +bool is_cmd_env_valid(const std::string _env_var) {
 +  /* following environment variable format is considered as invalid:
 +   * - containing 'whitespace'
 +   * - having none or more than one '='
 +   */
 +  if ((cmd_env_var.find_first_of(' ') != std::string::npos) ||
 +  (std::count(cmd_env_var.begin(), cmd_env_var.end(), '=') != 1)) {
 +return false;
 +  }
 +
 +  return true;
 +}
 +
  /**
   * Validate configuration attributes for an AMF Comp object
   * @param comp
 @@ -339,6 +359,7 @@ static int is_config_valid(const std::string ,
 CcbUtilOperationData_t *opdata) {
SaAisErrorT rc;
SaNameT aname;
 +  unsigned int num_of_cmd_env;
std::string::size_type pos;
SaUint32T value;
  
 @@ -399,6 +420,22 @@ static int is_config_valid(const std::string ,

  return 0;
}
  
 +  if ((immutil_getAttrValuesNumber(const_cast("saAmfCompCmdEnv")

 +   ,attributes, _of_cmd_env)) == 
SA_AIS_OK)
 +  {
 +for (unsigned int i = 0; i < num_of_cmd_env; i++) {
 +  std::string cmd_env = immutil_getStringAttr(attributes,
 +  "saAmfCompCmdEnv", i);
 +
 +  if (!is_cmd_env_valid(cmd_env)) {
 +report_ccb_validation_error(opdata, "Unknown environment variable 
format"
 +" '%s' for '%s'. Should be 
'var=value'",
 +cmd_env.c_str(), dn.c_str());

[GL] return value should be an int

[Nguyen] Thanks. I will update the return value.
  
+return false;

 +  }
 +} // for (...; i < num_of_cmd_env;...)
 +  }
 +
  #if 0
  if ((comp->comp_info.category == AVSV_COMP_TYPE_SA_AWARE) && 
(comp->comp_info.init_len == 0)) {
  LOG_ER("Sa Aware Component: instantiation command not 
configured");
 @@ -1038,6 +1075,21 @@ static SaAisErrorT 
ccb_completed_modify_hdlr(CcbUtilOperationData_t *opdata) {
  opdata, "Modification of saAmfCompCmdEnv failed, nullptr 
arg");
  goto done;
}
 +  for (unsigned index = 0; index < attribute->attrValuesNumber; 
index++) {
 +std::string mod_comp_env = *(static_cast(attribute->
 +  
attrValues[index]));
 +
 +if (!is_cmd_env_valid(mod_comp_env)) {
 +  report_ccb_validation_error(opdata, "Modific

[devel] [PATCH 1/1] amf: validate env variable format set in comptype/comp objects [#2409]

2018-02-05 Thread Nguyen Luu
Valid environment variable should have the format 'var=value'.

AMF currently does not validate this format during CREATE CCBs
for comptype and comp objects (MODIFY allowed for comp after #2255)
related to saAmfxxxCmdEnv attribute.
Besides, the existing validation in avnd_comp_clc_cmd_execute()
is not good enough. This results in invalid env variables getting
printed with weird output.

Also, there is currently no check for duplicate env variables set
in both comptype and comp, so they get printed twice in trace.

This ticket fixes the above issues:
- Validate env variable format during comp[type] CREATE, MODIFY CCBs.
- Overwrite env variable set in comptype if it is also set in comp.
---
 src/amf/amfd/comp.cc | 54 +++-
 src/amf/amfd/comp.h  |  2 ++
 src/amf/amfd/comptype.cc | 22 +---
 src/amf/amfnd/clc.cc |  7 +--
 src/amf/amfnd/compdb.cc  | 42 ++---
 5 files changed, 110 insertions(+), 17 deletions(-)

diff --git a/src/amf/amfd/comp.cc b/src/amf/amfd/comp.cc
index 482322d..8805029 100644
--- a/src/amf/amfd/comp.cc
+++ b/src/amf/amfd/comp.cc
@@ -1,7 +1,7 @@
 /*  -*- OpenSAF  -*-
  *
  * (C) Copyright 2008 The OpenSAF Foundation
- * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
+ * (C) Copyright 2017, 2018 Ericsson AB. All rights reserved.
  * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
  *
  * This program is distributed in the hope that it will be useful, but
@@ -328,6 +328,26 @@ done:
   TRACE_LEAVE();
 }
 
+/*
+ * Validate the component CmdEnv attribute
+ *
+ * @param const std::string
+ *
+ * @return bool
+ */
+bool is_cmd_env_valid(const std::string _env_var) {
+  /* following environment variable format is considered as invalid:
+   * - containing 'whitespace'
+   * - having none or more than one '='
+   */
+  if ((cmd_env_var.find_first_of(' ') != std::string::npos) ||
+  (std::count(cmd_env_var.begin(), cmd_env_var.end(), '=') != 1)) {
+return false;
+  }
+
+  return true;
+}
+
 /**
  * Validate configuration attributes for an AMF Comp object
  * @param comp
@@ -339,6 +359,7 @@ static int is_config_valid(const std::string ,
CcbUtilOperationData_t *opdata) {
   SaAisErrorT rc;
   SaNameT aname;
+  unsigned int num_of_cmd_env;
   std::string::size_type pos;
   SaUint32T value;
 
@@ -399,6 +420,22 @@ static int is_config_valid(const std::string ,
 return 0;
   }
 
+  if 
((immutil_getAttrValuesNumber(const_cast("saAmfCompCmdEnv")
+   ,attributes, _of_cmd_env)) == SA_AIS_OK)
+  {
+for (unsigned int i = 0; i < num_of_cmd_env; i++) {
+  std::string cmd_env = immutil_getStringAttr(attributes,
+  "saAmfCompCmdEnv", i);
+
+  if (!is_cmd_env_valid(cmd_env)) {
+report_ccb_validation_error(opdata, "Unknown environment variable 
format"
+" '%s' for '%s'. Should be 'var=value'",
+cmd_env.c_str(), dn.c_str());
+return false;
+  }
+} // for (...; i < num_of_cmd_env;...)
+  }
+
 #if 0
 if ((comp->comp_info.category == AVSV_COMP_TYPE_SA_AWARE) && 
(comp->comp_info.init_len == 0)) {
 LOG_ER("Sa Aware Component: instantiation command not 
configured");
@@ -1038,6 +1075,21 @@ static SaAisErrorT 
ccb_completed_modify_hdlr(CcbUtilOperationData_t *opdata) {
 opdata, "Modification of saAmfCompCmdEnv failed, nullptr arg");
 goto done;
   }
+  for (unsigned index = 0; index < attribute->attrValuesNumber; index++) {
+std::string mod_comp_env = *(static_cast(attribute->
+  attrValues[index]));
+
+if (!is_cmd_env_valid(mod_comp_env)) {
+  report_ccb_validation_error(opdata, "Modification of saAmfCompCmdEnv"
+  " failed. Unknown environment variable"
+  " format '%s' for '%s'."
+  " Should be 'var=value'",
+  mod_comp_env.c_str(),
+  osaf_extended_name_borrow(>
+objectName));
+  goto done;
+}
+  }
 } else if (!strcmp(attribute->attrName, "saAmfCompInstantiateCmdArgv")) {
   if (value_is_deleted == true) continue;
   char *param_val = *((char **)value);
diff --git a/src/amf/amfd/comp.h b/src/amf/amfd/comp.h
index 1493d71..3544a3a 100644
--- a/src/amf/amfd/comp.h
+++ b/src/amf/amfd/comp.h
@@ -1,6 +1,7 @@
 /*  -*- OpenSAF  -*-
  *
  * (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017, 2018 Ericsson AB. All rights reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the 

[devel] [PATCH 0/1] Review Request for amf: validate env variable format set in comptype and comp objects [#2409] V3

2018-02-05 Thread Nguyen Luu
Summary: amf: validate env variable format set in comptype/comp objects [#2409]
Review request for Ticket(s): 2409
Peer Reviewer(s): AMF maintainers
Pull request to: Gary Lee, Hans Nordeback
Affected branch(es): develop, release
Development branch: ticket-2409
Base revision: a53f5615dc7c2ece6669edd82949168982ae4355
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n

NOTE: Patch(es) contain lines longer than 80 characers

Comments (indicate scope for each "y" above):
-
revision bf0660bdc4010f77086dabb6ea2c5b0a77ca4070
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Tue, 6 Feb 2018 09:44:41 +0700

amf: validate env variable format set in comptype/comp objects [#2409]

Valid environment variable should have the format 'var=value'.

AMF currently does not validate this format during CREATE CCBs
for comptype and comp objects (MODIFY allowed for comp after #2255)
related to saAmfxxxCmdEnv attribute.
Besides, the existing validation in avnd_comp_clc_cmd_execute()
is not good enough. This results in invalid env variables getting
printed with weird output.

Also, there is currently no check for duplicate env variables set
in both comptype and comp, so they get printed twice in trace.

This ticket fixes the above issues:
- Validate env variable format during comp[type] CREATE, MODIFY CCBs.
- Overwrite env variable set in comptype if it is also set in comp.

Complete diffstat:
--
 src/amf/amfd/comp.cc | 54 +++-
 src/amf/amfd/comp.h  |  2 ++
 src/amf/amfd/comptype.cc | 22 +---
 src/amf/amfnd/clc.cc |  7 +--
 src/amf/amfnd/compdb.cc  | 42 ++---
 5 files changed, 110 insertions(+), 17 deletions(-)


Testing Commands:
-
1) Create SaAmfCompType/SaAmfComp objects with invalid env variable format
in attributes saAmfCtDefCmdEnv/saAmfCompCmdEnv. (e.g 'var = value', 
'var==value')
2) Modify attribute saAmfCompCmdEnv of SaAmfComp object with invalid env
variable format.


Testing, Expected Results:
--
AMFD will reject CREATE/MODIFY CCBs with invalid env variable format.


Conditions of Submission:
-
Ack from an AMF maintainer.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Yo

[devel] [PATCH 0/1] Review Request for Review Request for amf: validate env variable format set in comptype and comp objects [#2409] V3

2018-02-05 Thread Nguyen Luu
Summary: amf: validate env variable format set in comptype/comp objects [#2409]
Review request for Ticket(s): 2409
Peer Reviewer(s): AMF maintainers
Pull request to: Gary Lee, Hans Nordeback
Affected branch(es): develop, release
Development branch: ticket-2409
Base revision: a53f5615dc7c2ece6669edd82949168982ae4355
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n

NOTE: Patch(es) contain lines longer than 80 characers

Comments (indicate scope for each "y" above):
-
revision bf0660bdc4010f77086dabb6ea2c5b0a77ca4070
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Tue, 6 Feb 2018 09:44:41 +0700

amf: validate env variable format set in comptype/comp objects [#2409]

Valid environment variable should have the format 'var=value'.

AMF currently does not validate this format during CREATE CCBs
for comptype and comp objects (MODIFY allowed for comp after #2255)
related to saAmfxxxCmdEnv attribute.
Besides, the existing validation in avnd_comp_clc_cmd_execute()
is not good enough. This results in invalid env variables getting
printed with weird output.

Also, there is currently no check for duplicate env variables set
in both comptype and comp, so they get printed twice in trace.

This ticket fixes the above issues:
- Validate env variable format during comp[type] CREATE, MODIFY CCBs.
- Overwrite env variable set in comptype if it is also set in comp.



Complete diffstat:
--
 src/amf/amfd/comp.cc | 54 +++-
 src/amf/amfd/comp.h  |  2 ++
 src/amf/amfd/comptype.cc | 22 +---
 src/amf/amfnd/clc.cc |  7 +--
 src/amf/amfnd/compdb.cc  | 42 ++---
 5 files changed, 110 insertions(+), 17 deletions(-)


Testing Commands:
-
1) Create SaAmfCompType/SaAmfComp objects with invalid env variable format
in attributes saAmfCtDefCmdEnv/saAmfCompCmdEnv. (e.g 'var = value', 
'var==value')
2) Modify attribute saAmfCompCmdEnv of SaAmfComp object with invalid env
variable format.


Testing, Expected Results:
--
AMFD will reject CREATE/MODIFY CCBs with invalid env variable format.


Conditions of Submission:
-
Ack from an AMF maintainer.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Yo

[devel] [PATCH 1/1] amf: validate env variable format set in comptype/comp objects [#2409]

2018-02-05 Thread Nguyen Luu
Valid environment variable should have the format 'var=value'.

AMF currently does not validate this format during CREATE CCBs
for comptype and comp objects (MODIFY allowed for comp after #2255)
related to saAmfxxxCmdEnv attribute.
Besides, the existing validation in avnd_comp_clc_cmd_execute()
is not good enough. This results in invalid env variables getting
printed with weird output.

Also, there is currently no check for duplicate env variables set
in both comptype and comp, so they get printed twice in trace.

This ticket fixes the above issues:
- Validate env variable format during comp[type] CREATE, MODIFY CCBs.
- Overwrite env variable set in comptype if it is also set in comp.
---
 src/amf/amfd/comp.cc | 54 +++-
 src/amf/amfd/comp.h  |  2 ++
 src/amf/amfd/comptype.cc | 22 +---
 src/amf/amfnd/clc.cc |  7 +--
 src/amf/amfnd/compdb.cc  | 42 ++---
 5 files changed, 110 insertions(+), 17 deletions(-)

diff --git a/src/amf/amfd/comp.cc b/src/amf/amfd/comp.cc
index 482322d..8805029 100644
--- a/src/amf/amfd/comp.cc
+++ b/src/amf/amfd/comp.cc
@@ -1,7 +1,7 @@
 /*  -*- OpenSAF  -*-
  *
  * (C) Copyright 2008 The OpenSAF Foundation
- * (C) Copyright 2017 Ericsson AB - All Rights Reserved.
+ * (C) Copyright 2017, 2018 Ericsson AB. All rights reserved.
  * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
  *
  * This program is distributed in the hope that it will be useful, but
@@ -328,6 +328,26 @@ done:
   TRACE_LEAVE();
 }
 
+/*
+ * Validate the component CmdEnv attribute
+ *
+ * @param const std::string
+ *
+ * @return bool
+ */
+bool is_cmd_env_valid(const std::string _env_var) {
+  /* following environment variable format is considered as invalid:
+   * - containing 'whitespace'
+   * - having none or more than one '='
+   */
+  if ((cmd_env_var.find_first_of(' ') != std::string::npos) ||
+  (std::count(cmd_env_var.begin(), cmd_env_var.end(), '=') != 1)) {
+return false;
+  }
+
+  return true;
+}
+
 /**
  * Validate configuration attributes for an AMF Comp object
  * @param comp
@@ -339,6 +359,7 @@ static int is_config_valid(const std::string ,
CcbUtilOperationData_t *opdata) {
   SaAisErrorT rc;
   SaNameT aname;
+  unsigned int num_of_cmd_env;
   std::string::size_type pos;
   SaUint32T value;
 
@@ -399,6 +420,22 @@ static int is_config_valid(const std::string ,
 return 0;
   }
 
+  if 
((immutil_getAttrValuesNumber(const_cast("saAmfCompCmdEnv")
+   ,attributes, _of_cmd_env)) == SA_AIS_OK)
+  {
+for (unsigned int i = 0; i < num_of_cmd_env; i++) {
+  std::string cmd_env = immutil_getStringAttr(attributes,
+  "saAmfCompCmdEnv", i);
+
+  if (!is_cmd_env_valid(cmd_env)) {
+report_ccb_validation_error(opdata, "Unknown environment variable 
format"
+" '%s' for '%s'. Should be 'var=value'",
+cmd_env.c_str(), dn.c_str());
+return false;
+  }
+} // for (...; i < num_of_cmd_env;...)
+  }
+
 #if 0
 if ((comp->comp_info.category == AVSV_COMP_TYPE_SA_AWARE) && 
(comp->comp_info.init_len == 0)) {
 LOG_ER("Sa Aware Component: instantiation command not 
configured");
@@ -1038,6 +1075,21 @@ static SaAisErrorT 
ccb_completed_modify_hdlr(CcbUtilOperationData_t *opdata) {
 opdata, "Modification of saAmfCompCmdEnv failed, nullptr arg");
 goto done;
   }
+  for (unsigned index = 0; index < attribute->attrValuesNumber; index++) {
+std::string mod_comp_env = *(static_cast(attribute->
+  attrValues[index]));
+
+if (!is_cmd_env_valid(mod_comp_env)) {
+  report_ccb_validation_error(opdata, "Modification of saAmfCompCmdEnv"
+  " failed. Unknown environment variable"
+  " format '%s' for '%s'."
+  " Should be 'var=value'",
+  mod_comp_env.c_str(),
+  osaf_extended_name_borrow(>
+objectName));
+  goto done;
+}
+  }
 } else if (!strcmp(attribute->attrName, "saAmfCompInstantiateCmdArgv")) {
   if (value_is_deleted == true) continue;
   char *param_val = *((char **)value);
diff --git a/src/amf/amfd/comp.h b/src/amf/amfd/comp.h
index 1493d71..3544a3a 100644
--- a/src/amf/amfd/comp.h
+++ b/src/amf/amfd/comp.h
@@ -1,6 +1,7 @@
 /*  -*- OpenSAF  -*-
  *
  * (C) Copyright 2008 The OpenSAF Foundation
+ * (C) Copyright 2017, 2018 Ericsson AB. All rights reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the 

[devel] [PATCH 1/1] pyosaf: Refactor NTF samples to make use of new pyosaf utils [#2707]

2017-12-20 Thread Nguyen Luu
- Refactor the ntfsend and ntfsubscribe python samples to make use of
  the new pyosaf utils implementation of enhancement ticket #2602.
- Add a new ntfread sample to demonstrate usage of the new NtfReader
  utils.
---
 python/samples/ntfread  | 411 
 python/samples/ntfsend  | 922 
 python/samples/ntfsubscribe | 795 --
 3 files changed, 1591 insertions(+), 537 deletions(-)
 create mode 100755 python/samples/ntfread
 mode change 100644 => 100755 python/samples/ntfsend
 mode change 100644 => 100755 python/samples/ntfsubscribe

diff --git a/python/samples/ntfread b/python/samples/ntfread
new file mode 100755
index 000..a70552b
--- /dev/null
+++ b/python/samples/ntfread
@@ -0,0 +1,411 @@
+#! /usr/bin/env python
+
+#
+# (C) Copyright 2017 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson
+#
+
+# pylint: disable=unused-argument
+"""
+ntfread tool used to read alarm and/or security alarm notifications from NTF
+
+Run ntfread --help/-h for more detail on usage
+"""
+from __future__ import print_function
+import sys
+import argparse
+from datetime import datetime, tzinfo, timedelta
+
+from pyosaf import saNtf
+from pyosaf.saAis import eSaAisErrorT
+from pyosaf.utils.ntf.reader import NtfReader
+
+
+class UTCOffsetTZ(tzinfo):
+""" Time zone represented as UTC hour-offset """
+def __init__(self, hour_offset):
+""" UTCOffsetTZ constructor """
+self._hour_offset = hour_offset
+super(UTCOffsetTZ, self).__init__()
+
+def utcoffset(self, dt):
+""" Return offset of local time from UTC, in minutes east of UTC """
+return timedelta(hours=self._hour_offset)
+
+def dst(self, dt):
+""" Return the daylight saving time (DST) adjustment, in minutes east
+of UTC, or None if DST information isn't known
+"""
+return timedelta(0)
+
+def tzname(self, dt):
+""" Return the time zone name represented in UTC hour-offset format as
+'UTC+/-offset'
+"""
+if self._hour_offset > 0:
+tzname = "UTC+%02d:00" % self._hour_offset
+elif self._hour_offset < 0:
+tzname = "UTC-%02d:00" % self._hour_offset
+else:  # hour_offset = 0
+tzname = "UTC"
+
+return tzname
+
+
+def satime_to_readable_datetime(sa_time, format_str=None):
+""" Convert the given SaTimeT time value to readable datetime string
+representation in ISO 8601 format
+
+Args:
+sa_time (SaTimeT): SaTimeT time value
+format_str (str): Format string for datetime output representation
+
+Returns:
+str: Datetime representation in format specified by format_str, or in
+ ISO 8601 format '-MM-DDTHH:MM:SS' if format_str not provided
+"""
+time_sec = sa_time / 10**9  # Convert the time from nsec to sec 10
+
+# Calculate the UTC offset for time zone information
+naive_dt = datetime.fromtimestamp(time_sec)
+utc_offset = (naive_dt - datetime.utcfromtimestamp(time_sec))
+hour_offset = utc_offset.total_seconds() // 3600
+utc_offset_tz = UTCOffsetTZ(hour_offset)
+
+aware_dt = naive_dt.replace(tzinfo=utc_offset_tz)
+
+if format_str is not None:
+return aware_dt.strftime(format_str)
+
+return aware_dt.isoformat(' ')
+
+
+def _validate_ntf_class_id(arg):
+""" Validate the input NtfClassId with format 'VENDOR_ID.MAJOR_ID.MINOR_ID'
+
+Args:
+arg (str): The NtfClassId to validate
+
+Returns:
+SaNtfClassIdT: The validated NtfClassId
+"""
+if arg.count('.') != 2:
+msg = "%r is not in correct format 'VENDOR_ID.MAJOR_ID.MINOR_ID'" % arg
+raise argparse.ArgumentTypeError(msg)
+if not arg.split('.')[0] or not arg.split('.')[1] or not arg.split('.')[2]:
+msg = "%r does not have enough required values" % arg
+raise argparse.ArgumentTypeError(msg)
+
+# Validate element type
+try:
+vendor_id = int(arg.split('.')[0])
+major_id = int(arg.split('.')[1])
+minor_id = int(arg.split('.')[2])
+except ValueError:
+msg = "%r must consist of all integers" % arg
+raise argparse.ArgumentTypeError(msg)
+
+return saNtf.SaNtfClassIdT(vendor_id, 

[devel] [PATCH 0/1] Review Request for pyosaf: Refactor NTF samples to make use of new pyosaf utils [#2707]

2017-12-20 Thread Nguyen Luu
Summary: pyosaf: Refactor NTF samples to make use of new pyosaf utils [#2707]
Review request for Ticket(s): 2707
Peer Reviewer(s): Hans Nordeback, Srinivas Mangipudy
Pull request to: Hans Nordeback
Affected branch(es): develop
Development branch: ticket-2707
Base revision: 5a520b91f37ef51ddf6fbdd97928a002e2967e0c
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples y
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
revision d56df110afd51411cb4fa75f6655ccca171e9f89
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Wed, 20 Dec 2017 15:23:32 +0700

pyosaf: Refactor NTF samples to make use of new pyosaf utils [#2707]

- Refactor the ntfsend and ntfsubscribe python samples to make use of
  the new pyosaf utils implementation of enhancement ticket #2602.
- Add a new ntfread sample to demonstrate usage of the new NtfReader
  utils.



Added Files:

 python/samples/ntfread


Complete diffstat:
--
 python/samples/ntfread  | 411 
 python/samples/ntfsend  | 922 
 python/samples/ntfsubscribe | 795 --
 3 files changed, 1591 insertions(+), 537 deletions(-)


Testing Commands:
-
Run the NTF python samples with provided options.
NOTE: some options depend on the fix of #2682 to be workable.


Testing, Expected Results:
--
The requested functions should work as expected.


Conditions of Submission:
-
Ack from one of the reviewers.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 1/1] pyosaf: Fix some issues in NTF utils [#2682]

2017-12-20 Thread Nguyen Luu
agent.py:
  - Update some default values for notificationSend.
  - Correct NtfAgent.finalize() to handle BAD_HANDLE error code.
producer.py:
  - Fix type conversion when assigning value of type SaNtfValueT.
  - Keep the notification info for reuse after sending notification.
  - Update the assigning of specificProblems for alarm notification.
  - Harden 'None' value checking.
subscriber.py:
  - Support handling of long-dn objects in subscribed/read notifications.
  - Fix the parsing of additionalText and specificProblems in
subscribed/read notifications.
  - Explicitly free the notification after parsing to avoid memory leak.
  - Fix some semantic errors.
reader.py:
  - Add the missing function to set search direction when creating
filter for notificationRead.
  - Check filterAllocate result before initializing notificationRead.
---
 python/pyosaf/utils/ntf/__init__.py   | 18 +++
 python/pyosaf/utils/ntf/agent.py  |  9 +++---
 python/pyosaf/utils/ntf/producer.py   | 59 ++-
 python/pyosaf/utils/ntf/reader.py | 29 +++--
 python/pyosaf/utils/ntf/subscriber.py | 45 +-
 5 files changed, 98 insertions(+), 62 deletions(-)

diff --git a/python/pyosaf/utils/ntf/__init__.py 
b/python/pyosaf/utils/ntf/__init__.py
index 0687517..3935a98 100644
--- a/python/pyosaf/utils/ntf/__init__.py
+++ b/python/pyosaf/utils/ntf/__init__.py
@@ -106,6 +106,9 @@ def send_object_create_notification(vendor_id, major_id, 
minor_id,
 if rc != eSaAisErrorT.SA_AIS_OK:
 raise SafException(rc)
 
+# Clear the internally saved notification information
+_ntf_producer.clear_info()
+
 return rc
 
 
@@ -158,6 +161,9 @@ def send_object_delete_notification(vendor_id, major_id, 
minor_id,
 if rc != eSaAisErrorT.SA_AIS_OK:
 raise SafException(rc)
 
+# Clear the internally saved notification information
+_ntf_producer.clear_info()
+
 return rc
 
 
@@ -211,6 +217,9 @@ def send_attribute_change_notification(
 if rc != eSaAisErrorT.SA_AIS_OK:
 raise SafException(rc)
 
+# Clear the internally saved notification information
+_ntf_producer.clear_info()
+
 return rc
 
 
@@ -266,6 +275,9 @@ def send_state_change_notification(vendor_id,
 if rc != eSaAisErrorT.SA_AIS_OK:
 raise SafException(rc)
 
+# Clear the internally saved notification information
+_ntf_producer.clear_info()
+
 return rc
 
 
@@ -316,6 +328,9 @@ def send_alarm_notification(
 if rc != eSaAisErrorT.SA_AIS_OK:
 raise SafException(rc)
 
+# Clear the internally saved notification information
+_ntf_producer.clear_info()
+
 return rc
 
 
@@ -378,6 +393,9 @@ def send_security_alarm_notification(
 if rc != eSaAisErrorT.SA_AIS_OK:
 raise SafException(rc)
 
+# Clear the internally saved notification information
+_ntf_producer.clear_info()
+
 return rc
 
 
diff --git a/python/pyosaf/utils/ntf/agent.py b/python/pyosaf/utils/ntf/agent.py
index dd2d218..34e2969 100644
--- a/python/pyosaf/utils/ntf/agent.py
+++ b/python/pyosaf/utils/ntf/agent.py
@@ -112,13 +112,14 @@ class NotificationInfo(object):
 self.probable_cause = \
 saNtf.eSaNtfProbableCauseT.SA_NTF_UNSPECIFIED_REASON
 self.specific_problems = []
-self.perceived_severity = saNtf.eSaNtfSeverityT.SA_NTF_SEVERITY_MINOR
-self.trend = None
+self.perceived_severity = \
+saNtf.eSaNtfSeverityT.SA_NTF_SEVERITY_INDETERMINATE
+self.trend = saNtf.eSaNtfSeverityTrendT.SA_NTF_TREND_NO_CHANGE
 self.threshold_information = None
 self.monitored_attrs = []
 self.proposed_repair_actions = []
 # Security alarm info
-self.severity = saNtf.eSaNtfSeverityT.SA_NTF_SEVERITY_MINOR
+self.severity = saNtf.eSaNtfSeverityT.SA_NTF_SEVERITY_INDETERMINATE
 self.security_alarm_detector = None
 self.service_user = None
 self.service_provider = None
@@ -491,7 +492,7 @@ class NtfAgent(object):
 rc = saNtfFinalize(self.handle)
 if rc != eSaAisErrorT.SA_AIS_OK:
 log_err("saNtfFinalize FAILED - %s" % eSaAisErrorT.whatis(rc))
-elif rc == eSaAisErrorT.SA_AIS_OK \
+if rc == eSaAisErrorT.SA_AIS_OK \
 or rc == eSaAisErrorT.SA_AIS_ERR_BAD_HANDLE:
 # If the Finalize() call returned BAD_HANDLE, the handle should
 # already become stale and invalid, so we reset it anyway
diff --git a/python/pyosaf/utils/ntf/producer.py 
b/python/pyosaf/utils/ntf/producer.py
index cea5585..1d54225 100644
--- a/python/pyosaf/utils/ntf/producer.py
+++ b/python/pyosaf/utils/ntf/producer.py
@@ -58,7 +58,7 @@ class NtfProducer(ntf.NtfAgent):
 attr_value.uint8Val = int(value)
 
 elif value_type == saNtf.eSaNtfValueTypeT.SA_NTF_VALUE_INT8:
-attr_value.int8Val = int(value)
+attr_value.int8Val = 

[devel] [PATCH 0/1] Review Request for pyosaf: Fix some issues in NTF utils [#2682]

2017-12-20 Thread Nguyen Luu
Summary: pyosaf: Fix some issues in NTF utils [#2682]
Review request for Ticket(s): 2682
Peer Reviewer(s): Hans Nordeback, Srinivas Mangipudy
Pull request to: Hans Nordeback
Affected branch(es): develop, release
Development branch: ticket-2682
Base revision: 5a520b91f37ef51ddf6fbdd97928a002e2967e0c
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   y


Comments (indicate scope for each "y" above):
-
revision fcec6c823a95bd8cf397edbe80600f3a129f6a87
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Wed, 20 Dec 2017 15:18:40 +0700

pyosaf: Fix some issues in NTF utils [#2682]

agent.py:
  - Update some default values for notificationSend.
  - Correct NtfAgent.finalize() to handle BAD_HANDLE error code.
producer.py:
  - Fix type conversion when assigning value of type SaNtfValueT.
  - Keep the notification info for reuse after sending notification.
  - Update the assigning of specificProblems for alarm notification.
  - Harden 'None' value checking.
subscriber.py:
  - Support handling of long-dn objects in subscribed/read notifications.
  - Fix the parsing of additionalText and specificProblems in
subscribed/read notifications.
  - Explicitly free the notification after parsing to avoid memory leak.
  - Fix some semantic errors.
reader.py:
  - Add the missing function to set search direction when creating
filter for notificationRead.
  - Check filterAllocate result before initializing notificationRead.



Complete diffstat:
--
 python/pyosaf/utils/ntf/__init__.py   | 18 +++
 python/pyosaf/utils/ntf/agent.py  |  9 +++---
 python/pyosaf/utils/ntf/producer.py   | 59 ++-
 python/pyosaf/utils/ntf/reader.py | 29 +++--
 python/pyosaf/utils/ntf/subscriber.py | 45 +-
 5 files changed, 98 insertions(+), 62 deletions(-)


Testing Commands:
-


Testing, Expected Results:
--


Conditions of Submission:
-
Ack from one of the reviewers.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.


[devel] [PATCH 1/1] pyosaf: Fix some issues in NTF utils [#2682]

2017-12-19 Thread Nguyen Luu
agent.py:
  - Update some default values for notificationSend.
  - Correct NtfAgent.finalize() to handle BAD_HANDLE error code.
producer.py:
  - Fix type conversion when assigning value of type SaNtfValueT.
  - Keep the notification info for reuse after sending notification.
  - Update the assigning of specificProblems for alarm notification.
  - Harden 'None' value checking.
subscriber.py:
  - Support handling of long-dn objects in subscribed/read notifications.
  - Fix the parsing of additionalText and specificProblems in
subscribed/read notifications.
  - Explicitly free the notification after parsing to avoid memory leak.
  - Fix some semantic errors.
reader.py:
  - Add the missing function to set search direction when creating
filter for notificationRead.
  - Check filterAllocate result before initializing notificationRead.
---
 python/pyosaf/utils/ntf/__init__.py   | 18 +++
 python/pyosaf/utils/ntf/agent.py  |  9 +++---
 python/pyosaf/utils/ntf/producer.py   | 59 ++-
 python/pyosaf/utils/ntf/reader.py | 29 +++--
 python/pyosaf/utils/ntf/subscriber.py | 45 +-
 5 files changed, 98 insertions(+), 62 deletions(-)

diff --git a/python/pyosaf/utils/ntf/__init__.py 
b/python/pyosaf/utils/ntf/__init__.py
index 0687517..3935a98 100644
--- a/python/pyosaf/utils/ntf/__init__.py
+++ b/python/pyosaf/utils/ntf/__init__.py
@@ -106,6 +106,9 @@ def send_object_create_notification(vendor_id, major_id, 
minor_id,
 if rc != eSaAisErrorT.SA_AIS_OK:
 raise SafException(rc)
 
+# Clear the internally saved notification information
+_ntf_producer.clear_info()
+
 return rc
 
 
@@ -158,6 +161,9 @@ def send_object_delete_notification(vendor_id, major_id, 
minor_id,
 if rc != eSaAisErrorT.SA_AIS_OK:
 raise SafException(rc)
 
+# Clear the internally saved notification information
+_ntf_producer.clear_info()
+
 return rc
 
 
@@ -211,6 +217,9 @@ def send_attribute_change_notification(
 if rc != eSaAisErrorT.SA_AIS_OK:
 raise SafException(rc)
 
+# Clear the internally saved notification information
+_ntf_producer.clear_info()
+
 return rc
 
 
@@ -266,6 +275,9 @@ def send_state_change_notification(vendor_id,
 if rc != eSaAisErrorT.SA_AIS_OK:
 raise SafException(rc)
 
+# Clear the internally saved notification information
+_ntf_producer.clear_info()
+
 return rc
 
 
@@ -316,6 +328,9 @@ def send_alarm_notification(
 if rc != eSaAisErrorT.SA_AIS_OK:
 raise SafException(rc)
 
+# Clear the internally saved notification information
+_ntf_producer.clear_info()
+
 return rc
 
 
@@ -378,6 +393,9 @@ def send_security_alarm_notification(
 if rc != eSaAisErrorT.SA_AIS_OK:
 raise SafException(rc)
 
+# Clear the internally saved notification information
+_ntf_producer.clear_info()
+
 return rc
 
 
diff --git a/python/pyosaf/utils/ntf/agent.py b/python/pyosaf/utils/ntf/agent.py
index dd2d218..34e2969 100644
--- a/python/pyosaf/utils/ntf/agent.py
+++ b/python/pyosaf/utils/ntf/agent.py
@@ -112,13 +112,14 @@ class NotificationInfo(object):
 self.probable_cause = \
 saNtf.eSaNtfProbableCauseT.SA_NTF_UNSPECIFIED_REASON
 self.specific_problems = []
-self.perceived_severity = saNtf.eSaNtfSeverityT.SA_NTF_SEVERITY_MINOR
-self.trend = None
+self.perceived_severity = \
+saNtf.eSaNtfSeverityT.SA_NTF_SEVERITY_INDETERMINATE
+self.trend = saNtf.eSaNtfSeverityTrendT.SA_NTF_TREND_NO_CHANGE
 self.threshold_information = None
 self.monitored_attrs = []
 self.proposed_repair_actions = []
 # Security alarm info
-self.severity = saNtf.eSaNtfSeverityT.SA_NTF_SEVERITY_MINOR
+self.severity = saNtf.eSaNtfSeverityT.SA_NTF_SEVERITY_INDETERMINATE
 self.security_alarm_detector = None
 self.service_user = None
 self.service_provider = None
@@ -491,7 +492,7 @@ class NtfAgent(object):
 rc = saNtfFinalize(self.handle)
 if rc != eSaAisErrorT.SA_AIS_OK:
 log_err("saNtfFinalize FAILED - %s" % eSaAisErrorT.whatis(rc))
-elif rc == eSaAisErrorT.SA_AIS_OK \
+if rc == eSaAisErrorT.SA_AIS_OK \
 or rc == eSaAisErrorT.SA_AIS_ERR_BAD_HANDLE:
 # If the Finalize() call returned BAD_HANDLE, the handle should
 # already become stale and invalid, so we reset it anyway
diff --git a/python/pyosaf/utils/ntf/producer.py 
b/python/pyosaf/utils/ntf/producer.py
index cea5585..1d54225 100644
--- a/python/pyosaf/utils/ntf/producer.py
+++ b/python/pyosaf/utils/ntf/producer.py
@@ -58,7 +58,7 @@ class NtfProducer(ntf.NtfAgent):
 attr_value.uint8Val = int(value)
 
 elif value_type == saNtf.eSaNtfValueTypeT.SA_NTF_VALUE_INT8:
-attr_value.int8Val = int(value)
+attr_value.int8Val = 

Re: [devel] [PATCH 1/1] imm: Restore printout format in immxml tools to maintain backward compatibility [#2728]

2017-12-14 Thread Nguyen Luu

Hi Zoran,

Please help me review this patch when possible.
The key change is the following:

@@ -409,10 +409,10 @@ class MergedImmDocument(BaseImmDocument):
 diff_classes = self.classes_parsed - len(self.classList)
 diff_objects = self.objects_parsed - len(self.objectList)
 print_info_stderr("Note! Merge ignored %d classes "
-  "(parsed: %d stored: %d)", diff_classes,
+  "(parsed:%d stored:%d)", diff_classes,
   self.classes_parsed, len(self.classList))
 print_info_stderr("Note! Merge ignored %d objects "
-  "(parsed: %d stored: %d)", diff_objects,
+  "(parsed:%d stored:%d)", diff_objects,
   self.objects_parsed, len(self.objectList)

Thanks,
Nguyen

On 12/5/2017 2:27 PM, Nguyen Luu wrote:

- Restore the previous printout format in the immxml tools, which
   happened to be changed by ticket #2664 for better readability, in order
   to maintain backward-compatibility for any user scripts/tools that have
   been depending their check on the former printout.
- Some other minor updates regarding formatting.
---
  src/imm/tools/baseimm.py  | 32 +---
  src/imm/tools/immxml-merge| 32 
  src/imm/tools/immxml-validate | 16 
  3 files changed, 41 insertions(+), 39 deletions(-)

diff --git a/src/imm/tools/baseimm.py b/src/imm/tools/baseimm.py
index fe1c3ce..17e85eb 100644
--- a/src/imm/tools/baseimm.py
+++ b/src/imm/tools/baseimm.py
@@ -84,7 +84,8 @@ class BaseImmDocument(object):
  @staticmethod
  def format_xml_file_with_xmllint(in_file_name, out_file_name):
  """ Format xml file with xmllint """
-trace("formatXmlFileWithXmlLint() prettify xml file:%s", in_file_name)
+trace("format_xml_file_with_xmllint() prettify xml file: %s",
+  in_file_name)
  
  # "prettify" the result file with xmllint

  # (due to inadequate python/minidom prettify functionality)
@@ -123,7 +124,7 @@ class BaseImmDocument(object):
  doc = open(file_name)
  str_list = []
  imm_contents_tag_found = False
-# imm_contents_tag_replaced = False
+imm_contents_tag_replaced = False
  for _line in doc:
  line = _line
  if not imm_contents_tag_found:
@@ -140,18 +141,19 @@ class BaseImmDocument(object):
  
  xml_str = ' '.join(str_list)
  
-# if Options.schemaFilename is not None:

-# if imm_contents_tag_replaced:
-# print_info_stderr("Cannot validate input file '%s' with "
-#   "schema file because of missing namespace "
-#   "specification in element "
-#   ". \nProceeding with "
-#   "processing of modified input data!",
-#   file_name)
-# else:
-# if self.validate_xml_file(file_name) != 0:
-# abort_script("Failed to validate the input file: %s",
-#  file_name)
+if Options.schemaFilename is not None:
+if imm_contents_tag_replaced:
+print_info_stderr("Cannot validate input file '%s' with "
+  "schema file because of missing namespace "
+  "specification in element "
+  ". \nProceeding with "
+  "processing of modified input data!",
+  file_name)
+else:
+if self.validate_xml_file(file_name) != 0:
+abort_script("Failed to validate the input file: %s",
+ file_name)
+
  return xml.dom.minidom.parseString(xml_str)
  
  @staticmethod

@@ -188,7 +190,7 @@ def trace(*args):
  
  def retrieve_file_names(args):

  """ Retrieve file names """
-trace("Before glob args:%s", args)
+trace("Before glob args: %s", args)
  # Wildcard expansion for WIN support, however not tested
  file_list = glob.glob(args[0])
  trace("After glob file list: %s length: %d", file_list, len(file_list))
diff --git a/src/imm/tools/immxml-merge b/src/imm/tools/immxml-merge
index 7489da3..3a9edda 100755
--- a/src/imm/tools/immxml-merge
+++ b/src/imm/tools/immxml-merge
@@ -113,7 +113,7 @@ class MergedImmDocument(BaseImmDocument):
  """ Add classes matching pattern """
  cla

[devel] [PATCH 1/1] imm: Restore printout format in immxml tools to maintain backward compatibility [#2728]

2017-12-04 Thread Nguyen Luu
- Restore the previous printout format in the immxml tools, which
  happened to be changed by ticket #2664 for better readability, in order
  to maintain backward-compatibility for any user scripts/tools that have
  been depending their check on the former printout.
- Some other minor updates regarding formatting.
---
 src/imm/tools/baseimm.py  | 32 +---
 src/imm/tools/immxml-merge| 32 
 src/imm/tools/immxml-validate | 16 
 3 files changed, 41 insertions(+), 39 deletions(-)

diff --git a/src/imm/tools/baseimm.py b/src/imm/tools/baseimm.py
index fe1c3ce..17e85eb 100644
--- a/src/imm/tools/baseimm.py
+++ b/src/imm/tools/baseimm.py
@@ -84,7 +84,8 @@ class BaseImmDocument(object):
 @staticmethod
 def format_xml_file_with_xmllint(in_file_name, out_file_name):
 """ Format xml file with xmllint """
-trace("formatXmlFileWithXmlLint() prettify xml file:%s", in_file_name)
+trace("format_xml_file_with_xmllint() prettify xml file: %s",
+  in_file_name)
 
 # "prettify" the result file with xmllint
 # (due to inadequate python/minidom prettify functionality)
@@ -123,7 +124,7 @@ class BaseImmDocument(object):
 doc = open(file_name)
 str_list = []
 imm_contents_tag_found = False
-# imm_contents_tag_replaced = False
+imm_contents_tag_replaced = False
 for _line in doc:
 line = _line
 if not imm_contents_tag_found:
@@ -140,18 +141,19 @@ class BaseImmDocument(object):
 
 xml_str = ' '.join(str_list)
 
-# if Options.schemaFilename is not None:
-# if imm_contents_tag_replaced:
-# print_info_stderr("Cannot validate input file '%s' with "
-#   "schema file because of missing namespace "
-#   "specification in element "
-#   ". \nProceeding with "
-#   "processing of modified input data!",
-#   file_name)
-# else:
-# if self.validate_xml_file(file_name) != 0:
-# abort_script("Failed to validate the input file: %s",
-#  file_name)
+if Options.schemaFilename is not None:
+if imm_contents_tag_replaced:
+print_info_stderr("Cannot validate input file '%s' with "
+  "schema file because of missing namespace "
+  "specification in element "
+  ". \nProceeding with "
+  "processing of modified input data!",
+  file_name)
+else:
+if self.validate_xml_file(file_name) != 0:
+abort_script("Failed to validate the input file: %s",
+ file_name)
+
 return xml.dom.minidom.parseString(xml_str)
 
 @staticmethod
@@ -188,7 +190,7 @@ def trace(*args):
 
 def retrieve_file_names(args):
 """ Retrieve file names """
-trace("Before glob args:%s", args)
+trace("Before glob args: %s", args)
 # Wildcard expansion for WIN support, however not tested
 file_list = glob.glob(args[0])
 trace("After glob file list: %s length: %d", file_list, len(file_list))
diff --git a/src/imm/tools/immxml-merge b/src/imm/tools/immxml-merge
index 7489da3..3a9edda 100755
--- a/src/imm/tools/immxml-merge
+++ b/src/imm/tools/immxml-merge
@@ -113,7 +113,7 @@ class MergedImmDocument(BaseImmDocument):
 """ Add classes matching pattern """
 class_name = class_element.getAttribute("name")
 self.classes_parsed = self.classes_parsed + 1
-trace("className: %s nodeType:%d nodeName:%s", class_name,
+trace("className:%s nodeType:%d nodeName:%s", class_name,
   class_element.nodeType, class_element.nodeName)
 
 if self.regexpObj is not None:
@@ -129,7 +129,7 @@ class MergedImmDocument(BaseImmDocument):
   Options.grep_class)
 return
 
-trace("match ok :%s", class_name)
+trace("match ok: %s", class_name)
 
 # Check if class exists in dictionary map
 if class_name in self.classDict:
@@ -146,7 +146,7 @@ class MergedImmDocument(BaseImmDocument):
 def add_object(self, object_element, other_nodes):
 """ Add objects matching pattern """
 class_name = object_element.getAttribute("class")
-trace("DUMPING Object with className: %s \n %s", class_name,
+trace("DUMPING Object with className: %s\n %s", class_name,
   object_element.toxml())
 self.objects_parsed = self.objects_parsed + 1
 
@@ -160,7 +160,7 @@ class MergedImmDocument(BaseImmDocument):
 if object_dn_element is None or class_name is None \
 

[devel] [PATCH 0/1] Review Request for imm: Restore printout format in immxml tools to maintain backward compatibility [#2728]

2017-12-04 Thread Nguyen Luu
Summary: imm: Restore printout format in immxml tools to maintain backward 
compatibility [#2728]
Review request for Ticket(s): 2728
Peer Reviewer(s): Zoran Milinkovic, Vu Minh Nguyen
Pull request to: Zoran Milinkovic
Affected branch(es): develop
Development branch: ticket-2728
Base revision: d54303925f86813c5c2fa1103f3c8ed841488145
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   y


Comments (indicate scope for each "y" above):
-
revision 17e0c8f44cb70a9763ef8b5b825f20b84d76627b
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Tue, 5 Dec 2017 13:52:39 +0700

imm: Restore printout format in immxml tools to maintain backward compatibility 
[#2728]

- Restore the previous printout format in the immxml tools, which
  happened to be changed by ticket #2664 for better readability, in order
  to maintain backward-compatibility for any user scripts/tools that have
  been depending their check on the former printout.
- Some other minor updates regarding formatting.



Complete diffstat:
--
 src/imm/tools/baseimm.py  | 32 +---
 src/imm/tools/immxml-merge| 32 
 src/imm/tools/immxml-validate | 16 
 3 files changed, 41 insertions(+), 39 deletions(-)


Testing Commands:
-
*** LIST THE COMMAND LINE TOOLS/STEPS TO TEST YOUR CHANGES ***


Testing, Expected Results:
--
*** PASTE COMMAND OUTPUTS / TEST RESULTS ***


Conditions of Submission:
-
Ack from Zoran.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 1/1] imm: Restore printout format in immxml tools to maintain backward compatibility [#2728]

2017-12-04 Thread Nguyen Luu
- Restore the previous printout format in the immxml tools, which
  happened to be changed by ticket #2664 for better readability, in order
  to maintain backward-compatibility for any user scripts/tools that have
  been depending their check on the former printout.
- Some other minor updates regarding formatting.
---
 src/imm/tools/baseimm.py  | 32 +---
 src/imm/tools/immxml-merge| 32 
 src/imm/tools/immxml-validate | 16 
 3 files changed, 41 insertions(+), 39 deletions(-)

diff --git a/src/imm/tools/baseimm.py b/src/imm/tools/baseimm.py
index fe1c3ce..17e85eb 100644
--- a/src/imm/tools/baseimm.py
+++ b/src/imm/tools/baseimm.py
@@ -84,7 +84,8 @@ class BaseImmDocument(object):
 @staticmethod
 def format_xml_file_with_xmllint(in_file_name, out_file_name):
 """ Format xml file with xmllint """
-trace("formatXmlFileWithXmlLint() prettify xml file:%s", in_file_name)
+trace("format_xml_file_with_xmllint() prettify xml file: %s",
+  in_file_name)
 
 # "prettify" the result file with xmllint
 # (due to inadequate python/minidom prettify functionality)
@@ -123,7 +124,7 @@ class BaseImmDocument(object):
 doc = open(file_name)
 str_list = []
 imm_contents_tag_found = False
-# imm_contents_tag_replaced = False
+imm_contents_tag_replaced = False
 for _line in doc:
 line = _line
 if not imm_contents_tag_found:
@@ -140,18 +141,19 @@ class BaseImmDocument(object):
 
 xml_str = ' '.join(str_list)
 
-# if Options.schemaFilename is not None:
-# if imm_contents_tag_replaced:
-# print_info_stderr("Cannot validate input file '%s' with "
-#   "schema file because of missing namespace "
-#   "specification in element "
-#   ". \nProceeding with "
-#   "processing of modified input data!",
-#   file_name)
-# else:
-# if self.validate_xml_file(file_name) != 0:
-# abort_script("Failed to validate the input file: %s",
-#  file_name)
+if Options.schemaFilename is not None:
+if imm_contents_tag_replaced:
+print_info_stderr("Cannot validate input file '%s' with "
+  "schema file because of missing namespace "
+  "specification in element "
+  ". \nProceeding with "
+  "processing of modified input data!",
+  file_name)
+else:
+if self.validate_xml_file(file_name) != 0:
+abort_script("Failed to validate the input file: %s",
+ file_name)
+
 return xml.dom.minidom.parseString(xml_str)
 
 @staticmethod
@@ -188,7 +190,7 @@ def trace(*args):
 
 def retrieve_file_names(args):
 """ Retrieve file names """
-trace("Before glob args:%s", args)
+trace("Before glob args: %s", args)
 # Wildcard expansion for WIN support, however not tested
 file_list = glob.glob(args[0])
 trace("After glob file list: %s length: %d", file_list, len(file_list))
diff --git a/src/imm/tools/immxml-merge b/src/imm/tools/immxml-merge
index 7489da3..3a9edda 100755
--- a/src/imm/tools/immxml-merge
+++ b/src/imm/tools/immxml-merge
@@ -113,7 +113,7 @@ class MergedImmDocument(BaseImmDocument):
 """ Add classes matching pattern """
 class_name = class_element.getAttribute("name")
 self.classes_parsed = self.classes_parsed + 1
-trace("className: %s nodeType:%d nodeName:%s", class_name,
+trace("className:%s nodeType:%d nodeName:%s", class_name,
   class_element.nodeType, class_element.nodeName)
 
 if self.regexpObj is not None:
@@ -129,7 +129,7 @@ class MergedImmDocument(BaseImmDocument):
   Options.grep_class)
 return
 
-trace("match ok :%s", class_name)
+trace("match ok: %s", class_name)
 
 # Check if class exists in dictionary map
 if class_name in self.classDict:
@@ -146,7 +146,7 @@ class MergedImmDocument(BaseImmDocument):
 def add_object(self, object_element, other_nodes):
 """ Add objects matching pattern """
 class_name = object_element.getAttribute("class")
-trace("DUMPING Object with className: %s \n %s", class_name,
+trace("DUMPING Object with className: %s\n %s", class_name,
   object_element.toxml())
 self.objects_parsed = self.objects_parsed + 1
 
@@ -160,7 +160,7 @@ class MergedImmDocument(BaseImmDocument):
 if object_dn_element is None or class_name is None \
 

[devel] [PATCH 0/1] Review Request for Restore printout format in immxml tools to maintain backward compatibility [#2728]

2017-12-04 Thread Nguyen Luu
Summary: imm: Restore printout format in immxml tools to maintain backward 
compatibility [#2728]
Review request for Ticket(s): 2728
Peer Reviewer(s): Zoran Milinkovic, Vu Minh Nguyen
Pull request to: Zoran Milinkovic
Affected branch(es): develop
Development branch: ticket-2728
Base revision: d54303925f86813c5c2fa1103f3c8ed841488145
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   y


Comments (indicate scope for each "y" above):
-
revision 17e0c8f44cb70a9763ef8b5b825f20b84d76627b
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Tue, 5 Dec 2017 13:52:39 +0700

imm: Restore printout format in immxml tools to maintain backward compatibility 
[#2728]

- Restore the previous printout format in the immxml tools, which
  happened to be changed by ticket #2664 for better readability, in order
  to maintain backward-compatibility for any user scripts/tools that have
  been depending their check on the former printout.
- Some other minor updates regarding formatting.



Complete diffstat:
--
 src/imm/tools/baseimm.py  | 32 +---
 src/imm/tools/immxml-merge| 32 
 src/imm/tools/immxml-validate | 16 
 3 files changed, 41 insertions(+), 39 deletions(-)


Testing Commands:
-
*** LIST THE COMMAND LINE TOOLS/STEPS TO TEST YOUR CHANGES ***


Testing, Expected Results:
--
*** PASTE COMMAND OUTPUTS / TEST RESULTS ***


Conditions of Submission:
-
Ack from one of the reviewers.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.ne

[devel] [PATCH 1/1] tools: Fix pylint and pep8 issues for tools written in Python [#2664]

2017-11-20 Thread Nguyen Luu
Fix pylint and pep8 issues for the following Python files:
  ./tools/devel/dot/trace2dot
  ./tools/devel/review/patch-tokenize.py
  ./src/imm/tools/immxml-merge
  ./src/imm/tools/immxml-validate
  ./src/imm/tools/baseimm.py
---
 src/imm/tools/baseimm.py | 376 ---
 src/imm/tools/immxml-merge   | 890 +++
 src/imm/tools/immxml-validate| 792 +--
 tools/devel/dot/trace2dot|  70 +--
 tools/devel/review/patch-tokenize.py |  16 +-
 5 files changed, 1176 insertions(+), 968 deletions(-)

diff --git a/src/imm/tools/baseimm.py b/src/imm/tools/baseimm.py
index 09a9b85..fe1c3ce 100644
--- a/src/imm/tools/baseimm.py
+++ b/src/imm/tools/baseimm.py
@@ -1,221 +1,258 @@
-'''
-  -*- OpenSAF  -*-
-
- (C) Copyright 2009 The OpenSAF Foundation
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
- under the GNU Lesser General Public License Version 2.1, February 1999.
- The complete license can be accessed from the following location:
- http://opensource.org/licenses/lgpl-license.php
- See the Copying file included with the OpenSAF distribution for full
- licensing terms.
-
- Author(s): Ericsson AB
-'''
-
-import sys,glob,os
+#  -*- OpenSAF  -*-
+#
+# (C) Copyright 2009 The OpenSAF Foundation
+# (C) Copyright Ericsson AB 2015, 2016, 2017. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+""" Common utils to manipulate immxml files """
+from __future__ import print_function
+import os
+import sys
+import glob
+import xml.dom.minidom
 from subprocess import call
 
-class BaseOptions:
+
+class BaseOptions(object):
+""" Base options for immxml tools """
 traceOn = False
 
 @staticmethod
-def printOptionSettings():
-return 'Options:\n traceOn:%s\n' % (BaseOptions.traceOn)
-
+def print_option_settings():
+return 'Options:\n traceOn:%s\n' % BaseOptions.traceOn
 
 
-class BaseImmDocument:
+class BaseImmDocument(object):
+""" Base class with common methods to manipulate IMM XML documents """
 imm_content_element_name = "imm:IMM-contents"
 imm_content_no_namespace_spec = ""
-imm_content_with_namespace_spec = "http://www.saforum.org/IMMSchema\; 
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\; 
xsi:noNamespaceSchemaLocation=\"SAI-AIS-IMM-XSD-A.02.13.xsd\">"
-
- # helper function to identify a problem where python/minidom
-# fails to parse some imm.xml files where the imm: namespace is missing
-# (for example the output of the immdump tool)
-def verifyInputXmlDocumentFileIsParsable(self, filename):
-if os.stat(filename).st_size == 0:
-abort_script("The inputfile %s is empty!", filename)
-
-f = open(filename)
-immContentsTagFound = False
-for line in f:
-s = line
-str = s.replace(self.imm_content_no_namespace_spec, 
self.imm_content_with_namespace_spec)
-if len(str) != len(s):
-# there was a substitutionfile will not be possible to 
parse
-abort_script("The inputfile lacks namespace specification in 
 tag")
-elif s.find(self.imm_content_element_name) != -1:
-# Assume file is ok w.r.t namespace 
+imm_content_with_namespace_spec = \
+"http://www.saforum.org/IMMSchema\; " \
+"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\; " \
+"xsi:noNamespaceSchemaLocation=\"SAI-AIS-IMM-XSD-A.02.13.xsd\">"
+
+def verify_input_xml_document_file_is_parsable(self, file_name):
+""" Helper function to identify a problem where python/minidom fails to
+parse some imm.xml files where the imm namespace is missing (for ex,
+the output of the immdump tool)
+"""
+if os.stat(file_name).st_size == 0:
+abort_script("The input file %s is empty!", file_name)
+
+doc = open(file_name)
+for _line in doc:
+line = _line
+string = line.replace(self.imm_content_no_namespace_spec,
+  self.imm_content_with_namespace_spec)
+if len(string) != len(line):
+# There was a substitutionfile will not be possible
+# to parse
+

[devel] [PATCH 0/1] Review Request for tools: Fix pylint and pep8 issues for tools written in Python V2 [#2664]

2017-11-20 Thread Nguyen Luu
Summary: tools: Fix pylint and pep8 issues for tools written in Python [#2664]
Review request for Ticket(s): 2664
Peer Reviewer(s): Hans Nordeback, Anders Widell, Quyen Dao
Pull request to: Hans Nordeback
Affected branch(es): develop
Development branch: ticket-2664
Base revision: f324f713e986016dd6719cb244e31e59df8fc01d
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   y


Comments (indicate scope for each "y" above):
-
*** Patch V2: updated with pylint and pep8 corrections for the change added by 
ticket #2663 ***

revision aad75ae26682701562f01b090ad7fdbe999a0746
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Mon, 20 Nov 2017 17:51:19 +0700

tools: Fix pylint and pep8 issues for tools written in Python [#2664]

Fix pylint and pep8 issues for the following Python files:
  ./tools/devel/dot/trace2dot
  ./tools/devel/review/patch-tokenize.py
  ./src/imm/tools/immxml-merge
  ./src/imm/tools/immxml-validate
  ./src/imm/tools/baseimm.py



Complete diffstat:
--
 src/imm/tools/baseimm.py | 376 ---
 src/imm/tools/immxml-merge   | 890 +++
 src/imm/tools/immxml-validate| 792 +--
 tools/devel/dot/trace2dot|  70 +--
 tools/devel/review/patch-tokenize.py |  16 +-
 5 files changed, 1176 insertions(+), 968 deletions(-)


Testing Commands:
-
Run pylint and pep8 for the tools mentioned in this commit.


Testing, Expected Results:
--
pylint score for each file is over 9.50.
pep8 should report no issue.


Conditions of Submission:
-
Ack from one of the reviewers.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://s

Re: [devel] [PATCH 1/1] base: Make pylint output format selectable V2 [#2686]

2017-11-20 Thread Nguyen Luu

Hi Hans,

Ack from me. Tested OK with both pylint-1.6.5 and pylint-1.7.4.

I just have one minor suggestion for the README. Please find it inline, 
marked with [Nguyen].


Thanks,
Nguyen

On 11/17/2017 6:50 PM, Hans Nordeback wrote:

The output format can now be given, e.g.:

make pylint (defaults to text)
make pylint FORMAT=html
make pylint FORMAT=parseable
make pylint FORMAT=json
---
  Makefile.am   | 4 +++-
  python/README | 8 
  2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index f6dd784c3..45fc5c207 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -66,6 +66,8 @@ AM_LDFLAGS = @OSAF_HARDEN_FLAGS@ -Wl,--as-needed -ldl -lrt 
-pthread -rdynamic
  ACLOCAL_AMFLAGS = -I m4
  OSAF_LIB_FLAGS =
  
+FORMAT = "text"

+
  systemdversion = $(systemdmodversion)
  #
  # Define some useful directory prefixes/suffixes
@@ -436,7 +438,7 @@ checkpatch:
  
  pylint:

@srcdir=$$(cd $(top_srcdir); pwd; cd - > /dev/null); \
-   cd "$$srcdir/python"; find . -name '*.py' | xargs pylint --rcfile=pylintrc 
--output-format=text > pylint.res; \
+   cd "$$srcdir/python"; find . -name '*.py' | xargs pylint --rcfile=pylintrc 
--output-format=$(FORMAT) > pylint.res; \
true
@echo "The pylint result can be found in the file python/pylint.res"
  
diff --git a/python/README b/python/README

index 798da53db..047a77b2c 100644
--- a/python/README
+++ b/python/README
@@ -228,3 +228,11 @@ for attr in unmarshalNullArray(attrDefs):
unmarshalSaImmValue(attr.attrDefaultValue, attr.attrValueType)
  
  saImmOmClassDescriptionMemoryFree_2(omHandle, attrDefs)

+
+
+To run pylint use the following command:
+
+make pylint (defaults to text)
+make pylint FORMAT=html
[Nguyen] Should note about this format not being supported anymore for 
pylint versions >=1.7, or the users may get confused about the error 
when it happens.
=> So probably put it like:    make pylint FORMAT=html (no longer 
supported since pylint-1.7.x)

+make pylint FORMAT=parseable
+make pylint FORMAT=json
\ No newline at end of file



--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 1/1] tools: Fix pylint and pep8 issues for tools written in Python [#2664]

2017-10-31 Thread Nguyen Luu
Fix pylint and pep8 issues for the following Python files:
  ./tools/devel/dot/trace2dot
  ./tools/devel/review/patch-tokenize.py
  ./src/imm/tools/immxml-merge
  ./src/imm/tools/immxml-validate
  ./src/imm/tools/baseimm.py
---
 src/imm/tools/baseimm.py | 376 ---
 src/imm/tools/immxml-merge   | 891 +++
 src/imm/tools/immxml-validate| 792 +--
 tools/devel/dot/trace2dot|  70 +--
 tools/devel/review/patch-tokenize.py |  16 +-
 5 files changed, 1174 insertions(+), 971 deletions(-)

diff --git a/src/imm/tools/baseimm.py b/src/imm/tools/baseimm.py
index 09a9b85..fe1c3ce 100644
--- a/src/imm/tools/baseimm.py
+++ b/src/imm/tools/baseimm.py
@@ -1,221 +1,258 @@
-'''
-  -*- OpenSAF  -*-
-
- (C) Copyright 2009 The OpenSAF Foundation
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
- under the GNU Lesser General Public License Version 2.1, February 1999.
- The complete license can be accessed from the following location:
- http://opensource.org/licenses/lgpl-license.php
- See the Copying file included with the OpenSAF distribution for full
- licensing terms.
-
- Author(s): Ericsson AB
-'''
-
-import sys,glob,os
+#  -*- OpenSAF  -*-
+#
+# (C) Copyright 2009 The OpenSAF Foundation
+# (C) Copyright Ericsson AB 2015, 2016, 2017. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+""" Common utils to manipulate immxml files """
+from __future__ import print_function
+import os
+import sys
+import glob
+import xml.dom.minidom
 from subprocess import call
 
-class BaseOptions:
+
+class BaseOptions(object):
+""" Base options for immxml tools """
 traceOn = False
 
 @staticmethod
-def printOptionSettings():
-return 'Options:\n traceOn:%s\n' % (BaseOptions.traceOn)
-
+def print_option_settings():
+return 'Options:\n traceOn:%s\n' % BaseOptions.traceOn
 
 
-class BaseImmDocument:
+class BaseImmDocument(object):
+""" Base class with common methods to manipulate IMM XML documents """
 imm_content_element_name = "imm:IMM-contents"
 imm_content_no_namespace_spec = ""
-imm_content_with_namespace_spec = "http://www.saforum.org/IMMSchema\; 
xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\; 
xsi:noNamespaceSchemaLocation=\"SAI-AIS-IMM-XSD-A.02.13.xsd\">"
-
- # helper function to identify a problem where python/minidom
-# fails to parse some imm.xml files where the imm: namespace is missing
-# (for example the output of the immdump tool)
-def verifyInputXmlDocumentFileIsParsable(self, filename):
-if os.stat(filename).st_size == 0:
-abort_script("The inputfile %s is empty!", filename)
-
-f = open(filename)
-immContentsTagFound = False
-for line in f:
-s = line
-str = s.replace(self.imm_content_no_namespace_spec, 
self.imm_content_with_namespace_spec)
-if len(str) != len(s):
-# there was a substitutionfile will not be possible to 
parse
-abort_script("The inputfile lacks namespace specification in 
 tag")
-elif s.find(self.imm_content_element_name) != -1:
-# Assume file is ok w.r.t namespace 
+imm_content_with_namespace_spec = \
+"http://www.saforum.org/IMMSchema\; " \
+"xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\; " \
+"xsi:noNamespaceSchemaLocation=\"SAI-AIS-IMM-XSD-A.02.13.xsd\">"
+
+def verify_input_xml_document_file_is_parsable(self, file_name):
+""" Helper function to identify a problem where python/minidom fails to
+parse some imm.xml files where the imm namespace is missing (for ex,
+the output of the immdump tool)
+"""
+if os.stat(file_name).st_size == 0:
+abort_script("The input file %s is empty!", file_name)
+
+doc = open(file_name)
+for _line in doc:
+line = _line
+string = line.replace(self.imm_content_no_namespace_spec,
+  self.imm_content_with_namespace_spec)
+if len(string) != len(line):
+# There was a substitutionfile will not be possible
+# to parse
+

[devel] [PATCH 0/1] Review Request for tools: Fix pylint and pep8 issues for tools written in Python [#2664]

2017-10-31 Thread Nguyen Luu
Summary: tools: Fix pylint and pep8 issues for tools written in Python [#2664]
Review request for Ticket(s): 2664
Peer Reviewer(s): Hans Nordeback, Srinivas Mangipudy, Quyen Dao
Pull request to: Hans Nordeback
Affected branch(es): develop
Development branch: ticket-2664
Base revision: 836ce640407fff9072227f91be17b0a9d2d6746d
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   y


Comments (indicate scope for each "y" above):
-
revision bcbf709cdd7a35ce0dfa7e2278092d2924740255
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Tue, 31 Oct 2017 17:14:49 +0700

tools: Fix pylint and pep8 issues for tools written in Python [#2664]

Fix pylint and pep8 issues for the following Python files:
  ./tools/devel/dot/trace2dot
  ./tools/devel/review/patch-tokenize.py
  ./src/imm/tools/immxml-merge
  ./src/imm/tools/immxml-validate
  ./src/imm/tools/baseimm.py



Complete diffstat:
--
 src/imm/tools/baseimm.py | 376 ---
 src/imm/tools/immxml-merge   | 891 +++
 src/imm/tools/immxml-validate| 792 +--
 tools/devel/dot/trace2dot|  70 +--
 tools/devel/review/patch-tokenize.py |  16 +-
 5 files changed, 1174 insertions(+), 971 deletions(-)


Testing Commands:
-
Run pylint and pep8 for the tools mentioned in this commit.


Testing, Expected Results:
--
pylint score for each file is over 9.50.
pep8 should report no issue.


Conditions of Submission:
-
Ack from one of the reviewers.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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
Opensaf-devel@lists.sourc

[devel] [PATCH 1/1] pyosaf: High level python interfaces for NTF [#2602]

2017-10-27 Thread Nguyen Luu
Improve the implementation of NTF pyosaf utils
---
 python/Makefile.am|   6 +-
 python/pyosaf/saNtf.py|   4 +-
 python/pyosaf/utils/ntf/__init__.py   | 855 ++-
 python/pyosaf/utils/ntf/agent.py  | 500 ++
 python/pyosaf/utils/ntf/producer.py   | 711 ++
 python/pyosaf/utils/ntf/reader.py | 187 +++
 python/pyosaf/utils/ntf/subscriber.py | 923 ++
 7 files changed, 2599 insertions(+), 587 deletions(-)
 create mode 100644 python/pyosaf/utils/ntf/agent.py
 create mode 100644 python/pyosaf/utils/ntf/producer.py
 create mode 100644 python/pyosaf/utils/ntf/reader.py
 create mode 100644 python/pyosaf/utils/ntf/subscriber.py

diff --git a/python/Makefile.am b/python/Makefile.am
index 390366a..0b79067 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -62,6 +62,10 @@ pkgpyosafutilsimmoi_PYTHON = \
python/pyosaf/utils/immoi/implementer.py
 
 pkgpyosafutilsntf_PYTHON = \
-   python/pyosaf/utils/ntf/__init__.py
+   python/pyosaf/utils/ntf/__init__.py \
+   python/pyosaf/utils/ntf/agent.py \
+   python/pyosaf/utils/ntf/producer.py \
+   python/pyosaf/utils/ntf/subscriber.py \
+   python/pyosaf/utils/ntf/reader.py
 
 endif
diff --git a/python/pyosaf/saNtf.py b/python/pyosaf/saNtf.py
index 7438cdc..9ee096e 100644
--- a/python/pyosaf/saNtf.py
+++ b/python/pyosaf/saNtf.py
@@ -15,7 +15,7 @@
 #
 
 
-from ctypes import POINTER, CFUNCTYPE, Structure, Union, CDLL, c_char
+from ctypes import POINTER, CFUNCTYPE, Structure, Union, CDLL, c_char, cast
 from pyosaf.saAis import SaUint64T, SaEnumT, Enumeration, Const, BYREF, \
 SaUint32T, SaUint16T, SaBoolT, SaStringT, SaNameT, SaTimeT, SaDoubleT, 
\
 SaInt64T, SaUint8T, SaInt8T, SaInt16T, SaInt32T, SaFloatT, SaAnyT
@@ -655,7 +655,7 @@ class SaNtfNotificationTypeFilterHandlesT_3(Structure):
('securityAlarmFilterHandle', SaNtfNotificationFilterHandleT),
('miscellaneousFilterHandle', SaNtfNotificationFilterHandleT)]
 
-saNtf.SA_NTF_FILTER_HANDLE_NULL = None
+saNtf.SA_NTF_FILTER_HANDLE_NULL = 0
 
 #if defined(SA_NTF_A01) || defined(SA_NTF_A02)
 class _notification(Union):
diff --git a/python/pyosaf/utils/ntf/__init__.py 
b/python/pyosaf/utils/ntf/__init__.py
index a76867e..0687517 100644
--- a/python/pyosaf/utils/ntf/__init__.py
+++ b/python/pyosaf/utils/ntf/__init__.py
@@ -15,259 +15,49 @@
 # Author(s): Ericsson
 #
 
-# pylint: disable=unused-argument,too-many-arguments
+# pylint: disable=too-many-arguments
 """ NTF common utilities """
-import ctypes
-
-from pyosaf.saAis import saAis, SaVersionT, SaSelectionObjectT, eSaBoolT, \
-eSaDispatchFlagsT
+from pyosaf.saAis import saAis, eSaAisErrorT, SaVersionT, eSaDispatchFlagsT
 from pyosaf import saNtf
-from pyosaf.utils import decorate, initialize_decorate
-
-
-# Decorate pure saNtf* API's with error-handling retry and exception raising
-saNtfInitialize = initialize_decorate(saNtf.saNtfInitialize)
-saNtfLocalizedMessageFree = decorate(saNtf.saNtfLocalizedMessageFree)
-saNtfStateChangeNotificationFilterAllocate = \
-decorate(saNtf.saNtfStateChangeNotificationFilterAllocate)
-saNtfNotificationUnsubscribe = decorate(saNtf.saNtfNotificationUnsubscribe)
-saNtfNotificationReadInitialize = \
-decorate(saNtf.saNtfNotificationReadInitialize)
-saNtfInitialize_2 = initialize_decorate(saNtf.saNtfInitialize_2)
-saNtfNotificationReadInitialize_2 = \
-decorate(saNtf.saNtfNotificationReadInitialize_2)
-saNtfNotificationSubscribe = decorate(saNtf.saNtfNotificationSubscribe)
-saNtfInitialize_3 = initialize_decorate(saNtf.saNtfInitialize_3)
-saNtfSelectionObjectGet = decorate(saNtf.saNtfSelectionObjectGet)
-saNtfDispatch = decorate(saNtf.saNtfDispatch)
-saNtfFinalize = decorate(saNtf.saNtfFinalize)
-saNtfObjectCreateDeleteNotificationAllocate = \
-decorate(saNtf.saNtfObjectCreateDeleteNotificationAllocate)
-saNtfAttributeChangeNotificationAllocate = \
-decorate(saNtf.saNtfAttributeChangeNotificationAllocate)
-saNtfStateChangeNotificationAllocate = \
-decorate(saNtf.saNtfStateChangeNotificationAllocate)
-saNtfStateChangeNotificationAllocate_3 = \
-decorate(saNtf.saNtfStateChangeNotificationAllocate_3)
-saNtfAlarmNotificationAllocate = decorate(saNtf.saNtfAlarmNotificationAllocate)
-saNtfSecurityAlarmNotificationAllocate = \
-decorate(saNtf.saNtfSecurityAlarmNotificationAllocate)
-saNtfMiscellaneousNotificationAllocate = \
-decorate(saNtf.saNtfMiscellaneousNotificationAllocate)
-saNtfPtrValAllocate = decorate(saNtf.saNtfPtrValAllocate)
-saNtfArrayValAllocate = decorate(saNtf.saNtfArrayValAllocate)
-saNtfIdentifierAllocate = decorate(saNtf.saNtfIdentifierAllocate)
-saNtfNotificationSend = decorate(saNtf.saNtfNotificationSend)

[devel] [PATCH 0/1] Review Request for pyosaf: High level python interfaces for NTF V4 [#2602]

2017-10-27 Thread Nguyen Luu
Summary: pyosaf: High level python interfaces for NTF [#2602]
Review request for Ticket(s): 2602
Peer Reviewer(s): Hans Nordeback, Anders Widell, Srinivas Mangipudy, Quyen Dao
Pull request to: Zoran Milinkovic
Affected branch(es): develop
Development branch: ticket-2602
Base revision: 864c0da8d303f420cdb86e3390f239d20ab9801c
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   y


Comments (indicate scope for each "y" above):
-
revision 6b05b92f072e0f247b52c656600ceaba0a852d86
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Fri, 27 Oct 2017 21:53:04 +0700

pyosaf: High level python interfaces for NTF [#2602]

Improve the implementation of NTF pyosaf utils



Added Files:

 python/pyosaf/utils/ntf/agent.py
 python/pyosaf/utils/ntf/producer.py
 python/pyosaf/utils/ntf/reader.py
 python/pyosaf/utils/ntf/subscriber.py


Complete diffstat:
--
 python/Makefile.am|   6 +-
 python/pyosaf/saNtf.py|   4 +-
 python/pyosaf/utils/ntf/__init__.py   | 855 ++-
 python/pyosaf/utils/ntf/agent.py  | 500 ++
 python/pyosaf/utils/ntf/producer.py   | 711 ++
 python/pyosaf/utils/ntf/reader.py | 187 +++
 python/pyosaf/utils/ntf/subscriber.py | 923 ++
 7 files changed, 2599 insertions(+), 587 deletions(-)


Testing Commands:
-


Testing, Expected Results:
--


Conditions of Submission:
-


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 1/1] pyosaf: High level python interfaces for NTF [#2602]

2017-10-27 Thread Nguyen Luu
Improve the implementation of NTF pyosaf utils
---
 python/pyosaf/saNtf.py|   4 +-
 python/pyosaf/utils/ntf/__init__.py   | 855 ++-
 python/pyosaf/utils/ntf/agent.py  | 500 ++
 python/pyosaf/utils/ntf/producer.py   | 711 ++
 python/pyosaf/utils/ntf/reader.py | 187 +++
 python/pyosaf/utils/ntf/subscriber.py | 923 ++
 6 files changed, 2594 insertions(+), 586 deletions(-)
 create mode 100644 python/pyosaf/utils/ntf/agent.py
 create mode 100644 python/pyosaf/utils/ntf/producer.py
 create mode 100644 python/pyosaf/utils/ntf/reader.py
 create mode 100644 python/pyosaf/utils/ntf/subscriber.py

diff --git a/python/pyosaf/saNtf.py b/python/pyosaf/saNtf.py
index 7438cdc..9ee096e 100644
--- a/python/pyosaf/saNtf.py
+++ b/python/pyosaf/saNtf.py
@@ -15,7 +15,7 @@
 #
 
 
-from ctypes import POINTER, CFUNCTYPE, Structure, Union, CDLL, c_char
+from ctypes import POINTER, CFUNCTYPE, Structure, Union, CDLL, c_char, cast
 from pyosaf.saAis import SaUint64T, SaEnumT, Enumeration, Const, BYREF, \
 SaUint32T, SaUint16T, SaBoolT, SaStringT, SaNameT, SaTimeT, SaDoubleT, 
\
 SaInt64T, SaUint8T, SaInt8T, SaInt16T, SaInt32T, SaFloatT, SaAnyT
@@ -655,7 +655,7 @@ class SaNtfNotificationTypeFilterHandlesT_3(Structure):
('securityAlarmFilterHandle', SaNtfNotificationFilterHandleT),
('miscellaneousFilterHandle', SaNtfNotificationFilterHandleT)]
 
-saNtf.SA_NTF_FILTER_HANDLE_NULL = None
+saNtf.SA_NTF_FILTER_HANDLE_NULL = 0
 
 #if defined(SA_NTF_A01) || defined(SA_NTF_A02)
 class _notification(Union):
diff --git a/python/pyosaf/utils/ntf/__init__.py 
b/python/pyosaf/utils/ntf/__init__.py
index a76867e..0687517 100644
--- a/python/pyosaf/utils/ntf/__init__.py
+++ b/python/pyosaf/utils/ntf/__init__.py
@@ -15,259 +15,49 @@
 # Author(s): Ericsson
 #
 
-# pylint: disable=unused-argument,too-many-arguments
+# pylint: disable=too-many-arguments
 """ NTF common utilities """
-import ctypes
-
-from pyosaf.saAis import saAis, SaVersionT, SaSelectionObjectT, eSaBoolT, \
-eSaDispatchFlagsT
+from pyosaf.saAis import saAis, eSaAisErrorT, SaVersionT, eSaDispatchFlagsT
 from pyosaf import saNtf
-from pyosaf.utils import decorate, initialize_decorate
-
-
-# Decorate pure saNtf* API's with error-handling retry and exception raising
-saNtfInitialize = initialize_decorate(saNtf.saNtfInitialize)
-saNtfLocalizedMessageFree = decorate(saNtf.saNtfLocalizedMessageFree)
-saNtfStateChangeNotificationFilterAllocate = \
-decorate(saNtf.saNtfStateChangeNotificationFilterAllocate)
-saNtfNotificationUnsubscribe = decorate(saNtf.saNtfNotificationUnsubscribe)
-saNtfNotificationReadInitialize = \
-decorate(saNtf.saNtfNotificationReadInitialize)
-saNtfInitialize_2 = initialize_decorate(saNtf.saNtfInitialize_2)
-saNtfNotificationReadInitialize_2 = \
-decorate(saNtf.saNtfNotificationReadInitialize_2)
-saNtfNotificationSubscribe = decorate(saNtf.saNtfNotificationSubscribe)
-saNtfInitialize_3 = initialize_decorate(saNtf.saNtfInitialize_3)
-saNtfSelectionObjectGet = decorate(saNtf.saNtfSelectionObjectGet)
-saNtfDispatch = decorate(saNtf.saNtfDispatch)
-saNtfFinalize = decorate(saNtf.saNtfFinalize)
-saNtfObjectCreateDeleteNotificationAllocate = \
-decorate(saNtf.saNtfObjectCreateDeleteNotificationAllocate)
-saNtfAttributeChangeNotificationAllocate = \
-decorate(saNtf.saNtfAttributeChangeNotificationAllocate)
-saNtfStateChangeNotificationAllocate = \
-decorate(saNtf.saNtfStateChangeNotificationAllocate)
-saNtfStateChangeNotificationAllocate_3 = \
-decorate(saNtf.saNtfStateChangeNotificationAllocate_3)
-saNtfAlarmNotificationAllocate = decorate(saNtf.saNtfAlarmNotificationAllocate)
-saNtfSecurityAlarmNotificationAllocate = \
-decorate(saNtf.saNtfSecurityAlarmNotificationAllocate)
-saNtfMiscellaneousNotificationAllocate = \
-decorate(saNtf.saNtfMiscellaneousNotificationAllocate)
-saNtfPtrValAllocate = decorate(saNtf.saNtfPtrValAllocate)
-saNtfArrayValAllocate = decorate(saNtf.saNtfArrayValAllocate)
-saNtfIdentifierAllocate = decorate(saNtf.saNtfIdentifierAllocate)
-saNtfNotificationSend = decorate(saNtf.saNtfNotificationSend)
-saNtfNotificationSendWithId = decorate(saNtf.saNtfNotificationSendWithId)
-saNtfNotificationFree = decorate(saNtf.saNtfNotificationFree)
-saNtfVariableDataSizeGet = decorate(saNtf.saNtfVariableDataSizeGet)
-saNtfLocalizedMessageGet = decorate(saNtf.saNtfLocalizedMessageGet)
-saNtfLocalizedMessageFree_2 = decorate(saNtf.saNtfLocalizedMessageFree_2)
-saNtfPtrValGet = decorate(saNtf.saNtfPtrValGet)
-saNtfArrayValGet = decorate(saNtf.saNtfArrayValGet)
-saNtfObjectCreateDeleteNotificationFilterAllocate = \
-decorate(saNtf.saNtfObjectCreateDeleteNotificationFilterAllocate)

[devel] [PATCH 0/1] Review Request for pyosaf: High level python interfaces for NTF V3 [#2602]

2017-10-27 Thread Nguyen Luu
Summary: pyosaf: High level python interfaces for NTF [#2602]
Review request for Ticket(s): 2602
Peer Reviewer(s): Hans Nordeback, Anders Widell, Srinivas Mangipudy, Quyen Dao
Pull request to: Zoran Milinkovic
Affected branch(es): develop
Development branch: ticket-2602
Base revision: 2a7a20bafa7f189fca79bd73e6d678c58fda64dd
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   y


Comments (indicate scope for each "y" above):
-
revision e582f51adac286b9492fcc358468cbc0c7fdf2cb
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Fri, 27 Oct 2017 20:52:50 +0700

pyosaf: High level python interfaces for NTF [#2602]

Improve the implementation of NTF pyosaf utils



Added Files:

 python/pyosaf/utils/ntf/agent.py
 python/pyosaf/utils/ntf/producer.py
 python/pyosaf/utils/ntf/reader.py
 python/pyosaf/utils/ntf/subscriber.py


Complete diffstat:
--
 python/pyosaf/saNtf.py|   4 +-
 python/pyosaf/utils/ntf/__init__.py   | 855 ++-
 python/pyosaf/utils/ntf/agent.py  | 500 ++
 python/pyosaf/utils/ntf/producer.py   | 711 ++
 python/pyosaf/utils/ntf/reader.py | 187 +++
 python/pyosaf/utils/ntf/subscriber.py | 923 ++
 6 files changed, 2594 insertions(+), 586 deletions(-)


Testing Commands:
-
Create a test NTF producer/subscriber/reader using the new
NTF pyosaf utils and execute some provided functions.


Testing, Expected Results:
--
The NTF producer/subscriber/reader functions are successfully
achieved with the new NTF pyosaf utils.


Conditions of Submission:
-
Ack from one of the reviewers.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Sl

[devel] [PATCH 1/1] pyosaf: High level python interfaces for NTF [#2602]

2017-10-27 Thread Nguyen Luu
Improve the implementation of NTF pyosaf utils.

The following comments shall be removed when the patch is pushed.
- This is the 2nd patch in the series of patches to improve the
  implementation of the pyosaf utils for OpenSAF services.
- This patch is based on and uses the code change of the
  pyosaf/utils/__init__.py file in the following patch for CLM:

  [devel] [PATCH 1/1] pyosaf: High level python interfaces for CLM [#2602]
  https://sourceforge.net/p/opensaf/mailman/message/36088562/
---
 python/pyosaf/saNtf.py|   4 +-
 python/pyosaf/utils/ntf/__init__.py   | 899 -
 python/pyosaf/utils/ntf/agent.py  | 498 ++
 python/pyosaf/utils/ntf/producer.py   | 711 ++
 python/pyosaf/utils/ntf/reader.py | 182 +++
 python/pyosaf/utils/ntf/subscriber.py | 921 ++
 6 files changed, 2637 insertions(+), 578 deletions(-)
 create mode 100644 python/pyosaf/utils/ntf/agent.py
 create mode 100644 python/pyosaf/utils/ntf/producer.py
 create mode 100644 python/pyosaf/utils/ntf/reader.py
 create mode 100644 python/pyosaf/utils/ntf/subscriber.py

diff --git a/python/pyosaf/saNtf.py b/python/pyosaf/saNtf.py
index 7438cdc..9ee096e 100644
--- a/python/pyosaf/saNtf.py
+++ b/python/pyosaf/saNtf.py
@@ -15,7 +15,7 @@
 #
 
 
-from ctypes import POINTER, CFUNCTYPE, Structure, Union, CDLL, c_char
+from ctypes import POINTER, CFUNCTYPE, Structure, Union, CDLL, c_char, cast
 from pyosaf.saAis import SaUint64T, SaEnumT, Enumeration, Const, BYREF, \
 SaUint32T, SaUint16T, SaBoolT, SaStringT, SaNameT, SaTimeT, SaDoubleT, 
\
 SaInt64T, SaUint8T, SaInt8T, SaInt16T, SaInt32T, SaFloatT, SaAnyT
@@ -655,7 +655,7 @@ class SaNtfNotificationTypeFilterHandlesT_3(Structure):
('securityAlarmFilterHandle', SaNtfNotificationFilterHandleT),
('miscellaneousFilterHandle', SaNtfNotificationFilterHandleT)]
 
-saNtf.SA_NTF_FILTER_HANDLE_NULL = None
+saNtf.SA_NTF_FILTER_HANDLE_NULL = 0
 
 #if defined(SA_NTF_A01) || defined(SA_NTF_A02)
 class _notification(Union):
diff --git a/python/pyosaf/utils/ntf/__init__.py 
b/python/pyosaf/utils/ntf/__init__.py
index a76867e..f44c06e 100644
--- a/python/pyosaf/utils/ntf/__init__.py
+++ b/python/pyosaf/utils/ntf/__init__.py
@@ -15,259 +15,109 @@
 # Author(s): Ericsson
 #
 
-# pylint: disable=unused-argument,too-many-arguments
+# pylint: disable=too-many-arguments
 """ NTF common utilities """
-import ctypes
-
-from pyosaf.saAis import saAis, SaVersionT, SaSelectionObjectT, eSaBoolT, \
-eSaDispatchFlagsT
+from pyosaf.saAis import saAis, eSaAisErrorT, SaVersionT, eSaDispatchFlagsT
 from pyosaf import saNtf
-from pyosaf.utils import decorate, initialize_decorate
-
-
-# Decorate pure saNtf* API's with error-handling retry and exception raising
-saNtfInitialize = initialize_decorate(saNtf.saNtfInitialize)
-saNtfLocalizedMessageFree = decorate(saNtf.saNtfLocalizedMessageFree)
-saNtfStateChangeNotificationFilterAllocate = \
-decorate(saNtf.saNtfStateChangeNotificationFilterAllocate)
-saNtfNotificationUnsubscribe = decorate(saNtf.saNtfNotificationUnsubscribe)
-saNtfNotificationReadInitialize = \
-decorate(saNtf.saNtfNotificationReadInitialize)
-saNtfInitialize_2 = initialize_decorate(saNtf.saNtfInitialize_2)
-saNtfNotificationReadInitialize_2 = \
-decorate(saNtf.saNtfNotificationReadInitialize_2)
-saNtfNotificationSubscribe = decorate(saNtf.saNtfNotificationSubscribe)
-saNtfInitialize_3 = initialize_decorate(saNtf.saNtfInitialize_3)
-saNtfSelectionObjectGet = decorate(saNtf.saNtfSelectionObjectGet)
-saNtfDispatch = decorate(saNtf.saNtfDispatch)
-saNtfFinalize = decorate(saNtf.saNtfFinalize)
+from pyosaf.utils import deprecate, SafException
+from pyosaf.utils.ntf import agent as ntf
+from pyosaf.utils.ntf.producer import NtfProducer
+from pyosaf.utils.ntf.subscriber import NtfSubscriber
+
+# Library Life Cycle API's
+saNtfInitialize = saNtf.saNtfInitialize
+saNtfInitialize_2 = saNtf.saNtfInitialize_2
+saNtfInitialize_3 = saNtf.saNtfInitialize_3
+saNtfSelectionObjectGet = saNtf.saNtfSelectionObjectGet
+saNtfDispatch = saNtf.saNtfDispatch
+saNtfFinalize = saNtf.saNtfFinalize
+# Producer API's
 saNtfObjectCreateDeleteNotificationAllocate = \
-decorate(saNtf.saNtfObjectCreateDeleteNotificationAllocate)
+saNtf.saNtfObjectCreateDeleteNotificationAllocate
 saNtfAttributeChangeNotificationAllocate = \
-decorate(saNtf.saNtfAttributeChangeNotificationAllocate)
+saNtf.saNtfAttributeChangeNotificationAllocate
 saNtfStateChangeNotificationAllocate = \
-decorate(saNtf.saNtfStateChangeNotificationAllocate)
+saNtf.saNtfStateChangeNotificationAllocate
 saNtfStateChangeNotificationAllocate_3 = \
-decorate(saNtf.saNtfStateChangeNotificationAllocate_3)
-saNtfAlarmNotificationAllocate 

[devel] [PATCH 0/1] Review Request for pyosaf: High level python interfaces for NTF V2 [#2602]

2017-10-27 Thread Nguyen Luu
Summary: pyosaf: High level python interfaces for NTF [#2602]
Review request for Ticket(s): 2602
Peer Reviewer(s): Hans Nordeback, Anders Widell, Srinivas Mangipudy
Pull request to: Hans Nordeback, Anders Widell
Affected branch(es): develop
Development branch: ticket-2602
Base revision: 0da15c4702eaed9a39f4697eee38dbd2f99f17bd
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   y


Comments (indicate scope for each "y" above):
-
revision ba8ecebcd399440496f0baf5bf95e0dcdc9b64fd
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Fri, 27 Oct 2017 16:01:03 +0700

pyosaf: High level python interfaces for NTF [#2602]

Improve the implementation of NTF pyosaf utils.

The following comments shall be removed when the patch is pushed.
- This is the 2nd patch in the series of patches to improve the
  implementation of the pyosaf utils for OpenSAF services.
- This patch is based on and uses the code change of the
  pyosaf/utils/__init__.py file in the following patch for CLM:

  [devel] [PATCH 1/1] pyosaf: High level python interfaces for CLM [#2602]
  https://sourceforge.net/p/opensaf/mailman/message/36088562/



Added Files:

 python/pyosaf/utils/ntf/agent.py
 python/pyosaf/utils/ntf/producer.py
 python/pyosaf/utils/ntf/reader.py
 python/pyosaf/utils/ntf/subscriber.py


Complete diffstat:
--
 python/pyosaf/saNtf.py|   4 +-
 python/pyosaf/utils/ntf/__init__.py   | 899 -
 python/pyosaf/utils/ntf/agent.py  | 498 ++
 python/pyosaf/utils/ntf/producer.py   | 711 ++
 python/pyosaf/utils/ntf/reader.py | 182 +++
 python/pyosaf/utils/ntf/subscriber.py | 921 ++
 6 files changed, 2637 insertions(+), 578 deletions(-)


Testing Commands:
-
Create a test NTF producer/subscriber/reader using the new
NTF pyosaf utils and execute some provided functions.


Testing, Expected Results:
--
The NTF producer/subscriber/reader functions are successfully
achieved with the new NTF pyosaf utils.


Conditions of Submission:
-
Ack from one of the reviewers.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and

[devel] [PATCH 1/1] pyosaf: High level python interfaces for NTF [#2602]

2017-10-25 Thread Nguyen Luu
Improved implementation of NTF pyosaf utils

The following comments shall be removed when the patch is pushed.

- This is the 2nd patch in the series of patches to improve the
  implementation of the pyosaf utils of OpenSAF services.
- This patch is based on and uses the code change of the
  pyosf/utils/__init__.py file in the following patch for CLM:

  [devel] [PATCH 1/1] pyosaf: High level python interfaces for CLM [#2602]
  https://sourceforge.net/p/opensaf/mailman/message/36088562/
---
 python/pyosaf/utils/ntf/__init__.py   | 881 -
 python/pyosaf/utils/ntf/agent.py  | 485 ++
 python/pyosaf/utils/ntf/producer.py   | 711 ++
 python/pyosaf/utils/ntf/reader.py | 167 +++
 python/pyosaf/utils/ntf/subscriber.py | 907 ++
 5 files changed, 2575 insertions(+), 576 deletions(-)
 create mode 100644 python/pyosaf/utils/ntf/agent.py
 create mode 100644 python/pyosaf/utils/ntf/producer.py
 create mode 100644 python/pyosaf/utils/ntf/reader.py
 create mode 100644 python/pyosaf/utils/ntf/subscriber.py

diff --git a/python/pyosaf/utils/ntf/__init__.py 
b/python/pyosaf/utils/ntf/__init__.py
index a76867e..48c3fa2 100644
--- a/python/pyosaf/utils/ntf/__init__.py
+++ b/python/pyosaf/utils/ntf/__init__.py
@@ -15,259 +15,109 @@
 # Author(s): Ericsson
 #
 
-# pylint: disable=unused-argument,too-many-arguments
+# pylint: disable=too-many-arguments
 """ NTF common utilities """
-import ctypes
-
-from pyosaf.saAis import saAis, SaVersionT, SaSelectionObjectT, eSaBoolT, \
-eSaDispatchFlagsT
+from pyosaf.saAis import saAis, eSaAisErrorT, SaVersionT, eSaDispatchFlagsT
 from pyosaf import saNtf
-from pyosaf.utils import decorate, initialize_decorate
-
-
-# Decorate pure saNtf* API's with error-handling retry and exception raising
-saNtfInitialize = initialize_decorate(saNtf.saNtfInitialize)
-saNtfLocalizedMessageFree = decorate(saNtf.saNtfLocalizedMessageFree)
-saNtfStateChangeNotificationFilterAllocate = \
-decorate(saNtf.saNtfStateChangeNotificationFilterAllocate)
-saNtfNotificationUnsubscribe = decorate(saNtf.saNtfNotificationUnsubscribe)
-saNtfNotificationReadInitialize = \
-decorate(saNtf.saNtfNotificationReadInitialize)
-saNtfInitialize_2 = initialize_decorate(saNtf.saNtfInitialize_2)
-saNtfNotificationReadInitialize_2 = \
-decorate(saNtf.saNtfNotificationReadInitialize_2)
-saNtfNotificationSubscribe = decorate(saNtf.saNtfNotificationSubscribe)
-saNtfInitialize_3 = initialize_decorate(saNtf.saNtfInitialize_3)
-saNtfSelectionObjectGet = decorate(saNtf.saNtfSelectionObjectGet)
-saNtfDispatch = decorate(saNtf.saNtfDispatch)
-saNtfFinalize = decorate(saNtf.saNtfFinalize)
+from pyosaf.utils import deprecate, SafException
+from pyosaf.utils.ntf import agent as ntf
+from pyosaf.utils.ntf.producer import NtfProducer
+from pyosaf.utils.ntf.subscriber import NtfSubscriber
+
+# Library Life Cycle API's
+saNtfInitialize = saNtf.saNtfInitialize
+saNtfInitialize_2 = saNtf.saNtfInitialize_2
+saNtfInitialize_3 = saNtf.saNtfInitialize_3
+saNtfSelectionObjectGet = saNtf.saNtfSelectionObjectGet
+saNtfDispatch = saNtf.saNtfDispatch
+saNtfFinalize = saNtf.saNtfFinalize
+# Producer API's
 saNtfObjectCreateDeleteNotificationAllocate = \
-decorate(saNtf.saNtfObjectCreateDeleteNotificationAllocate)
+saNtf.saNtfObjectCreateDeleteNotificationAllocate
 saNtfAttributeChangeNotificationAllocate = \
-decorate(saNtf.saNtfAttributeChangeNotificationAllocate)
+saNtf.saNtfAttributeChangeNotificationAllocate
 saNtfStateChangeNotificationAllocate = \
-decorate(saNtf.saNtfStateChangeNotificationAllocate)
+saNtf.saNtfStateChangeNotificationAllocate
 saNtfStateChangeNotificationAllocate_3 = \
-decorate(saNtf.saNtfStateChangeNotificationAllocate_3)
-saNtfAlarmNotificationAllocate = decorate(saNtf.saNtfAlarmNotificationAllocate)
+saNtf.saNtfStateChangeNotificationAllocate_3
+saNtfAlarmNotificationAllocate = saNtf.saNtfAlarmNotificationAllocate
 saNtfSecurityAlarmNotificationAllocate = \
-decorate(saNtf.saNtfSecurityAlarmNotificationAllocate)
+saNtf.saNtfSecurityAlarmNotificationAllocate
 saNtfMiscellaneousNotificationAllocate = \
-decorate(saNtf.saNtfMiscellaneousNotificationAllocate)
-saNtfPtrValAllocate = decorate(saNtf.saNtfPtrValAllocate)
-saNtfArrayValAllocate = decorate(saNtf.saNtfArrayValAllocate)
-saNtfIdentifierAllocate = decorate(saNtf.saNtfIdentifierAllocate)
-saNtfNotificationSend = decorate(saNtf.saNtfNotificationSend)
-saNtfNotificationSendWithId = decorate(saNtf.saNtfNotificationSendWithId)
-saNtfNotificationFree = decorate(saNtf.saNtfNotificationFree)
-saNtfVariableDataSizeGet = decorate(saNtf.saNtfVariableDataSizeGet)
-saNtfLocalizedMessageGet = decorate(saNtf.saNtfLocalizedMessageGet)
-saNtfLocalizedMessageFree_2 = decorate(saNtf.saNtfLocalizedMessageFree_2)
-saNtfPtrValGet = 

[devel] [PATCH 0/1] Review Request for pyosaf: High level python interfaces for NTF [#2602]

2017-10-25 Thread Nguyen Luu
Summary: pyosaf: High level python interfaces for NTF [#2602]
Review request for Ticket(s): 2602
Peer Reviewer(s): Hans Nordeback, Anders Widell, Srinivas Mangipudy
Pull request to: Hans Nordeback, Anders Widell
Affected branch(es): develop
Development branch: ticket-2602
Base revision: ee7cb901b8eb023502e3c21180afb78dd15c328b
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   y


Comments (indicate scope for each "y" above):
-
revision 13615cadcdb4f433f00cb9504878312db68c41ad
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Wed, 25 Oct 2017 17:48:42 +0700

pyosaf: High level python interfaces for NTF [#2602]

Improved implementation of NTF pyosaf utils

The following comments shall be removed when the patch is pushed.

- This is the 2nd patch in the series of patches to improve the
  implementation of the pyosaf utils of OpenSAF services.
- This patch is based on and uses the code change of the
  pyosf/utils/__init__.py file in the following patch for CLM:

  [devel] [PATCH 1/1] pyosaf: High level python interfaces for CLM [#2602]
  https://sourceforge.net/p/opensaf/mailman/message/36088562/



Added Files:

 python/pyosaf/utils/ntf/agent.py
 python/pyosaf/utils/ntf/producer.py
 python/pyosaf/utils/ntf/reader.py
 python/pyosaf/utils/ntf/subscriber.py


Complete diffstat:
--
 python/pyosaf/utils/ntf/__init__.py   | 881 -
 python/pyosaf/utils/ntf/agent.py  | 485 ++
 python/pyosaf/utils/ntf/producer.py   | 711 ++
 python/pyosaf/utils/ntf/reader.py | 167 +++
 python/pyosaf/utils/ntf/subscriber.py | 907 ++
 5 files changed, 2575 insertions(+), 576 deletions(-)


Testing Commands:
-
Create a test NTF producer/subscriber/reader using the new
NTF pyosaf utils and execute some respective functions.


Testing, Expected Results:
--
The NTF producer/subscriber/reader functions are successully
achieved with the new NTF pyosaf utils.


Conditions of Submission:
-
Ack from one of the reviewers.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your ch

Re: [devel] [PATCH 1/1] pyosaf: Create a pylint makefile target for pyosaf V2 [#2636]

2017-10-24 Thread Nguyen Luu

Hi Hans,

I have one comment inline marked with [Nguyen].

Thanks,
Nguyen

On 10/23/2017 7:40 PM, Hans Nordeback wrote:

---
  Makefile.am |   9 +-
  python/pylintrc | 381 
  2 files changed, 389 insertions(+), 1 deletion(-)
  create mode 100644 python/pylintrc

diff --git a/Makefile.am b/Makefile.am
index a7548d274..f9ba87b35 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -429,7 +429,14 @@ checkpatch:
perl "$$builddir/bin/checkpatch.pl" --no-tree --file --ignore SPLIT_STRING 
--summary-file $$(cat "$$builddir/checkpatch_files.txt") 1>&2; \
true
  
-.PHONY: cppcheck.xml cppcheck cpplint shellcheck checkpatch

+pylint:
+   @srcdir=$$(cd $(top_srcdir); pwd; cd - > /dev/null); \
+   cd "$$srcdir/python"; find . -name '*.py' | xargs pylint --rcfile=pylintrc 
--output-format=html > pylint.html; \
[Nguyen] The HTML reporter (--output-format=html) has been removed since 
pylint 1.7 in favor of the JSON reporter. So the above --output-format 
option would produce error when run with pylint version >= 1.7. Could 
you check and reconsider the output format?

+   true
+   @echo "The pylint result can be found in the file python/pylint.html"
+   @echo "Use the follwing command to view it: firefox python/pylint.html"
+
+.PHONY: cppcheck.xml cppcheck cpplint shellcheck checkpatch pylint
  
  clean-local:

-rm -f $(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz
diff --git a/python/pylintrc b/python/pylintrc
new file mode 100644
index 0..c4d2e222d
--- /dev/null
+++ b/python/pylintrc
@@ -0,0 +1,381 @@
+[MASTER]
+
+# Specify a configuration file.
+#rcfile=
+
+# Python code to execute, usually for sys.path manipulation such as
+# pygtk.require().
+#init-hook=
+
+# Profiled execution.
+# option profile is obsolete and it is slated for removal in Pylint 1.6.
+# profile=no
+
+# Add files or directories to the blacklist. They should be base names, not
+# paths.
+ignore=CVS
+
+# Pickle collected data for later comparisons.
+persistent=yes
+
+# List of plugins (as comma separated values of python modules names) to load,
+# usually to register additional checkers.
+load-plugins=
+
+# Use multiple processes to speed up Pylint.
+jobs=1
+
+# Allow loading of arbitrary C extensions. Extensions are imported into the
+# active Python interpreter and may run arbitrary code.
+unsafe-load-any-extension=no
+
+# A comma-separated list of package or module names from where C extensions may
+# be loaded. Extensions are loading into the active Python interpreter and may
+# run arbitrary code
+extension-pkg-whitelist=
+
+# Allow optimization of some AST trees. This will activate a peephole AST
+# optimizer, which will apply various small optimizations. For instance, it can
+# be used to obtain the result of joining multiple strings with the addition
+# operator. Joining a lot of strings can lead to a maximum recursion error in
+# Pylint and this flag can prevent that. It has one side effect, the resulting
+# AST will be different than the one from reality.
+optimize-ast=no
+
+
+[MESSAGES CONTROL]
+
+# Only show warnings with the listed confidence levels. Leave empty to show
+# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
+confidence=
+
+# Enable the message, report, category or checker with the given id(s). You can
+# either give multiple identifier separated by comma (,) or put this option
+# multiple time. See also the "--disable" option for examples.
+#enable=
+
+# Disable the message, report, category or checker with the given id(s). You
+# can either give multiple identifiers separated by comma (,) or put this
+# option multiple times (only on the command line, not in the configuration
+# file where it should appear only once).You can also use "--disable=all" to
+# disable everything first and then reenable specific checks. For example, if
+# you want to run only the similarities checker, you can use "--disable=all
+# --enable=similarities". If you want to run only the classes checker, but have
+# no Warning level messages displayed, use"--disable=all --enable=classes
+# --disable=W"
+#
+# Added "W0105": pointless-string-statement
+# Added "W0511": Used when a warning note as FIXME or XXX is detected.
+# Added "W0511": Used when a warning note as FIXME or XXX is detected.
+#disable=W0511,W0105,E1608,W1627,E1601,E1603,E1602,E1605,E1604,E1607,E1606,W1621,W1620,W1623,W1622,W1625,W1624,W1609,#W1608,W1607,W1606,W1605,W1604,W1603,W1602,W1601,W1639,W1640,I0021,W1638,I0020,W1618,W1619,W1630,W1626,W1637,W1634,W1#635,W1610,W1611,W1612,W1613,W1614,W1615,W1616,W1617,W1632,W1633,W0704,W1628,W1629,W1636
+
+
+[REPORTS]
+
+# Set the output format. Available formats are text, parseable, colorized, msvs
+# (visual studio) and html. You can also give a reporter class, eg
+# mypackage.mymodule.MyReporterClass.
+# output-format=text
+
+# Put messages in a separate file for each module / package specified on the
+# command line instead of 

[devel] [PATCH 1/1] pyosaf: Create a common pylint config file for pyosaf [#2636]

2017-10-19 Thread Nguyen Luu
---
 python/pylintrc | 380 
 1 file changed, 380 insertions(+)
 create mode 100644 python/pylintrc

diff --git a/python/pylintrc b/python/pylintrc
new file mode 100644
index 000..c1021a1
--- /dev/null
+++ b/python/pylintrc
@@ -0,0 +1,380 @@
+[MASTER]
+
+# Specify a configuration file.
+#rcfile=
+
+# Python code to execute, usually for sys.path manipulation such as
+# pygtk.require().
+#init-hook=
+
+# Profiled execution.
+# option profile is obsolete and it is slated for removal in Pylint 1.6.
+# profile=no
+
+# Add files or directories to the blacklist. They should be base names, not
+# paths.
+ignore=CVS
+
+# Pickle collected data for later comparisons.
+persistent=yes
+
+# List of plugins (as comma separated values of python modules names) to load,
+# usually to register additional checkers.
+load-plugins=
+
+# Use multiple processes to speed up Pylint.
+jobs=1
+
+# Allow loading of arbitrary C extensions. Extensions are imported into the
+# active Python interpreter and may run arbitrary code.
+unsafe-load-any-extension=no
+
+# A comma-separated list of package or module names from where C extensions may
+# be loaded. Extensions are loading into the active Python interpreter and may
+# run arbitrary code
+extension-pkg-whitelist=
+
+# Allow optimization of some AST trees. This will activate a peephole AST
+# optimizer, which will apply various small optimizations. For instance, it can
+# be used to obtain the result of joining multiple strings with the addition
+# operator. Joining a lot of strings can lead to a maximum recursion error in
+# Pylint and this flag can prevent that. It has one side effect, the resulting
+# AST will be different than the one from reality.
+optimize-ast=no
+
+
+[MESSAGES CONTROL]
+
+# Only show warnings with the listed confidence levels. Leave empty to show
+# all. Valid levels: HIGH, INFERENCE, INFERENCE_FAILURE, UNDEFINED
+confidence=
+
+# Enable the message, report, category or checker with the given id(s). You can
+# either give multiple identifier separated by comma (,) or put this option
+# multiple time. See also the "--disable" option for examples.
+#enable=
+
+# Disable the message, report, category or checker with the given id(s). You
+# can either give multiple identifiers separated by comma (,) or put this
+# option multiple times (only on the command line, not in the configuration
+# file where it should appear only once).You can also use "--disable=all" to
+# disable everything first and then reenable specific checks. For example, if
+# you want to run only the similarities checker, you can use "--disable=all
+# --enable=similarities". If you want to run only the classes checker, but have
+# no Warning level messages displayed, use"--disable=all --enable=classes
+# --disable=W"
+#
+# Added "W0105": pointless-string-statement
+# Added "W0511": Used when a warning note as FIXME or XXX is detected.
+disable=W0511,W0105,E1608,W1627,E1601,E1603,E1602,E1605,E1604,E1607,E1606,W1621,W1620,W1623,W1622,W1625,W1624,W1609,W1608,W1607,W1606,W1605,W1604,W1603,W1602,W1601,W1639,W1640,I0021,W1638,I0020,W1618,W1619,W1630,W1626,W1637,W1634,W1635,W1610,W1611,W1612,W1613,W1614,W1615,W1616,W1617,W1632,W1633,W0704,W1628,W1629,W1636
+
+
+[REPORTS]
+
+# Set the output format. Available formats are text, parseable, colorized, msvs
+# (visual studio) and html. You can also give a reporter class, eg
+# mypackage.mymodule.MyReporterClass.
+output-format=text
+
+# Put messages in a separate file for each module / package specified on the
+# command line instead of printing them on stdout. Reports (if any) will be
+# written in a file name "pylint_global.[txt|html]".
+files-output=no
+
+# Tells whether to display a full report or only the messages
+reports=yes
+
+# Python expression which should return a note less than 10 (10 is the highest
+# note). You have access to the variables errors warning, statement which
+# respectively contain the number of errors / warnings messages and the total
+# number of statements analyzed. This is used by the global evaluation report
+# (RP0004).
+evaluation=10.0 - ((float(5 * error + warning + refactor + convention) / 
statement) * 10)
+
+# Add a comment according to your evaluation note. This is used by the global
+# evaluation report (RP0004).
+# option comment is obsolete and it is slated for removal in Pylint 1.6.
+# comment=yes
+
+# Template used to display messages. This is a python new-style format string
+# used to format the message information. See doc for all details
+#msg-template=
+
+
+[FORMAT]
+
+# Maximum number of characters on a single line.
+max-line-length=80
+
+# Regexp for a line that is allowed to be longer than the limit.
+ignore-long-lines=^\s*(# )??$
+
+# Allow the body of an if to be on the same line as the test if there is no
+# else.
+single-line-if-stmt=no
+
+# List of optional constructs for which whitespace checking is disabled

[devel] [PATCH 0/1] Review Request for pyosaf: Create a common pylint config file for pyosaf [#2636]

2017-10-19 Thread Nguyen Luu
Summary: pyosaf: Create a common pylint config file for pyosaf [#2636]
Review request for Ticket(s): 2636
Peer Reviewer(s): Hans Nordeback, Anders Widell, Srinivas Mangipudy
Pull request to: Hans Nordeback, Anders Widell
Affected branch(es): develop
Development branch: ticket-2636
Base revision: 7261f72a76883008f59a23b66273f213d08ba894
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   y

NOTE: Patch(es) contain lines longer than 80 characers

Comments (indicate scope for each "y" above):
-
revision 51ec9f79721a03210f2a693eb37cd2e0698fd2a5
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Thu, 19 Oct 2017 14:46:58 +0700

pyosaf: Create a common pylint config file for pyosaf [#2636]



Added Files:

 python/pylintrc


Complete diffstat:
--
 python/pylintrc | 380 
 1 file changed, 380 insertions(+)


Testing Commands:
-
Run pylint for pyosaf files with this config file.


Testing, Expected Results:
--
pylint should check and warn about any issues in
accordance with options set in the config file.


Conditions of Submission:
-
Ack from one of the reviewers.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 0/1] Review Request for pyosaf: Fix various pylint and PEP8 issues of pyosaf utils V3 [#2603]

2017-10-19 Thread Nguyen Luu
Summary: pyosaf: Fix various pylint and PEP8 issues of pyosaf utils [#2603]
Review request for Ticket(s): 2603
Peer Reviewer(s): Hans Nordeback, Anders Widell, Srinivas Mangipudy
Pull request to: Hans Nordeback, Anders Widell
Affected branch(es): develop
Development branch: ticket-2603
Base revision: 7261f72a76883008f59a23b66273f213d08ba894
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   y

NOTE: Patch(es) contain lines longer than 80 characers

Comments (indicate scope for each "y" above):
-
revision 02c0cbb22ae82801ada8e206d09427516a0a848b
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Thu, 19 Oct 2017 13:23:57 +0700

pyosaf: Fix various pylint and PEP8 issues of pyosaf utils [#2603]

- Fix most pylint and PEP8 warnings of files under pyosaf/utils
- Add a common pylint config file for Python files in opensaf



Added Files:

 python/pylintrc


Complete diffstat:
--
 python/pylintrc  | 380 +
 python/pyosaf/utils/__init__.py  |  84 +--
 python/pyosaf/utils/clm/__init__.py  | 194 ---
 python/pyosaf/utils/immoi/__init__.py| 351 +++-
 python/pyosaf/utils/immoi/implementer.py | 944 +--
 python/pyosaf/utils/immom/__init__.py| 202 ---
 python/pyosaf/utils/immom/ccb.py | 181 +++---
 python/pyosaf/utils/immom/iterator.py|  69 ++-
 python/pyosaf/utils/immom/object.py  |  91 +--
 python/pyosaf/utils/log/__init__.py  |  32 +-
 python/pyosaf/utils/log/logger.py| 139 +++--
 python/pyosaf/utils/ntf/__init__.py  | 646 -
 12 files changed, 2053 insertions(+), 1260 deletions(-)


Testing Commands:
-
Run pylint and pep8 check for pyosaf utils.


Testing, Expected Results:
--
Expect pylint score > 9.00, and no pep8 warnings.


Conditions of Submission:
-
ACK from one of the reviewers.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series

[devel] [PATCH 0/1] Review Request for pyosaf: Fix various pylint and PEP8 issues of pyosaf utils V2 [#2603]

2017-10-17 Thread Nguyen Luu
Summary: pyosaf: Fix various pylint and PEP8 issues of pyosaf utils [#2603]
Review request for Ticket(s): 2603
Peer Reviewer(s): Hans Nordeback, Anders Widell, Srinivas Mangipudy
Pull request to: Anders Widell
Affected branch(es): develop
Development branch: ticket-2603
Base revision: 6a3ae89b9ab2aae9d07e02fc60dc60293986c442
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   y


Comments (indicate scope for each "y" above):
-
revision 78efa1ad3c85e245a3e262c84662a3f0354f4436
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Wed, 18 Oct 2017 11:56:06 +0700

pyosaf: Fix various pylint and PEP8 issues of pyosaf utils [#2603]



Complete diffstat:
--
 python/pyosaf/utils/__init__.py  |  84 +--
 python/pyosaf/utils/clm/__init__.py  | 194 ---
 python/pyosaf/utils/immoi/__init__.py| 351 +++-
 python/pyosaf/utils/immoi/implementer.py | 944 +--
 python/pyosaf/utils/immom/__init__.py| 202 ---
 python/pyosaf/utils/immom/ccb.py | 181 +++---
 python/pyosaf/utils/immom/iterator.py|  69 ++-
 python/pyosaf/utils/immom/object.py  |  91 +--
 python/pyosaf/utils/log/__init__.py  |  32 +-
 python/pyosaf/utils/log/logger.py| 139 +++--
 python/pyosaf/utils/ntf/__init__.py  | 646 -
 11 files changed, 1673 insertions(+), 1260 deletions(-)


Testing Commands:
-
Run pylint and pep8 check for pyosaf utils.


Testing, Expected Results:
--
Expect pylint score > 9.00, and no pep8 warnings.
(Ignore some pylint warnings of invalid variable name)


Conditions of Submission:
-
ACK from one of the reviewers.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http:

Re: [devel] [PATCH 1/1] pyosaf: decorate function does not handle version struct in initialize functions [#2524]

2017-10-06 Thread Nguyen Luu

Hi,

My comments:
Why not just simply reusing the decorate() function as below, instead of 
inventing a new initialize_decorate() function only for zzzInitialize() 
API? And why making 'version' a global variable when it is only used by 
initialize()?

/
//@decorate//
//def initialize(callbacks=None)://
//    ''' Initializes IMM OI '''//
//
//    version = SaVersionT('A', 2, 15)//
//
//    return saImmOi.saImmOiInitialize_2(HANDLE, callbacks, version)/

Also, please consider having a short description in the commit message 
about the existing issue and how it is fixed by this patch.


Thanks,
Nguyen

On 10/5/2017 5:26 PM, Hieu Nguyen wrote:

---
  python/pyosaf/utils/__init__.py   | 38 +++
  python/pyosaf/utils/clm/__init__.py   | 18 -
  python/pyosaf/utils/immoi/__init__.py | 12 +--
  python/pyosaf/utils/immom/__init__.py | 11 +-
  python/pyosaf/utils/log/__init__.py   |  4 ++--
  python/pyosaf/utils/ntf/__init__.py   | 17 
  6 files changed, 69 insertions(+), 31 deletions(-)

diff --git a/python/pyosaf/utils/__init__.py b/python/pyosaf/utils/__init__.py
index 0d4b648..17a1408 100644
--- a/python/pyosaf/utils/__init__.py
+++ b/python/pyosaf/utils/__init__.py
@@ -16,6 +16,7 @@
  
  
  import time

+from copy import deepcopy
  
  from pyosaf.saAis import eSaAisErrorT
  
@@ -70,3 +71,40 @@ def decorate(function):

  return error
  
  return inner

+
+
+def initialize_decorate(function, current_version):
+''' Decorate the given SAF initialize() with current version so that it
+retries a fixed number of times if needed and raises an exception
+if it encounters any fault other than SA_AIS_ERR_TRY_AGAIN.
+'''
+# Backup current version
+backup_version = deepcopy(current_version)
+
+def inner(*args):
+''' Calls "function" in the lexical scope in a retry loop and raises
+an exception if it encounters any other faults.
+'''
+one_sec_sleeps = 0
+error = function(*args)
+
+while error == eSaAisErrorT.SA_AIS_ERR_TRY_AGAIN:
+if one_sec_sleeps == TRY_AGAIN_COUNT:
+break
+
+time.sleep(1)
+one_sec_sleeps += 1
+
+# If SAF initialize() returns ERR_TRY_AGAIN, the version will be
+# updated to the latest version
+# Set current version in this case
+current_version = deepcopy(backup_version)
+args = args[:2] + (current_version,)
+error = function(*args)
+
+if error != eSaAisErrorT.SA_AIS_OK:
+raise_saf_exception(function, error)
+
+return error
+
+return inner
diff --git a/python/pyosaf/utils/clm/__init__.py 
b/python/pyosaf/utils/clm/__init__.py
index 9b9e11f..926e2f4 100644
--- a/python/pyosaf/utils/clm/__init__.py
+++ b/python/pyosaf/utils/clm/__init__.py
@@ -20,12 +20,15 @@
  
  from pyosaf import saClm, saAis
  
-from pyosaf.utils import decorate

+from pyosaf.utils import decorate, initialize_decorate
+
+# Define CLM version
+CLM_VER = saAis.SaVersionT('B', 4, 1)
  
  # Decorate the raw saClm* functions with retry and raising exceptions

-saClmInitialize= decorate(saClm.saClmInitialize)
-saClmInitialize_3  = decorate(saClm.saClmInitialize_3)
-saClmInitialize_4  = decorate(saClm.saClmInitialize_4)
+saClmInitialize = initialize_decorate(saClm.saClmInitialize, CLM_VER)
+saClmInitialize_3 = initialize_decorate(saClm.saClmInitialize_3, CLM_VER)
+saClmInitialize_4 = initialize_decorate(saClm.saClmInitialize_4, CLM_VER)
  saClmSelectionObjectGet= decorate(saClm.saClmSelectionObjectGet)
  saClmDispatch  = decorate(saClm.saClmDispatch)
  saClmFinalize  = decorate(saClm.saClmFinalize)
@@ -119,11 +122,8 @@ def initialize(track_fn=None):
  callbacks.saClmClusterNodeGetCallback = 
saClm.SaClmClusterNodeGetCallbackT_4(node_get_callback)
  callbacks.saClmClusterTrackCallback = 
saClm.SaClmClusterTrackCallbackT_4(track_callback)
  
-# Define which version to use of the CLM API

-version = saAis.SaVersionT('B', 4, 1)
-
  # Initialize the CLM API
-saClmInitialize_4(HANDLE, callbacks, version)
+saClmInitialize_4(HANDLE, callbacks, CLM_VER)
  
  def track(flags=saAis.saAis.SA_TRACK_CHANGES_ONLY):

  saClmClusterTrack_4(HANDLE, flags, None)
@@ -131,7 +131,7 @@ def track(flags=saAis.saAis.SA_TRACK_CHANGES_ONLY):
  def get_members():
  notification_buffer = saClm.SaClmClusterNotificationBufferT_4()
  
-saClmClusterTrack_4(HANDLE, saAis.saAis.SA_TRACK_CURRENT,

+saClmClusterTrack_4(HANDLE, saAis.saAis.SA_TRACK_CURRENT,
  notification_buffer)
  
  cluster_nodes = []

diff --git a/python/pyosaf/utils/immoi/__init__.py 
b/python/pyosaf/utils/immoi/__init__.py
index 02ad89b..ecfeb7e 100644

[devel] [PATCH 0/1] Review Request for pyosaf: Fix various pylint and PEP8 issues of pyosaf utils [#2603]

2017-10-06 Thread Nguyen Luu
Summary: pyosaf: Fix various pylint and PEP8 issues of pyosaf utils [#2603]
Review request for Ticket(s): 2603
Peer Reviewer(s): Hans Nordeback, Anders Widell
Pull request to: Hans Nordeback, Anders Widell
Affected branch(es): develop
Development branch: ticket-2603
Base revision: 44d113c4fa669065afe78d70bc81c5297d79ec0e
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   y


Comments (indicate scope for each "y" above):
-
revision 300b97ff3e52f29f9696a8b7e799af0880eb3b58
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Fri, 6 Oct 2017 13:49:30 +0700

pyosaf: Fix various pylint and PEP8 issues of pyosaf utils [#2603]



Complete diffstat:
--
 python/pyosaf/utils/__init__.py  |  48 +-
 python/pyosaf/utils/clm/__init__.py  | 201 ---
 python/pyosaf/utils/immoi/__init__.py| 352 +++-
 python/pyosaf/utils/immoi/implementer.py | 944 +--
 python/pyosaf/utils/immom/__init__.py| 206 +++
 python/pyosaf/utils/immom/ccb.py | 181 +++---
 python/pyosaf/utils/immom/iterator.py|  69 ++-
 python/pyosaf/utils/immom/object.py  |  93 +--
 python/pyosaf/utils/log/__init__.py  |  34 +-
 python/pyosaf/utils/log/logger.py| 139 +++--
 python/pyosaf/utils/ntf/__init__.py  | 652 -
 11 files changed, 1665 insertions(+), 1254 deletions(-)


Testing Commands:
-
Run pylint and pep8 check for pyosaf utils.


Testing, Expected Results:
--
Expect pylint score > 9.00, and no pep8 warnings.
(Ignore some pylint warnings of invalid variable name)


Conditions of Submission:
-
ACK from either reviewer.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http:

Re: [devel] [PATCH 1/1] amfa: return BAD HANDLE in error report or error clear [#248]

2017-08-17 Thread Nguyen Luu

Hi,

Tested OK with legacy test. This change is similar to that in #2539 
which was already pushed.


Thanks,
Nguyen

On 7/28/2017 4:41 PM, Nagendra Kumar wrote:

---
  src/amf/agent/amf_agent.cc | 15 +++
  1 file changed, 15 insertions(+)

diff --git a/src/amf/agent/amf_agent.cc b/src/amf/agent/amf_agent.cc
index 20528e9..af4b30b 100644
--- a/src/amf/agent/amf_agent.cc
+++ b/src/amf/agent/amf_agent.cc
@@ -2686,6 +2686,13 @@ SaAisErrorT 
AmfAgent::ComponentErrorReport_4(SaAmfHandleT hdl,
SaAisErrorT rc = SA_AIS_OK;
TRACE_ENTER2("SaAmfHandleT passed is %llx", hdl);
  
+  /* Verifying the input Handle & global handle */

+  if (!gl_ava_hdl || hdl > AVSV_UNS32_HDL_MAX) {
+TRACE_2("Invalid SaAmfHandle passed by component: %llx", hdl);
+rc = SA_AIS_ERR_BAD_HANDLE;
+goto done;
+  }
+
/* Version is previously set in in initialize function */
if (!ava_B4_ver_used(0)) {
  TRACE_2(
@@ -2779,6 +2786,14 @@ SaAisErrorT AmfAgent::ComponentErrorClear_4(SaAmfHandleT 
hdl,
SaAisErrorT rc = SA_AIS_OK;
TRACE_ENTER2("SaAmfHandleT passed is %llx", hdl);
  
+  /* Verifying the input Handle & global handle */

+  if (!gl_ava_hdl || hdl > AVSV_UNS32_HDL_MAX) {
+TRACE_2("Invalid SaAmfHandle passed by component: %llx", hdl);
+rc = SA_AIS_ERR_BAD_HANDLE;
+goto done;
+  }
+
+
/* Version is previously set in in initialize function */
if (!ava_B4_ver_used(0)) {
  TRACE_2(



--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


Re: [devel] [PATCH 1/1] amfa: Fix saAmfComponentErrorClear_4 to return ERR_NOT_EXIST for non-exist comp [#2540]

2017-08-16 Thread Nguyen Luu

Hi Praveen,

Thank you for your comment. I have sent the AMF PR document update for 
review.


Thanks,
Nguyen

On 8/14/2017 12:17 PM, praveen malviya wrote:

Hi,

Both ErrorReport() and ErrorClear() APIs can be called for any 
component hosted anywhere.
Since amfnd only maintains local components, component may not be 
found in its data base. A message should be sent to AMFD or AMFND 
should instantly read IMM database for validating the component.


I am ok, if this patch is pushed by documenting this limitation for 
both ErrorReport() and ErrorClear() APIs.



Thanks
Praveen

On 02-Aug-17 12:51 PM, Nguyen Luu wrote:
When called with a non-existing component name, 
saAmfComponentErrorClear_4

should return SA_AIS_ERR_NOT_EXIST instead of SA_AIS_ERR_BAD_OPERATION
as previously done.
---
  src/amf/amfnd/err.cc | 6 --
  1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/amf/amfnd/err.cc b/src/amf/amfnd/err.cc
index e4cb9f0..65c54f5 100644
--- a/src/amf/amfnd/err.cc
+++ b/src/amf/amfnd/err.cc
@@ -269,9 +269,11 @@ uint32_t avnd_evt_ava_err_clear_evh(AVND_CB *cb, 
AVND_EVT *evt) {
comp = avnd_compdb_rec_get(cb->compdb, 
Amf::to_string(_clear->comp_name));

  /* determine the error code, if any */
-  if (!comp || !m_AVND_COMP_IS_REG(comp) ||
+  if (!comp) amf_rc = SA_AIS_ERR_NOT_EXIST;
+
+  if ((comp) && (!m_AVND_COMP_IS_REG(comp) ||
(!m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(comp) &&
-   !m_AVND_COMP_TYPE_IS_PROXIED(comp)))
+   !m_AVND_COMP_TYPE_IS_PROXIED(comp
  amf_rc = SA_AIS_ERR_BAD_OPERATION;
  if ((comp) && m_AVND_COMP_OPER_STATE_IS_ENABLED(comp))




--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 0/1] Review Request for amfa: Fix saAmfComponentErrorClear_4 to return ERR_NOT_EXIST for non-exist comp V3 [#2540]

2017-08-16 Thread Nguyen Luu
Summary: amfa: Fix saAmfComponentErrorClear_4 to return ERR_NOT_EXIST for 
non-exist comp [#2540]
Review request for Ticket(s): 2540
Peer Reviewer(s): AMF devs
Pull request to: AMF maintainers
Affected branch(es): develop, release
Development branch: ticket-2540
Base revision: 0b0d224ff3da7e59c7bb215664b1b39144a789f7
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
revision 7d907166c175fef1ca5e1ddbb258a8b5d915a364
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Wed, 16 Aug 2017 14:48:56 +0700

amfa: Fix saAmfComponentErrorClear_4 to return ERR_NOT_EXIST for non-exist comp 
[#2540]

When called with a non-existing component name, saAmfComponentErrorClear_4
should return SA_AIS_ERR_NOT_EXIST instead of SA_AIS_ERR_BAD_OPERATION
as previously done.



Complete diffstat:
--
 src/amf/amfnd/err.cc | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)


Testing Commands:
-
Test steps:
1) Call saAmfInitialize_4().
2) Call saAmfComponentErrorClear_4() with a non-existing component name.
3) Call saAmfFinalize to finalize the handle obtained in 1st step.


Testing, Expected Results:
--
The saAmfComponentErrorClear_4() call in step 2) should return
SA_AIS_ERR_NOT_EXIST.


Conditions of Submission:
-
Ack from reviewers of after 2 weeks.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 1/1] amfa: Fix saAmfComponentErrorClear_4 to return ERR_NOT_EXIST for non-exist comp [#2540]

2017-08-16 Thread Nguyen Luu
When called with a non-existing component name, saAmfComponentErrorClear_4
should return SA_AIS_ERR_NOT_EXIST instead of SA_AIS_ERR_BAD_OPERATION
as previously done.
---
 src/amf/amfnd/err.cc | 17 +++--
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/src/amf/amfnd/err.cc b/src/amf/amfnd/err.cc
index e4cb9f0..a0529b9 100644
--- a/src/amf/amfnd/err.cc
+++ b/src/amf/amfnd/err.cc
@@ -2,6 +2,7 @@
  *
  * (C) Copyright 2008 The OpenSAF Foundation
  * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (C) 2017, Ericsson AB. All rights reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -13,6 +14,7 @@
  * licensing terms.
  *
  * Author(s): Emerson Network Power
+ *Ericsson
  *
  */
 
@@ -164,11 +166,12 @@ uint32_t avnd_evt_ava_err_rep_evh(AVND_CB *cb, AVND_EVT 
*evt) {
 }
   }
 
-  /* get the comp */
+  /* check if component exists on local AvND node */
   comp = avnd_compdb_rec_get(cb->compdb, Amf::to_string(_rep->err_comp));
-  /* determine the error code, if any */
   if (!comp) amf_rc = SA_AIS_ERR_NOT_EXIST;
 
+  /* determine other error codes, if any */
+
   /* We need not entertain errors when comp is not in shape */
   if (comp && (m_AVND_COMP_PRES_STATE_IS_UNINSTANTIATED(comp) ||
m_AVND_COMP_PRES_STATE_IS_INSTANTIATIONFAILED(comp) ||
@@ -265,13 +268,15 @@ uint32_t avnd_evt_ava_err_clear_evh(AVND_CB *cb, AVND_EVT 
*evt) {
 }
   }
 
-  /* get the comp */
+  /* check if component exists on local AvND node */
   comp = avnd_compdb_rec_get(cb->compdb, 
Amf::to_string(_clear->comp_name));
+  if (!comp) amf_rc = SA_AIS_ERR_NOT_EXIST;
+
+  /* determine other error codes, if any */
 
-  /* determine the error code, if any */
-  if (!comp || !m_AVND_COMP_IS_REG(comp) ||
+  if ((comp) && (!m_AVND_COMP_IS_REG(comp) ||
   (!m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(comp) &&
-   !m_AVND_COMP_TYPE_IS_PROXIED(comp)))
+   !m_AVND_COMP_TYPE_IS_PROXIED(comp
 amf_rc = SA_AIS_ERR_BAD_OPERATION;
 
   if ((comp) && m_AVND_COMP_OPER_STATE_IS_ENABLED(comp))
-- 
2.7.4


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


Re: [devel] [PATCH 1/1] amfa: Fix saAmfPmStart_3 and saAmfResponse_4 to correctly return BAD_HANDLE [#2539]

2017-08-13 Thread Nguyen Luu

Hi,

I'd like to push this patch tomorrow if there are no more comments.

Thanks,
Nguyen

On 8/7/2017 2:00 PM, Nguyen Luu wrote:

Thanks, Hans and Anders, for your review.

About the code refactoring, should we do it in a separate ticket for 
all AMF API's that use such constant and format specifier? That should 
be an enhancement rather than a defect ticket like this one.


Thanks,
Nguyen

On 8/2/2017 6:16 PM, Anders Widell wrote:
UINT32_MAX from  is a better constant here since we are 
dealing with a 32-bit integer.


regards,

Anders Widell


On 08/02/2017 09:19 AM, Hans Nordebäck wrote:

ack, code review only.

When refactoring the code, perhaps UINT_MAX from  can be 
used instead of AVSV_UNS32_HDL_MAX?


And PRIx64 from  instead of %llx?

/Regards HansN

On 08/02/2017 06:01 AM, Nguyen Luu wrote:

When called with an uninitialized or already finalized handle,
saAmfPmStart_3 and saAmfResponse_4 should return SA_AIS_ERR_BAD_HANDLE
instead of SA_AIS_ERR_VERSION as previously done.
---
  src/amf/agent/amf_agent.cc | 14 ++
  1 file changed, 14 insertions(+)

diff --git a/src/amf/agent/amf_agent.cc b/src/amf/agent/amf_agent.cc
index 20528e9..b9191dd 100644
--- a/src/amf/agent/amf_agent.cc
+++ b/src/amf/agent/amf_agent.cc
@@ -2296,6 +2296,13 @@ SaAisErrorT AmfAgent::PmStart_3(SaAmfHandleT 
hdl, const SaNameT *comp_name,

SaAisErrorT rc = SA_AIS_OK;
TRACE_ENTER2("SaAmfHandleT passed is %llx", hdl);
  +  /* Verifying the input Handle & global handle */
+  if (!gl_ava_hdl || hdl > AVSV_UNS32_HDL_MAX) {
+TRACE_2("Invalid SaAmfHandle passed by component: %llx", hdl);
+rc = SA_AIS_ERR_BAD_HANDLE;
+goto done;
+  }
+
/* Version is previously set in in initialize function */
if (!ava_B4_ver_used(0)) {
  TRACE_2(
@@ -2844,6 +2851,13 @@ SaAisErrorT 
AmfAgent::Response_4(SaAmfHandleT hdl, SaInvocationT inv,

SaAisErrorT rc = SA_AIS_OK;
TRACE_ENTER2("SaAmfHandleT passed is %llx", hdl);
  +  /* Verifying the input Handle & global handle */
+  if (!gl_ava_hdl || hdl > AVSV_UNS32_HDL_MAX) {
+TRACE_2("Invalid SaAmfHandle passed by component: %llx", hdl);
+rc = SA_AIS_ERR_BAD_HANDLE;
+goto done;
+  }
+
/* Version is previously set in in initialize function */
if (!ava_B4_ver_used(0)) {
  TRACE_2(



-- 


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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel







-- 


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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel



--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 1/1] amfa: Fix saAmfComponentErrorClear_4 to return ERR_NOT_EXIST for non-exist comp [#2540]

2017-08-11 Thread Nguyen Luu
When called with a non-existing component name, saAmfComponentErrorClear_4
should return SA_AIS_ERR_NOT_EXIST instead of SA_AIS_ERR_BAD_OPERATION
as previously done.
---
 src/amf/amfnd/err.cc | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/amf/amfnd/err.cc b/src/amf/amfnd/err.cc
index e4cb9f0..3da4363 100644
--- a/src/amf/amfnd/err.cc
+++ b/src/amf/amfnd/err.cc
@@ -2,6 +2,7 @@
  *
  * (C) Copyright 2008 The OpenSAF Foundation
  * Copyright (C) 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (C) 2017 Ericsson AB. All Rights Reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -13,6 +14,7 @@
  * licensing terms.
  *
  * Author(s): Emerson Network Power
+ *Ericsson
  *
  */
 
@@ -269,9 +271,11 @@ uint32_t avnd_evt_ava_err_clear_evh(AVND_CB *cb, AVND_EVT 
*evt) {
   comp = avnd_compdb_rec_get(cb->compdb, 
Amf::to_string(_clear->comp_name));
 
   /* determine the error code, if any */
-  if (!comp || !m_AVND_COMP_IS_REG(comp) ||
+  if (!comp) amf_rc = SA_AIS_ERR_NOT_EXIST;
+
+  if ((comp) && (!m_AVND_COMP_IS_REG(comp) ||
   (!m_AVND_COMP_TYPE_IS_PREINSTANTIABLE(comp) &&
-   !m_AVND_COMP_TYPE_IS_PROXIED(comp)))
+   !m_AVND_COMP_TYPE_IS_PROXIED(comp
 amf_rc = SA_AIS_ERR_BAD_OPERATION;
 
   if ((comp) && m_AVND_COMP_OPER_STATE_IS_ENABLED(comp))
-- 
2.7.4


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 0/1] Review Request for amfa: Fix saAmfComponentErrorClear_4 to return ERR_NOT_EXIST for non-exist comp V2 [#2540]

2017-08-11 Thread Nguyen Luu
Summary: amfa: Fix saAmfComponentErrorClear_4 to return ERR_NOT_EXIST for 
non-exist comp [#2540]
Review request for Ticket(s): 2540
Peer Reviewer(s): AMF devs
Pull request to: AMF maintainers
Affected branch(es): develop
Development branch: ticket-2540
Base revision: 8a15fb881c238d4e3246d97d7e5201e5ae235af5
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
revision 2df1d81a8b76eebf0f7fe8df25bc942e00c4aa7f
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Fri, 11 Aug 2017 15:23:24 +0700

amfa: Fix saAmfComponentErrorClear_4 to return ERR_NOT_EXIST for non-exist comp 
[#2540]

When called with a non-existing component name, saAmfComponentErrorClear_4
should return SA_AIS_ERR_NOT_EXIST instead of SA_AIS_ERR_BAD_OPERATION
as previously done.



Complete diffstat:
--
 src/amf/amfnd/err.cc | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)


Testing Commands:
-
Test steps:
1) Call saAmfInitialize_4().
2) Call saAmfComponentErrorClear_4() with a non-existing component name.
3) Call saAmfFinalize to finalize the handle obtained in 1st step.


Testing, Expected Results:
--
The saAmfComponentErrorClear_4() call in step 2) should return
SA_AIS_ERR_NOT_EXIST.


Conditions of Submission:
-
Ack from reviewers of after 2 weeks.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 1/1] amfa: Fix api internal check to avoid fatal mutex unlock [#2548]

2017-08-11 Thread Nguyen Luu
Current check for the required setting of the SA_AMF_COMPONENT_NAME
env variable in some amf api's (ComponentRegister, QuiescingComplete)
would crash the invoking process if that env variable was missed
to be set for some reason, as the agent lib tries, during cleanup,
to unlock a mutex which it has not previously locked yet.
---
 src/amf/agent/amf_agent.cc | 51 --
 1 file changed, 31 insertions(+), 20 deletions(-)

diff --git a/src/amf/agent/amf_agent.cc b/src/amf/agent/amf_agent.cc
index 20528e9..0d62e2a 100644
--- a/src/amf/agent/amf_agent.cc
+++ b/src/amf/agent/amf_agent.cc
@@ -1,6 +1,7 @@
 /*  -*- OpenSAF  -*-
  *
  * (C) Copyright 2008 The OpenSAF Foundation
+ * Copyright (C) 2017 Ericsson AB. All Rights Reserved.
  *
  * This program is distributed in the hope that it will be useful, but
  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -12,6 +13,7 @@
  * licensing terms.
  *
  * Author(s): Emerson Network Power
+ *Ericsson
  *
  */
 
@@ -271,7 +273,7 @@ SaAisErrorT AmfAgent::Dispatch(SaAmfHandleT hdl, 
SaDispatchFlagsT flags) {
 rc = SA_AIS_ERR_LIBRARY;
 goto done;
   }
-  /* acquire cb read lock */
+  /* acquire cb write lock */
   m_NCS_LOCK(>lock, NCS_LOCK_WRITE);
   /* retrieve hdl rec */
   if (!(hdl_rec = (AVA_HDL_REC *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, hdl))) {
@@ -292,7 +294,7 @@ SaAisErrorT AmfAgent::Dispatch(SaAmfHandleT hdl, 
SaDispatchFlagsT flags) {
   pend_fin = cb->pend_fin;
 
 done:
-  /* release cb read lock and return handles */
+  /* release cb write lock and return handles */
   if (cb) {
 m_NCS_UNLOCK(>lock, NCS_LOCK_WRITE);
 ncshm_give_hdl(gl_ava_hdl);
@@ -347,7 +349,7 @@ SaAisErrorT AmfAgent::Finalize(SaAmfHandleT hdl) {
 rc = SA_AIS_ERR_LIBRARY;
 goto done;
   }
-  /* acquire cb read lock */
+  /* acquire cb write lock */
   m_NCS_LOCK(>lock, NCS_LOCK_WRITE);
 
   /* retrieve hdl rec */
@@ -385,7 +387,7 @@ SaAisErrorT AmfAgent::Finalize(SaAmfHandleT hdl) {
 cb->pend_fin++;
 
 done:
-  /* release cb read lock and return handles */
+  /* release cb read write and return handles */
   if (cb) {
 m_NCS_UNLOCK(>lock, NCS_LOCK_WRITE);
 ncshm_give_hdl(gl_ava_hdl);
@@ -448,8 +450,7 @@ SaAisErrorT AmfAgent::ComponentRegister(SaAmfHandleT hdl,
 goto done;
   }
   /* retrieve AvA CB */
-  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl)) ||
-  !m_AVA_FLAG_IS_COMP_NAME(cb)) {
+  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl))) {
 TRACE_4("SA_AIS_ERR_LIBRARY: Unable to retrieve cb handle");
 rc = SA_AIS_ERR_LIBRARY;
 goto done;
@@ -618,8 +619,7 @@ SaAisErrorT AmfAgent::ComponentUnregister(SaAmfHandleT hdl,
 goto done;
   }
   /* retrieve AvA CB */
-  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl)) ||
-  !m_AVA_FLAG_IS_COMP_NAME(cb)) {
+  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl))) {
 TRACE_4("SA_AIS_ERR_LIBRARY: Unable to retrieve cb handle");
 rc = SA_AIS_ERR_LIBRARY;
 goto done;
@@ -627,6 +627,13 @@ SaAisErrorT AmfAgent::ComponentUnregister(SaAmfHandleT hdl,
 
   /* acquire cb read lock */
   m_NCS_LOCK(>lock, NCS_LOCK_READ);
+
+  if (!m_AVA_FLAG_IS_COMP_NAME(cb)) {
+TRACE_2("The SA_AMF_COMPONENT_NAME environment variable is NULL");
+rc = SA_AIS_ERR_LIBRARY;
+goto done;
+  }
+
   /* Version is previously set in in initialize function */
   if (ava_B4_ver_used(cb)) {
 TRACE_2("Invalid AMF version, B 4.1");
@@ -1364,14 +1371,20 @@ SaAisErrorT AmfAgent::CSIQuiescingComplete(SaAmfHandleT 
hdl, SaInvocationT inv,
 goto done;
   }
   /* retrieve AvA CB */
-  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl)) ||
-  !m_AVA_FLAG_IS_COMP_NAME(cb)) {
+  if (!(cb = (AVA_CB *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, gl_ava_hdl))) {
 TRACE_4("SA_AIS_ERR_LIBRARY: Unable to retrieve cb handle");
 rc = SA_AIS_ERR_LIBRARY;
 goto done;
   }
   /* acquire cb read lock */
   m_NCS_LOCK(>lock, NCS_LOCK_READ);
+
+  if (!m_AVA_FLAG_IS_COMP_NAME(cb)) {
+TRACE_2("The SA_AMF_COMPONENT_NAME environment variable is NULL");
+rc = SA_AIS_ERR_LIBRARY;
+goto done;
+  }
+
   /* retrieve hdl rec */
   if (!(hdl_rec = (AVA_HDL_REC *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, hdl))) {
 rc = SA_AIS_ERR_BAD_HANDLE;
@@ -1582,7 +1595,7 @@ SaAisErrorT AmfAgent::ProtectionGroupTrack(
 goto done;
   }
   /* acquire cb read lock */
-  m_NCS_LOCK(>lock, NCS_LOCK_WRITE);
+  m_NCS_LOCK(>lock, NCS_LOCK_READ);
   /* retrieve hdl rec */
   if (!(hdl_rec = (AVA_HDL_REC *)ncshm_take_hdl(NCS_SERVICE_ID_AVA, hdl))) {
 rc = SA_AIS_ERR_BAD_HANDLE;
@@ -1693,7 +1706,7 @@ SaAisErrorT AmfAgent::ProtectionGroupTrack(
 done:
   /* release cb read lock and return handles */
   if (cb) {
-m_NCS_UNLOCK(>lock, NCS_LOCK_WRITE);
+m_NCS_UNLOCK(>lock, NCS_LOCK_READ);
 ncshm_give_hdl(gl_ava_hdl);
   }
   if (hdl_rec) 

[devel] [PATCH 0/1] Review Request for amfa: Fix api internal check to avoid fatal mutex unlock [#2548]

2017-08-11 Thread Nguyen Luu
Summary: amfa: Fix api internal check to avoid fatal mutex unlock [#2548]
Review request for Ticket(s): 2548
Peer Reviewer(s): AMF devs
Pull request to: AMF maintainers
Affected branch(es): develop, release
Development branch: ticket-2548
Base revision: 8a15fb881c238d4e3246d97d7e5201e5ae235af5
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
revision 93aa170d6896c1eac5bd8cd9ac004b7da04c1a07
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Fri, 11 Aug 2017 14:51:31 +0700

amfa: Fix api internal check to avoid fatal mutex unlock [#2548]

Current check for the required setting of the SA_AMF_COMPONENT_NAME
env variable in some amf api's (ComponentRegister, QuiescingComplete)
would crash the invoking process if that env variable was missed
to be set for some reason, as the agent lib tries, during cleanup,
to unlock a mutex which it has not previously locked yet.



Complete diffstat:
--
 src/amf/agent/amf_agent.cc | 51 --
 1 file changed, 31 insertions(+), 20 deletions(-)


Testing Commands:
-
First call saAmfInitialize, then call saAmfComponentRegister without having
previously set the environment variable SA_AMF_COMPONENT_NAME.


Testing, Expected Results:
--
saAmfComponentRegister should return SA_AIS_ERR_LIBRARY.


Conditions of Submission:
-
Ack from reviewers of after 2 weeks.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


Re: [devel] [PATCH 1/1] amfa: Fix saAmfPmStart_3 and saAmfResponse_4 to correctly return BAD_HANDLE [#2539]

2017-08-07 Thread Nguyen Luu

Thanks, Hans and Anders, for your review.

About the code refactoring, should we do it in a separate ticket for all 
AMF API's that use such constant and format specifier? That should be an 
enhancement rather than a defect ticket like this one.


Thanks,
Nguyen

On 8/2/2017 6:16 PM, Anders Widell wrote:
UINT32_MAX from  is a better constant here since we are 
dealing with a 32-bit integer.


regards,

Anders Widell


On 08/02/2017 09:19 AM, Hans Nordebäck wrote:

ack, code review only.

When refactoring the code, perhaps UINT_MAX from  can be 
used instead of AVSV_UNS32_HDL_MAX?


And PRIx64 from  instead of %llx?

/Regards HansN

On 08/02/2017 06:01 AM, Nguyen Luu wrote:

When called with an uninitialized or already finalized handle,
saAmfPmStart_3 and saAmfResponse_4 should return SA_AIS_ERR_BAD_HANDLE
instead of SA_AIS_ERR_VERSION as previously done.
---
  src/amf/agent/amf_agent.cc | 14 ++
  1 file changed, 14 insertions(+)

diff --git a/src/amf/agent/amf_agent.cc b/src/amf/agent/amf_agent.cc
index 20528e9..b9191dd 100644
--- a/src/amf/agent/amf_agent.cc
+++ b/src/amf/agent/amf_agent.cc
@@ -2296,6 +2296,13 @@ SaAisErrorT AmfAgent::PmStart_3(SaAmfHandleT 
hdl, const SaNameT *comp_name,

SaAisErrorT rc = SA_AIS_OK;
TRACE_ENTER2("SaAmfHandleT passed is %llx", hdl);
  +  /* Verifying the input Handle & global handle */
+  if (!gl_ava_hdl || hdl > AVSV_UNS32_HDL_MAX) {
+TRACE_2("Invalid SaAmfHandle passed by component: %llx", hdl);
+rc = SA_AIS_ERR_BAD_HANDLE;
+goto done;
+  }
+
/* Version is previously set in in initialize function */
if (!ava_B4_ver_used(0)) {
  TRACE_2(
@@ -2844,6 +2851,13 @@ SaAisErrorT AmfAgent::Response_4(SaAmfHandleT 
hdl, SaInvocationT inv,

SaAisErrorT rc = SA_AIS_OK;
TRACE_ENTER2("SaAmfHandleT passed is %llx", hdl);
  +  /* Verifying the input Handle & global handle */
+  if (!gl_ava_hdl || hdl > AVSV_UNS32_HDL_MAX) {
+TRACE_2("Invalid SaAmfHandle passed by component: %llx", hdl);
+rc = SA_AIS_ERR_BAD_HANDLE;
+goto done;
+  }
+
/* Version is previously set in in initialize function */
if (!ava_B4_ver_used(0)) {
  TRACE_2(



-- 


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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel







--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 0/1] Review Request for amfa: Fix saAmfComponentErrorClear_4 to return ERR_NOT_EXIST for non-exist comp [#2540]

2017-08-02 Thread Nguyen Luu
Summary: amfa: Fix saAmfComponentErrorClear_4 to return ERR_NOT_EXIST for 
non-exist comp [#2540]
Review request for Ticket(s): 2540
Peer Reviewer(s): AMF devs
Pull request to: AMF maintainers
Affected branch(es): develop
Development branch: ticket-2540
Base revision: 4aec4a89cadeff7a642ae49bbb6c638632e73b7e
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
revision a8676a873a86f9836e2a1a55e27c8f1acee0535f
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Wed, 2 Aug 2017 13:48:13 +0700

amfa: Fix saAmfComponentErrorClear_4 to return ERR_NOT_EXIST for non-exist comp 
[#2540]

When called with a non-existing component name, saAmfComponentErrorClear_4
should return SA_AIS_ERR_NOT_EXIST instead of SA_AIS_ERR_BAD_OPERATION
as previously done.



Complete diffstat:
--
 src/amf/amfnd/err.cc | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)


Testing Commands:
-
Test steps:
1) Call saAmfInitialize_4().
2) Call saAmfComponentErrorClear_4() with a non-existing component name.
3) Call saAmfFinalize to finalize the handle obtained in 1st step.


Testing, Expected Results:
--
The saAmfComponentErrorClear_4() call in step 2) should return
SA_AIS_ERR_NOT_EXIST. 


Conditions of Submission:
-
Ack from reviewers of after 2 weeks.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 0/1] Review Request for amfa: Fix saAmfPmStart_3 and saAmfResponse_4 to correctly return BAD_HANDLE [#2539]

2017-08-01 Thread Nguyen Luu
Summary: amfa: Fix saAmfPmStart_3 and saAmfResponse_4 to correctly return 
BAD_HANDLE [#2539]
Review request for Ticket(s): 2539
Peer Reviewer(s): AMF devs
Pull request to: AMF maintainers
Affected branch(es): develop, release
Development branch: ticket-2539
Base revision: 4aec4a89cadeff7a642ae49bbb6c638632e73b7e
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
revision 5c481c9e0fb45afe6cb9c7ae838191ff68b64b48
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Wed, 2 Aug 2017 10:11:02 +0700

amfa: Fix saAmfPmStart_3 and saAmfResponse_4 to correctly return BAD_HANDLE 
[#2539]

When called with an uninitialized or already finalized handle,
saAmfPmStart_3 and saAmfResponse_4 should return SA_AIS_ERR_BAD_HANDLE
instead of SA_AIS_ERR_VERSION as previously done.



Complete diffstat:
--
 src/amf/agent/amf_agent.cc | 14 ++
 1 file changed, 14 insertions(+)


Testing Commands:
-
1) Call saAmfPmStart_3 and saAmfResponse_4 with an uninitialized handle.
2) Call saAmfPmStart_3 and saAmfResponse_4 with an already finalized handle.


Testing, Expected Results:
--
saAmfPmStart_3 and saAmfResponse_4 should return SA_AIS_ERR_BAD_HANDLE
in both cases.


Conditions of Submission:
-
Ack from reviewers of after 2 weeks.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 0/1] Review Request for ntf: ntftest to check longDnsAllowed to run or skip suite 35 [#2463] V2

2017-05-19 Thread Nguyen Luu
Summary: ntf: ntftest to check longDnsAllowed to run or skip suite 35 [#2463]
Review request for Ticket(s): 2463
Peer Reviewer(s): Minh H Chau, Vu M Nguyen
Pull request to: Minh H Chau
Affected branch(es): develop, release
Development branch: ticket-2463
Base revision: 1867ef71083edfad88dc3a9970549e6d35085bd2
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   y
 Other   n


Comments (indicate scope for each "y" above):
-
revision 46f41bc31bc2c25346916a816144ec7370da7373
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Fri, 19 May 2017 15:47:20 +0700

ntf: ntftest to check longDnsAllowed to run or skip suite 35 [#2463]

Suite 35 of ntftest requires long-dns support be enabled in the system.

If ntftest is run without any argument or specific test suite, suite 35
should be skipped if long-dns support is not enabled in the system.



Complete diffstat:
--
 src/ntf/apitest/test_ntf_imcn.c | 70 ++---
 1 file changed, 51 insertions(+), 19 deletions(-)


Testing Commands:
-
Disble long-dns support in the system,
and run 'ntftest' without any argument.


Testing, Expected Results:
--
ntftest should pass and not run suite 35.


Conditions of Submission:
-
Ack from reviewers.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 1/1] ntf: ntftest to check longDnsAllowed to run or skip suite 35 [#2463]

2017-05-19 Thread Nguyen Luu
Suite 35 of ntftest requires long-dns support be enabled in the system.

If ntftest is run without any argument or specific test suite, suite 35
should be skipped if long-dns support is not enabled in the system.
---
 src/ntf/apitest/test_ntf_imcn.c | 70 ++---
 1 file changed, 51 insertions(+), 19 deletions(-)

diff --git a/src/ntf/apitest/test_ntf_imcn.c b/src/ntf/apitest/test_ntf_imcn.c
index 6973be3..c56e739 100644
--- a/src/ntf/apitest/test_ntf_imcn.c
+++ b/src/ntf/apitest/test_ntf_imcn.c
@@ -1625,6 +1625,38 @@ static void delete_rt_test_object(const char *dn)
safassert(saImmOiFinalize(immOiHnd), SA_AIS_OK);
 }
 
+static int isLongDnsAllowed()
+{
+  SaImmHandleT immHandle;
+  SaImmAccessorHandleT accessorHandle;
+  SaVersionT immVersion = {'A', 2, 15};
+  SaImmAttrNameT attrName = "longDnsAllowed";
+  SaImmAttrNameT attrNames[2] = {attrName, NULL};
+  SaImmAttrValuesT_2 **attributes = NULL;
+  SaConstStringT immObjectName = "opensafImm=opensafImm,safApp=safImmService";
+  int longDnsAllowed = 0;
+  int i;
+
+  safassert(saImmOmInitialize(, NULL, ), SA_AIS_OK);
+  safassert(saImmOmAccessorInitialize(immHandle, ), SA_AIS_OK);
+  safassert(saImmOmAccessorGet_o3(accessorHandle, immObjectName,
+attrNames, ), SA_AIS_OK);
+
+  for (i = 0; attributes[i]; ++i) {
+if (!strcmp(attrName, attributes[i]->attrName) &&
+attributes[i]->attrValuesNumber == 1 &&
+attributes[i]->attrValueType == SA_IMM_ATTR_SAUINT32T) {
+  longDnsAllowed = *(int *)attributes[i]->attrValues[0];
+  break;
+}
+  }
+
+  saImmOmAccessorFinalize(accessorHandle);
+  saImmOmFinalize(immHandle);
+
+  return longDnsAllowed;
+}
+
 /**
  * Create a runtime test object and verify correctness of generated
  * notification.
@@ -6289,23 +6321,23 @@ __attribute__((constructor)) static void 
ntf_imcn_constructor(void)
test_case_add(34, objectDeleteTest_3404,
  "DELETE, runtime (OsafNtfCmTestRT1) object");
 
-   test_suite_add(35, "CM notification test for extended name attribute");
-   test_case_add(
-   35, objectCreateTest_3501,
-   "CREATE, runtime (OsafNtfCmTestRT) object, extended name 
attribute");
-   test_case_add(35, objectModifyTest_3502,
- "runtime, attr ch, REPLACE (EXTENDED NAME, ANY)");
-   test_case_add(35, objectModifyTest_3503,
- "runtime, attr ch, ADD (EXTENDED NAME)");
-   test_case_add(35, objectDeleteTest_19,
- "DELETE, runtime (OsafNtfCmTestRT) object");
-   test_case_add(
-   35, objectCreateTest_3505,
-   "CREATE, config (OsafNtfCmTestCFG) object, extended name 
attribute");
-   test_case_add(35, objectModifyTest_3506,
- "config, attr ch, REPLACE (EXTENDED NAME, ANY)");
-   test_case_add(35, objectModifyTest_3507,
- "config, attr ch, ADD (EXTENDED NAME)");
-   test_case_add(35, objectDeleteTest_40,
- "DELETE, config (OsafNtfCmTestCFG) object");
+  if (isLongDnsAllowed()) {
+test_suite_add(35, "CM notification test for extended name attribute");
+test_case_add(35, objectCreateTest_3501,
+"CREATE, runtime (OsafNtfCmTestRT) object, extended name attribute");
+test_case_add(35, objectModifyTest_3502,
+"runtime, attr ch, REPLACE (EXTENDED NAME, ANY)");
+test_case_add(35, objectModifyTest_3503,
+"runtime, attr ch, ADD (EXTENDED NAME)");
+test_case_add(35, objectDeleteTest_19,
+"DELETE, runtime (OsafNtfCmTestRT) object");
+test_case_add(35, objectCreateTest_3505,
+"CREATE, config (OsafNtfCmTestCFG) object, extended name attribute");
+test_case_add(35, objectModifyTest_3506,
+"config, attr ch, REPLACE (EXTENDED NAME, ANY)");
+test_case_add(35, objectModifyTest_3507,
+"config, attr ch, ADD (EXTENDED NAME)");
+test_case_add(35, objectDeleteTest_40,
+"DELETE, config (OsafNtfCmTestCFG) object");
+  }
 }
-- 
2.7.4


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 0/1] Review Request for amf: validate env variable format set in comptype and comp objects [#2409] V2

2017-04-28 Thread Nguyen Luu
Summary: amf: validate env variable format set in comptype/comp objects [#2409]
Review request for Ticket(s): 2409
Peer Reviewer(s): AMF devs 
Pull request to: AMF maintainers
Affected branch(es): develop, release
Development branch: ticket-2409
Base revision: ced8d99726a51b9306e53fb8fc1f80f70f715b96
Personal repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
revision 94ced33d5ee94030122a5431a3a131ed705736a6
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Fri, 28 Apr 2017 17:03:05 +0700

amf: validate env variable format set in comptype/comp objects [#2409]

Valid environment variable should have the format 'var=value'.

AMF currently does not validate this format during CREATE CCBs
for comptype and comp objects (MODIFY allowed for comp after #2255)
related to saAmfxxxCmdEnv attribute.
Besides, the existing validation in avnd_comp_clc_cmd_execute()
is not good enough. This results in invalid env variables getting
printed with weird output.

Also, there is currently no check for duplicate env variables set
in both comptype and comp, so they get printed twice in trace.

This ticket fixes the above issues:
- Validate env variable format during comp[type] CREATE, MODIFY CCBs.
- Overwrite env variable set in comptype if it is also set in comp.



Complete diffstat:
--
 src/amf/amfd/comp.cc | 68 
 src/amf/amfd/comptype.cc | 36 ++---
 src/amf/amfnd/clc.cc |  6 -
 src/amf/amfnd/compdb.cc  | 43 +-
 4 files changed, 138 insertions(+), 15 deletions(-)


Testing Commands:
-
1) Create SaAmfCompType/SaAmfComp objects with invalid env variable format
in attributes saAmfCtDefCmdEnv/saAmfCompCmdEnv. (e.g 'var = value', 
'var==value')
2) Modify attribute saAmfCompCmdEnv of SaAmfComp object with invalid env
variable format.


Testing, Expected Results:
--
AMFD will reject CREATE/MODIFY CCBs with invalid env variable format.


Conditions of Submission:
-
Ack from reviewers of after 2 weeks.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.


[devel] [PATCH 1/1] amf: validate env variable format set in comptype/comp objects [#2409]

2017-04-28 Thread Nguyen Luu
Valid environment variable should have the format 'var=value'.

AMF currently does not validate this format during CREATE CCBs
for comptype and comp objects (MODIFY allowed for comp after #2255)
related to saAmfxxxCmdEnv attribute.
Besides, the existing validation in avnd_comp_clc_cmd_execute()
is not good enough. This results in invalid env variables getting
printed with weird output.

Also, there is currently no check for duplicate env variables set
in both comptype and comp, so they get printed twice in trace.

This ticket fixes the above issues:
- Validate env variable format during comp[type] CREATE, MODIFY CCBs.
- Overwrite env variable set in comptype if it is also set in comp.
---
 src/amf/amfd/comp.cc | 68 
 src/amf/amfd/comptype.cc | 36 ++---
 src/amf/amfnd/clc.cc |  6 -
 src/amf/amfnd/compdb.cc  | 43 +-
 4 files changed, 138 insertions(+), 15 deletions(-)

diff --git a/src/amf/amfd/comp.cc b/src/amf/amfd/comp.cc
index d4b51a6..c866891 100644
--- a/src/amf/amfd/comp.cc
+++ b/src/amf/amfd/comp.cc
@@ -339,6 +339,8 @@ static int is_config_valid(const std::string ,
CcbUtilOperationData_t *opdata) {
   SaAisErrorT rc;
   SaNameT aname;
+  unsigned int num_of_cmd_env;
+  std::string cmd_env;
   std::string::size_type pos;
   SaUint32T value;
 
@@ -399,6 +401,38 @@ static int is_config_valid(const std::string ,
 return 0;
   }
 
+  if 
((immutil_getAttrValuesNumber(const_cast("saAmfCompCmdEnv")
+   ,attributes, _of_cmd_env)) == SA_AIS_OK)
+  {
+for (unsigned int i = 0; i < num_of_cmd_env; i++) {
+  cmd_env = immutil_getStringAttr(attributes, "saAmfCompCmdEnv", i);
+
+  /* env variable format with 'whitespace' is considered as invalid */
+  if (cmd_env.find_first_of(' ') != std::string::npos) {
+report_ccb_validation_error(opdata, "Unknown enviroment variable 
format"
+" '%s' for '%s'. Should be 'var=value'",
+cmd_env.c_str(), dn.c_str());
+return false;
+  }
+
+  std::size_t equalPos = cmd_env.find_first_of('=');
+  unsigned int equal_sign = 0;
+
+  while (equalPos != std::string::npos) {
+equal_sign++;
+equalPos = cmd_env.find_first_of('=', equalPos + 1);
+  }
+  /* env variable format with none or more than one '='
+   * is considered as invalid */
+  if (equal_sign != 1) {
+report_ccb_validation_error(opdata, "Unknown enviroment variable 
format"
+" '%s' for '%s'. Should be 'var=value'",
+cmd_env.c_str(), dn.c_str());
+return false;
+  }
+}
+  }
+
 #if 0
 if ((comp->comp_info.category == AVSV_COMP_TYPE_SA_AWARE) && 
(comp->comp_info.init_len == 0)) {
 LOG_ER("Sa Aware Component: instantiation command not 
configured");
@@ -1035,6 +1069,40 @@ static SaAisErrorT 
ccb_completed_modify_hdlr(CcbUtilOperationData_t *opdata) {
 opdata, "Modification of saAmfCompCmdEnv failed, nullptr arg");
 goto done;
   }
+  for (unsigned index = 0; index < attribute->attrValuesNumber; index++) {
+std::string mod_comp_env = *(static_cast(attribute->
+  attrValues[index]));
+
+/* env variable format with 'whitespace' is considered as invalid */
+if (mod_comp_env.find_first_of(' ') != std::string::npos) {
+  report_ccb_validation_error(opdata, "Modification of saAmfCompCmdEnv"
+  " failed. Unknown enviroment variable"
+  " format '%s' for '%s'."
+  " Should be 'var=value'",
+  mod_comp_env.c_str(),
+  osaf_extended_name_borrow(>
+objectName));
+  goto done;
+}
+std::size_t equalPos = mod_comp_env.find_first_of('=');
+unsigned int equal_sign = 0;
+while (equalPos != std::string::npos) {
+  equal_sign++;
+  equalPos = mod_comp_env.find_first_of('=', equalPos + 1);
+}
+/* env variable format with none or more than one '='
+ * is considered as invalid */
+if (equal_sign != 1) {
+  report_ccb_validation_error(opdata, "Modification of saAmfCompCmdEnv"
+  " failed. Unknown enviroment variable"
+  " format '%s' for '%s'."
+  " Should be 'var=value'",
+  mod_comp_env.c_str(),
+  osaf_extended_name_borrow(>
+

[devel] [PATCH 0/1] Review Request for amf: validate env variable format set in comptype and comp objects [#2409]

2017-04-13 Thread Nguyen Luu
Summary: amf: validate env variable format set in comptype/comp objects [#2409]
Review request for Ticket(s): 2409
Peer Reviewer(s): AMF devs 
Pull request to: AMF maintainers
Affected branch(es): develop, release
Development branch: ticket-2409
Private repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesy
 OpenSAF servicesn
 Core libraries  n
 Samples n
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
revision 92f39d85213eea901334dcdf3c6b3ac7669810d1
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Thu, 13 Apr 2017 19:37:46 +0700

amf: validate env variable format set in comptype/comp objects [#2409]

Valid environment variable should have the format 'var=value'.

AMF currently does not validate this format during CREATE CCBs
for comptype and comp objects (MODIFY allowed for comp after #2255)
related to saAmfxxxCmdEnv attribute.
Besides, the existing validation in avnd_comp_clc_cmd_execute()
is not good enough. This results in invalid env variables getting
printed with weird output.

Also, there is currently no check for duplicate env variables set
in both comptype and comp, so they get printed twice in trace.

This ticket fixes the above issues:
- Validate env variable format during comp[type] CREATE, MODIFY CCBs.
- Overwrite env variable set in comptype if it is also set in comp.



Complete diffstat:
--
 src/amf/amfd/comp.cc | 59 
 src/amf/amfd/comptype.cc | 33 ---
 src/amf/amfnd/clc.cc |  6 -
 src/amf/amfnd/compdb.cc  | 44 +++-
 4 files changed, 127 insertions(+), 15 deletions(-)


Testing Commands:
-
1) Create SaAmfCompType/SaAmfComp objects with invalid env variable format
in attributes saAmfCtDefCmdEnv/saAmfCompCmdEnv. (e.g 'var = value', 
'var==value')
2) Modify attribute saAmfCompCmdEnv of SaAmfComp object with invalid env
variable format.


Testing, Expected Results:
--
AMFD will reject CREATE/MODIFY CCBs with invalid env variable format.


Conditions of Submission:
-
Ack from reviewers of after 2 weeks.


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you d

[devel] [PATCH 1/1] amf: validate env variable format set in comptype/comp objects [#2409]

2017-04-13 Thread Nguyen Luu
Valid environment variable should have the format 'var=value'.

AMF currently does not validate this format during CREATE CCBs
for comptype and comp objects (MODIFY allowed for comp after #2255)
related to saAmfxxxCmdEnv attribute.
Besides, the existing validation in avnd_comp_clc_cmd_execute()
is not good enough. This results in invalid env variables getting
printed with weird output.

Also, there is currently no check for duplicate env variables set
in both comptype and comp, so they get printed twice in trace.

This ticket fixes the above issues:
- Validate env variable format during comp[type] CREATE, MODIFY CCBs.
- Overwrite env variable set in comptype if it is also set in comp.
---
 src/amf/amfd/comp.cc | 59 
 src/amf/amfd/comptype.cc | 33 ---
 src/amf/amfnd/clc.cc |  6 -
 src/amf/amfnd/compdb.cc  | 44 +++-
 4 files changed, 127 insertions(+), 15 deletions(-)

diff --git a/src/amf/amfd/comp.cc b/src/amf/amfd/comp.cc
index d4b51a6..2840e36 100644
--- a/src/amf/amfd/comp.cc
+++ b/src/amf/amfd/comp.cc
@@ -339,6 +339,8 @@ static int is_config_valid(const std::string ,
CcbUtilOperationData_t *opdata) {
   SaAisErrorT rc;
   SaNameT aname;
+  unsigned int num_of_cmd_env;
+  std::string cmd_env;
   std::string::size_type pos;
   SaUint32T value;
 
@@ -399,6 +401,36 @@ static int is_config_valid(const std::string ,
 return 0;
   }
 
+  if 
((immutil_getAttrValuesNumber(const_cast("saAmfCompCmdEnv"),
+   attributes, _of_cmd_env)) == SA_AIS_OK)
+  {
+for (unsigned int i = 0; i < num_of_cmd_env; i++) {
+  cmd_env = immutil_getStringAttr(attributes, "saAmfCompCmdEnv", i);
+  osafassert(cmd_env.c_str());
+
+  /* env variable format with 'whitespace' is considered as invalid */
+  if (cmd_env.find_first_of(' ') != std::string::npos) {
+report_ccb_validation_error(opdata, "Unknown enviroment variable 
format '%s' for '%s'."
+" Should be 'var=value'", cmd_env.c_str(), 
dn.c_str());
+return false;
+  }
+
+  std::size_t equalPos = cmd_env.find_first_of('=');
+  unsigned int equal_sign = 0;
+
+  while (equalPos != std::string::npos) {
+equal_sign++;
+equalPos = cmd_env.find_first_of('=', equalPos + 1);
+  }
+  /* env variable format with none or more than one '=' is considered as 
invalid */
+  if (equal_sign != 1) {
+report_ccb_validation_error(opdata, "Unknown enviroment variable 
format '%s' for '%s'."
+" Should be 'var=value'", cmd_env.c_str(), 
dn.c_str());
+return false;
+  }
+ }
+  }
+
 #if 0
 if ((comp->comp_info.category == AVSV_COMP_TYPE_SA_AWARE) && 
(comp->comp_info.init_len == 0)) {
 LOG_ER("Sa Aware Component: instantiation command not 
configured");
@@ -1035,6 +1067,33 @@ static SaAisErrorT 
ccb_completed_modify_hdlr(CcbUtilOperationData_t *opdata) {
 opdata, "Modification of saAmfCompCmdEnv failed, nullptr arg");
 goto done;
   }
+  for (unsigned index = 0; index < attribute->attrValuesNumber; index++) {
+std::string mod_comp_env = *(static_cast(attribute->attrValues[index]));
+osafassert(mod_comp_env.c_str());
+
+/* env variable format with 'whitespace' is considered as invalid */
+if (mod_comp_env.find_first_of(' ') != std::string::npos) {
+  report_ccb_validation_error(opdata, "Modification of saAmfCompCmdEnv 
failed."
+  " Unknown enviroment variable format 
'%s' for '%s'."
+  " Should be 'var=value'", 
mod_comp_env.c_str(),
+  
osaf_extended_name_borrow(>objectName));
+  goto done;
+}
+std::size_t equalPos = mod_comp_env.find_first_of('=');
+unsigned int equal_sign = 0;
+while (equalPos != std::string::npos) {
+  equal_sign++;
+  equalPos = mod_comp_env.find_first_of('=', equalPos + 1);
+}
+/* env variable format with none or more than one '=' is considered as 
invalid */
+if (equal_sign != 1) {
+  report_ccb_validation_error(opdata, "Modification of saAmfCompCmdEnv 
failed."
+  " Unknown enviroment variable format 
'%s' for '%s'."
+  " Should be 'var=value'", 
mod_comp_env.c_str(),
+  
osaf_extended_name_borrow(>objectName));
+  goto done;
+}
+  }
 } else if (!strcmp(attribute->attrName, "saAmfCompInstantiateCmdArgv")) {
   if (value_is_deleted == true) continue;
   char *param_val = *((char **)value);
diff --git a/src/amf/amfd/comptype.cc b/src/amf/amfd/comptype.cc
index 3d2636e..08e8b24 100644
--- 

[devel] [PATCH 0/1] Review Request for samples: amf_demo_script missed to define $piddir [#2410]

2017-04-12 Thread Nguyen Luu
Summary: samples: fix $piddir undefined in amf_demo_script [#2410]
Review request for Ticket(s): 2410
Peer Reviewer(s): AMF devs 
Pull request to: AMF maintainers
Affected branch(es): develop, release
Development branch: ticket-2410
Private repository: git://git.code.sf.net/u/nguyenluu/review


Impacted area   Impact y/n

 Docsn
 Build systemn
 RPM/packaging   n
 Configuration files n
 Startup scripts n
 SAF servicesn
 OpenSAF servicesn
 Core libraries  n
 Samples y
 Tests   n
 Other   n


Comments (indicate scope for each "y" above):
-
revision 842d06c3a6787789b018221ed5ee43ee02f48e0d
Author: Nguyen Luu <nguyen.tk@dektech.com.au>
Date:   Wed, 12 Apr 2017 14:23:46 +0700

samples: fix $piddir undefined in amf_demo_script [#2410]

The $piddir variable (containing path to amf_demo comp's pid file)
is missed to be defined in amf_demo_script.

This could lead to the amf_demo process not getting truely killed
in some cases when cleanup is called (e.g when invoking
saAmfComponentErrorReport()), leaving the process unmanaged by AMF.



Complete diffstat:
--
 samples/amf/sa_aware/amf_demo_script | 1 +
 1 file changed, 1 insertion(+)


Testing Commands:
-
Invoke saAmfComponentErrorReport_4() within sa_aware amf_demo code


Testing, Expected Results:
--
AmfDemo component is successfully cleaned up (amf_demo process got
killed) and recovered according to configured recovery.


Conditions of Submission:
-
Ack from reviewers or after 2 weeks


Arch  Built StartedLinux distro
---
mipsn  n
mips64  n  n
x86 n  n
x86_64  y  y
powerpc n  n
powerpc64   n  n


Reviewer Checklist:
---
[Submitters: make sure that your review doesn't trigger any checkmarks!]


Your checkin has not passed review because (see checked entries):

___ Your RR template is generally incomplete; it has too many blank entries
that need proper data filled in.

___ You have failed to nominate the proper persons for review and push.

___ Your patches do not have proper short+long header

___ You have grammar/spelling in your header that is unacceptable.

___ You have exceeded a sensible line length in your headers/comments/text.

___ You have failed to put in a proper Trac Ticket # into your commits.

___ You have incorrectly put/left internal data in your comments/files
(i.e. internal bug tracking tool IDs, product names etc)

___ You have not given any evidence of testing beyond basic build tests.
Demonstrate some level of runtime or other sanity testing.

___ You have ^M present in some of your files. These have to be removed.

___ You have needlessly changed whitespace or added whitespace crimes
like trailing spaces, or spaces before tabs.

___ You have mixed real technical changes with whitespace and other
cosmetic code cleanup changes. These have to be separate commits.

___ You need to refactor your submission into logical chunks; there is
too much content into a single commit.

___ You have extraneous garbage in your review (merge commits etc)

___ You have giant attachments which should never have been sent;
Instead you should place your content in a public tree to be pulled.

___ You have too many commits attached to an e-mail; resend as threaded
commits, or place in a public tree for a pull.

___ You have resent this content multiple times without a clear indication
of what has changed between each re-send.

___ You have failed to adequately and individually address all of the
comments and change requests that were proposed in the initial review.

___ You have a misconfigured ~/.gitconfig file (i.e. user.name, user.email etc)

___ Your computer have a badly configured date and time; confusing the
the threaded patch review.

___ Your changes affect IPC mechanism, and you don't present any results
for in-service upgradability test.

___ Your changes affect user manual and documentation, your patch series
do not contain the patch that updates the Doxygen manual.


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel


[devel] [PATCH 1/1] samples: fix $piddir undefined in amf_demo_script [#2410]

2017-04-12 Thread Nguyen Luu
The $piddir variable (containing path to amf_demo comp's pid file)
is missed to be defined in amf_demo_script.

This could lead to the amf_demo process not getting truely killed
in some cases when cleanup is called (e.g when invoking
saAmfComponentErrorReport()), leaving the process unmanaged by AMF.
---
 samples/amf/sa_aware/amf_demo_script | 1 +
 1 file changed, 1 insertion(+)

diff --git a/samples/amf/sa_aware/amf_demo_script 
b/samples/amf/sa_aware/amf_demo_script
index eb61ac0..a033f53 100755
--- a/samples/amf/sa_aware/amf_demo_script
+++ b/samples/amf/sa_aware/amf_demo_script
@@ -34,6 +34,7 @@ fi
 # Source LSB functions library
 . /lib/lsb/init-functions
 
+piddir="/tmp"
 compname=`echo $SA_AMF_COMPONENT_NAME | md5sum | awk '{print $1}'`
 pidfile="$piddir/${compname}.pid"
 
-- 
2.7.4


--
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
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel