---
 python/samples/caps                               |  69 +++++----
 python/samples/caps-inheritance-impl              |  78 ++++++----
 python/samples/imm-listener                       | 130 +++++++++-------
 python/samples/imm-listener-inheritance-impl      | 172 ++++++++++------------
 python/samples/immadm                             | 161 +++++++++++---------
 python/samples/immbase.py                         | 140 ++++++++++--------
 python/samples/immlist                            |  85 ++++++-----
 python/samples/interface-handler                  | 138 ++++++++++-------
 python/samples/interface-handler-inheritance-impl | 122 +++++++++------
 python/samples/ping-pong                          |  95 ++++++------
 python/samples/ping-pong-inheritance-impl         | 105 +++++++------
 python/samples/scale_opensaf                      | 111 +++++++++-----
 python/samples/time-reporter                      |  93 +++++++-----
 python/samples/time-reporter-inheritance-impl     | 107 +++++++-------
 python/samples/tones                              |  54 ++++---
 python/samples/tones-inheritance-impl             |  51 +++++--
 python/samples/users                              |  57 +++++--
 python/samples/users-inheritance-impl             |  60 +++++---
 18 files changed, 1065 insertions(+), 763 deletions(-)

diff --git a/python/samples/caps b/python/samples/caps
index 494571d..46158b1 100755
--- a/python/samples/caps
+++ b/python/samples/caps
@@ -1,60 +1,77 @@
 #!/usr/bin/env python
-
+############################################################################
+#
+# (C) Copyright 2015 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+############################################################################
+# pylint: disable=unused-argument
+""" Sample illustrates the usage of Implementer """
 import itertools
 import argparse
 
 from pyosaf.saAis import eSaAisErrorT
-
 from pyosaf.utils import SafException
-
 from pyosaf.utils.immoi.implementer import Implementer
 
-caps_class_name = "CapsSample"
 
-def handle_validate(all_instances, updated, created, deleted):
+def handle_validate(instances, updated, created, deleted):
+    """ Validates that the rules for upperCaps and lowerCaps are kept """
 
     # Verify that upper and lower caps are correct in created objects
     # and updated objects
-    for mo in itertools.chain(created, updated):
-
+    for obj in itertools.chain(created, updated):
         # Verify upper caps
-        if mo.upperCaps and not mo.upperCaps.isupper():
+        if obj.upperCaps and not obj.upperCaps.isupper():
             err_str = "ERROR: %s.upperCaps must be upper case (was %s)" % \
-                (mo.dn, mo.upperCaps)
+                (obj.dn, obj.upperCaps)
             raise SafException(eSaAisErrorT.SA_AIS_ERR_INVALID_PARAM, err_str)
 
         # Verify lower caps
-        if mo.lowerCaps and not mo.lowerCaps.islower():
+        if obj.lowerCaps and not obj.lowerCaps.islower():
             err_str = "ERROR: %s.lowerCaps must be lower case (was %s)" % \
-                      (mo.dn, mo.lowerCaps)
+                      (obj.dn, obj.lowerCaps)
             raise SafException(eSaAisErrorT.SA_AIS_ERR_INVALID_PARAM, err_str)
 
 
 if __name__ == "__main__":
-
     # Parse command line arguments
-    parser = argparse.ArgumentParser(
-        description='''Validates that the lowerCaps and upperCaps attributes
-of instances of the CapsSample class can only contain
-lower case and upper case text respectively.
+    description = """
+    Validates that the lowerCaps and upperCaps attributes
+    of instances of the CapsSample class can only contain
+    lower case and upper case text respectively.
+
+    Use like this:
 
-Use like this:
-$ caps &
+    $ caps &
 
-$ immcfg -c CapsSample capsId=<RDN>
+    $ immcfg -c CapsSample capsId=<RDN>
 
-$ immcfg -a upperCaps=ABC capsId=<RDN>  (allowed)
+    $ immcfg -a upperCaps=ABC capsId=<RDN>  (allowed)
 
-$ immcfg -a lowerCaps=Abc capsId=<RDN>  (not allowed)
-''', formatter_class=argparse.RawTextHelpFormatter)
+    $ immcfg -a lowerCaps=Abc capsId=<RDN>  (not allowed)
+    """
+    parser = argparse.ArgumentParser(
+        description=description,
+        formatter_class=argparse.RawTextHelpFormatter)
 
     parser.parse_args()
 
     # Create the implementer
-    classes = [caps_class_name]
-
-    caps_implementer = Implementer(on_validate=handle_validate, 
-                                   class_names=classes,
+    class_name = "CapsSample"
+    caps_implementer = Implementer(on_validate=handle_validate,
+                                   class_names=[class_name],
                                    name="CapsImplementer")
 
     # Start the infinite dispatch loop
diff --git a/python/samples/caps-inheritance-impl 
b/python/samples/caps-inheritance-impl
index a5a6d2b..b9dd677 100755
--- a/python/samples/caps-inheritance-impl
+++ b/python/samples/caps-inheritance-impl
@@ -1,63 +1,85 @@
 #!/usr/bin/env python
-
+############################################################################
+#
+# (C) Copyright 2015 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+############################################################################
+# pylint: disable=invalid-name
+""" Sample illustrates the usage of Implementer by inheritance way """
 import itertools
 import argparse
 
 from pyosaf.saAis import eSaAisErrorT
-
 from pyosaf.utils import SafException
-
 from pyosaf.utils.immoi.implementer import Implementer
 
-caps_class_name = "CapsSample"
 
 class Caps(Implementer):
-    ''' The Caps implementer implements CapsSample and makes sure that
+    """ The Caps implementer implements CapsSample and makes sure that
         the upperCaps and lowerCaps consist only of uppercase characters
-        and lowercase characters respectively.'''
+        and lowercase characters respectively.
+    """
 
     def __init__(self):
-        ''' Constructs the Caps instance '''
-        Implementer.__init__(self, class_names=[caps_class_name],
+        """ Constructs the Caps instance """
+        class_name = "CapsSample"
+        Implementer.__init__(self, class_names=[class_name],
                              name="CapsImplementer")
 
-    def on_validate(self, all_instances, to_update, to_create, to_delete):
-        ''' Validates that the rules for upperCaps and lowerCaps are kept '''
+    def on_validate(self, instances, updated, created, deleted):
+        """ Validates that the rules for upperCaps and lowerCaps are kept """
 
         # Verify that upper and lower caps are correct in created objects
         # and updated objects
-        for mo in itertools.chain(to_create, to_update):
+        for obj in itertools.chain(created, updated):
 
             # Verify upper caps
-            if mo.upperCaps and not mo.upperCaps.isupper():
+            if obj.upperCaps and not obj.upperCaps.isupper():
                 err_str = "ERROR: %s.upperCaps must be upper case (was %s)" % \
-                    (mo.dn, mo.upperCaps)
-                raise SafException(eSaAisErrorT.SA_AIS_ERR_INVALID_PARAM, 
err_str)
+                    (obj.dn, obj.upperCaps)
+                raise SafException(eSaAisErrorT.SA_AIS_ERR_INVALID_PARAM,
+                                   err_str)
 
             # Verify lower caps
-            if mo.lowerCaps and not mo.lowerCaps.islower():
+            if obj.lowerCaps and not obj.lowerCaps.islower():
                 err_str = "ERROR: %s.lowerCaps must be lower case (was %s)" % \
-                          (mo.dn, mo.lowerCaps)
-                raise SafException(eSaAisErrorT.SA_AIS_ERR_INVALID_PARAM, 
err_str)
+                          (obj.dn, obj.lowerCaps)
+                raise SafException(eSaAisErrorT.SA_AIS_ERR_INVALID_PARAM,
+                                   err_str)
 
 
 if __name__ == "__main__":
-
     # Parse command line arguments
-    parser = argparse.ArgumentParser(
-        description='''Validates that the lowerCaps and upperCaps attributes
-of instances of the CapsSample class can only contain
-lower case and upper case text respectively.
+    description = """
+    Validates that the lowerCaps and upperCaps attributes
+    of instances of the CapsSample class can only contain
+    lower case and upper case text respectively.
+
+    Use like this:
 
-Use like this:
-$ caps-inheritance-impl &
+    $ caps-inheritance-impl &
 
-$ immcfg -c CapsSample capsId=<RDN>
+    $ immcfg -c CapsSample capsId=<RDN>
 
-$ immcfg -a upperCaps=ABC capsId=<RDN>  (allowed)
+    $ immcfg -a upperCaps=ABC capsId=<RDN>  (allowed)
 
-$ immcfg -a lowerCaps=Abc capsId=<RDN>  (not allowed)
-''', formatter_class=argparse.RawTextHelpFormatter)
+    $ immcfg -a lowerCaps=Abc capsId=<RDN>  (not allowed)
+    """
+    parser = argparse.ArgumentParser(
+        description=description,
+        formatter_class=argparse.RawTextHelpFormatter)
 
     parser.parse_args()
 
diff --git a/python/samples/imm-listener b/python/samples/imm-listener
index 40cfc75..db8bbea 100755
--- a/python/samples/imm-listener
+++ b/python/samples/imm-listener
@@ -1,78 +1,98 @@
 #!/usr/bin/env python
-
+############################################################################
+#
+# (C) Copyright 2015 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+############################################################################
+# pylint: disable=invalid-name
+# pylint: disable=unused-argument
+""" Sample illustrates the usage of Applier """
+from __future__ import print_function
 import argparse
 import sys
 
 from pyosaf.saImm import eSaImmClassCategoryT
-
-from pyosaf.utils.immoi import get_available_classes_in_imm
-from pyosaf.utils.immom import get_class_category
 from pyosaf.utils.immoi.implementer import Applier
+from pyosaf.utils.immoi.agent import OiAgent
 
 
-def is_config_class(class_name):
-
-    category = get_class_category(class_name)
-
+def is_config_class(cls_name):
+    """ Check is configuration class """
+    category = oi_agent.imm_om.get_class_category(cls_name)
     return category == eSaImmClassCategoryT.SA_IMM_CLASS_CONFIG
 
 
-def parse_class_names():
-
-    return args.classes
-
-def print_mo(mo):
-    ''' Prints an MO instance '''
-
-    print "    %s" % mo.dn
+def print_object(obj):
+    """ Prints an MO instance """
+    print("\t%s" % obj.dn)
 
     # Print attributes
-    for name, type_value_pair in mo.attrs.iteritems():
+    for name, type_value_pair in obj.attrs.iteritems():
         value = type_value_pair[1]
 
         if len(value) == 1:
             value = value[0]
 
-        print "        - %s: %s" % (name, value)
+        print("\t\t %s: %s" % (name, value))
 
-def handle_apply(all_instances, updated, created, to_delete):
 
-    print
-    print '-' * 10 + " Configuration changed " + '-' * 10
+def handle_apply(instances, updated, created, deleted):
+    """ Callback function of OI """
+    print('-' * 10 + " Configuration changed " + '-' * 10)
 
     # Handle creates
-    print "  Created objects"
-    for mo in created:
-        print_mo(mo)
+    print("Created objects")
+    for obj in created:
+        print_object(obj)
 
     # Handle deletes
