Re: [devel] [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

2018-01-09 Thread Hieu Nguyen
Many thanks Hans.

Regards,
Hieu

-Original Message-
From: Hans Nordebäck [mailto:hans.nordeb...@ericsson.com] 
Sent: Tuesday, January 9, 2018 10:27 PM
To: Hieu Thanh Nguyen <hieu.t.ngu...@dektech.com.au>; Anders Widell 
<anders.wid...@ericsson.com>; srinivas.mangip...@oracle.com
Cc: opensaf-devel@lists.sourceforge.net
Subject: RE: [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

Hi Hieu,
Nice work, the changes looks fine./Thanks HansN

-Original Message-
From: Hieu Nguyen [mailto:hieu.t.ngu...@dektech.com.au] 
Sent: den 9 januari 2018 12:26
To: Hans Nordebäck <hans.nordeb...@ericsson.com>; Anders Widell 
<anders.wid...@ericsson.com>; srinivas.mangip...@oracle.com
Cc: opensaf-devel@lists.sourceforge.net
Subject: RE: [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

Hi Hans,

Thanks for your suggestion.
I already implement the initialize() in some needed functions and sent out new 
patch in attached file.
Please help me review on the new patch.

Regards,
Hieu

-Original Message-
From: Hans Nordebäck [mailto:hans.nordeb...@ericsson.com] 
Sent: Tuesday, January 9, 2018 1:47 PM
To: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>; 'Anders Widell' 
<anders.wid...@ericsson.com>; srinivas.mangip...@oracle.com
Cc: opensaf-devel@lists.sourceforge.net
Subject: Re: [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

Hi Hieu,

it sounds good. The question about backwards compatible was to highlight 
possible application problems, it should not

be too hard to avoid this non backward compatibility, either as you 
suggest, changing version, or perhaps, with some overhead,

do the init if needed in each function, (similar to the singleton pattern).

/Regards HansN



On 01/09/2018 04:28 AM, Hieu Nguyen wrote:
> Thanks Hans,
>
> New exception is just an improvement to make exception type and message 
> clearer. It informs ERR_INIT to user so that user knows that OI needs to be 
> initialized before any function is used. Something like that:
>
>>>> from pyosaf.utils import immoi
>>>> immoi.get_available_classes_in_imm()
> Traceback (most recent call last):
>File "", line 1, in 
>File "/usr/local/lib/python2.7/dist-packages/pyosaf/utils/__init__.py", 
> line 243, in inner
>  return func(*args, **kwargs)
>File 
> "/usr/local/lib/python2.7/dist-packages/pyosaf/utils/immoi/__init__.py", line 
> 312, in get_available_classes_in_imm
>  raise SafException(eSaAisErrorT.SA_AIS_ERR_INIT)
> pyosaf.utils.SafException: SA_AIS_ERR_INIT
>
>
> If not use new exception (current version in develop branch), it is raising 
> AttributeError exception for the case above.
>
>>>> from pyosaf.utils import immoi
>>>> immoi.get_available_classes_in_imm()
> Traceback (most recent call last):
>File "", line 1, in 
>File "/usr/local/lib/python2.7/dist-packages/pyosaf/utils/__init__.py", 
> line 243, in inner
>  return func(*args, **kwargs)
>File 
> "/usr/local/lib/python2.7/dist-packages/pyosaf/utils/immoi/__init__.py", line 
> 314, in get_available_classes_in_imm
>  return _oi_agent.get_available_classes_in_imm()
> AttributeError: 'NoneType' object has no attribute 
> 'get_available_classes_in_imm'
>
> To avoid this minor non-backwards compatible issue, I will increase the 
> version of pyosaf utils (pyosaf/utils/__init__.py) to "1.0.1", how do you 
> think?
>
> Regards,
> Hieu
>
> -Original Message-
> From: Hans Nordebäck [mailto:hans.nordeb...@ericsson.com]
> Sent: Monday, January 8, 2018 7:23 PM
> To: Hieu Thanh Nguyen <hieu.t.ngu...@dektech.com.au>; Anders Widell 
> <anders.wid...@ericsson.com>; srinivas.mangip...@oracle.com
> Cc: opensaf-devel@lists.sourceforge.net
> Subject: RE: [PATCH 1/1] pyosaf: refactor IMM utils [#2683]
>
> Hi Hieu,
>
> Yes, I noticed that e.g. initialize is needed, but also other changes e.g. 
> new exceptions are thrown.
> These changes implies that applications may have to be updated and thus the 
> changes are not backwards compatible.
>
> /Regards HansN
>
> -Original Message-
> From: Hieu Nguyen [mailto:hieu.t.ngu...@dektech.com.au]
> Sent: den 8 januari 2018 13:06
> To: Hans Nordebäck <hans.nordeb...@ericsson.com>; Anders Widell 
> <anders.wid...@ericsson.com>; srinivas.mangip...@oracle.com
> Cc: opensaf-devel@lists.sourceforge.net
> Subject: RE: [PATCH 1/1] pyosaf: refactor IMM utils [#2683]
>
> Hi Hans,
>
> I answered your questions below:
> Q: " These changes are not backwards compatible ?"
> A: These change still support pyosaf utils old version. Your sample missing 
> immoi.initialize() before, correctly:
> python
>>>> from pyosaf.ut

[devel] [PATCH 0/1] Review Request for pyosaf: refactor IMM utils V2[#2683]

2018-01-09 Thread Hieu Nguyen
Summary: pyosaf: refactor IMM utils [#2683]
Review request for Ticket(s): 2683
Peer Reviewer(s): Hans, Anders, Sir
Pull request to: Hans or Anders
Affected branch(es): develop
Development branch: ticket-2683
Base revision: 51e30cbf5f891f2479013bf9ce4289a27c47aa17
Personal repository: git://git.code.sf.net/u/dhiengu/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 757a61b997aa2e3dca884d504a25175cb455a45e
Author: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>
Date:   Tue, 9 Jan 2018 18:01:36 +0700

pyosaf: refactor IMM utils [#2683]

+ improve OI utils use a separate instance OM agent
+ refactor OM utils with Ccb inheritace OmAgent, rename some classes...



Added Files:

 python/pyosaf/utils/immoi/agent.py


Complete diffstat:
--
 python/Makefile.am   |   1 +
 python/pyosaf/utils/immoi/__init__.py| 465 +-
 python/pyosaf/utils/immoi/agent.py   | 473 +++
 python/pyosaf/utils/immoi/implementer.py | 151 ++
 python/pyosaf/utils/immom/__init__.py|  34 +--
 python/pyosaf/utils/immom/accessor.py|  31 +-
 python/pyosaf/utils/immom/agent.py   |  31 +-
 python/pyosaf/utils/immom/ccb.py |  76 ++---
 python/pyosaf/utils/immom/iterator.py|   4 +-
 python/pyosaf/utils/immom/object.py  |   4 +-
 10 files changed, 698 insertions(+), 572 deletions(-)


Testing Commands:
-


Testing, Expected Results:
--
Use /samples to test for IMM utils


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 li

[devel] [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

2018-01-09 Thread Hieu Nguyen
+ improve OI utils use a separate instance OM agent
+ refactor OM utils with Ccb inheritace OmAgent, rename some classes...
---
 python/Makefile.am   |   1 +
 python/pyosaf/utils/immoi/__init__.py| 465 +-
 python/pyosaf/utils/immoi/agent.py   | 473 +++
 python/pyosaf/utils/immoi/implementer.py | 151 ++
 python/pyosaf/utils/immom/__init__.py|  34 +--
 python/pyosaf/utils/immom/accessor.py|  31 +-
 python/pyosaf/utils/immom/agent.py   |  31 +-
 python/pyosaf/utils/immom/ccb.py |  76 ++---
 python/pyosaf/utils/immom/iterator.py|   4 +-
 python/pyosaf/utils/immom/object.py  |   4 +-
 10 files changed, 698 insertions(+), 572 deletions(-)
 create mode 100644 python/pyosaf/utils/immoi/agent.py

diff --git a/python/Makefile.am b/python/Makefile.am
index 08338bb..1952d5e 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -61,6 +61,7 @@ pkgpyosafutilslog_PYTHON = \
 
 pkgpyosafutilsimmoi_PYTHON = \
python/pyosaf/utils/immoi/__init__.py \
+   python/pyosaf/utils/immoi/agent.py \
python/pyosaf/utils/immoi/implementer.py
 
 pkgpyosafutilsntf_PYTHON = \
diff --git a/python/pyosaf/utils/immoi/__init__.py 
b/python/pyosaf/utils/immoi/__init__.py
index 1b4dece..41e21ca 100644
--- a/python/pyosaf/utils/immoi/__init__.py
+++ b/python/pyosaf/utils/immoi/__init__.py
@@ -22,298 +22,23 @@ Supported functions:
 - Set/clear/release implementer for class/object
 - Create/delete/update runtime object
 - Get class/object attributes
-- Get IMM error strings
+- Get/set IMM error strings
+- Get parent for dn
+- Get class for dn
+- Get objects for class
+- Get available classes of IMM
 """
 from __future__ import print_function
-from copy import deepcopy
-from ctypes import c_char_p, c_void_p, cast, pointer
-
-from pyosaf.saAis import SaStringT, SaVersionT, SaNameT, SaSelectionObjectT, \
-unmarshalSaStringTArray, eSaDispatchFlagsT, eSaAisErrorT
-from pyosaf import saImm, saImmOi
-from pyosaf.saImm import unmarshalSaImmValue, SaImmAttrNameT,  \
-SaImmAttrValuesT_2, SaImmClassNameT, SaImmSearchParametersT_2, \
-eSaImmValueTypeT, SaImmAttrDefinitionT_2, SaImmClassCategoryT, \
-SaImmAttrModificationT_2, eSaImmAttrModificationTypeT
-from pyosaf.saImmOi import SaImmOiHandleT, SaImmOiImplementerNameT
-from pyosaf.utils import immom, log_err, bad_handle_retry, decorate, \
-deprecate, initialize_decorate, SafException
+
+from pyosaf.saAis import SaSelectionObjectT, eSaAisErrorT
+from pyosaf.utils import deprecate, SafException
 from pyosaf.utils.immom.object import ImmObject
-from pyosaf.utils.immom.ccb import marshal_c_array
-from pyosaf.utils.immom.iterator import SearchIterator
+from pyosaf.utils.immoi.agent import OiAgent
 
 
-OPENSAF_IMM_OBJECT = "opensafImm=opensafImm,safApp=safImmService"
 _oi_agent = None
 
 
-# Decorate pure saImmOi* API's with error-handling retry and exception raising
-saImmOiInitialize_2 = initialize_decorate(saImmOi.saImmOiInitialize_2)
-saImmOiSelectionObjectGet = decorate(saImmOi.saImmOiSelectionObjectGet)
-saImmOiDispatch = decorate(saImmOi.saImmOiDispatch)
-saImmOiFinalize = decorate(saImmOi.saImmOiFinalize)
-saImmOiImplementerSet = decorate(saImmOi.saImmOiImplementerSet)
-saImmOiImplementerClear = decorate(saImmOi.saImmOiImplementerClear)
-saImmOiClassImplementerSet = decorate(saImmOi.saImmOiClassImplementerSet)
-saImmOiClassImplementerRelease = \
-decorate(saImmOi.saImmOiClassImplementerRelease)
-saImmOiObjectImplementerSet = decorate(saImmOi.saImmOiObjectImplementerSet)
-saImmOiObjectImplementerRelease = \
-decorate(saImmOi.saImmOiObjectImplementerRelease)
-saImmOiRtObjectCreate_2 = decorate(saImmOi.saImmOiRtObjectCreate_2)
-saImmOiRtObjectDelete = decorate(saImmOi.saImmOiRtObjectDelete)
-saImmOiRtObjectUpdate_2 = decorate(saImmOi.saImmOiRtObjectUpdate_2)
-saImmOiAdminOperationResult = decorate(saImmOi.saImmOiAdminOperationResult)
-saImmOiAdminOperationResult_o2 = \
-decorate(saImmOi.saImmOiAdminOperationResult_o2)
-saImmOiAugmentCcbInitialize = decorate(saImmOi.saImmOiAugmentCcbInitialize)
-saImmOiCcbSetErrorString = decorate(saImmOi.saImmOiCcbSetErrorString)
-
-
-class OiAgent(object):
-""" This class acts as a high-level OI agent, providing OI functions to
-the users as a higher level, and relieving the users of the need to manage
-the life cycle of the OI agent and providing general interface for
-Implementer or Applier used
-"""
-def __init__(self, version=None):
-""" Constructor for OiAgent class
-
-Args:
-version (SaVersionT): OI API version
-"""
-self.handle = None
-self.init_version = version if version is not None \
-else SaVersionT('A', 2, 15)
-self.version = None
-self.selection_object = None
-self.callbacks = None
-global _oi_agent
-_oi_agent = self
-
-def _fetch_sel_obj(self):
-   

Re: [devel] [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

2018-01-08 Thread Hieu Nguyen
Thanks Hans,

New exception is just an improvement to make exception type and message 
clearer. It informs ERR_INIT to user so that user knows that OI needs to be 
initialized before any function is used. Something like that: 

>>> from pyosaf.utils import immoi
>>> immoi.get_available_classes_in_imm()
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.7/dist-packages/pyosaf/utils/__init__.py", line 
243, in inner
return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pyosaf/utils/immoi/__init__.py", 
line 312, in get_available_classes_in_imm
raise SafException(eSaAisErrorT.SA_AIS_ERR_INIT)
pyosaf.utils.SafException: SA_AIS_ERR_INIT


If not use new exception (current version in develop branch), it is raising 
AttributeError exception for the case above.

>>> from pyosaf.utils import immoi
>>> immoi.get_available_classes_in_imm()
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/lib/python2.7/dist-packages/pyosaf/utils/__init__.py", line 
243, in inner
return func(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/pyosaf/utils/immoi/__init__.py", 
line 314, in get_available_classes_in_imm
return _oi_agent.get_available_classes_in_imm()
AttributeError: 'NoneType' object has no attribute 
'get_available_classes_in_imm'

To avoid this minor non-backwards compatible issue, I will increase the version 
of pyosaf utils (pyosaf/utils/__init__.py) to "1.0.1", how do you think?

Regards,
Hieu

-Original Message-
From: Hans Nordebäck [mailto:hans.nordeb...@ericsson.com] 
Sent: Monday, January 8, 2018 7:23 PM
To: Hieu Thanh Nguyen <hieu.t.ngu...@dektech.com.au>; Anders Widell 
<anders.wid...@ericsson.com>; srinivas.mangip...@oracle.com
Cc: opensaf-devel@lists.sourceforge.net
Subject: RE: [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

Hi Hieu,

Yes, I noticed that e.g. initialize is needed, but also other changes e.g. new 
exceptions are thrown. 
These changes implies that applications may have to be updated and thus the 
changes are not backwards compatible.

/Regards HansN

-Original Message-
From: Hieu Nguyen [mailto:hieu.t.ngu...@dektech.com.au] 
Sent: den 8 januari 2018 13:06
To: Hans Nordebäck <hans.nordeb...@ericsson.com>; Anders Widell 
<anders.wid...@ericsson.com>; srinivas.mangip...@oracle.com
Cc: opensaf-devel@lists.sourceforge.net
Subject: RE: [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

Hi Hans,

I answered your questions below:
Q: " These changes are not backwards compatible ?"
A: These change still support pyosaf utils old version. Your sample missing 
immoi.initialize() before, correctly:
python
>>> from pyosaf.utils import immoi
>>> immoi.initialize()
>>> immoi.get_available_classes_in_imm()

I keep all old interfaces of imm utils with @deprecate functions in __init__.py 
file.

Q: " Why is some behavior changed in e.g. functions marked as deprecated?"
A: We changed some imm utils behavior because that is requested by ticket #2602.
https://sourceforge.net/p/opensaf/tickets/2602/

Same as title of ticket #2602 " improvement of high level python interfaces ". 
We want users should be change from functions to OOP.

Regards,
Hieu
-Original Message-
From: Hans Nordebäck [mailto:hans.nordeb...@ericsson.com] 
Sent: Monday, January 8, 2018 5:56 PM
To: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>; anders.wid...@ericsson.com; 
srinivas.mangip...@oracle.com
Cc: opensaf-devel@lists.sourceforge.net
Subject: Re: [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

Hi Hieu,

I have some initial questions regarding this patch:

These changes are not backwards compatible, e.g.:

 python

 >>> from pyosaf.utils import immoi

 >>> immoi.get_available_classes_in_imm()

do not work after this patch.

Why is some behavior changed in e.g. functions marked as deprecated? E.g 
adding exceptions.

/Regards HansN


On 12/20/2017 09:25 AM, Hieu Nguyen wrote:
> + improve OI utils use a separate instance OM agent
> + refactor OM utils with Ccb inheritace OmAgent, rename some classes...
> ---
>   python/Makefile.am   |   1 +
>   python/pyosaf/utils/immoi/__init__.py| 531 
> +++
>   python/pyosaf/utils/immoi/agent.py   | 473 +++
>   python/pyosaf/utils/immoi/implementer.py | 145 +
>   python/pyosaf/utils/immom/__init__.py|   7 +-
>   python/pyosaf/utils/immom/accessor.py|  31 +-
>   python/pyosaf/utils/immom/agent.py   |  31 +-
>   python/pyosaf/utils/immom/ccb.py |  71 +
>   python/pyosaf/utils/immom/iterator.py|   4 +-
>   python/pyosaf/utils/immom/object.py  |   4 +-
>   10 files changed, 739 insertions(+), 559 de

Re: [devel] [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

2018-01-08 Thread Hieu Nguyen
Hi Hans,

I answered your questions below:
Q: " These changes are not backwards compatible ?"
A: These change still support pyosaf utils old version. Your sample missing 
immoi.initialize() before, correctly:
python
>>> from pyosaf.utils import immoi
>>> immoi.initialize()
>>> immoi.get_available_classes_in_imm()

I keep all old interfaces of imm utils with @deprecate functions in __init__.py 
file.

Q: " Why is some behavior changed in e.g. functions marked as deprecated?"
A: We changed some imm utils behavior because that is requested by ticket #2602.
https://sourceforge.net/p/opensaf/tickets/2602/

Same as title of ticket #2602 " improvement of high level python interfaces ". 
We want users should be change from functions to OOP.

Regards,
Hieu
-Original Message-
From: Hans Nordebäck [mailto:hans.nordeb...@ericsson.com] 
Sent: Monday, January 8, 2018 5:56 PM
To: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>; anders.wid...@ericsson.com; 
srinivas.mangip...@oracle.com
Cc: opensaf-devel@lists.sourceforge.net
Subject: Re: [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

Hi Hieu,

I have some initial questions regarding this patch:

These changes are not backwards compatible, e.g.:

 python

 >>> from pyosaf.utils import immoi

 >>> immoi.get_available_classes_in_imm()

do not work after this patch.

Why is some behavior changed in e.g. functions marked as deprecated? E.g 
adding exceptions.

/Regards HansN


On 12/20/2017 09:25 AM, Hieu Nguyen wrote:
> + improve OI utils use a separate instance OM agent
> + refactor OM utils with Ccb inheritace OmAgent, rename some classes...
> ---
>   python/Makefile.am   |   1 +
>   python/pyosaf/utils/immoi/__init__.py| 531 
> +++
>   python/pyosaf/utils/immoi/agent.py   | 473 +++
>   python/pyosaf/utils/immoi/implementer.py | 145 +
>   python/pyosaf/utils/immom/__init__.py|   7 +-
>   python/pyosaf/utils/immom/accessor.py|  31 +-
>   python/pyosaf/utils/immom/agent.py   |  31 +-
>   python/pyosaf/utils/immom/ccb.py |  71 +
>   python/pyosaf/utils/immom/iterator.py|   4 +-
>   python/pyosaf/utils/immom/object.py  |   4 +-
>   10 files changed, 739 insertions(+), 559 deletions(-)
>   create mode 100644 python/pyosaf/utils/immoi/agent.py
>
> diff --git a/python/Makefile.am b/python/Makefile.am
> index 08338bb..1952d5e 100644
> --- a/python/Makefile.am
> +++ b/python/Makefile.am
> @@ -61,6 +61,7 @@ pkgpyosafutilslog_PYTHON = \
>   
>   pkgpyosafutilsimmoi_PYTHON = \
>   python/pyosaf/utils/immoi/__init__.py \
> + python/pyosaf/utils/immoi/agent.py \
>   python/pyosaf/utils/immoi/implementer.py
>   
>   pkgpyosafutilsntf_PYTHON = \
> diff --git a/python/pyosaf/utils/immoi/__init__.py 
> b/python/pyosaf/utils/immoi/__init__.py
> index 1b4dece..7247b0e 100644
> --- a/python/pyosaf/utils/immoi/__init__.py
> +++ b/python/pyosaf/utils/immoi/__init__.py
> @@ -22,298 +22,23 @@ Supported functions:
>   - Set/clear/release implementer for class/object
>   - Create/delete/update runtime object
>   - Get class/object attributes
> -- Get IMM error strings
> +- Get/set IMM error strings
> +- Get parent for dn
> +- Get class for dn
> +- Get objects for class
> +- Get available classes of IMM
>   """
>   from __future__ import print_function
> -from copy import deepcopy
> -from ctypes import c_char_p, c_void_p, cast, pointer
> -
> -from pyosaf.saAis import SaStringT, SaVersionT, SaNameT, SaSelectionObjectT, 
> \
> -unmarshalSaStringTArray, eSaDispatchFlagsT, eSaAisErrorT
> -from pyosaf import saImm, saImmOi
> -from pyosaf.saImm import unmarshalSaImmValue, SaImmAttrNameT,  \
> -SaImmAttrValuesT_2, SaImmClassNameT, SaImmSearchParametersT_2, \
> -eSaImmValueTypeT, SaImmAttrDefinitionT_2, SaImmClassCategoryT, \
> -SaImmAttrModificationT_2, eSaImmAttrModificationTypeT
> -from pyosaf.saImmOi import SaImmOiHandleT, SaImmOiImplementerNameT
> -from pyosaf.utils import immom, log_err, bad_handle_retry, decorate, \
> -deprecate, initialize_decorate, SafException
> +
> +from pyosaf.saAis import SaSelectionObjectT, eSaAisErrorT
> +from pyosaf.utils import deprecate, SafException
>   from pyosaf.utils.immom.object import ImmObject
> -from pyosaf.utils.immom.ccb import marshal_c_array
> -from pyosaf.utils.immom.iterator import SearchIterator
> +from pyosaf.utils.immoi.agent import OiAgent
>   
>   
> -OPENSAF_IMM_OBJECT = "opensafImm=opensafImm,safApp=safImmService"
>   _oi_agent = None
>   
>   
> -# Decorate pure saImmOi* API's with error-handling retry and exception 
> raising
> -saImmOiInitiali

Re: [devel] [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

2018-01-02 Thread Hieu Nguyen
Hi Hans,  Anders and Srinivas,

 

Happy new year !!!

I wish you will be healthy and happiness in 2018.

 

I already  answered Hans's question, how can I test for this patch.

Please spend a little time help me review for this patch. Ticket-2681 
<https://sourceforge.net/p/opensaf/tickets/2681/>  depends on this patch.

 

Regards,

Hieu

 

-Original Message-
From: Hieu Nguyen [mailto:hieu.t.ngu...@dektech.com.au] 
Sent: Wednesday, December 20, 2017 8:16 AM
To: 'Hans Nordebäck' <hans.nordeb...@ericsson.com>; 
'anders.wid...@ericsson.com' <anders.wid...@ericsson.com>; 
'srinivas.mangip...@oracle.com' <srinivas.mangip...@oracle.com>
Cc: 'opensaf-devel@lists.sourceforge.net' <opensaf-devel@lists.sourceforge.net>
Subject: RE: [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

 

Hi Hans,

 

Thank for your reply.

I have been modified /samples in pyosaf to test. That's in attached file.

 

Regards,

Hieu

 

-Original Message-

From: Hans Nordebäck [ <mailto:hans.nordeb...@ericsson.com> 
mailto:hans.nordeb...@ericsson.com] 

Sent: Tuesday, December 19, 2017 10:19 PM

To: Hieu Nguyen < <mailto:hieu.t.ngu...@dektech.com.au> 
hieu.t.ngu...@dektech.com.au>;  <mailto:anders.wid...@ericsson.com> 
anders.wid...@ericsson.com;  <mailto:srinivas.mangip...@oracle.com> 
srinivas.mangip...@oracle.com

Cc:  <mailto:opensaf-devel@lists.sourceforge.net> 
opensaf-devel@lists.sourceforge.net

Subject: Re: [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

 

Hi Hieu,

 

before I start reviewing, a question, how has this patch been tested? 

/Regards HansN

 

 

On 12/19/2017 06:17 AM, Hieu Nguyen wrote:

> + improve OI utils use a separate instance OM agent

> + refactor OM utils with Ccb inheritace OmAgent, rename some classes...

> ---

>   python/pyosaf/utils/immoi/__init__.py| 531 
> +++

>   python/pyosaf/utils/immoi/agent.py   | 473 +++

>   python/pyosaf/utils/immoi/implementer.py | 145 +

>   python/pyosaf/utils/immom/__init__.py|   7 +-

>   python/pyosaf/utils/immom/accessor.py|  31 +-

>   python/pyosaf/utils/immom/agent.py   |  31 +-

>   python/pyosaf/utils/immom/ccb.py |  71 +

>   python/pyosaf/utils/immom/iterator.py|   4 +-

>   python/pyosaf/utils/immom/object.py  |   4 +-

>   9 files changed, 738 insertions(+), 559 deletions(-)

>   create mode 100644 python/pyosaf/utils/immoi/agent.py

> 

> diff --git a/python/pyosaf/utils/immoi/__init__.py 
> b/python/pyosaf/utils/immoi/__init__.py

> index 1b4dece..7247b0e 100644

> --- a/python/pyosaf/utils/immoi/__init__.py

> +++ b/python/pyosaf/utils/immoi/__init__.py

> @@ -22,298 +22,23 @@ Supported functions:

>   - Set/clear/release implementer for class/object

>   - Create/delete/update runtime object

>   - Get class/object attributes

> -- Get IMM error strings

> +- Get/set IMM error strings

> +- Get parent for dn

> +- Get class for dn

> +- Get objects for class

> +- Get available classes of IMM

>   """

>   from __future__ import print_function

> -from copy import deepcopy

> -from ctypes import c_char_p, c_void_p, cast, pointer

> -

> -from pyosaf.saAis import SaStringT, SaVersionT, SaNameT, SaSelectionObjectT, 
> \

> -unmarshalSaStringTArray, eSaDispatchFlagsT, eSaAisErrorT

> -from pyosaf import saImm, saImmOi

> -from pyosaf.saImm import unmarshalSaImmValue, SaImmAttrNameT,  \

> -SaImmAttrValuesT_2, SaImmClassNameT, SaImmSearchParametersT_2, \

> -eSaImmValueTypeT, SaImmAttrDefinitionT_2, SaImmClassCategoryT, \

> -SaImmAttrModificationT_2, eSaImmAttrModificationTypeT

> -from pyosaf.saImmOi import SaImmOiHandleT, SaImmOiImplementerNameT

> -from pyosaf.utils import immom, log_err, bad_handle_retry, decorate, \

> -deprecate, initialize_decorate, SafException

> +

> +from pyosaf.saAis import SaSelectionObjectT, eSaAisErrorT

> +from pyosaf.utils import deprecate, SafException

>   from pyosaf.utils.immom.object import ImmObject

> -from pyosaf.utils.immom.ccb import marshal_c_array

> -from pyosaf.utils.immom.iterator import SearchIterator

> +from pyosaf.utils.immoi.agent import OiAgent

>   

>   

> -OPENSAF_IMM_OBJECT = "opensafImm=opensafImm,safApp=safImmService"

>   _oi_agent = None

>   

>   

> -# Decorate pure saImmOi* API's with error-handling retry and exception 
> raising

> -saImmOiInitialize_2 = initialize_decorate(saImmOi.saImmOiInitialize_2)

> -saImmOiSelectionObjectGet = decorate(saImmOi.saImmOiSelectionObjectGet)

> -saImmOiDispatch = decorate(saImmOi.saImmOiDispatch)

> -saImmOiFinalize = decorate(saImmOi.saImmOiFinalize)

> -saImmOiImplementerSet = decorate(saImmOi.saImmOiImplementerS

[devel] [PATCH 0/1] Review Request for pyosaf: refactor IMM utils V3[#2683]

2017-12-20 Thread Hieu Nguyen
Summary: pyosaf: refactor IMM utils [#2683]
Review request for Ticket(s): 2683
Peer Reviewer(s): Hans, Anders, Sir 
Pull request to: Hans or Anders
Affected branch(es): develop
Development branch: ticket-2683
Base revision: 5a520b91f37ef51ddf6fbdd97928a002e2967e0c
Personal repository: git://git.code.sf.net/u/dhiengu/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 621e3e27beddbaac2c466bec846c768e22b260a3
Author: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>
Date:   Wed, 20 Dec 2017 15:13:27 +0700

pyosaf: refactor IMM utils [#2683]

+ improve OI utils use a separate instance OM agent
+ refactor OM utils with Ccb inheritace OmAgent, rename some classes...



Added Files:

 python/pyosaf/utils/immoi/agent.py


Complete diffstat:
--
 python/Makefile.am   |   1 +
 python/pyosaf/utils/immoi/__init__.py| 531 +++
 python/pyosaf/utils/immoi/agent.py   | 473 +++
 python/pyosaf/utils/immoi/implementer.py | 145 +
 python/pyosaf/utils/immom/__init__.py|   7 +-
 python/pyosaf/utils/immom/accessor.py|  31 +-
 python/pyosaf/utils/immom/agent.py   |  31 +-
 python/pyosaf/utils/immom/ccb.py |  71 +
 python/pyosaf/utils/immom/iterator.py|   4 +-
 python/pyosaf/utils/immom/object.py  |   4 +-
 10 files changed, 739 insertions(+), 559 deletions(-)


Testing Commands:
-


Testing, Expected Results:
--
Use /samples to test for IMM utils


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 li

[devel] [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

2017-12-20 Thread Hieu Nguyen
+ improve OI utils use a separate instance OM agent
+ refactor OM utils with Ccb inheritace OmAgent, rename some classes...
---
 python/Makefile.am   |   1 +
 python/pyosaf/utils/immoi/__init__.py| 531 +++
 python/pyosaf/utils/immoi/agent.py   | 473 +++
 python/pyosaf/utils/immoi/implementer.py | 145 +
 python/pyosaf/utils/immom/__init__.py|   7 +-
 python/pyosaf/utils/immom/accessor.py|  31 +-
 python/pyosaf/utils/immom/agent.py   |  31 +-
 python/pyosaf/utils/immom/ccb.py |  71 +
 python/pyosaf/utils/immom/iterator.py|   4 +-
 python/pyosaf/utils/immom/object.py  |   4 +-
 10 files changed, 739 insertions(+), 559 deletions(-)
 create mode 100644 python/pyosaf/utils/immoi/agent.py

diff --git a/python/Makefile.am b/python/Makefile.am
index 08338bb..1952d5e 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -61,6 +61,7 @@ pkgpyosafutilslog_PYTHON = \
 
 pkgpyosafutilsimmoi_PYTHON = \
python/pyosaf/utils/immoi/__init__.py \
+   python/pyosaf/utils/immoi/agent.py \
python/pyosaf/utils/immoi/implementer.py
 
 pkgpyosafutilsntf_PYTHON = \
diff --git a/python/pyosaf/utils/immoi/__init__.py 
b/python/pyosaf/utils/immoi/__init__.py
index 1b4dece..7247b0e 100644
--- a/python/pyosaf/utils/immoi/__init__.py
+++ b/python/pyosaf/utils/immoi/__init__.py
@@ -22,298 +22,23 @@ Supported functions:
 - Set/clear/release implementer for class/object
 - Create/delete/update runtime object
 - Get class/object attributes
-- Get IMM error strings
+- Get/set IMM error strings
+- Get parent for dn
+- Get class for dn
+- Get objects for class
+- Get available classes of IMM
 """
 from __future__ import print_function
-from copy import deepcopy
-from ctypes import c_char_p, c_void_p, cast, pointer
-
-from pyosaf.saAis import SaStringT, SaVersionT, SaNameT, SaSelectionObjectT, \
-unmarshalSaStringTArray, eSaDispatchFlagsT, eSaAisErrorT
-from pyosaf import saImm, saImmOi
-from pyosaf.saImm import unmarshalSaImmValue, SaImmAttrNameT,  \
-SaImmAttrValuesT_2, SaImmClassNameT, SaImmSearchParametersT_2, \
-eSaImmValueTypeT, SaImmAttrDefinitionT_2, SaImmClassCategoryT, \
-SaImmAttrModificationT_2, eSaImmAttrModificationTypeT
-from pyosaf.saImmOi import SaImmOiHandleT, SaImmOiImplementerNameT
-from pyosaf.utils import immom, log_err, bad_handle_retry, decorate, \
-deprecate, initialize_decorate, SafException
+
+from pyosaf.saAis import SaSelectionObjectT, eSaAisErrorT
+from pyosaf.utils import deprecate, SafException
 from pyosaf.utils.immom.object import ImmObject
-from pyosaf.utils.immom.ccb import marshal_c_array
-from pyosaf.utils.immom.iterator import SearchIterator
+from pyosaf.utils.immoi.agent import OiAgent
 
 
-OPENSAF_IMM_OBJECT = "opensafImm=opensafImm,safApp=safImmService"
 _oi_agent = None
 
 
-# Decorate pure saImmOi* API's with error-handling retry and exception raising
-saImmOiInitialize_2 = initialize_decorate(saImmOi.saImmOiInitialize_2)
-saImmOiSelectionObjectGet = decorate(saImmOi.saImmOiSelectionObjectGet)
-saImmOiDispatch = decorate(saImmOi.saImmOiDispatch)
-saImmOiFinalize = decorate(saImmOi.saImmOiFinalize)
-saImmOiImplementerSet = decorate(saImmOi.saImmOiImplementerSet)
-saImmOiImplementerClear = decorate(saImmOi.saImmOiImplementerClear)
-saImmOiClassImplementerSet = decorate(saImmOi.saImmOiClassImplementerSet)
-saImmOiClassImplementerRelease = \
-decorate(saImmOi.saImmOiClassImplementerRelease)
-saImmOiObjectImplementerSet = decorate(saImmOi.saImmOiObjectImplementerSet)
-saImmOiObjectImplementerRelease = \
-decorate(saImmOi.saImmOiObjectImplementerRelease)
-saImmOiRtObjectCreate_2 = decorate(saImmOi.saImmOiRtObjectCreate_2)
-saImmOiRtObjectDelete = decorate(saImmOi.saImmOiRtObjectDelete)
-saImmOiRtObjectUpdate_2 = decorate(saImmOi.saImmOiRtObjectUpdate_2)
-saImmOiAdminOperationResult = decorate(saImmOi.saImmOiAdminOperationResult)
-saImmOiAdminOperationResult_o2 = \
-decorate(saImmOi.saImmOiAdminOperationResult_o2)
-saImmOiAugmentCcbInitialize = decorate(saImmOi.saImmOiAugmentCcbInitialize)
-saImmOiCcbSetErrorString = decorate(saImmOi.saImmOiCcbSetErrorString)
-
-
-class OiAgent(object):
-""" This class acts as a high-level OI agent, providing OI functions to
-the users as a higher level, and relieving the users of the need to manage
-the life cycle of the OI agent and providing general interface for
-Implementer or Applier used
-"""
-def __init__(self, version=None):
-""" Constructor for OiAgent class
-
-Args:
-version (SaVersionT): OI API version
-"""
-self.handle = None
-self.init_version = version if version is not None \
-else SaVersionT('A', 2, 15)
-self.version = None
-self.selection_object = None
-self.callbacks = None
-global _oi_agent
-_oi_agent = self
-
-def _fetch_sel_obj(self):
-""" 

[devel] [PATCH 0/1] Review Request for pyosaf: refactor IMM utils V2[#2683]

2017-12-18 Thread Hieu Nguyen
Summary: pyosaf: refactor IMM utils [#2683]
Review request for Ticket(s): 2683
Peer Reviewer(s): Hans, Anders, Sir
Pull request to: Hans or Anders
Affected branch(es): develop
Development branch: ticket-2683
Base revision: 52724f300293bc26ea33ac63367e826a9e3b054a
Personal repository: git://git.code.sf.net/u/dhiengu/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 4177a66b8fca7826d964a2bea3c812cf26f35ad4
Author: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>
Date:   Tue, 19 Dec 2017 11:58:56 +0700

pyosaf: refactor IMM utils [#2683]

+ improve OI utils use a separate instance OM agent
+ refactor OM utils with Ccb inheritace OmAgent, rename some classes...



Added Files:

 python/pyosaf/utils/immoi/agent.py


Complete diffstat:
--
 python/pyosaf/utils/immoi/__init__.py| 531 +++
 python/pyosaf/utils/immoi/agent.py   | 473 +++
 python/pyosaf/utils/immoi/implementer.py | 145 +
 python/pyosaf/utils/immom/__init__.py|   7 +-
 python/pyosaf/utils/immom/accessor.py|  31 +-
 python/pyosaf/utils/immom/agent.py   |  31 +-
 python/pyosaf/utils/immom/ccb.py |  71 +
 python/pyosaf/utils/immom/iterator.py|   4 +-
 python/pyosaf/utils/immom/object.py  |   4 +-
 9 files changed, 738 insertions(+), 559 deletions(-)


Testing Commands:
-


Testing, Expected Results:
--
Use /samples to test for IMM utils


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.ne

[devel] [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

2017-12-18 Thread Hieu Nguyen
+ improve OI utils use a separate instance OM agent
+ refactor OM utils with Ccb inheritace OmAgent, rename some classes...
---
 python/pyosaf/utils/immoi/__init__.py| 531 +++
 python/pyosaf/utils/immoi/agent.py   | 473 +++
 python/pyosaf/utils/immoi/implementer.py | 145 +
 python/pyosaf/utils/immom/__init__.py|   7 +-
 python/pyosaf/utils/immom/accessor.py|  31 +-
 python/pyosaf/utils/immom/agent.py   |  31 +-
 python/pyosaf/utils/immom/ccb.py |  71 +
 python/pyosaf/utils/immom/iterator.py|   4 +-
 python/pyosaf/utils/immom/object.py  |   4 +-
 9 files changed, 738 insertions(+), 559 deletions(-)
 create mode 100644 python/pyosaf/utils/immoi/agent.py

diff --git a/python/pyosaf/utils/immoi/__init__.py 
b/python/pyosaf/utils/immoi/__init__.py
index 1b4dece..7247b0e 100644
--- a/python/pyosaf/utils/immoi/__init__.py
+++ b/python/pyosaf/utils/immoi/__init__.py
@@ -22,298 +22,23 @@ Supported functions:
 - Set/clear/release implementer for class/object
 - Create/delete/update runtime object
 - Get class/object attributes
-- Get IMM error strings
+- Get/set IMM error strings
+- Get parent for dn
+- Get class for dn
+- Get objects for class
+- Get available classes of IMM
 """
 from __future__ import print_function
-from copy import deepcopy
-from ctypes import c_char_p, c_void_p, cast, pointer
-
-from pyosaf.saAis import SaStringT, SaVersionT, SaNameT, SaSelectionObjectT, \
-unmarshalSaStringTArray, eSaDispatchFlagsT, eSaAisErrorT
-from pyosaf import saImm, saImmOi
-from pyosaf.saImm import unmarshalSaImmValue, SaImmAttrNameT,  \
-SaImmAttrValuesT_2, SaImmClassNameT, SaImmSearchParametersT_2, \
-eSaImmValueTypeT, SaImmAttrDefinitionT_2, SaImmClassCategoryT, \
-SaImmAttrModificationT_2, eSaImmAttrModificationTypeT
-from pyosaf.saImmOi import SaImmOiHandleT, SaImmOiImplementerNameT
-from pyosaf.utils import immom, log_err, bad_handle_retry, decorate, \
-deprecate, initialize_decorate, SafException
+
+from pyosaf.saAis import SaSelectionObjectT, eSaAisErrorT
+from pyosaf.utils import deprecate, SafException
 from pyosaf.utils.immom.object import ImmObject
-from pyosaf.utils.immom.ccb import marshal_c_array
-from pyosaf.utils.immom.iterator import SearchIterator
+from pyosaf.utils.immoi.agent import OiAgent
 
 
-OPENSAF_IMM_OBJECT = "opensafImm=opensafImm,safApp=safImmService"
 _oi_agent = None
 
 
-# Decorate pure saImmOi* API's with error-handling retry and exception raising
-saImmOiInitialize_2 = initialize_decorate(saImmOi.saImmOiInitialize_2)
-saImmOiSelectionObjectGet = decorate(saImmOi.saImmOiSelectionObjectGet)
-saImmOiDispatch = decorate(saImmOi.saImmOiDispatch)
-saImmOiFinalize = decorate(saImmOi.saImmOiFinalize)
-saImmOiImplementerSet = decorate(saImmOi.saImmOiImplementerSet)
-saImmOiImplementerClear = decorate(saImmOi.saImmOiImplementerClear)
-saImmOiClassImplementerSet = decorate(saImmOi.saImmOiClassImplementerSet)
-saImmOiClassImplementerRelease = \
-decorate(saImmOi.saImmOiClassImplementerRelease)
-saImmOiObjectImplementerSet = decorate(saImmOi.saImmOiObjectImplementerSet)
-saImmOiObjectImplementerRelease = \
-decorate(saImmOi.saImmOiObjectImplementerRelease)
-saImmOiRtObjectCreate_2 = decorate(saImmOi.saImmOiRtObjectCreate_2)
-saImmOiRtObjectDelete = decorate(saImmOi.saImmOiRtObjectDelete)
-saImmOiRtObjectUpdate_2 = decorate(saImmOi.saImmOiRtObjectUpdate_2)
-saImmOiAdminOperationResult = decorate(saImmOi.saImmOiAdminOperationResult)
-saImmOiAdminOperationResult_o2 = \
-decorate(saImmOi.saImmOiAdminOperationResult_o2)
-saImmOiAugmentCcbInitialize = decorate(saImmOi.saImmOiAugmentCcbInitialize)
-saImmOiCcbSetErrorString = decorate(saImmOi.saImmOiCcbSetErrorString)
-
-
-class OiAgent(object):
-""" This class acts as a high-level OI agent, providing OI functions to
-the users as a higher level, and relieving the users of the need to manage
-the life cycle of the OI agent and providing general interface for
-Implementer or Applier used
-"""
-def __init__(self, version=None):
-""" Constructor for OiAgent class
-
-Args:
-version (SaVersionT): OI API version
-"""
-self.handle = None
-self.init_version = version if version is not None \
-else SaVersionT('A', 2, 15)
-self.version = None
-self.selection_object = None
-self.callbacks = None
-global _oi_agent
-_oi_agent = self
-
-def _fetch_sel_obj(self):
-""" Obtain a selection object (OS file descriptor)
-
-Returns:
-SaAisErrorT: Return code of the saImmOiSelectionObjectGet() API
-"""
-rc = saImmOiSelectionObjectGet(self.handle, self.selection_object)
-if rc != eSaAisErrorT.SA_AIS_OK:
-log_err("saImmOiSelectionObjectGet FAILED - %s" %
-eSaAisErrorT.whatis(rc))
-
-return rc
-
-def initialize(self, 

Re: [devel] [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

2017-12-13 Thread Hieu Nguyen
Hi Hans, Anders & Srinivas,

Just reminding.
Please spend a little time to help me review this patch.

Many thanks,
Hieu


-Original Message-
From: Hieu Nguyen [mailto:hieu.t.ngu...@dektech.com.au] 
Sent: Wednesday, December 6, 2017 2:46 PM
To: hans.nordeb...@ericsson.com; anders.wid...@ericsson.com;
srinivas.mangip...@oracle.com
Cc: opensaf-devel@lists.sourceforge.net; Hieu Nguyen
<hieu.t.ngu...@dektech.com.au>
Subject: [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

+ improve OI utils use a separate instance OM agent
+ refactor OM utils with Ccb inheritace OmAgent, rename some classes...
---
 python/pyosaf/utils/immoi/__init__.py| 531
+++
 python/pyosaf/utils/immoi/agent.py   | 473 +++
 python/pyosaf/utils/immoi/implementer.py | 141 
 python/pyosaf/utils/immom/__init__.py|   7 +-
 python/pyosaf/utils/immom/accessor.py|  31 +-
 python/pyosaf/utils/immom/agent.py   |  31 +-
 python/pyosaf/utils/immom/ccb.py |  71 +
 python/pyosaf/utils/immom/iterator.py|   4 +-
 python/pyosaf/utils/immom/object.py  |   4 +-
 9 files changed, 736 insertions(+), 557 deletions(-)
 create mode 100644 python/pyosaf/utils/immoi/agent.py

diff --git a/python/pyosaf/utils/immoi/__init__.py
b/python/pyosaf/utils/immoi/__init__.py
index 1b4dece..7247b0e 100644
--- a/python/pyosaf/utils/immoi/__init__.py
+++ b/python/pyosaf/utils/immoi/__init__.py
@@ -22,298 +22,23 @@ Supported functions:
 - Set/clear/release implementer for class/object
 - Create/delete/update runtime object
 - Get class/object attributes
-- Get IMM error strings
+- Get/set IMM error strings
+- Get parent for dn
+- Get class for dn
+- Get objects for class
+- Get available classes of IMM
 """
 from __future__ import print_function
-from copy import deepcopy
-from ctypes import c_char_p, c_void_p, cast, pointer
-
-from pyosaf.saAis import SaStringT, SaVersionT, SaNameT,
SaSelectionObjectT, \
-unmarshalSaStringTArray, eSaDispatchFlagsT, eSaAisErrorT
-from pyosaf import saImm, saImmOi
-from pyosaf.saImm import unmarshalSaImmValue, SaImmAttrNameT,  \
-SaImmAttrValuesT_2, SaImmClassNameT, SaImmSearchParametersT_2, \
-eSaImmValueTypeT, SaImmAttrDefinitionT_2, SaImmClassCategoryT, \
-SaImmAttrModificationT_2, eSaImmAttrModificationTypeT
-from pyosaf.saImmOi import SaImmOiHandleT, SaImmOiImplementerNameT
-from pyosaf.utils import immom, log_err, bad_handle_retry, decorate, \
-deprecate, initialize_decorate, SafException
+
+from pyosaf.saAis import SaSelectionObjectT, eSaAisErrorT
+from pyosaf.utils import deprecate, SafException
 from pyosaf.utils.immom.object import ImmObject
-from pyosaf.utils.immom.ccb import marshal_c_array
-from pyosaf.utils.immom.iterator import SearchIterator
+from pyosaf.utils.immoi.agent import OiAgent
 
 
-OPENSAF_IMM_OBJECT = "opensafImm=opensafImm,safApp=safImmService"
 _oi_agent = None
 
 
-# Decorate pure saImmOi* API's with error-handling retry and exception
raising
-saImmOiInitialize_2 = initialize_decorate(saImmOi.saImmOiInitialize_2)
-saImmOiSelectionObjectGet = decorate(saImmOi.saImmOiSelectionObjectGet)
-saImmOiDispatch = decorate(saImmOi.saImmOiDispatch)
-saImmOiFinalize = decorate(saImmOi.saImmOiFinalize)
-saImmOiImplementerSet = decorate(saImmOi.saImmOiImplementerSet)
-saImmOiImplementerClear = decorate(saImmOi.saImmOiImplementerClear)
-saImmOiClassImplementerSet = decorate(saImmOi.saImmOiClassImplementerSet)
-saImmOiClassImplementerRelease = \
-decorate(saImmOi.saImmOiClassImplementerRelease)
-saImmOiObjectImplementerSet = decorate(saImmOi.saImmOiObjectImplementerSet)
-saImmOiObjectImplementerRelease = \
-decorate(saImmOi.saImmOiObjectImplementerRelease)
-saImmOiRtObjectCreate_2 = decorate(saImmOi.saImmOiRtObjectCreate_2)
-saImmOiRtObjectDelete = decorate(saImmOi.saImmOiRtObjectDelete)
-saImmOiRtObjectUpdate_2 = decorate(saImmOi.saImmOiRtObjectUpdate_2)
-saImmOiAdminOperationResult = decorate(saImmOi.saImmOiAdminOperationResult)
-saImmOiAdminOperationResult_o2 = \
-decorate(saImmOi.saImmOiAdminOperationResult_o2)
-saImmOiAugmentCcbInitialize = decorate(saImmOi.saImmOiAugmentCcbInitialize)
-saImmOiCcbSetErrorString = decorate(saImmOi.saImmOiCcbSetErrorString)
-
-
-class OiAgent(object):
-""" This class acts as a high-level OI agent, providing OI functions to
-the users as a higher level, and relieving the users of the need to
manage
-the life cycle of the OI agent and providing general interface for
-Implementer or Applier used
-"""
-def __init__(self, version=None):
-""" Constructor for OiAgent class
-
-Args:
-version (SaVersionT): OI API version
-"""
-self.handle = None
-self.init_version = version if version is not None \
-else SaVersionT('A', 2, 15)
-self.version = None
-self.selection_o

[devel] [PATCH 1/1] pyosaf: refactor IMM utils [#2683]

2017-12-05 Thread Hieu Nguyen
+ improve OI utils use a separate instance OM agent
+ refactor OM utils with Ccb inheritace OmAgent, rename some classes...
---
 python/pyosaf/utils/immoi/__init__.py| 531 +++
 python/pyosaf/utils/immoi/agent.py   | 473 +++
 python/pyosaf/utils/immoi/implementer.py | 141 
 python/pyosaf/utils/immom/__init__.py|   7 +-
 python/pyosaf/utils/immom/accessor.py|  31 +-
 python/pyosaf/utils/immom/agent.py   |  31 +-
 python/pyosaf/utils/immom/ccb.py |  71 +
 python/pyosaf/utils/immom/iterator.py|   4 +-
 python/pyosaf/utils/immom/object.py  |   4 +-
 9 files changed, 736 insertions(+), 557 deletions(-)
 create mode 100644 python/pyosaf/utils/immoi/agent.py

diff --git a/python/pyosaf/utils/immoi/__init__.py 
b/python/pyosaf/utils/immoi/__init__.py
index 1b4dece..7247b0e 100644
--- a/python/pyosaf/utils/immoi/__init__.py
+++ b/python/pyosaf/utils/immoi/__init__.py
@@ -22,298 +22,23 @@ Supported functions:
 - Set/clear/release implementer for class/object
 - Create/delete/update runtime object
 - Get class/object attributes
-- Get IMM error strings
+- Get/set IMM error strings
+- Get parent for dn
+- Get class for dn
+- Get objects for class
+- Get available classes of IMM
 """
 from __future__ import print_function
-from copy import deepcopy
-from ctypes import c_char_p, c_void_p, cast, pointer
-
-from pyosaf.saAis import SaStringT, SaVersionT, SaNameT, SaSelectionObjectT, \
-unmarshalSaStringTArray, eSaDispatchFlagsT, eSaAisErrorT
-from pyosaf import saImm, saImmOi
-from pyosaf.saImm import unmarshalSaImmValue, SaImmAttrNameT,  \
-SaImmAttrValuesT_2, SaImmClassNameT, SaImmSearchParametersT_2, \
-eSaImmValueTypeT, SaImmAttrDefinitionT_2, SaImmClassCategoryT, \
-SaImmAttrModificationT_2, eSaImmAttrModificationTypeT
-from pyosaf.saImmOi import SaImmOiHandleT, SaImmOiImplementerNameT
-from pyosaf.utils import immom, log_err, bad_handle_retry, decorate, \
-deprecate, initialize_decorate, SafException
+
+from pyosaf.saAis import SaSelectionObjectT, eSaAisErrorT
+from pyosaf.utils import deprecate, SafException
 from pyosaf.utils.immom.object import ImmObject
-from pyosaf.utils.immom.ccb import marshal_c_array
-from pyosaf.utils.immom.iterator import SearchIterator
+from pyosaf.utils.immoi.agent import OiAgent
 
 
-OPENSAF_IMM_OBJECT = "opensafImm=opensafImm,safApp=safImmService"
 _oi_agent = None
 
 
-# Decorate pure saImmOi* API's with error-handling retry and exception raising
-saImmOiInitialize_2 = initialize_decorate(saImmOi.saImmOiInitialize_2)
-saImmOiSelectionObjectGet = decorate(saImmOi.saImmOiSelectionObjectGet)
-saImmOiDispatch = decorate(saImmOi.saImmOiDispatch)
-saImmOiFinalize = decorate(saImmOi.saImmOiFinalize)
-saImmOiImplementerSet = decorate(saImmOi.saImmOiImplementerSet)
-saImmOiImplementerClear = decorate(saImmOi.saImmOiImplementerClear)
-saImmOiClassImplementerSet = decorate(saImmOi.saImmOiClassImplementerSet)
-saImmOiClassImplementerRelease = \
-decorate(saImmOi.saImmOiClassImplementerRelease)
-saImmOiObjectImplementerSet = decorate(saImmOi.saImmOiObjectImplementerSet)
-saImmOiObjectImplementerRelease = \
-decorate(saImmOi.saImmOiObjectImplementerRelease)
-saImmOiRtObjectCreate_2 = decorate(saImmOi.saImmOiRtObjectCreate_2)
-saImmOiRtObjectDelete = decorate(saImmOi.saImmOiRtObjectDelete)
-saImmOiRtObjectUpdate_2 = decorate(saImmOi.saImmOiRtObjectUpdate_2)
-saImmOiAdminOperationResult = decorate(saImmOi.saImmOiAdminOperationResult)
-saImmOiAdminOperationResult_o2 = \
-decorate(saImmOi.saImmOiAdminOperationResult_o2)
-saImmOiAugmentCcbInitialize = decorate(saImmOi.saImmOiAugmentCcbInitialize)
-saImmOiCcbSetErrorString = decorate(saImmOi.saImmOiCcbSetErrorString)
-
-
-class OiAgent(object):
-""" This class acts as a high-level OI agent, providing OI functions to
-the users as a higher level, and relieving the users of the need to manage
-the life cycle of the OI agent and providing general interface for
-Implementer or Applier used
-"""
-def __init__(self, version=None):
-""" Constructor for OiAgent class
-
-Args:
-version (SaVersionT): OI API version
-"""
-self.handle = None
-self.init_version = version if version is not None \
-else SaVersionT('A', 2, 15)
-self.version = None
-self.selection_object = None
-self.callbacks = None
-global _oi_agent
-_oi_agent = self
-
-def _fetch_sel_obj(self):
-""" Obtain a selection object (OS file descriptor)
-
-Returns:
-SaAisErrorT: Return code of the saImmOiSelectionObjectGet() API
-"""
-rc = saImmOiSelectionObjectGet(self.handle, self.selection_object)
-if rc != eSaAisErrorT.SA_AIS_OK:
-log_err("saImmOiSelectionObjectGet FAILED - %s" %
-eSaAisErrorT.whatis(rc))
-
-return rc
-
-def initialize(self, 

[devel] [PATCH 0/1] Review Request for pyosaf: refactor IMM utils [#2683]

2017-12-05 Thread Hieu Nguyen
Summary: pyosaf: refactor IMM utils [#2683]
Review request for Ticket(s): 2683
Peer Reviewer(s): Hans, Anders, Sir
Pull request to: Hans or Anders
Affected branch(es): develop
Development branch: ticket-2683
Base revision: 9ab54933456632260be87c2c763bd36b1ab7e5d2
Personal repository: git://git.code.sf.net/u/dhiengu/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 fc12344a5085f03b0efe7a9f09ef940def56b18f
Author: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>
Date:   Wed, 6 Dec 2017 09:28:50 +0700

pyosaf: refactor IMM utils [#2683]

+ improve OI utils use a separate instance OM agent
+ refactor OM utils with Ccb inheritace OmAgent, rename some classes...



Added Files:

 python/pyosaf/utils/immoi/agent.py


Complete diffstat:
--
 python/pyosaf/utils/immoi/__init__.py| 531 +++
 python/pyosaf/utils/immoi/agent.py   | 473 +++
 python/pyosaf/utils/immoi/implementer.py | 141 
 python/pyosaf/utils/immom/__init__.py|   7 +-
 python/pyosaf/utils/immom/accessor.py|  31 +-
 python/pyosaf/utils/immom/agent.py   |  31 +-
 python/pyosaf/utils/immom/ccb.py |  71 +
 python/pyosaf/utils/immom/iterator.py|   4 +-
 python/pyosaf/utils/immom/object.py  |   4 +-
 9 files changed, 736 insertions(+), 557 deletions(-)


Testing Commands:
-


Testing, Expected Results:
--
Use /samples to test for IMM utils


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.ne

[devel] [PATCH 0/1] Review Request for pyosaf: High level python interfaces for IMM V2[#2602]

2017-10-27 Thread Hieu Nguyen
Summary: pyosaf: High level python interfaces for IMM V2[#2602]
Review request for Ticket(s): 2602
Peer Reviewer(s): Hans, Anders, Quyen, Srinivas
Pull request to: Zoran/Hans
Affected branch(es): develop
Development branch: ticket-2602
Base revision: 2a7a20bafa7f189fca79bd73e6d678c58fda64dd
Personal repository: git://git.code.sf.net/u/dhiengu/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 6ab6b243db7a503d837ee8c06707a3e3dbc9163d
Author: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>
Date:   Fri, 27 Oct 2017 21:30:28 +0700

pyosaf: High level python interfaces for IMM [#2602]



Added Files:

 python/pyosaf/utils/immom/accessor.py
 python/pyosaf/utils/immom/agent.py


Complete diffstat:
--
 python/Makefile.am   |4 +-
 python/pyosaf/utils/immoi/__init__.py|  456 ++
 python/pyosaf/utils/immoi/implementer.py | 1009 --
 python/pyosaf/utils/immom/__init__.py|  241 ---
 python/pyosaf/utils/immom/accessor.py|  135 
 python/pyosaf/utils/immom/agent.py   |  421 +
 python/pyosaf/utils/immom/ccb.py |  455 --
 python/pyosaf/utils/immom/iterator.py|  109 ++--
 python/pyosaf/utils/immom/object.py  |   34 +-
 9 files changed, 1882 insertions(+), 982 deletions(-)


Testing Commands:
-
Write a new IMM demo or modify samples:imm-listener, ping-pong, tones... to 
test.


Testing, Expected Results:
--
Be able use implemeter or applier to create/modify/delete object.


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
___

[devel] [PATCH 1/1] pyosaf: High level python interfaces for IMM [#2602]

2017-10-27 Thread Hieu Nguyen
---
 python/Makefile.am   |4 +-
 python/pyosaf/utils/immoi/__init__.py|  456 ++
 python/pyosaf/utils/immoi/implementer.py | 1009 --
 python/pyosaf/utils/immom/__init__.py|  241 ---
 python/pyosaf/utils/immom/accessor.py|  135 
 python/pyosaf/utils/immom/agent.py   |  421 +
 python/pyosaf/utils/immom/ccb.py |  455 --
 python/pyosaf/utils/immom/iterator.py|  109 ++--
 python/pyosaf/utils/immom/object.py  |   34 +-
 9 files changed, 1882 insertions(+), 982 deletions(-)
 create mode 100644 python/pyosaf/utils/immom/accessor.py
 create mode 100644 python/pyosaf/utils/immom/agent.py

diff --git a/python/Makefile.am b/python/Makefile.am
index 390366a..bc0f32a 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -48,7 +48,9 @@ pkgpyosafutilsimmom_PYTHON = \
python/pyosaf/utils/immom/__init__.py \
python/pyosaf/utils/immom/ccb.py \
python/pyosaf/utils/immom/iterator.py \
-   python/pyosaf/utils/immom/object.py
+   python/pyosaf/utils/immom/object.py \
+   python/pyosaf/utils/immom/agent.py \
+   python/pyosaf/utils/immom/accessor.py
 
 pkgpyosafutilsclm_PYTHON = \
python/pyosaf/utils/clm/__init__.py
diff --git a/python/pyosaf/utils/immoi/__init__.py 
b/python/pyosaf/utils/immoi/__init__.py
index 55cb1ff..1b4dece 100644
--- a/python/pyosaf/utils/immoi/__init__.py
+++ b/python/pyosaf/utils/immoi/__init__.py
@@ -25,28 +25,27 @@ Supported functions:
 - Get IMM error strings
 """
 from __future__ import print_function
-
+from copy import deepcopy
 from ctypes import c_char_p, c_void_p, cast, pointer
 
 from pyosaf.saAis import SaStringT, SaVersionT, SaNameT, SaSelectionObjectT, \
-unmarshalSaStringTArray, eSaDispatchFlagsT
+unmarshalSaStringTArray, eSaDispatchFlagsT, eSaAisErrorT
 from pyosaf import saImm, saImmOi
 from pyosaf.saImm import unmarshalSaImmValue, SaImmAttrNameT,  \
 SaImmAttrValuesT_2, SaImmClassNameT, SaImmSearchParametersT_2, \
 eSaImmValueTypeT, SaImmAttrDefinitionT_2, SaImmClassCategoryT, \
 SaImmAttrModificationT_2, eSaImmAttrModificationTypeT
 from pyosaf.saImmOi import SaImmOiHandleT, SaImmOiImplementerNameT
-from pyosaf.utils import immom
+from pyosaf.utils import immom, log_err, bad_handle_retry, decorate, \
+deprecate, initialize_decorate, SafException
 from pyosaf.utils.immom.object import ImmObject
 from pyosaf.utils.immom.ccb import marshal_c_array
 from pyosaf.utils.immom.iterator import SearchIterator
-from pyosaf.utils import decorate, initialize_decorate
 
 
-selection_object = SaSelectionObjectT()
-handle = SaImmOiHandleT()
-TRY_AGAIN_CNT = 60
 OPENSAF_IMM_OBJECT = "opensafImm=opensafImm,safApp=safImmService"
+_oi_agent = None
+
 
 # Decorate pure saImmOi* API's with error-handling retry and exception raising
 saImmOiInitialize_2 = initialize_decorate(saImmOi.saImmOiInitialize_2)
@@ -71,61 +70,290 @@ saImmOiAugmentCcbInitialize = 
decorate(saImmOi.saImmOiAugmentCcbInitialize)
 saImmOiCcbSetErrorString = decorate(saImmOi.saImmOiCcbSetErrorString)
 
 
-def initialize(callbacks=None):
-""" Initialize the IMM OI library
-
-Args:
-callbacks (SaImmOiCallbacksT_2): OI callbacks to register with IMM
+class OiAgent(object):
+""" This class acts as a high-level OI agent, providing OI functions to
+the users as a higher level, and relieving the users of the need to manage
+the life cycle of the OI agent and providing general interface for
+Implementer or Applier used
 """
-version = SaVersionT('A', 2, 15)
-saImmOiInitialize_2(handle, callbacks, version)
+def __init__(self, version=None):
+""" Constructor for OiAgent class
+
+Args:
+version (SaVersionT): OI API version
+"""
+self.handle = None
+self.init_version = version if version is not None \
+else SaVersionT('A', 2, 15)
+self.version = None
+self.selection_object = None
+self.callbacks = None
+global _oi_agent
+_oi_agent = self
+
+def _fetch_sel_obj(self):
+""" Obtain a selection object (OS file descriptor)
+
+Returns:
+SaAisErrorT: Return code of the saImmOiSelectionObjectGet() API
+"""
+rc = saImmOiSelectionObjectGet(self.handle, self.selection_object)
+if rc != eSaAisErrorT.SA_AIS_OK:
+log_err("saImmOiSelectionObjectGet FAILED - %s" %
+eSaAisErrorT.whatis(rc))
+
+return rc
+
+def initialize(self, callbacks=None):
+""" Initialize the IMM OI agent
+
+Args:
+callbacks (SaImmOiCallbacksT_2): OI callbacks to register with IMM
+
+Returns:
+SaAisErrorT: Return code of OI initialize
+"""
+self.handle = SaImmOiHandleT()
+self.selection_object = SaSelectionObjectT()
+if callbacks is not None:
+

[devel] [PATCH 1/1] pyosaf: High level python interfaces for IMM [#2602]

2017-10-26 Thread Hieu Nguyen
---
 python/pyosaf/utils/immoi/__init__.py|  275 +---
 python/pyosaf/utils/immoi/implementer.py | 1006 --
 python/pyosaf/utils/immom/__init__.py|  242 ---
 python/pyosaf/utils/immom/accessor.py|  112 
 python/pyosaf/utils/immom/agent.py   |  404 
 python/pyosaf/utils/immom/ccb.py |  455 --
 python/pyosaf/utils/immom/iterator.py|   95 +--
 python/pyosaf/utils/immom/object.py  |   34 +-
 8 files changed, 1697 insertions(+), 926 deletions(-)
 create mode 100644 python/pyosaf/utils/immom/accessor.py
 create mode 100644 python/pyosaf/utils/immom/agent.py

diff --git a/python/pyosaf/utils/immoi/__init__.py 
b/python/pyosaf/utils/immoi/__init__.py
index 55cb1ff..d1ff870 100644
--- a/python/pyosaf/utils/immoi/__init__.py
+++ b/python/pyosaf/utils/immoi/__init__.py
@@ -29,24 +29,24 @@ from __future__ import print_function
 from ctypes import c_char_p, c_void_p, cast, pointer
 
 from pyosaf.saAis import SaStringT, SaVersionT, SaNameT, SaSelectionObjectT, \
-unmarshalSaStringTArray, eSaDispatchFlagsT
+unmarshalSaStringTArray, eSaDispatchFlagsT, eSaAisErrorT
 from pyosaf import saImm, saImmOi
 from pyosaf.saImm import unmarshalSaImmValue, SaImmAttrNameT,  \
 SaImmAttrValuesT_2, SaImmClassNameT, SaImmSearchParametersT_2, \
 eSaImmValueTypeT, SaImmAttrDefinitionT_2, SaImmClassCategoryT, \
 SaImmAttrModificationT_2, eSaImmAttrModificationTypeT
 from pyosaf.saImmOi import SaImmOiHandleT, SaImmOiImplementerNameT
-from pyosaf.utils import immom
+from pyosaf.utils import immom, log_err, bad_handle_retry
 from pyosaf.utils.immom.object import ImmObject
 from pyosaf.utils.immom.ccb import marshal_c_array
 from pyosaf.utils.immom.iterator import SearchIterator
-from pyosaf.utils import decorate, initialize_decorate
+from pyosaf.utils import decorate, deprecate, initialize_decorate, SafException
 
 
-selection_object = SaSelectionObjectT()
-handle = SaImmOiHandleT()
 TRY_AGAIN_CNT = 60
 OPENSAF_IMM_OBJECT = "opensafImm=opensafImm,safApp=safImmService"
+_oi_agent = None
+
 
 # Decorate pure saImmOi* API's with error-handling retry and exception raising
 saImmOiInitialize_2 = initialize_decorate(saImmOi.saImmOiInitialize_2)
@@ -71,68 +71,169 @@ saImmOiAugmentCcbInitialize = 
decorate(saImmOi.saImmOiAugmentCcbInitialize)
 saImmOiCcbSetErrorString = decorate(saImmOi.saImmOiCcbSetErrorString)
 
 
+class OiAgent(object):
+""" This class acts as a high-level OI agent, providing OI functions to
+the users as a higher level, and relieving the users of the need to manage
+the life cycle of the OI agent and providing general interface for
+Implementer or Applier used
+"""
+def __init__(self, callbacks=None, version=None):
+""" Constructor for OiAgent class
+
+Args:
+version (SaVersionT): OI API version
+"""
+self.handle = None
+self.version = version if version else SaVersionT('A', 2, 15)
+self.selection_object = None
+self.callbacks = callbacks
+global _oi_agent
+_oi_agent = self
+
+def _fetch_sel_obj(self):
+""" Obtain a selection object (OS file descriptor)
+
+Returns:
+SaAisErrorT: Return code of the saImmOiSelectionObjectGet() API
+"""
+rc = saImmOiSelectionObjectGet(self.handle, self.selection_object)
+if rc != eSaAisErrorT.SA_AIS_OK:
+log_err("saImmOiSelectionObjectGet FAILED - %s" %
+eSaAisErrorT.whatis(rc))
+
+return rc
+
+def initialize(self, callbacks):
+""" Initialize the IMM OI agent
+
+Args:
+callbacks (SaImmOiCallbacksT_2): OI callbacks to register with IMM
+
+Returns:
+SaAisErrorT: Return code of OI initialize
+"""
+self.handle = SaImmOiHandleT()
+self.selection_object = SaSelectionObjectT()
+if callbacks is not None:
+self.callbacks = callbacks
+rc = saImmOi.saImmOiInitialize_2(self.handle, self.callbacks,
+ self.version)
+if rc == eSaAisErrorT.SA_AIS_OK:
+rc = self._fetch_sel_obj()
+if rc == eSaAisErrorT.SA_AIS_ERR_BAD_HANDLE:
+rc = self.re_initialize(self.callbacks)
+
+return rc
+
+@bad_handle_retry
+def re_initialize(self, callbacks):
+""" Re-initialize the IMM OI agent
+
+Args:
+callbacks (SaImmOiCallbacksT_2): OI callbacks to register with IMM
+
+Returns:
+SaAisErrorT: Return code of OI initialize
+"""
+self.finalize()
+rc = self.initialize(callbacks=callbacks)
+if rc != eSaAisErrorT.SA_AIS_OK:
+log_err("saImmOiInitialize_2 FAILED - %s" %
+eSaAisErrorT.whatis(rc))
+else:
+rc = self._fetch_sel_obj()
+return rc
+
+def finalize(self):
+""" Finalize 

[devel] [PATCH 0/1] Review Request for pyosaf: High level python interfaces for IMM [#2602]

2017-10-26 Thread Hieu Nguyen
Summary: pyosaf: High level python interfaces for IMM [#2602]
Review request for Ticket(s): 2602
Peer Reviewer(s): Hans, Anders, Quyen, Srinivas
Pull request to: hans.nordeb...@ericsson.com, anders.wid...@ericsson.com, 
quyen@dektech.com.au, srinivas.mangip...@oracle.com
Affected branch(es): develop
Development branch: ticket-2602
Base revision: ba5302f6e65108d9023b16b3bd8e4986fe178ea8
Personal repository: git://git.code.sf.net/u/dhiengu/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 409b0a3c7e6fce85a28a80ebdb0de643e4323aa9
Author: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>
Date:   Thu, 26 Oct 2017 14:57:01 +0700

pyosaf: High level python interfaces for IMM [#2602]



Added Files:

 python/pyosaf/utils/immom/accessor.py
 python/pyosaf/utils/immom/agent.py


Complete diffstat:
--
 python/pyosaf/utils/immoi/__init__.py|  275 +---
 python/pyosaf/utils/immoi/implementer.py | 1006 --
 python/pyosaf/utils/immom/__init__.py|  242 ---
 python/pyosaf/utils/immom/accessor.py|  112 
 python/pyosaf/utils/immom/agent.py   |  404 
 python/pyosaf/utils/immom/ccb.py |  455 --
 python/pyosaf/utils/immom/iterator.py|   95 +--
 python/pyosaf/utils/immom/object.py  |   34 +-
 8 files changed, 1697 insertions(+), 926 deletions(-)


Testing Commands:
-
Write a new IMM demo or modify samples:imm-listener, ping-pong, tones... to 
test.


Testing, Expected Results:
--
be able use implemeter or applier to create/modify/delete object.


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

[devel] [PATCH 1/1] pyosaf: retry SAF initialize() function with original version [#2524]

2017-10-16 Thread Hieu Nguyen
---
 python/pyosaf/utils/__init__.py   | 44 +++
 python/pyosaf/utils/clm/__init__.py   | 11 +
 python/pyosaf/utils/immoi/__init__.py |  7 +++---
 python/pyosaf/utils/immom/__init__.py |  7 +++---
 python/pyosaf/utils/log/__init__.py   |  4 ++--
 python/pyosaf/utils/ntf/__init__.py   | 16 ++---
 6 files changed, 66 insertions(+), 23 deletions(-)

diff --git a/python/pyosaf/utils/__init__.py b/python/pyosaf/utils/__init__.py
index 0d4b648..3776cef 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,46 @@ def decorate(function):
 return error
 
 return inner
+
+
+def initialize_decorate(function):
+''' Decorate the given SAF initialize(handle, callbacks, version) so that
+it retries a fixed number of times if needed with the same arguments 
and
+raises an exception if it encounters any fault other than
+SA_AIS_ERR_TRY_AGAIN.
+'''
+
+def inner(*args):
+''' Calls "function" in the lexical scope in a retry loop and raises
+an exception if it encounters any other faults.
+
+Args:
+args(tuple): Argument of initialize() with format:
+ tuple(handle, callbacks, version)
+'''
+# Backup current version
+backup_version = deepcopy(args[2])
+
+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, so set original version on
+# next initialization.
+version = deepcopy(backup_version)
+args = args[:2] + (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..b9b853a 100644
--- a/python/pyosaf/utils/clm/__init__.py
+++ b/python/pyosaf/utils/clm/__init__.py
@@ -20,12 +20,13 @@
 
 from pyosaf import saClm, saAis
 
-from pyosaf.utils import decorate
+from pyosaf.utils import decorate, initialize_decorate
+
 
 # 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)
+saClmInitialize_3 = initialize_decorate(saClm.saClmInitialize_3)
+saClmInitialize_4 = initialize_decorate(saClm.saClmInitialize_4)
 saClmSelectionObjectGet= decorate(saClm.saClmSelectionObjectGet)
 saClmDispatch  = decorate(saClm.saClmDispatch)
 saClmFinalize  = decorate(saClm.saClmFinalize)
@@ -131,7 +132,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..2ea0f33 100644
--- a/python/pyosaf/utils/immoi/__init__.py
+++ b/python/pyosaf/utils/immoi/__init__.py
@@ -38,7 +38,7 @@ from pyosaf.utils.immom.object import ImmObject
 from pyosaf.utils.immom.ccb import marshal_c_array
 from pyosaf.utils.immom.iterator import SearchIterator
 
-from pyosaf.utils import decorate
+from pyosaf.utils import decorate, initialize_decorate
 
 from ctypes import c_char_p, c_void_p, cast, pointer
 
@@ -49,8 +49,9 @@ TRYAGAIN_CNT = 60
 
 OPENSAF_IMM_OBJECT = "opensafImm=opensafImm,safApp=safImmService"
 
+
 # Decorate the raw saImmOi* functions with retry and raising exceptions
-saImmOiInitialize_2   = decorate(saImmOi.saImmOiInitialize_2)
+saImmOiInitialize_2 = initialize_decorate(saImmOi.saImmOiInitialize_2)
 saImmOiSelectionObjectGet = decorate(saImmOi.saImmOiSelectionObjectGet)
 saImmOiDispatch   = decorate(saImmOi.saImmOiDispatch)
 saImmOiFinalize   = decorate(saImmOi.saImmOiFinalize)
@@ -71,9 +72,7 @@ saImmOiCcbSetErrorString  = 
decorate(saImmOi.saImmOiCcbSetErrorString)
 
 def initialize(callbacks=None):
 ''' Initializes IMM OI '''
-
 version = SaVersionT('A', 2, 15)
-
 saImmOiInitialize_2(HANDLE, callbacks, version)
 
 
diff --git 

[devel] [PATCH 0/1] Review Request for retry SAF initialize() function with original version V3 [#2524]

2017-10-16 Thread Hieu Nguyen
Summary: pyosaf: retry SAF initialize() function with original version [#2524]
Review request for Ticket(s): 2524
Peer Reviewer(s): Hans, Anders, Quyen, Srinivas
Pull request to: Anders
Affected branch(es): develop
Development branch: ticket-2524
Base revision: 3d33c10e172b69a989304cc57199e2c714ae4059
Personal repository: git://git.code.sf.net/u/dhiengu/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 cc9d2fa6f105505218727a0d764cf5021b9c873d
Author: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>
Date:   Tue, 17 Oct 2017 12:35:13 +0700

pyosaf: retry SAF initialize() function with original version [#2524]



Complete diffstat:
--
 python/pyosaf/utils/__init__.py   | 44 +++
 python/pyosaf/utils/clm/__init__.py   | 11 +
 python/pyosaf/utils/immoi/__init__.py |  7 +++---
 python/pyosaf/utils/immom/__init__.py |  7 +++---
 python/pyosaf/utils/log/__init__.py   |  4 ++--
 python/pyosaf/utils/ntf/__init__.py   | 16 ++---
 6 files changed, 66 insertions(+), 23 deletions(-)


Testing Commands:
-


Testing, Expected Results:
--


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] pyosaf: decorate function does not handle version struct in initialize functions [#2524]

2017-10-16 Thread Hieu Nguyen
---
 python/pyosaf/utils/__init__.py   | 44 +++
 python/pyosaf/utils/clm/__init__.py   | 11 +
 python/pyosaf/utils/immoi/__init__.py |  7 +++---
 python/pyosaf/utils/immom/__init__.py |  7 +++---
 python/pyosaf/utils/log/__init__.py   |  4 ++--
 python/pyosaf/utils/ntf/__init__.py   | 16 ++---
 6 files changed, 66 insertions(+), 23 deletions(-)

diff --git a/python/pyosaf/utils/__init__.py b/python/pyosaf/utils/__init__.py
index 0d4b648..3776cef 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,46 @@ def decorate(function):
 return error
 
 return inner
+
+
+def initialize_decorate(function):
+''' Decorate the given SAF initialize(handle, callbacks, version) so that
+it retries a fixed number of times if needed with the same arguments 
and
+raises an exception if it encounters any fault other than
+SA_AIS_ERR_TRY_AGAIN.
+'''
+
+def inner(*args):
+''' Calls "function" in the lexical scope in a retry loop and raises
+an exception if it encounters any other faults.
+
+Args:
+args(tuple): Argument of initialize() with format:
+ tuple(handle, callbacks, version)
+'''
+# Backup current version
+backup_version = deepcopy(args[2])
+
+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, so set original version on
+# next initialization.
+version = deepcopy(backup_version)
+args = args[:2] + (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..b9b853a 100644
--- a/python/pyosaf/utils/clm/__init__.py
+++ b/python/pyosaf/utils/clm/__init__.py
@@ -20,12 +20,13 @@
 
 from pyosaf import saClm, saAis
 
-from pyosaf.utils import decorate
+from pyosaf.utils import decorate, initialize_decorate
+
 
 # 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)
+saClmInitialize_3 = initialize_decorate(saClm.saClmInitialize_3)
+saClmInitialize_4 = initialize_decorate(saClm.saClmInitialize_4)
 saClmSelectionObjectGet= decorate(saClm.saClmSelectionObjectGet)
 saClmDispatch  = decorate(saClm.saClmDispatch)
 saClmFinalize  = decorate(saClm.saClmFinalize)
@@ -131,7 +132,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..2ea0f33 100644
--- a/python/pyosaf/utils/immoi/__init__.py
+++ b/python/pyosaf/utils/immoi/__init__.py
@@ -38,7 +38,7 @@ from pyosaf.utils.immom.object import ImmObject
 from pyosaf.utils.immom.ccb import marshal_c_array
 from pyosaf.utils.immom.iterator import SearchIterator
 
-from pyosaf.utils import decorate
+from pyosaf.utils import decorate, initialize_decorate
 
 from ctypes import c_char_p, c_void_p, cast, pointer
 
@@ -49,8 +49,9 @@ TRYAGAIN_CNT = 60
 
 OPENSAF_IMM_OBJECT = "opensafImm=opensafImm,safApp=safImmService"
 
+
 # Decorate the raw saImmOi* functions with retry and raising exceptions
-saImmOiInitialize_2   = decorate(saImmOi.saImmOiInitialize_2)
+saImmOiInitialize_2 = initialize_decorate(saImmOi.saImmOiInitialize_2)
 saImmOiSelectionObjectGet = decorate(saImmOi.saImmOiSelectionObjectGet)
 saImmOiDispatch   = decorate(saImmOi.saImmOiDispatch)
 saImmOiFinalize   = decorate(saImmOi.saImmOiFinalize)
@@ -71,9 +72,7 @@ saImmOiCcbSetErrorString  = 
decorate(saImmOi.saImmOiCcbSetErrorString)
 
 def initialize(callbacks=None):
 ''' Initializes IMM OI '''
-
 version = SaVersionT('A', 2, 15)
-
 saImmOiInitialize_2(HANDLE, callbacks, version)
 
 
diff --git 

[devel] [PATCH 0/1] Review Request for pyosaf: decorate function does not handle version struct in initialize functions V2 [#2524]

2017-10-16 Thread Hieu Nguyen
Summary: pyosaf: decorate function does not handle version struct in initialize 
functions [#2524]
Review request for Ticket(s): 2524
Peer Reviewer(s): Hans, Anders, Quyen, Srinivas
Pull request to: Anders
Affected branch(es): develop
Development branch: ticket-2524
Base revision: 3d33c10e172b69a989304cc57199e2c714ae4059
Personal repository: git://git.code.sf.net/u/dhiengu/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):
-


Author: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>
Date:   Tue, 17 Oct 2017 12:17:32 +0700

pyosaf: decorate function does not handle version struct in initialize 
functions [#2524]



Complete diffstat:
--
 python/pyosaf/utils/__init__.py   | 44 +++
 python/pyosaf/utils/clm/__init__.py   | 11 +
 python/pyosaf/utils/immoi/__init__.py |  7 +++---
 python/pyosaf/utils/immom/__init__.py |  7 +++---
 python/pyosaf/utils/log/__init__.py   |  4 ++--
 python/pyosaf/utils/ntf/__init__.py   | 16 ++---
 6 files changed, 66 insertions(+), 23 deletions(-)


Testing Commands:
-


Testing, Expected Results:
--


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


Re: [devel] [PATCH 1/1] pyosaf: decorate function does not handle version struct in initialize functions [#2524]

2017-10-16 Thread Hieu Nguyen
Hi a.Quyen,

 

Thanks for your review.

I answer your comments marked with [Hieu].

 

BR,

Hieu

 

From: Quyen Dao [mailto:quyen@dektech.com.au] 
Sent: Tuesday, October 17, 2017 11:45 AM
To: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>; hans.nordeb...@ericsson.com; 
anders.wid...@ericsson.com; zoran.milinko...@ericsson.com
Cc: opensaf-devel@lists.sourceforge.net
Subject: Re: [devel] [PATCH 1/1] pyosaf: decorate function does not handle 
version struct in initialize functions [#2524]

 

Hi Hieu,

Please see my comment marked with [Quyen].

Thanks,
Quyen

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):

[Quyen] I think argument current_version should be removed, it should use the 
version that user passes to `function`

[Hieu] Yes, I will remove current_version and use the user version passed.





 
+''' 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)

[Quyen] Backing up the version should be done inside the inner function.
[Hieu] Yes, move to inside the inner function with change:

backup_version = deepcopy(args[2])

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

[Quyen] the backup_version should be done at here, please also have a note in 
the function docstring to emphasize that the give SAF initialize must have 3 
arguments and the last argument is the version. 
backup_version = deepcopy(args[2])
[Hieu] Yes, same as above comment.

 
+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

[Quyen] Should we rephrase it like this: "So we need to revert the version back 
to the original version before trying again" or something similar.

[Hieu] Yes, change with “updated to the latest version, so set original version 
on next initialization.”





 
+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)

[Quyen] No need to have a constant here as it's only used in one place

[Hieu] Yes, will remove it and keep original codes for CLM version initialize



 
 
 # 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 @@ de

[devel] [PATCH 1/1] pyosaf: Raise ValueError instead NoneType Exception [#1410]

2017-10-16 Thread Hieu Nguyen
---
 python/pyosaf/utils/immom/object.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python/pyosaf/utils/immom/object.py 
b/python/pyosaf/utils/immom/object.py
index c2924d3..7d8ece8 100644
--- a/python/pyosaf/utils/immom/object.py
+++ b/python/pyosaf/utils/immom/object.py
@@ -59,7 +59,7 @@ class ImmObject(object):
 self.class_desc[class_name] = \
 pyosaf.utils.immom.class_description_get(class_name)
 else:
-raise
+raise ValueError("Class and attributes are None")
 
 self.__dict__["rdn_attribute"] = \
 pyosaf.utils.immom.get_rdn_attribute_for_class(class_name)
-- 
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 pyosaf: Raise ValueError instead NoneType Exception V2 [#1410]

2017-10-16 Thread Hieu Nguyen
Summary: pyosaf: Raise ValueError instead NoneType Exception [#1410]
Review request for Ticket(s): 1410
Peer Reviewer(s): Hans, Anders, Quyen, Srinivas
Pull request to: Anders
Affected branch(es): develop
Development branch: ticket-1410
Base revision: 3d33c10e172b69a989304cc57199e2c714ae4059
Personal repository: git://git.code.sf.net/u/dhiengu/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 e7fb995f41a4bfabe3d1e48bda3ba004e2935074
Author: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>
Date:   Tue, 17 Oct 2017 09:49:24 +0700

pyosaf: Raise ValueError instead NoneType Exception [#1410]



Complete diffstat:
--
 python/pyosaf/utils/immom/object.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


Testing Commands:
-


Testing, Expected Results:
--


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


Re: [devel] [PATCH 1/1] pyosaf: Invalid exception used in ImmObject (object.py) [#1410]

2017-10-16 Thread Hieu Nguyen
Hi a.Quyen,

 

Thanks for your comments.

Will fix same as your suggestion.

 

BR,

Hieu

From: Quyen Dao [mailto:quyen@dektech.com.au] 
Sent: Monday, October 16, 2017 6:41 PM
To: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>; hans.nordeb...@ericsson.com; 
anders.wid...@ericsson.com
Cc: opensaf-devel@lists.sourceforge.net
Subject: Re: [devel] [PATCH 1/1] pyosaf: Invalid exception used in ImmObject 
(object.py) [#1410]

 

Hi Hieu,

Please see my minor comment marked with [Quyen]

Thanks,
Quyen

On 10/3/2017 10:50 AM, Hieu Nguyen wrote:

---
 python/pyosaf/utils/immom/object.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
 
diff --git a/python/pyosaf/utils/immom/object.py 
b/python/pyosaf/utils/immom/object.py
index c2924d3..30cd63c 100644
--- a/python/pyosaf/utils/immom/object.py
+++ b/python/pyosaf/utils/immom/object.py
@@ -59,7 +59,7 @@ class ImmObject(object):
 self.class_desc[class_name] = \
 pyosaf.utils.immom.class_description_get(class_name)
 else:
-raise
+raise Exception("ERROR: class and attributes are None")

[Quyen] I think it's better to raise ValueError instead Exception as Exception 
is quite general.
Please also remove the prefix "ERROR: " in the exception description.
BTW: The patch title should describe the summary of the change not the title of 
the ticket 

 
 self.__dict__["rdn_attribute"] = \
 pyosaf.utils.immom.get_rdn_attribute_for_class(class_name)

 

--
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] pyosaf: decorate function does not handle version struct in initialize functions [#2524]

2017-10-11 Thread Hieu Nguyen
Just remind,

Hi Anders, Hans and Zoran,

Do you have any comments for my patch?
I hope you spend a little time to quick look this patch. It's related to MR
HL Python Interface [MR54015], will be first demo on this Friday (13th Oct).

Also,  ticket #1410

Thanks,
Hieu
-Original Message-
From: Hieu Nguyen [mailto:hieu.t.ngu...@dektech.com.au] 
Sent: Thursday, October 5, 2017 5:27 PM
To: hans.nordeb...@ericsson.com; anders.wid...@ericsson.com;
zoran.milinko...@ericsson.com
Cc: opensaf-devel@lists.sourceforge.net; Hieu Nguyen
<hieu.t.ngu...@dektech.com.au>
Subject: [PATCH 1/1] pyosaf: decorate function does not handle version
struct in initialize functions [#2524]

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

[devel] [PATCH 0/1] Review Request for pyosaf: decorate function does not handle version struct in initialize functions [#2524]

2017-10-05 Thread Hieu Nguyen
Summary: pyosaf: decorate function does not handle version struct in initialize 
functions [#2524]
Review request for Ticket(s): 2524
Peer Reviewer(s): Anders, Hans, Zoran
Pull request to: Anders
Affected branch(es): develop
Development branch: ticket-2524
Base revision: 8c725cd2d873aebd420e1857ece516ba8d0eab5b
Personal repository: git://git.code.sf.net/u/dhiengu/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 cb13c15ce7a5ab4e09418865570d06c413f99f2e
Author: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>
Date:   Thu, 5 Oct 2017 17:12:46 +0700

pyosaf: decorate function does not handle version struct in initialize 
functions [#2524]



Complete diffstat:
--
 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(-)


Testing Commands:
-


Testing, Expected Results:
--


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] pyosaf: decorate function does not handle version struct in initialize functions [#2524]

2017-10-05 Thread Hieu Nguyen
---
 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
--- a/python/pyosaf/utils/immoi/__init__.py
+++ b/python/pyosaf/utils/immoi/__init__.py
@@ -38,7 +38,7 @@ from pyosaf.utils.immom.object import ImmObject
 from pyosaf.utils.immom.ccb import marshal_c_array
 from pyosaf.utils.immom.iterator import SearchIterator
 
-from pyosaf.utils import decorate
+from pyosaf.utils import decorate, initialize_decorate
 
 from ctypes import c_char_p, c_void_p, cast, pointer
 
@@ -49,8 +49,11 @@ TRYAGAIN_CNT = 60
 
 OPENSAF_IMM_OBJECT = "opensafImm=opensafImm,safApp=safImmService"
 
+# Define IMM OI version
+OI_VER = SaVersionT('A', 2, 15)
+
 # Decorate the raw saImmOi* functions with retry and raising exceptions
-saImmOiInitialize_2   = 

[devel] [PATCH 0/1] Review Request for pyosaf: Invalid exception used in ImmObject (object.py) [#1410]

2017-10-02 Thread Hieu Nguyen
Summary: pyosaf: Invalid exception used in ImmObject (object.py) [#1410]
Review request for Ticket(s): 1410
Peer Reviewer(s): Hans/Anders
Pull request to: Hans
Affected branch(es): develop
Development branch: ticket-1410
Base revision: bc497981905f39aaa5b63cdf85b7557972650d94
Personal repository: git://git.code.sf.net/u/dhiengu/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 0cdec4f977048b789e75294216cfb47fdf420bab
Author: Hieu Nguyen <hieu.t.ngu...@dektech.com.au>
Date:   Tue, 3 Oct 2017 10:37:20 +0700

pyosaf: Invalid exception used in ImmObject (object.py) [#1410]



Complete diffstat:
--
 python/pyosaf/utils/immom/object.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)


Testing Commands:
-



Testing, Expected Results:
--



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] pyosaf: Invalid exception used in ImmObject (object.py) [#1410]

2017-10-02 Thread Hieu Nguyen
---
 python/pyosaf/utils/immom/object.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/python/pyosaf/utils/immom/object.py 
b/python/pyosaf/utils/immom/object.py
index c2924d3..30cd63c 100644
--- a/python/pyosaf/utils/immom/object.py
+++ b/python/pyosaf/utils/immom/object.py
@@ -59,7 +59,7 @@ class ImmObject(object):
 self.class_desc[class_name] = \
 pyosaf.utils.immom.class_description_get(class_name)
 else:
-raise
+raise Exception("ERROR: class and attributes are None")
 
 self.__dict__["rdn_attribute"] = \
 pyosaf.utils.immom.get_rdn_attribute_for_class(class_name)
-- 
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