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 ; Anders Widell 
; 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 ; Anders Widell 
; 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 ; 'Anders Widell' 
; 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 ; Anders Widell 
> ; 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 ; Anders Widell 
> ; 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 

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

2018-01-09 Thread Hans Nordebäck
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 ; Anders Widell 
; 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 ; 'Anders Widell' 
; 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 ; Anders Widell 
> ; 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 ; Anders Widell 
> ; 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 ; anders.wid...@ericsson.com; 
> srinivas.mangip...@oracle.com
> Cc: 

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

2018-01-09 Thread Hans Nordebäck

Hi Hieu, ack, code review only/Thanks HansN


On 01/09/2018 12:17 PM, 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| 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
- 

[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 Hans Nordebäck

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 ; Anders Widell 
; 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 ; Anders Widell 
; 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 ; 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 

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 ; Anders Widell 
; 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 ; Anders Widell 
; 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 ; 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 

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

2018-01-08 Thread Hans Nordebäck
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 ; Anders Widell 
; 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 ; 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 

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 ; 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
> -saImmOiInitialize_2 = initialize_decorate(saImmOi.saImmOiInitialize_2)
> -saImmOiSelectionObjectGet = decorate(saImmOi.saImmOiSelectionObjectGet)
> -saImmOiDispatch = decorate(saImmOi.saImmOiDispatch)
> -saImmOiFinalize = decorate(saImmOi.saImmOiFinalize)
> -saImmOiImplementerSet = decorate(saImmOi.saImmOiImplementerSet)
> -saImmOiImplementerClear = 

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

2018-01-08 Thread Hans Nordebäck

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

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

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 
  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' ; 
'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,

 

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] 

Sent: Tuesday, December 19, 2017 10:19 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,

 

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.saImmOiImplementerSet)

> -saImmOiImplementerClear = decorate(saImmOi.saImmOiImplementerClear)

> -saImmOiClassImplementerSet = decorate(saImmOi.saImmOiClassImplementerSet)

> -saImmOiClassImplementerRelease = \

> -decorate(saImmOi.saImmOiClassImplementerRelease)

> -saImmOiObjectImplementerSet = 

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

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

2017-12-19 Thread Hans Nordebäck

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.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 != 

[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

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_object = None
-self.callbacks = None
-global _oi_agent
-_oi_agent = self
-
-   

[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,