-    print "  Deleted objects"
-    for mo in to_delete:
-        print "    %s" % mo
+    print("Deleted objects")
+    for obj in deleted:
+        print("\t%s" % obj.dn)
 
     # Handle updates
-    print "  Updated objects"
-    for mo in updated:
-        print_mo(mo)
-        
+    print("Updated objects")
+    for obj in updated:
+        print_object(obj)
+
+
 if __name__ == "__main__":
+    # Initialize OI agent
+    oi_agent = OiAgent()
+    oi_agent.initialize()
 
     # Parse command line arguments
-    parser = argparse.ArgumentParser(
-        description='''Listens to changes to objects of the given classes
-Use like this:
+    description = """
+    Listens to changes to objects of the given configuration classes
 
-$ imm-listener SampleClass1
+    Use like this:
 
-or, to listen for changes to all configuration classes:
+    $ imm-listener SampleClass1 SampleClass2
 
-$ imm-listener --all
-''', formatter_class=argparse.RawTextHelpFormatter)
+    or, to listen for changes to all configuration classes:
 
-    parser.add_argument('classes', type=str, nargs='*', 
+    $ imm-listener --all
+    """
+    parser = argparse.ArgumentParser(
+        description=description,
+        formatter_class=argparse.RawTextHelpFormatter)
+
+    parser.add_argument('classes', type=str, nargs='*',
                         help='space-separated list of class names')
     parser.add_argument('--all', help='listens to changes to all classes',
-                        dest='all', action='store_const', const=all, 
+                        dest='all', action='store_const', const=all,
                         default=False)
 
     args = parser.parse_args()
@@ -83,38 +103,40 @@ $ imm-listener --all
 
     # Exit if no classes are passed
     if not listen_to_all and (not classes or classes == []):
-        print "ERROR: Must specify classes to listen to or '--all'"
+        print("ERROR: Must specify classes to listen to or '--all'")
         sys.exit(1)
 
     # Sort out which classes to listen to
-    all_available_classes = get_available_classes_in_imm()
+    all_available_classes = oi_agent.get_available_classes_in_imm()
     classes_to_listen_to = []
 
     if listen_to_all:
-        print "INFO: Listening to changes to all configuration classes"
-
-        classes_to_listen_to = [c for c in all_available_classes if 
is_config_class(c)]
+        print("INFO: Listening to changes to all configuration classes")
+        classes_to_listen_to = \
+            [c for c in all_available_classes if is_config_class(c)]
 
     else:
-
         # Validate classes
         for class_name in classes:
-
-            if not class_name in all_available_classes:
-                print "WARNING: Ignoring %s. It does not exist in IMM" % 
class_name
-
+            if class_name not in all_available_classes:
+                print("WARNING: Ignoring %s. It does not exist in IMM" %
+                      class_name)
                 continue
 
             elif not is_config_class(class_name):
-                print "WARNING: Ignoring runtime class %s" % class_name
-
+                print("WARNING: Ignoring runtime class %s" % class_name)
                 continue
 
             classes_to_listen_to.append(class_name)
 
-    print "INFO: Listening for changes in %s" % ", ".join(classes_to_listen_to)
+    if not classes_to_listen_to:
+        print("INFO: There is nothing to listen")
+        sys.exit(1)
+
+    print("INFO: Listening for changes in %s" % ", "
+          .join(classes_to_listen_to))
 
-    echo_applier = Applier(on_apply=handle_apply, 
+    echo_applier = Applier(on_apply=handle_apply,
                            class_names=classes_to_listen_to,
                            name="ImmListener")
 
diff --git a/python/samples/imm-listener-inheritance-impl 
b/python/samples/imm-listener-inheritance-impl
index 5787546..5a0df8d 100755
--- a/python/samples/imm-listener-inheritance-impl
+++ b/python/samples/imm-listener-inheritance-impl
@@ -1,125 +1,110 @@
 #!/usr/bin/env python
-
+############################################################################
+#
+# (C) Copyright 2015 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+############################################################################
+# pylint: disable=invalid-name
+""" Sample illustrates the usage of Applier by inheritance way """
+from __future__ import print_function
 import argparse
 import sys
 
-from pyosaf.saAis import eSaAisErrorT
-
 from pyosaf.saImm import eSaImmClassCategoryT
-
-from pyosaf.utils.immoi import get_available_classes_in_imm
-from pyosaf.utils.immom import get_class_category
+from pyosaf.utils.immoi.agent import OiAgent
 from pyosaf.utils.immoi.implementer import Applier
 
 
 class ImmListener(Applier):
-    ''' This class listens to modifications to IMM and prints
-        them on STDOUT. 
-
+    """ This class listens to modifications to IMM and prints them on STDOUT.
         It extends the Applier class and overrides the apply function.
+    """
 
-    '''
-
-    def __init__(self, class_names=[]):
-        ''' Creates a listener applier for the given class names '''
+    def __init__(self, class_names):
+        """ Creates a listener applier for the given class names """
         Applier.__init__(self, class_names, name='ImmListener')
 
     def on_apply(self, instances, updated, created, deleted):
-        ''' Overrides the apply method in Applier to print
-            any modifications to configuration data in IMM
-        '''
-
-        print
-        print '-' * 10 + " Configuration changed " + '-' * 10
+        """ Overrides the apply method in Applier to print any modifications to
+            configuration data in IMM
+        """
+        print('-' * 10 + " Configuration changed " + '-' * 10)
 
         # Handle creates
-        print "  Created objects"
-        for mo in created:
-            self.print_mo(mo)
+        print("Created objects")
+        for obj in created:
+            self.print_mo(obj)
 
         # Handle deletes
-        print "  Deleted objects"
-        for mo in deleted:
-            print "    %s" % mo
+        print("Deleted objects")
+        for obj in deleted:
+            print("\t%s" % obj.dn)
 
         # Handle updates
-        print "  Updated objects"
-        for mo in updated:
-            self.print_mo(mo)
-
-    def on_create_added(self, class_name, parent, obj):
-        ''' Overrides on_create in Applier. This method is called each
-            time a create operation is added to a CCB.
-        '''
+        print("Updated objects")
+        for obj in updated:
+            self.print_mo(obj)
 
-        print
-        print
-        print '-' * 10  + " Create added to CCB " + '-' * 10
-        print
-        print "Class: %s" % class_name
-        print "Parent: %s" % parent
-        print
-        self.print_mo(obj)
-        print
-
-        return eSaAisErrorT.SA_AIS_OK
-
-    def on_delete_added(self, dn):
-        ''' Overrides on_delete in Applier. This method is called each
-            time a delete operations is added to a CCB.
-        '''
-
-        print
-        print
-        print '-' * 10 + " Delete added to CCB " + '-' * 10
-        print
-        print "    %s" % dn
-
-        return eSaAisErrorT.SA_AIS_OK
-
-    def print_mo(self, mo):
-        ''' Prints an MO instance '''
-
-        print "    %s" % mo.dn
+    @staticmethod
+    def print_mo(obj):
+        """ Prints an MO instance """
+        print("\t%s" % obj.dn)
 
         # Print attributes
-        for name, type_value_pair in mo.attrs.iteritems():
+        for name, type_value_pair in obj.attrs.iteritems():
             value = type_value_pair[1]
 
             if len(value) == 1:
                 value = value[0]
 
-            print "        - %s: %s" % (name, value)
+            print("\t\t %s: %s" % (name, value))
 
 
-def is_config_class(class_name):
-    ''' Returns True if the given class is a configuration class,
+def is_config_class(cls_name):
+    """ Returns True if the given class is a configuration class,
         otherwise False
-    '''
-
-    category = get_class_category(class_name)
-
+    """
+    category = oi_agent.imm_om.get_class_category(cls_name)
     return category == eSaImmClassCategoryT.SA_IMM_CLASS_CONFIG
 
 
 if __name__ == "__main__":
+    # Initialize OI agent
+    oi_agent = OiAgent()
+    oi_agent.initialize()
 
     # Parse command line arguments
-    parser = argparse.ArgumentParser(
-        description='''Listens to changes to objects of the given classes
-Use like this:
+    description = """
+    Listens to changes to objects of the given classes
 
-$ imm-listener-inheritance-impl SampleClass1
+    Use like this:
 
-or, to listen for changes to all configuration classes:
+    $ imm-listener-inheritance-impl SampleClass1 SampleClass2
 
-$ imm-listener-inheritance-impl --all
-''', formatter_class=argparse.RawTextHelpFormatter)
+    or, to listen for changes to all configuration classes:
+
+    $ imm-listener-inheritance-impl --all
+    """
+    parser = argparse.ArgumentParser(
+        description=description,
+        formatter_class=argparse.RawTextHelpFormatter)
 
-    parser.add_argument('classes', type=str, nargs='*', 
+    parser.add_argument('classes', type=str, nargs='*',
                         help='space-separated list of class names')
     parser.add_argument('--all', help='listens to changes to all classes',
-                        dest='all', action='store_const', const=all, 
+                        dest='all', action='store_const', const=all,
                         default=False)
 
     args = parser.parse_args()
@@ -130,39 +115,38 @@ $ imm-listener-inheritance-impl --all
 
     # Exit if no classes are passed
     if not listen_to_all and (not classes or classes == []):
-        print "ERROR: Must specify classes to listen to or '--all'"
+        print("ERROR: Must specify classes to listen to or '--all'")
         sys.exit(1)
 
     # Sort out which classes to listen to
-    all_available_classes = get_available_classes_in_imm()
+    all_available_classes = oi_agent.get_available_classes_in_imm()
     classes_to_listen_to = []
 
     if listen_to_all:
-        print "INFO: Listening to changes to all configuration classes"
+        print("INFO: Listening to changes to all configuration classes")
 
-        classes_to_listen_to = [c for c in all_available_classes \
+        classes_to_listen_to = [c for c in all_available_classes
                                 if is_config_class(c)]
-
     else:
-
         # Validate classes
         for class_name in classes:
-
-            if not class_name in all_available_classes:
-                print "WARNING: Ignoring %s. It does not exist in IMM" % 
class_name
-
+            if class_name not in all_available_classes:
+                print("WARNING: Ignoring %s. It does not exist in IMM" %
+                      class_name)
                 continue
-
             elif not is_config_class(class_name):
-                print "WARNING: Ignoring runtime class %s" % class_name
-
+                print("WARNING: Ignoring runtime class %s" % class_name)
                 continue
 
             classes_to_listen_to.append(class_name)
 
-    print "INFO: Listening for changes in %s" % ", ".join(classes_to_listen_to)
+    if not classes_to_listen_to:
+        print("INFO: There is nothing to listen")
+        sys.exit(1)
+
+    print("INFO: Listening for changes in %s" % ", "
+          .join(classes_to_listen_to))
 
     imm_listener = ImmListener(classes_to_listen_to)
 
     imm_listener.enter_dispatch_loop()
-
diff --git a/python/samples/immadm b/python/samples/immadm
index a8b3b0f..a03acaf 100755
--- a/python/samples/immadm
+++ b/python/samples/immadm
@@ -2,6 +2,7 @@
 ############################################################################
 #
 # (C) Copyright 2011 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
 #
 # This program is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -13,79 +14,103 @@
 # licensing terms.
 #
 # Author(s): Wind River Systems, Inc.
+#            Ericsson AB
 #
 ############################################################################
-
-from optparse import OptionParser
-from pyosaf import saImm
-from pyosaf.utils import immom, SafException
-from socket import gethostname
-from os import getpid
-from pyosaf.saAis import eSaAisErrorT, SaAisErrorT
+""" Sample illustrates the usage of admin operation """
+from __future__ import print_function
 import json
 import sys
+import argparse
+
+from os import getpid
+from socket import gethostname
+
+from pyosaf import saImm
+from pyosaf.utils import SafException
+from pyosaf.saAis import eSaAisErrorT
+from pyosaf.utils.immom.agent import ImmOmAgent
+
+
+def get_execute_name():
+    """ Get execute name """
+    return ':'.join((gethostname(), sys.argv[0], str(getpid())))
+
+
+def cast(value_type, value):
+    """ Cast value to int, float or string type """
+    if value_type in [saImm.eSaImmValueTypeT.SA_IMM_ATTR_SAUINT64T,
+                      saImm.eSaImmValueTypeT.SA_IMM_ATTR_SAINT64T,
+                      saImm.eSaImmValueTypeT.SA_IMM_ATTR_SAUINT32T,
+                      saImm.eSaImmValueTypeT.SA_IMM_ATTR_SAINT32T]:
+        return int(value)
+
+    if value_type in [saImm.eSaImmValueTypeT.SA_IMM_ATTR_SADOUBLET,
+                      saImm.eSaImmValueTypeT.SA_IMM_ATTR_SAFLOATT]:
+        return float(value)
+
+    return value
+
+
+def immadm(args):
+    """ Return admin operation information """
+    dn = args.obj_dn
+    op_id = int(args.op_id)
+    params = args.params
+
+    rc = eSaAisErrorT.SA_AIS_OK
+    _params = []
+
+    if params is not None:
+        try:
+            for param in params:
+                (name, val_type, val) = param.split(':', 2)
+                ptype = saImm.eSaImmValueTypeT.lookup[val_type]
+                val = cast(ptype, val)
+                _params.append(saImm.SaImmAdminOperationParamsT_2(
+                    name, ptype, val))
+            om_agent = ImmOmAgent()
+            om_agent.init()
+            rc = om_agent.invoke_admin_operation(dn, op_id, params=_params)
+        except SafException as err:
+            if err.value != eSaAisErrorT.SA_AIS_ERR_NOT_EXIST:
+                raise err
+
+    return {'dn': dn,
+            'opId': op_id,
+            'params': params,
+            'rc': eSaAisErrorT.whatis(rc)}
 
-from pyosaf.utils.log.logger import SafLogger
-
-def getExecName():
-       return ':'.join((gethostname(), sys.argv[0], str(getpid())))
-
-def parseArgs(cmd=sys.argv[1:]):
-       usage = 'usage: %prog [options] OP_ID object_dn'
-       epilog = '\nOP_ID: an integer, dependent on the class of object.\n'\
-                       '\nTYPE: one of:\n%s\n' % 
'\n'.join(saImm.eSaImmValueTypeT.lookup.keys())
-       OptionParser.format_epilog = lambda self, formatter: self.epilog
-       parser = OptionParser(usage=usage, epilog=epilog)
-       parser.add_option('-a', '--admin-owner', dest='adminOwner',
-                       help='Name denoting owner of the operation.',
-                       metavar='OWNERNAME', default=getExecName())
-       parser.add_option('-p', '--param', dest='params',
-                       help='parameters to admin operation.',
-                       metavar='NAME:TYPE:VAL', action='append', default=[])
-       parser.add_option('-u', '--pretty-off', dest='ugly',
-                       help='turn off pretty printing.',
-                       action='store_true', default=False)
-       (options, args) = parser.parse_args(cmd)
-
-       if len(args) < 2:
-               parser.print_help()
-               sys.exit()
-
-       return options, args
-
-def immadm(options, args):
-
-       if len(args) < 2:
-               raise SafException(eSaAisErrorT.SA_AIS_ERR_INIT)
-
-        op_id  = int(args[0])
-        dn     = args[1]
-        retVal = SaAisErrorT(eSaAisErrorT.SA_AIS_OK)
-
-       try:
-               params = []
-               for p in options.params:
-                       (name, type, val) = p.split(':', 2)
-                       ptype = saImm.eSaImmValueTypeT.lookup[type]
-                       params.append(
-                               saImm.SaImmAdminOperationParamsT_2(name, ptype, 
val))
-
-                immom.admin_op_invoke(dn, op_id, params=params)
-
-       except SafException, e:
-               if e.value != eSaAisErrorT.SA_AIS_ERR_NOT_EXIST:
-                       raise e
-
-       return {'opId':   op_id,
-               'dname':  args[1],
-               'owner':  options.adminOwner,
-               'params': options.params,
-               'rc':     eSaAisErrorT.whatis(retVal.value)}
 
 if __name__ == '__main__':
-       (options, args) = parseArgs()
-       result = immadm(options, args)
-       logger = SafLogger(result['owner'])
-       logger.log('ADMIN_CMD: OP_ID %(opId)s %(dname)s: %(rc)s' % result)
+    description = """
+    Illustrates the usage of admin operation.
+
+    Use like this:
+
+    $ immadm -o 1 rdn=1
+
+    $ immadm -o 1 -p param_name:SA_IMM_ATTR_SAUINT32T:1 rdn=1
+
+    TYPE: one of:\n\t%s\n
+    """ % '\n\t'.join(saImm.eSaImmValueTypeT.lookup.keys())
+
+    parser = argparse.ArgumentParser(
+        description=description,
+        formatter_class=argparse.RawTextHelpFormatter)
+
+    parser.add_argument('obj_dn', type=str, help='object DN')
+    parser.add_argument('-o', '--op-id', help='operation id', dest='op_id',
+                        required=True)
+    parser.add_argument('-p', '--params', help='param of admin operation',
+                        dest='params', action='append',
+                        metavar='NAME:TYPE:VAL')
+    parser.add_argument('-u', '--pretty-off', dest='ugly',
+                        help='turn off pretty printing.',
+                        action='store_true', default=False)
+
+    arguments = parser.parse_args()
+
+    result = immadm(arguments)
 
-       print json.dumps(result, indent=None if options.ugly else 4)
+    print(json.dumps(result, indent=None if arguments.ugly else 4))
diff --git a/python/samples/immbase.py b/python/samples/immbase.py
index 6096428..2f6afba 100644
--- a/python/samples/immbase.py
+++ b/python/samples/immbase.py
@@ -1,6 +1,7 @@
 ############################################################################
 #
 # (C) Copyright 2011 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
 #
 # This program is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -12,80 +13,89 @@
 # licensing terms.
 #
 # Author(s): Wind River Systems, Inc.
+#            Ericsson AB
 #
 ############################################################################
-
+# pylint: disable=fixme
 from pyosaf import saImm
-from pyosaf.saImmOm import *
-from pyosaf.saAmf import *
+from pyosaf.saAis import eSaAisErrorT, unmarshalNullArray
+from pyosaf.saAmf import SaVersionT, eSaAmfPresenceStateT, \
+    eSaAmfReadinessStateT, eSaAmfOperationalStateT, eSaAmfAdminStateT, \
+    eSaAmfHAStateT, eSaAmfAssignmentStateT
+
 
 IMM_VERSION = SaVersionT('A', 2, 1)
 
+
 class SafException(Exception):
-       def __init__(self, value):
-               self.value = value
-       def __str__(self):
-               return eSaAisErrorT.whatis(self.value)
+    """ SafException class """
+    def __init__(self, value):
+        self.value = value
+        Exception.__init__(value)
+
+    def __str__(self):
+        return eSaAisErrorT.whatis(self.value)
+
 
 class SafObject(object):
-       resolver = {
-               # SaAmfComp
-                       'saAmfCompPresenceState': eSaAmfPresenceStateT,
-                       'saAmfCompReadinessState': eSaAmfReadinessStateT,
-                       'saAmfCompOperState': eSaAmfOperationalStateT,
-               # SaAmfNode
-                       'saAmfNodeOperState': eSaAmfOperationalStateT,
-                       'saAmfNodeAdminState': eSaAmfAdminStateT,
-               # SaAmfCSIAssignment
-                       'saAmfCSICompHAReadinessState': eSaAmfReadinessStateT,
-                       'saAmfCSICompHAState': eSaAmfHAStateT,
-               # SaAmfSIAssignment
-                       'saAmfSISUHAReadinessState': eSaAmfReadinessStateT,
-                       'saAmfSISUHAState': eSaAmfHAStateT,
-               # SaAmfApplication
-                       'saAmfApplicationAdminState': eSaAmfAdminStateT,
-               # SaClmNode
-                       'saClmNodeAdminState': eSaAmfAdminStateT,
-               # SaAmfSU
-                       'saAmfSUPresenceState': eSaAmfPresenceStateT,
-                       'saAmfSUReadinessState': eSaAmfReadinessStateT,
-                       'saAmfSUAdminState': eSaAmfAdminStateT,
-                       'saAmfSUOperState': eSaAmfOperationalStateT,
-               # SaAmfSG
-                       'saAmfSGAdminState': eSaAmfAdminStateT,
-               # SaAmfSI
-                       'saAmfSIAdminState': eSaAmfAdminStateT,
-                       'saAmfSIAssignmentState': eSaAmfAssignmentStateT,
-               # SaAmfCluster
-                       'saAmfClusterAdminState': eSaAmfAdminStateT,
-               # TODO: Once we create saSmf.py
-               # SaSmfProcedure
-               # SaSmfStep
-               # SaSmfCampaign
-       }
+    """ SafObject class """
+    resolver = {
+        # SaAmfComp
+        'saAmfCompPresenceState': eSaAmfPresenceStateT,
+        'saAmfCompReadinessState': eSaAmfReadinessStateT,
+        'saAmfCompOperState': eSaAmfOperationalStateT,
+        # SaAmfNode
+        'saAmfNodeOperState': eSaAmfOperationalStateT,
+        'saAmfNodeAdminState': eSaAmfAdminStateT,
+        # SaAmfCSIAssignment
+        'saAmfCSICompHAReadinessState': eSaAmfReadinessStateT,
+        'saAmfCSICompHAState': eSaAmfHAStateT,
+        # SaAmfSIAssignment
+        'saAmfSISUHAReadinessState': eSaAmfReadinessStateT,
+        'saAmfSISUHAState': eSaAmfHAStateT,
+        # SaAmfApplication
+        'saAmfApplicationAdminState': eSaAmfAdminStateT,
+        # SaClmNode
+        'saClmNodeAdminState': eSaAmfAdminStateT,
+        # SaAmfSU
+        'saAmfSUPresenceState': eSaAmfPresenceStateT,
+        'saAmfSUReadinessState': eSaAmfReadinessStateT,
+        'saAmfSUAdminState': eSaAmfAdminStateT,
+        'saAmfSUOperState': eSaAmfOperationalStateT,
+        # SaAmfSG
+        'saAmfSGAdminState': eSaAmfAdminStateT,
+        # SaAmfSI
+        'saAmfSIAdminState': eSaAmfAdminStateT,
+        'saAmfSIAssignmentState': eSaAmfAssignmentStateT,
+        # SaAmfCluster
+        'saAmfClusterAdminState': eSaAmfAdminStateT,
+        # TODO: Once we create saSmf.py
+        # SaSmfProcedure
+        # SaSmfStep
+        # SaSmfCampaign
+    }
 
-       @staticmethod
-       def resolveStates(attribs):
-               for (attr, vals) in attribs.iteritems():
-                       enum = SafObject.resolver.get(attr)
-                       if enum:
-                               vals[1] = [enum.whatis(val) for val in vals[1]]
+    @staticmethod
+    def resolveStates(attribs):
+        for (attr, vals) in attribs.iteritems():
+            enum = SafObject.resolver.get(attr)
+            if enum:
+                vals[1] = [enum.whatis(val) for val in vals[1]]
 
-       @staticmethod
-       def serialize(entry):
-               return entry.attribs
+    @staticmethod
+    def serialize(entry):
+        return entry.attribs
 
-       def __init__(self, dn, attribs, numeric=False):
-               self.dn = dn
-               self.attribs = {}
-               attrList = unmarshalNullArray(attribs)
-               for attr in attrList:
-                       attrRange = range(attr.attrValuesNumber)
-                       self.attribs[attr.attrName] = [
-                               
saImm.eSaImmValueTypeT.whatis(attr.attrValueType),
-                               [saImm.unmarshalSaImmValue(
-                                       attr.attrValues[val],
-                                       attr.attrValueType) for val in 
attrRange]
-                               ]
-               if not numeric:
-                       SafObject.resolveStates(self.attribs)
+    def __init__(self, dn, attribs, numeric=False):
+        self.dn = dn
+        self.attribs = {}
+        attrList = unmarshalNullArray(attribs)
+        for attr in attrList:
+            attrRange = range(attr.attrValuesNumber)
+            self.attribs[attr.attrName] = [
+                saImm.eSaImmValueTypeT.whatis(attr.attrValueType),
+                [saImm.unmarshalSaImmValue(
+                    attr.attrValues[val],
+                    attr.attrValueType) for val in attrRange]]
+        if not numeric:
+            SafObject.resolveStates(self.attribs)
diff --git a/python/samples/immlist b/python/samples/immlist
index ec23739..1034421 100755
--- a/python/samples/immlist
+++ b/python/samples/immlist
@@ -2,6 +2,7 @@
 ############################################################################
 #
 # (C) Copyright 2011 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
 #
 # This program is distributed in the hope that it will be useful, but
 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
@@ -13,54 +14,62 @@
 # licensing terms.
 #
 # Author(s): Wind River Systems, Inc.
+#            Ericsson AB.
 #
 ############################################################################
+""" Sample illustrates the usage of immlist """
+from __future__ import print_function
+import json
+import argparse
 
 from pyosaf import saImm
-from pyosaf.utils import immom
-from optparse import OptionParser
-import json
-import sys
+from pyosaf.utils.immom.accessor import ImmOmAccessor
 
-def parseArgs(cmd=sys.argv[1:]):
-       usage = 'usage: %prog [options] object_dn [object_dn ..]'
-       parser = OptionParser(usage)
-       parser.add_option('-a', '--attr', dest='attr',
-                       help='Attribute name to collect.',
-                       metavar='ATTRNAME', action='append', default=None)
-       parser.add_option('-n', '--numeric-states', dest='numeric',
-                       help='report states in numeric format.',
-                       action='store_true', default=False)
-       parser.add_option('-u', '--pretty-off', dest='ugly',
-                       help='turn off pretty printing.',
-                       action='store_true', default=False)
-       return parser.parse_args(cmd)
 
-class ListOptions(object):
-       def __init__(self):
-               self.attr = None
-               self.numeric = False
-               self.ugly = False
+def immlist(args):
+    """ Get imm objects with dn input in arguments """
+    objects = {}
+    accessor = ImmOmAccessor()
+    accessor.init()
 
-def immlist(options, args):
-        objects = {}
+    for dn in args.obj_dn:
+        _, obj = accessor.get(dn, attr_name_list=args.attributes)
+        if obj:
+            attributes = {}
+            for name, value_pair in obj.attrs.iteritems():
+                type_str = saImm.eSaImmValueTypeT.whatis(value_pair[0])
+                value = value_pair[1]
+                attributes[name] = [type_str, value]
 
-        for dn in args:
-                obj = immom.get(dn, attr_name_list=options.attr)
+            objects[dn] = attributes
+        else:
+            objects[dn] = None
 
-                if obj:
-                        attributes = {}
-                        for name, value_pair in obj.attrs.iteritems():
-                                type_str = 
saImm.eSaImmValueTypeT.whatis(value_pair[0])
-                                value    = value_pair[1]
+    return objects
 
-                                attributes[name] = [type_str, value]
 
-                        objects[dn] = attributes
+if __name__ == '__main__':
+    description = """
+    Illustrates the usage of immlist
 
-        return objects
+    Use like this
 
-if __name__ == '__main__':
-       (options, args) = parseArgs()
-        print json.dumps(immlist(options, args), 
-                         indent=None if options.ugly else 4)
+    $ immlist -a attr_name_1 -a attr_name_2 obj_dn
+    """
+
+    parser = argparse.ArgumentParser(
+        description=description,
+        formatter_class=argparse.RawTextHelpFormatter)
+
+    parser.add_argument('obj_dn', type=str, help='object DN', nargs='*')
+    parser.add_argument('-a', '--attributes', help='attribute list of object',
+                        dest='attributes', action='append')
+    parser.add_argument('-u', '--pretty-off', dest='ugly',
+                        help='turn off pretty printing.',
+                        action='store_true', default=False)
+
+    arguments = parser.parse_args()
+
+    result = immlist(arguments)
+
+    print(json.dumps(result, indent=None if arguments.ugly else 4))
diff --git a/python/samples/interface-handler b/python/samples/interface-handler
index 3c180f8..f7a1e38 100755
--- a/python/samples/interface-handler
+++ b/python/samples/interface-handler
@@ -1,106 +1,124 @@
 #!/usr/bin/env python
-
+############################################################################
+#
+# (C) Copyright 2015 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+############################################################################
+# pylint: disable=invalid-name
+# pylint: disable=import-error
+""" This is a sample give usage: OI create runtime object
+
+    Make sure 'netifaces' library installed on Opensaf environment, if NOT
+    please follow command: $sudo apt-get install python-netifaces
+"""
+import select
 import argparse
-import sys
 import netifaces
-import select
-
-from pyosaf.saAis import eSaAisErrorT
-
-from pyosaf.utils import immom, immoi
 
 from pyosaf.utils.immom.object import ImmObject
 from pyosaf.utils.immom.iterator import InstanceIterator
-
-
-from pyosaf.utils.immoi import get_object_no_runtime
 from pyosaf.utils.immoi.implementer import Implementer
 
+
 interface_class_name = "InterfaceRO01"
 timeout = 1
 
+
 def get_interface_name_from_dn(dn):
+    """ Split dn object by comma
+
+    Args:
+        dn (str): object dn
 
+    Returns:
+        str: dn name in string
+    """
     return dn.split(',')[0].split('=')[1]
 
-def create_rt_object_for_interface(implementer, interface):
 
-    mo = ImmObject(class_name=interface_class_name, dn='interfaceId=%s' % 
interface)
+def create_rt_object_for_interface(implementer, interface):
+    """ Create runtime object based on interface """
+    obj = ImmObject(class_name=interface_class_name,
+                    dn='interfaceId=%s' % interface)
 
     # Set the RDN with the right interface name
-    mo.interfaceId = 'interfaceId=%s' % interface
+    obj.interfaceId = 'interfaceId=%s' % interface
 
     # Look up the IPv4 and IPv6 addresses
     addresses = netifaces.ifaddresses(interface)
 
-    mo.ipv4Addresses = None
-    mo.ipv6Addresses = None
+    obj.ipv4Addresses = None
+    obj.ipv6Addresses = None
 
     if netifaces.AF_INET in addresses:
         ipv4 = [a['addr'] for a in addresses[netifaces.AF_INET]]
-        mo.ipv4Addresses = ipv4
+        obj.ipv4Addresses = ipv4
     else:
-        mo.ipv4Addresses = "dummy"
+        obj.ipv4Addresses = "dummy"
 
     if netifaces.AF_INET6 in addresses:
         ipv6 = [a['addr'] for a in addresses[netifaces.AF_INET6]]
-        mo.ipv6Addresses = ipv6
+        obj.ipv6Addresses = ipv6
     else:
-        mo.ipv6Addresses = "dummy"
+        obj.ipv6Addresses = "dummy"
 
-    ##
-    ## This exposes a potential fault in IMM.
-    ##
-    ## Cached attributes need to have their values set when 
-    ## the object is created. If there is an interface that lacks
-    ## an IPv4 or IPv6 address, this will be set to None and 
-    ## converted to an empty list in the implementer code. IMM
-    ## does not allow this and responds with SA_AIS_ERR_INVALID_PARAM
-    ##
+    #
+    # This exposes a potential fault in IMM.
+    #
+    # Cached attributes need to have their values set when
+    # the object is created. If there is an interface that lacks
+    # an IPv4 or IPv6 address, this will be set to None and
+    # converted to an empty list in the implementer code. IMM
+    # does not allow this and responds with SA_AIS_ERR_INVALID_PARAM
+    #
 
-    implementer.create(mo)
+    implementer.create(obj)
 
-def select_loop(implementer):
 
+def select_loop(implementer):
+    """ Implementer poll a loop to select object """
     # Get selection object for the implementer
     selection_object = implementer.get_selection_object()
 
     # Wait for next IO event or N seconds
-    inputs  = [selection_object]
+    inputs = [selection_object.value]
     outputs = []
 
     while inputs:
+        ioe = select.select(inputs, outputs, inputs, timeout)
 
-        readable, writable, exceptional = \
-        select.select(inputs, outputs, inputs, timeout)
-
-        if selection_object in readable:
+        if selection_object in ioe[0]:
             implementer.dispatch()
         else:
-
             interfaces = netifaces.interfaces()
-
             # Add objects for new interfaces
             for interface in interfaces:
-
-                try:
-                    create_rt_object_for_interface(implementer, interface)
-                except Exception as err:
-                    pass
+                create_rt_object_for_interface(implementer, interface)
 
             # Go through existing objects
-            for mo in InstanceIterator('InterfaceRO01'):
-                interface_name = get_interface_name_from_dn(mo.dn)
-
+            inst_iter = InstanceIterator('InterfaceRO01')
+            inst_iter.init()
+            for obj in inst_iter:
+                interface_name = get_interface_name_from_dn(obj.dn)
                 # Remove objects for deleted interfaces
-                if not mo.interfaceId.split('=')[1] in interfaces:
-                    implementer.delete(mo.dn)
-
+                if not obj.interfaceId.split('=')[1] in interfaces:
+                    implementer.delete(obj.dn)
                     continue
 
                 # Update interfaces
                 addresses = netifaces.ifaddresses(interface_name)
-
                 attributes = {}
 
                 if netifaces.AF_INET in addresses:
@@ -112,21 +130,27 @@ def select_loop(implementer):
                             [a['addr'] for a in addresses[netifaces.AF_INET6]]
 
                 if attributes:
-                    implementer.update_runtime_attributes(mo.dn, attributes)
+                    implementer.update_runtime_attributes(obj.dn, attributes)
 
 
 if __name__ == "__main__":
-
     # Parse command line arguments
-    parser = argparse.ArgumentParser(
-        description='''Creates a runtime object per network interface on the 
machine and populates the ipv4Addresses and ipv6Addresses attributes.
+    description = """
+    Creates a runtime object per network interface on the machine and
+    populates the ipv4Addresses and ipv6Addresses attributes.
+
+    Make sure 'netifaces' library installed on Opensaf environment, if NOT
+    please follow command: $sudo apt-get install python-netifaces
 
-Use like this:
+    Use like this:
 
-$ interface-handler &
+    $ interface-handler &
 
-$ immfind -c InterfaceRO01
-''', formatter_class=argparse.RawTextHelpFormatter)
+    $ immfind -c InterfaceRO01
+    """
+    parser = argparse.ArgumentParser(
+        description=description,
+        formatter_class=argparse.RawTextHelpFormatter)
 
     parser.parse_args()
 
diff --git a/python/samples/interface-handler-inheritance-impl 
b/python/samples/interface-handler-inheritance-impl
index 584aa24..2863465 100755
--- a/python/samples/interface-handler-inheritance-impl
+++ b/python/samples/interface-handler-inheritance-impl
@@ -1,39 +1,63 @@
 #!/usr/bin/env python
-
+############################################################################
+#
+# (C) Copyright 2015 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+############################################################################
+# pylint: disable=invalid-name
+# pylint: disable=import-error
+""" This is a sample give inheritance and use Implementer class
+
+    Make sure 'netifaces' library installed on Opensaf environment, if NOT
+    please follow command: $sudo apt-get install python-netifaces
+"""
+import select
 import argparse
-import sys
 import netifaces
-import select
-
-from pyosaf.saAis import eSaAisErrorT
-
-from pyosaf.utils import immom, immoi
 
 from pyosaf.utils.immom.object import ImmObject
 from pyosaf.utils.immom.iterator import InstanceIterator
-
-
-from pyosaf.utils.immoi import get_object_no_runtime
 from pyosaf.utils.immoi.implementer import Implementer
 
+
 interface_class_name = "InterfaceRO01"
 timeout = 1
 
-class InterfaceImplementer(Implementer):
-    
 
-    def __init__(self, timeout=1):
+class InterfaceImplementer(Implementer):
+    """ This is class inheritance from Implementer class """
+    def __init__(self):
         Implementer.__init__(self, name="InterfaceImplementer")
-
         self.timeout = timeout
 
-    def get_interface_name_from_dn(self, dn):
+    @staticmethod
+    def get_interface_name_from_dn(dn):
+        """ Split dn object by comma
 
+        Args:
+            dn (str): object dn
+
+        Returns:
+            str: dn name in string
+        """
         return dn.split(',')[0].split('=')[1]
 
     def create_rt_object_for_interface(self, interface):
-
-        mo = ImmObject(class_name=interface_class_name, dn='interfaceId=%s' % 
interface)
+        """ Create runtime object based on interface """
+        mo = ImmObject(class_name=interface_class_name,
+                       dn='interfaceId=%s' % interface)
 
         # Set the RDN with the right interface name
         mo.interfaceId = 'interfaceId=%s' % interface
@@ -53,57 +77,51 @@ class InterfaceImplementer(Implementer):
         else:
             mo.ipv6Addresses = "dummy"
 
-        ##
-        ## This exposes a potential fault in IMM.
-        ##
-        ## Cached attributes need to have their values set when 
-        ## the object is created. If there is an interface that lacks
-        ## an IPv4 or IPv6 address, this will be set to None and 
-        ## converted to an empty list in the implementer code. IMM
-        ## does not allow this and responds with SA_AIS_ERR_INVALID_PARAM
-        ##
-        ## Work around this for now by setting dummy values
-        ##
+        #
+        # This exposes a potential fault in IMM.
+        #
+        # Cached attributes need to have their values set when
+        # the object is created. If there is an interface that lacks
+        # an IPv4 or IPv6 address, this will be set to None and
+        # converted to an empty list in the implementer code. IMM
+        # does not allow this and responds with SA_AIS_ERR_INVALID_PARAM
+        #
+        # Work around this for now by setting dummy values
+        #
 
         self.create(mo)
 
     def enter_dispatch_loop(self):
-
+        """ Implementer poll a loop to select object """
         # Wait for next IO event or N seconds
-        inputs  = [self.get_selection_object()]
+        inputs = [self.get_selection_object().value]
         outputs = []
 
         while inputs:
+            ioe = select.select(inputs, outputs, inputs, timeout)
 
-            readable, writable, exceptional = \
-            select.select(inputs, outputs, inputs, timeout)
-
-            if self.get_selection_object() in readable:
+            if self.get_selection_object() in ioe[0]:
                 self.dispatch()
             else:
-
                 interfaces = netifaces.interfaces()
 
                 # Add objects for new interfaces
                 for interface in interfaces:
-                    try:
-                        self.create_rt_object_for_interface(interface)
-                    except Exception as err:
-                        pass
+                    self.create_rt_object_for_interface(interface)
 
                 # Go through existing objects
-                for mo in InstanceIterator('InterfaceRO01'):
+                inst_iter = InstanceIterator('InterfaceRO01')
+                inst_iter.init()
+                for mo in inst_iter:
                     interface_name = self.get_interface_name_from_dn(mo.dn)
 
                     # Remove objects for deleted interfaces
                     if not mo.interfaceId.split('=')[1] in interfaces:
                         self.delete(mo.dn)
-
                         continue
 
                     # Update interfaces
                     addresses = netifaces.ifaddresses(interface_name)
-
                     attributes = {}
 
                     if netifaces.AF_INET in addresses:
@@ -119,17 +137,23 @@ class InterfaceImplementer(Implementer):
 
 
 if __name__ == "__main__":
-
     # Parse command line arguments
-    parser = argparse.ArgumentParser(
-        description='''Creates a runtime object per network interface on the 
machine and populates the ipv4Addresses and ipv6Addresses attributes.
+    description = """
+    Creates a runtime object per network interface on the machine and
+    populates the ipv4Addresses and ipv6Addresses attributes.
 
-Use like this:
+    Make sure 'netifaces' library installed on Opensaf environment, if NOT
+    please follow command: $sudo apt-get install python-netifaces
 
-$ interface-handler-inheritance-impl &
+    Use like this:
 
-$ immfind -c InterfaceRO01
-''', formatter_class=argparse.RawTextHelpFormatter)
+    $ interface-handler-inheritance-impl &
+
+    $ immfind -c InterfaceRO01
+    """
+    parser = argparse.ArgumentParser(
+        description=description,
+        formatter_class=argparse.RawTextHelpFormatter)
 
     parser.parse_args()
 
diff --git a/python/samples/ping-pong b/python/samples/ping-pong
index 4c318ac..b545616 100755
--- a/python/samples/ping-pong
+++ b/python/samples/ping-pong
@@ -1,84 +1,89 @@
 #!/usr/bin/env python
-
-import select
+############################################################################
+#
+# (C) Copyright 2015 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+############################################################################
+# pylint: disable=invalid-name
+""" Sample illustrates the admin operation handling in OI """
+from __future__ import print_function
 import argparse
 
-from pyosaf.saAis import eSaAisErrorT
-
-from pyosaf.utils import immom
 from pyosaf.utils.immoi.implementer import Implementer, AdminOperationFunction
 from pyosaf.utils.immom.object import ImmObject
 from pyosaf.utils.immom.ccb import Ccb
 
+
 class_name = "PingPong"
-dn         = "pingPongId=1"
+object_name = "pingPongId=1"
 
 
-def print_admin_operation_info(dn, arguments):
-    print "INFO: I am %s" % dn
+def print_admin_operation_info(dn, params):
+    """ Print admin operation information """
+    print("INFO: I am %s" % dn)
 
-    if arguments:
-        print "INFO: Received arguments"
+    if params:
+        print("INFO: Received parameters")
 
-        for argument in arguments:
-            print " - %s: %s (%s)" % \
-                (argument.name, argument.value, argument.type)
+        for param in params:
+            print("\t- %s: %s (%s)" % (param.name, param.value, param.type))
 
 
 def ping(dn, arguments):
-    print
-    print
-    print "Pong!"
-    print
-
+    """ Ping """
+    print("\nPing!\n")
     print_admin_operation_info(dn, arguments)
 
-    return eSaAisErrorT.SA_AIS_OK
-
 
 def pong(dn, arguments):
-    print 
-    print
-    print "Ping!"
-    print
-
+    """ Pong """
+    print("\nPong!\n")
     print_admin_operation_info(dn, arguments)
 
-    return eSaAisErrorT.SA_AIS_OK
-
 
 if __name__ == '__main__':
-
     # Parse command line arguments
-    parser = argparse.ArgumentParser(
-        description='''Logs and replies to admin operations 0 and 1 towards %s,
-and replies
-
-Use like this:
+    description = """
+    Logs and replies to admin operations 0 and 1 towards %s, and replies
 
-$ ping-pong &
+    Use like this:
 
-$ immadm -o [0|1] pingPongId=1 <parameters..>
-''' % dn, formatter_class=argparse.RawTextHelpFormatter)
+    $ ping-pong &
 
+    $ immadm -o [0|1] pingPongId=1 <parameters..>
+    """ % object_name
+    parser = argparse.ArgumentParser(
+        description=description,
+        formatter_class=argparse.RawTextHelpFormatter)
     parser.parse_args()
 
     # Create the ping-pong instance if it doesn't exist
-    if not immom.get(dn):
-
-        with Ccb(flags=None) as ccb:
-            obj = ImmObject(class_name=class_name, dn=dn)
+    ccb = Ccb(flags=None)
+    obj = ImmObject(dn=object_name, class_name=class_name)
+    setattr(obj, "pingPongId", object_name)
+    ccb.init()
+    ccb.create(obj=obj)
+    ccb.apply()
 
-            obj.pingPongId  = "pingPongId=1"
-
-            ccb.create(obj)
+    # Clear admin owner after apply CCB
+    ccb.clear_admin_owner(obj_name=object_name)
 
     # Create the implementer instance
     operations = [AdminOperationFunction(class_name, 0, ping),
                   AdminOperationFunction(class_name, 1, pong)]
-
     implementer = Implementer(class_names=[class_name])
-
     implementer.set_admin_operations(operations)
 
     # Start dispatch and time update loop
diff --git a/python/samples/ping-pong-inheritance-impl 
b/python/samples/ping-pong-inheritance-impl
index 37061b7..a4d464f 100755
--- a/python/samples/ping-pong-inheritance-impl
+++ b/python/samples/ping-pong-inheritance-impl
@@ -1,76 +1,85 @@
 #!/usr/bin/env python
-
-import select
+############################################################################
+#
+# (C) Copyright 2015 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+############################################################################
+# pylint: disable=invalid-name
+""" Sample illustrates the admin operation handling in OI by inheritance way
+"""
+from __future__ import print_function
 import argparse
 
-from pyosaf.saAis import eSaAisErrorT
-
-from pyosaf.utils import immom
-from pyosaf.utils.immoi.implementer import Implementer, AdminOperation
+from pyosaf.utils.immoi.implementer import Implementer, AdminOperationFunction
 from pyosaf.utils.immom.object import ImmObject
 from pyosaf.utils.immom.ccb import Ccb
 
 class_name = "PingPong"
-dn         = "pingPongId=1"
+object_name = "pingPongId=1"
 
-class PingPong(Implementer):
 
+class PingPong(Implementer):
+    """ Define PingPong class inheritance from Implementer class """
     def __init__(self):
-        Implementer.__init__(self, class_names=[class_name])
-
-    @AdminOperation(class_name, 0)
-    def ping(self, dn, arguments):
-        print
-        print
-        print "Pong!"
-        print
+        operations = [AdminOperationFunction(class_name, 0, self.ping),
+                      AdminOperationFunction(class_name, 1, self.pong)]
+        Implementer.__init__(self, class_names=[class_name],
+                             admin_operations=operations)
 
-        self.print_admin_operation_info(dn, arguments)
+    def ping(self, dn, params):
+        print("\nPing!\n")
+        self.print_admin_operation_info(dn, params)
 
-    @AdminOperation(class_name, 1)
-    def pong(self, dn, arguments):
-        print 
-        print
-        print "Ping!"
-        print
+    def pong(self, dn, params):
+        print("\nPong!\n")
+        self.print_admin_operation_info(dn, params)
 
-        self.print_admin_operation_info(dn, arguments)
+    @staticmethod
+    def print_admin_operation_info(dn, params):
+        print("INFO: I am %s" % dn)
 
-    def print_admin_operation_info(self, dn, arguments):
-        print "INFO: I am %s" % dn
+        if params:
+            print("INFO: Received parameters")
 
-        if arguments:
-            print "INFO: Received arguments"
+            for param in params:
+                print(" - %s: %s (%s)" % (param.name, param.value, param.type))
 
-            for argument in arguments:
-                print " - %s: %s (%s)" % \
-                    (argument.name, argument.value, argument.type)
 
 if __name__ == '__main__':
-
     # Parse command line arguments
-    parser = argparse.ArgumentParser(
-        description='''Logs and replies to admin operations 0 and 1 towards %s,
-and replies
-
-Use like this:
+    description = """
+    Logs and replies to admin operations 0 and 1 towards %s, and replies
 
-$ ping-pong-inheritance-impl &
+    Use like this:
 
-$ immadm -o [0|1] pingPongId=1 <parameters..>
-''' % dn, formatter_class=argparse.RawTextHelpFormatter)
+    $ ping-pong-inheritance-impl &
 
+    $ immadm -o [0|1] pingPongId=1 <parameters..>
+    """ % object_name
+    parser = argparse.ArgumentParser(
+        description=description,
+        formatter_class=argparse.RawTextHelpFormatter)
     parser.parse_args()
 
     # Create the ping-pong instance if it doesn't exist
-    if not immom.get(dn):
-
-        with Ccb(flags=None) as ccb:
-            obj = ImmObject(class_name=class_name, dn=dn)
-
-            obj.pingPongId  = "pingPongId=1"
-
-            ccb.create(obj)
+    ccb = Ccb(flags=None)
+    obj = ImmObject(class_name=class_name, dn=object_name)
+    setattr(obj, "pingPongId", object_name)
+    ccb.init()
+    ccb.create(obj=obj)
+    ccb.apply()
 
     # Create the implementer instance
     implementer = PingPong()
diff --git a/python/samples/scale_opensaf b/python/samples/scale_opensaf
index 9c2fff5..3de8632 100755
--- a/python/samples/scale_opensaf
+++ b/python/samples/scale_opensaf
@@ -1,41 +1,60 @@
 #!/usr/bin/env python
-""" Adds and removes IMM configuration for nodes """
-
+############################################################################
+#
+# (C) Copyright 2015 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+############################################################################
+""" The Sample adds and removes IMM configuration for nodes """
+from __future__ import print_function
 import re
 import hashlib
 import time
 import argparse
 import os
 import subprocess
-from pyosaf.utils import immom
+
+from pyosaf.utils.immom.accessor import ImmOmAccessor
 from pyosaf.utils.immom.ccb import Ccb
 from pyosaf.utils.immom.iterator import InstanceIterator as inst_iter
 from pyosaf.saAmf import eSaAmfRedundancyModelT, eSaAmfAdminOperationIdT
 
+
 TWO_N = eSaAmfRedundancyModelT.SA_AMF_2N_REDUNDANCY_MODEL
 NWAYACTIVE = eSaAmfRedundancyModelT.SA_AMF_N_WAY_ACTIVE_REDUNDANCY_MODEL
 NORED = eSaAmfRedundancyModelT.SA_AMF_NO_REDUNDANCY_MODEL
-
 ADMIN_UNLOCK = eSaAmfAdminOperationIdT.SA_AMF_ADMIN_UNLOCK
 ADMIN_LOCK = eSaAmfAdminOperationIdT.SA_AMF_ADMIN_LOCK
 ADMIN_LOCK_IN = eSaAmfAdminOperationIdT.SA_AMF_ADMIN_LOCK_INSTANTIATION
 ADMIN_UNLOCK_IN = eSaAmfAdminOperationIdT.SA_AMF_ADMIN_UNLOCK_INSTANTIATION
+accessor = None
 
 
 def print_object(immobj, new_dn=None):
     """ Print an ImmObject and attributes with the type enum """
     if new_dn:
-        print new_dn
+        print(new_dn)
     else:
-        print immobj.dn
+        print(immobj.dn)
     for key, value in immobj.attrs.iteritems():
         val = ''
-        if len(value[1]):
+        if value[1]:
             val = value[1]
             if value[1][0]:
                 val = value[1][0]
         if val:
-            print '\t{0}: {1} : {2}'.format(key, val, value[0])
+            print('\t{0}: {1} : {2}'.format(key, val, value[0]))
 
 
 def find_object_type(class_name, parent_list):
@@ -44,7 +63,9 @@ def find_object_type(class_name, parent_list):
     """
     result = []
     for par in parent_list:
-        for immobj in inst_iter(class_name, par.dn):
+        _iter = inst_iter(class_name, par.dn)
+        _iter.init()
+        for immobj in _iter:
             result.append(immobj)
     return result
 
@@ -53,7 +74,9 @@ def find_node_dns(hostname):
     """ Find the DNs of CLM and AMF node for the hostname
         returns: AMF node DN and CLM node DN
     """
-    for node in inst_iter('SaAmfNode'):
+    _iter = inst_iter('SaAmfNode')
+    _iter.init()
+    for node in _iter:
         # Get the first value part of the DN
         hname = node.saAmfNodeClmNode.split(',')[0].split('=')[1]
         if hname == hostname:
@@ -67,9 +90,9 @@ def redundancy_of_su(su_dn):
     """
     # Get the SG DN from the SU DN
     sg_of_su = su_dn.split(',', 1)[1]
-    itsg = immom.get(sg_of_su)
+    _, itsg = accessor.get(sg_of_su)
     # Get the redundancy from the SG type
-    itsg_t = immom.get(itsg.saAmfSGType)
+    _, itsg_t = accessor.get(itsg.saAmfSGType)
     return itsg_t.saAmfSgtRedundancyModel
 
 
@@ -78,7 +101,9 @@ def find_sus(amfnode_dn, scalable_redundancy):
         returns: list of SUs (ImmObject)
     """
     sus = []
-    for itsu in inst_iter('SaAmfSU'):
+    _iter = inst_iter('SaAmfSU')
+    _iter.init()
+    for itsu in _iter:
         if amfnode_dn == itsu.saAmfSUHostedByNode:
             if redundancy_of_su(itsu.dn) in scalable_redundancy:
                 sus.append(itsu)
@@ -108,13 +133,15 @@ def find_sis_apps(sus, redundancy):
     matched_apps = sorted(set(matched_apps), key=matched_apps.index)
 
     # Collect the SIs protected by the SGs
-    for itsi in inst_iter('SaAmfSI'):
+    _iter = inst_iter('SaAmfSI')
+    _iter.init()
+    for itsi in _iter:
         if itsi.saAmfSIProtectedbySG in matched_sgs:
             protected_sis.append(itsi)
 
     # Collect the SvcTypes of the SUs
     for itsu in matched_sus:
-        su_type = immom.get(itsu.saAmfSUType)
+        _, su_type = accessor.get(itsu.saAmfSUType)
         for svc_type in su_type.saAmfSutProvidesSvcTypes:
             su_svctypes.append(svc_type)
 
@@ -133,7 +160,7 @@ def prepare_for_write(objects):
     """
     conf_objects = []
     for immobj in objects:
-        immobj = immom.get(immobj.dn, ['SA_IMM_SEARCH_GET_CONFIG_ATTR'])
+        _, immobj = accessor.get(immobj.dn, ['SA_IMM_SEARCH_GET_CONFIG_ATTR'])
         del immobj.attrs['SaImmAttrAdminOwnerName']
         del immobj.attrs['SaImmAttrClassName']
         del immobj.attrs['SaImmAttrImplementerName']
@@ -144,7 +171,9 @@ def prepare_for_write(objects):
 def find_node_groups(amf_node):
     """ fetch all node groups a node belongs to """
     matching_groups = []
-    for ngrp in inst_iter('SaAmfNodeGroup'):
+    _iter = inst_iter('SaAmfNodeGroup')
+    _iter.init()
+    for ngrp in _iter:
         if str.find(''.join(ngrp.saAmfNGNodeList), amf_node) >= 0:
             matching_groups.append(ngrp)
     return matching_groups
@@ -163,11 +192,13 @@ def collect_scalable_immobjects(from_amfnode_dn, 
from_clmnode_dn):
     csiattrs = find_object_type('SaAmfCSIAttribute', csis)
 
     swbundles = []
-    for immobj in inst_iter('SaAmfNodeSwBundle', from_amfnode_dn):
+    _iter = inst_iter(class_name='SaAmfNodeSwBundle', 
root_name=from_amfnode_dn)
+    _iter.init()
+    for immobj in _iter:
         swbundles.append(immobj)
 
-    from_amfnode = immom.get(from_amfnode_dn)
-    from_clmnode = immom.get(from_clmnode_dn)
+    _, from_amfnode = accessor.get(from_amfnode_dn)
+    _, from_clmnode = accessor.get(from_clmnode_dn)
 
     # Order is important
     return [from_amfnode, from_clmnode] + sus + sis + csis + comps + \
@@ -225,22 +256,24 @@ def scale_out(new_hostname, from_hostname):
             new_hostname - hostname of the new node
             from_hostname - hostname of the template node
     """
-    print '-Scaling out to [%s] config copied from [%s]' % (new_hostname,
-                                                            from_hostname)
-    for itsu in inst_iter('SaAmfSU'):
+    print('-Scaling out to [%s] config copied from [%s]' % (new_hostname,
+                                                            from_hostname))
+    print(new_hostname)
+    print(from_hostname)
+    _iter = inst_iter('SaAmfSU')
+    _iter.init()
+    for itsu in _iter:
         # Get the first value part of the DN
         hname = itsu.saAmfSUHostedByNode.split(',')[0].split('=')[1]
         if hname == new_hostname:
-            print 'Node already has SUs, no scaling-out done'
+            print('Node already has SUs, no scaling-out done')
             return 0
 
-    new_amfnode = new_hostname
     from_amfnode_dn, from_clmnode_dn = find_node_dns(from_hostname)
-    new_amfnode_dn = re.sub('safAmfNode=[^,]*,', 'safAmfNode={0},'.
-                            format(new_amfnode), from_amfnode_dn)
+    new_amfnode_dn = from_amfnode_dn.replace(from_hostname, new_hostname)
     objects = collect_scalable_immobjects(from_amfnode_dn, from_clmnode_dn)
     conf_objects = prepare_for_write(objects)
-    #nodegroups_to_join = find_node_groups(from_amfnode_dn)
+    # nodegroups_to_join = find_node_groups(from_amfnode_dn)
 
     suffix = str(time.time())
     for immobj in conf_objects:
@@ -255,6 +288,7 @@ def scale_out(new_hostname, from_hostname):
             objs.append(obj)
 
     ccb = Ccb(flags=None)
+    ccb.init()
 
     for immobj in objs:
         rdn, parent = split_rdn_and_parent(immobj)
@@ -263,31 +297,33 @@ def scale_out(new_hostname, from_hostname):
         del immobj.attrs['new_dn']
         ccb.create(immobj, parent)
     ccb.apply()
-    print '-Scaling out done'
+    print('-Scaling out done')
 
 
 def scale_in(hostname):
     """ Remove the configuration for the host node """
-    print '-Scaling in: %s' % hostname
+    print('-Scaling in: %s' % hostname)
     amfnode_dn, clmnode_dn = find_node_dns(hostname)
-    clmnode = immom.get(clmnode_dn)
-    amfnode = immom.get(amfnode_dn)
+    _, clmnode = accessor.get(clmnode_dn)
+    _, amfnode = accessor.get(amfnode_dn)
 
     subprocess.call(['amf-adm', 'lock', clmnode_dn])
 
     sus = find_sus(amfnode_dn, [TWO_N, NWAYACTIVE, NORED])
 
     ccb = Ccb(flags=None)
+    ccb.init()
     ccb.delete(amfnode.dn)
     ccb.delete(clmnode.dn)
     for itsu in sus:
-        print itsu.dn
+        print(itsu.dn)
         ccb.delete(itsu.dn)
 
     sis, apps = find_sis_apps(sus, NORED)
     for itsi in sis:
         # Check if this SI has a assignment
         siass = inst_iter('SaAmfSIAssignment')
+        siass.init()
         assigned = [ass for ass in siass if str.find(ass.dn, itsi.dn) != -1]
 
         # Check if the SU App is used by this SI... Why? Not sure, the example
@@ -297,15 +333,18 @@ def scale_in(hostname):
         if not assigned and usedapp and si_app in apps:
             csis = find_object_type('SaAmfCSI', [itsi])
             for csi in csis:
-                print csi.dn
+                print(csi.dn)
                 ccb.delete(csi.dn)
-            print itsi.dn
+            print(itsi.dn)
             ccb.delete(itsi.dn)
     ccb.apply()
-    print '-Scaling in done'
+    print('-Scaling in done')
 
 
 if __name__ == '__main__':
+    accessor = ImmOmAccessor()
+    accessor.init()
+
     parser = argparse.ArgumentParser(
         description='Scales OpenSAF by adding and removing node configuration')
     parser.add_argument(
diff --git a/python/samples/time-reporter b/python/samples/time-reporter
index d183b6b..3246493 100755
--- a/python/samples/time-reporter
+++ b/python/samples/time-reporter
@@ -1,64 +1,83 @@
 #!/usr/bin/env python
-
+############################################################################
+#
+# (C) Copyright 2015 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+############################################################################
+# pylint: disable=invalid-name
+
+""" Sample illustrates runtime attribute update """
+from __future__ import print_function
+import sys
 import select
 import datetime
 import argparse
 
-from pyosaf.utils import immom, immoi
+from pyosaf.saAis import eSaAisErrorT
 from pyosaf.utils.immoi.implementer import Implementer
 from pyosaf.utils.immom.object import ImmObject
 
+
 class_name = "TimeSample"
-dn         = "timeId=1"
-timeout    = 1
+dn = "timeId=1"
+timeout = 1
+
 
 def get_time():
+    """ Get current time """
     now = datetime.datetime.now()
+    return now.hour, now.minute, now.second
 
-    return (now.hour, now.minute, now.second)
 
 def select_loop(implementer):
-
+    """ Forever loop """
     # Get selection object for the implementer
     selection_object = implementer.get_selection_object()
 
     # Wait for next OI event or one second timeout
-    inputs  = [selection_object]
+    inputs = [selection_object.value]
     outputs = []
 
     while inputs:
+        ieo = select.select(inputs, outputs, inputs, timeout)
 
-        readable, writable, exceptional = \
-        select.select(inputs, outputs, inputs, timeout)
-
-        if selection_object in readable:
+        if selection_object in ieo[0]:
             implementer.dispatch()
         else:
-
             # Update the time
-            (hours, minutes, seconds) = get_time()
-
-            attributes = {'hours'   : hours,
-                          'minutes' : minutes,
-                          'seconds' : seconds}
-
+            _hours, _minutes, _seconds = get_time()
+            attributes = {'hours': _hours,
+                          'minutes': _minutes,
+                          'seconds': _seconds}
             implementer.update_runtime_attributes(dn, attributes)
 
+
 if __name__ == '__main__':
+    description = """
+    Keeps the timeId=1 object updated with the current time.
+
+    Use like this:
 
+    $ time-reporter &
 
+    $ immlist timeId=1
+    """
     # Parse command line arguments
     parser = argparse.ArgumentParser(
-        description='''Keeps the %s object updated with the current time.
-
-Use like this:
-
-$ time-reporter &
-
-$ immlist timeId=1
-
-''' % dn, formatter_class=argparse.RawTextHelpFormatter)
-
+        description=description,
+        formatter_class=argparse.RawTextHelpFormatter)
     parser.parse_args()
 
     # Create the implementer instance
@@ -68,17 +87,17 @@ $ immlist timeId=1
     (hours, minutes, seconds) = get_time()
 
     # Create the time instance if it doesn't exist
-    try:
-        obj = ImmObject(class_name=class_name, dn=dn)
+    obj = ImmObject(class_name=class_name, dn=dn)
 
-        obj.hours   = hours
-        obj.minutes = minutes
-        obj.seconds = seconds
-        obj.timeId  = "timeId=1"
+    obj.hours = hours
+    obj.minutes = minutes
+    obj.seconds = seconds
+    obj.timeId = "timeId=1"
 
-        time_implementer.create(obj)
-    except Exception as err:
-        pass
+    rc = time_implementer.create(obj)
+    if rc != eSaAisErrorT.SA_AIS_OK:
+        print("Create object failed")
+        sys.exit(1)
 
     # Start dispatch and time update loop
     select_loop(time_implementer)
diff --git a/python/samples/time-reporter-inheritance-impl 
b/python/samples/time-reporter-inheritance-impl
index 6b0e58a..7c0f7d5 100755
--- a/python/samples/time-reporter-inheritance-impl
+++ b/python/samples/time-reporter-inheritance-impl
@@ -1,98 +1,99 @@
 #!/usr/bin/env python
-
+############################################################################
+#
+# (C) Copyright 2015 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+############################################################################
+# pylint: disable=invalid-name
+""" Sample illustrates runtime attribute update by inheritance way """
+from __future__ import print_function
 import select
 import datetime
 import argparse
 
-from pyosaf.utils import immom, immoi
 from pyosaf.utils.immoi.implementer import Implementer
 from pyosaf.utils.immom.object import ImmObject
 
-class_name = "TimeSample"
-dn         = "timeId=1"
-timeout    = 1
 
 class TimeReporter(Implementer):
-    ''' This implementer creates a runtime object and updates it with
-        the current time according to the configured timeout (in seconds)'''
+    """ This implementer creates a runtime object and updates it with
+        the current time according to the configured timeout (in seconds).
+    """
 
     def __init__(self, timeout=1, time_id=1):
-        ''' Initializes this time reporter instance '''
-
+        """ Initializes this time reporter instance """
         Implementer.__init__(self, name="TimeReporter")
-
+        self.dn = "timeId=%s" % time_id
         self.timeout = timeout
-        self.time_id = time_id
+        self.class_name = "TimeSample"
+        self.create_time_instance()
 
     def create_time_instance(self):
-
-        # Create the time instance if it doesn't exist
-        dn = "timeId=%s" % self.time_id
-
-        try:
-            now = datetime.datetime.now()
-
-            obj = ImmObject(class_name=class_name, dn=dn)
-
-            obj.hours   = now.hour
-            obj.minutes = now.minute
-            obj.seconds = now.second
-            obj.timeId  = "timeId=%" % self.time_id
-
-            self.create(obj)
-        except Exception as err:
-            pass
+        """ Create the time instance if it doesn't exist """
+        now = datetime.datetime.now()
+        obj = ImmObject(class_name=self.class_name, dn=self.dn)
+        obj.hours = now.hour
+        obj.minutes = now.minute
+        obj.seconds = now.second
+        obj.timeId = self.dn
+        self.create(obj)
 
     def enter_dispatch_loop(self):
-        ''' 
-            Loops continuously and dispatches callbacks or updates the 
+        """ Loops continuously and dispatches callbacks or updates the
             current time
-        '''
-
+        """
         # Get selection object for the implementer
         selection_object = self.get_selection_object()
 
         # Wait for next OI event or one second timeout
-        inputs  = [selection_object]
+        inputs = [selection_object.value]
         outputs = []
 
         while inputs:
+            ioe = select.select(inputs, outputs, inputs, self.timeout)
 
-            readable, writable, exceptional = \
-            select.select(inputs, outputs, inputs, self.timeout)
-
-            if selection_object in readable:
+            if selection_object in ioe[0]:
                 self.dispatch()
             else:
-
                 # Update the time
                 now = datetime.datetime.now()
+                attributes = {'hours': now.hour,
+                              'minutes': now.minute,
+                              'seconds': now.second}
+                self.update_runtime_attributes(self.dn, attributes)
 
-                attributes = {'hours'   : now.hour,
-                              'minutes' : now.minute,
-                              'seconds' : now.second}
-
-                self.update_runtime_attributes(dn, attributes)
 
 if __name__ == '__main__':
-
     # Parse command line arguments
-    parser = argparse.ArgumentParser(
-        description='''Keeps the %s object updated with the current time.
-
-Use like this:
+    description = """
+    Keeps the timeId=1 object updated with the current time.
 
-$ time-reporter-inheritance-impl &
+    Use like this:
 
-$ immlist timeId=1
+    $ time-reporter-inheritance-impl &
 
-''' % dn, formatter_class=argparse.RawTextHelpFormatter)
+    $ immlist timeId=1
+    """
+    parser = argparse.ArgumentParser(
+        description=description,
+        formatter_class=argparse.RawTextHelpFormatter)
 
     parser.parse_args()
 
     # Create the implementer instance
-    time_implementer = TimeReporter(time_id=1)
-
+    time_implementer = TimeReporter()
 
     # Start dispatch and time update loop
     time_implementer.enter_dispatch_loop()
diff --git a/python/samples/tones b/python/samples/tones
index eef1f9a..55e01e0 100755
--- a/python/samples/tones
+++ b/python/samples/tones
@@ -1,36 +1,56 @@
 #!/usr/bin/env python
+############################################################################
+#
+# (C) Copyright 2015 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+############################################################################
+""" This is a Tones application give usage Implementer handle create object """
+import argparse
 
-from pyosaf.utils.immoi import implementer
+from pyosaf.utils.immoi.implementer import Implementer, Constraints
 
-import argparse
 
 tone_class_names = ["Do", "Re", "Mi", "Fa", "So", "La", "Ti"]
 
-        
-if __name__ == "__main__":
 
+if __name__ == "__main__":
     # Parse command line arguments
-    parser = argparse.ArgumentParser(
-        description=('''Ensures that instances of %s can only be created in 
this '
-                     'order.
+    description = """
+    Ensures that instances of %s can only be created in this order.
+
+    Use like this:
 
-Use like this:
+    $ tones &
 
-$ tones &
+    $ immcfg -c Do doId=1                 (allowed)
 
-$ immcfg -c Do doId=1                 (allowed)
+    $ immcfg -c Re reId=1,doId=1          (allowed)
 
-$ immcfg -c Re reId=1,doId=1          (allowed)
+    $ immcfg -c Do doId=1,reId=1,doId=1   (not allowed)
 
-$ immcfg -c Do doId=1,reId=1,doId=1   (not allowed)
+    $ immcfg -c Mi miId=1                 (not allowed)
+    """ % ', '.join(tone_class_names)
 
-$ immcfg -c Mi miId=1                 (not allowed)
-''') % ', '.join(tone_class_names), 
formatter_class=argparse.RawTextHelpFormatter)
+    parser = argparse.ArgumentParser(
+        description=description,
+        formatter_class=argparse.RawTextHelpFormatter)
 
     args = parser.parse_args()
 
     # Set up containment constraints
-    constraints = implementer.Constraints()
+    constraints = Constraints()
 
     constraints.add_allowed_containment('Do', 'Re', upper=1)
     constraints.add_allowed_containment('Re', 'Mi', upper=1)
@@ -40,8 +60,8 @@ $ immcfg -c Mi miId=1                 (not allowed)
     constraints.add_allowed_containment('La', 'Ti', upper=1)
 
     # Create the implementer
-    tones_implementer = implementer.Implementer(class_names=tone_class_names,
-                                                name="TonesImplementer")
+    tones_implementer = Implementer(class_names=tone_class_names,
+                                    name="TonesImplementer")
 
     tones_implementer.set_constraints(constraints)
 
diff --git a/python/samples/tones-inheritance-impl 
b/python/samples/tones-inheritance-impl
index aafe69f..3d02fe0 100755
--- a/python/samples/tones-inheritance-impl
+++ b/python/samples/tones-inheritance-impl
@@ -1,13 +1,34 @@
 #!/usr/bin/env python
+############################################################################
+#
+# (C) Copyright 2015 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+############################################################################
+# pylint: disable=invalid-name
+""" This is a Tones application give usage Implementer handle create object by
+    inheritance way
+"""
+import argparse
 
 from pyosaf.utils.immoi.implementer import Implementer, Constraints
 
-import argparse
 
 tone_class_names = ["Do", "Re", "Mi", "Fa", "So", "La", "Ti"]
 
-class Tones(Implementer):
 
+class Tones(Implementer):
     def __init__(self):
 
         Implementer.__init__(self, class_names=tone_class_names,
@@ -25,26 +46,28 @@ class Tones(Implementer):
 
         self.set_constraints(constraints)
 
-        
-if __name__ == "__main__":
 
+if __name__ == "__main__":
     # Parse command line arguments
-    parser = argparse.ArgumentParser(
-        description=('''Ensures that instances of %s can only be created in 
this '
-                     'order.
+    description = """
+    Ensures that instances of %s can only be created in this order.
 
-Use like this:
+    Use like this:
 
-$ tones-inheritance-impl &
+    $ tones &
 
-$ immcfg -c Do doId=1                 (allowed)
+    $ immcfg -c Do doId=1                 (allowed)
 
-$ immcfg -c Re reId=1,doId=1          (allowed)
+    $ immcfg -c Re reId=1,doId=1          (allowed)
 
-$ immcfg -c Do doId=1,reId=1,doId=1   (not allowed)
+    $ immcfg -c Do doId=1,reId=1,doId=1   (not allowed)
 
-$ immcfg -c Mi miId=1                 (not allowed)
-''') % ', '.join(tone_class_names), 
formatter_class=argparse.RawTextHelpFormatter)
+    $ immcfg -c Mi miId=1                 (not allowed)
+    """ % ', '.join(tone_class_names)
+
+    parser = argparse.ArgumentParser(
+        description=description,
+        formatter_class=argparse.RawTextHelpFormatter)
 
     args = parser.parse_args()
 
diff --git a/python/samples/users b/python/samples/users
index b7f3e68..6e2c541 100755
--- a/python/samples/users
+++ b/python/samples/users
@@ -1,32 +1,57 @@
 #!/usr/bin/env python
+############################################################################
+#
+# (C) Copyright 2015 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+############################################################################
+# pylint: disable=deprecated-lambda
+# pylint: disable=unused-argument
+# pylint: disable=import-error
+""" This is a Tones application give usage Implementer to create object """
+import argparse
+import psutil
 
 from pyosaf import saAis
-from pyosaf.utils import immom, immoi, SafException
+from pyosaf.utils import SafException
 from pyosaf.utils.immom.object import ImmObject
 from pyosaf.utils.immoi.implementer import Implementer
 
-import psutil
-import argparse
-
-class_name='UsersSampleClass'
 
 def on_attribute_update(*args):
+    """ Update attribute callback function """
     return list(set(map(lambda x: x.name, psutil.users())))
 
-if __name__ == '__main__':
 
+if __name__ == '__main__':
     # Parse command line arguments
-    parser = argparse.ArgumentParser(
-        description='''Creates the usersId=1 object and updates its users
-attribute with the current list of logged in users when it is read
-in IMM.
+    description = """
+    Creates the usersId=1 object and updates its users attribute with the
+    current list of logged in users when it is read in IMM.
 
-Use like this:
+    Make sure 'psutil' library installed on Opensaf environment, if NOT
+    please follow command: $sudo pip install psutil
 
-$ users &
+    Use like this:
 
-$ immlist usersId=1
-''', formatter_class=argparse.RawTextHelpFormatter)
+    $ users &
+
+    $ immlist usersId=1
+    """
+    parser = argparse.ArgumentParser(
+        description=description,
+        formatter_class=argparse.RawTextHelpFormatter)
 
     parser.parse_args()
 
@@ -34,7 +59,7 @@ $ immlist usersId=1
                                     name='UsersImplementer')
 
     try:
-        obj = ImmObject(class_name=class_name, dn='usersId=1')
+        obj = ImmObject(class_name='UsersSampleClass', dn='usersId=1')
 
         obj.usersId = 'usersId=1'
 
@@ -42,5 +67,5 @@ $ immlist usersId=1
     except SafException as err:
         if not err.value == saAis.eSaAisErrorT.SA_AIS_ERR_EXIST:
             raise err
-        
+
     users_implementer.enter_dispatch_loop()
diff --git a/python/samples/users-inheritance-impl 
b/python/samples/users-inheritance-impl
index 14a0f7b..d0765e3 100755
--- a/python/samples/users-inheritance-impl
+++ b/python/samples/users-inheritance-impl
@@ -1,44 +1,68 @@
 #!/usr/bin/env python
+############################################################################
+#
+# (C) Copyright 2015 The OpenSAF Foundation
+# (C) Copyright 2018 Ericsson AB. All rights reserved.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
+# under the GNU Lesser General Public License Version 2.1, February 1999.
+# The complete license can be accessed from the following location:
+# http://opensource.org/licenses/lgpl-license.php
+# See the Copying file included with the OpenSAF distribution for full
+# licensing terms.
+#
+# Author(s): Ericsson AB
+#
+############################################################################
+# pylint: disable=deprecated-lambda
+# pylint: disable=invalid-name
+# pylint: disable=import-error
+""" This is a Tones application give usage inheritance from Implementer
+    and use subclass to create object
+"""
+import argparse
+import psutil
 
 from pyosaf import saAis
-from pyosaf.utils import immom, immoi, SafException
+from pyosaf.utils import SafException
 from pyosaf.utils.immom.object import ImmObject
 from pyosaf.utils.immoi.implementer import Implementer
 
-import psutil
-import argparse
-
-class_name='UsersSampleClass'
 
 class UsersImplementer(Implementer):
-
     def __init__(self):
         Implementer.__init__(self, name='UsersImplementer')
 
-    def on_runtime_values_get(self, name, class_name, attribute):
+    def on_runtime_values_get(self, name, class_name, attribute_name):
         return list(set(map(lambda x: x.name, psutil.users())))
 
+
 if __name__ == '__main__':
+    description = """
+    Creates the usersId=1 object and updates its users attribute with the
+    current list of logged in users when it is read in IMM.
 
-    # Parse command line arguments
-    parser = argparse.ArgumentParser(
-        description='''Creates the usersId=1 object and updates its users
-attribute with the current list of logged in users when it is read
-in IMM.
+    Make sure 'psutil' library installed on Opensaf environment, if NOT
+    please follow command: $sudo pip install psutil
 
-Use like this:
+    Use like this:
 
-$ users-inheritance-impl &
+    $ users-inheritance-impl &
 
-$ immlist usersId=1
-''', formatter_class=argparse.RawTextHelpFormatter)
+    $ immlist usersId=1
+    """
+    # Parse command line arguments
+    parser = argparse.ArgumentParser(
+        description=description, formatter_class=argparse.RawTextHelpFormatter)
 
     parser.parse_args()
 
     users_implementer = UsersImplementer()
 
     try:
-        obj = ImmObject(class_name=class_name, dn='usersId=1')
+        obj = ImmObject(class_name='UsersSampleClass', dn='usersId=1')
 
         obj.usersId = 'usersId=1'
 
@@ -46,5 +70,5 @@ $ immlist usersId=1
     except SafException as err:
         if not err.value == saAis.eSaAisErrorT.SA_AIS_ERR_EXIST:
             raise err
-        
+
     users_implementer.enter_dispatch_loop()
-- 
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

Reply via email to