python/pyosaf/utils/immoi/__init__.py | 6 ++++-
python/pyosaf/utils/immoi/implementer.py | 25 +++++++++++++++++--
python/samples/interface-handler-inheritance-version | 2 +-
python/samples/ping-pong | 15 ++++++++++-
python/samples/ping-pong-inheritance-impl | 15 ++++++++++-
5 files changed, 54 insertions(+), 9 deletions(-)
Update according to review comments:
- Add AdminOperationParameter class and use it to pass name, type and value
for each parameter in the upcall
- Update ping-pong sample OI to use the AdminOperationParameter
- Correct creation of root-level DNs and lookup of parent's class in the
completed upcall where the parent is not yet created.
diff --git a/python/pyosaf/utils/immoi/__init__.py
b/python/pyosaf/utils/immoi/__init__.py
--- a/python/pyosaf/utils/immoi/__init__.py
+++ b/python/pyosaf/utils/immoi/__init__.py
@@ -378,7 +378,11 @@ def create_non_existing_imm_object(class
rdn_attribute = get_rdn_attribute_for_class(class_name)
rdn_value = attributes[rdn_attribute][0]
- dn = '%s,%s' % (rdn_value, parent_name)
+ if parent_name:
+ dn = '%s,%s' % (rdn_value, parent_name)
+ else:
+ dn = rdn_value
+
obj = ImmObject(class_name = class_name, dn=dn)
for name, values in attributes.iteritems():
diff --git a/python/pyosaf/utils/immoi/implementer.py
b/python/pyosaf/utils/immoi/implementer.py
--- a/python/pyosaf/utils/immoi/implementer.py
+++ b/python/pyosaf/utils/immoi/implementer.py
@@ -159,6 +159,18 @@ def _collect_full_transaction(ccb_id):
return out
+
+class AdminOperationParameter:
+ ''' This class represents an admin operation parameter '''
+
+ def __init__(self, name, param_type, value):
+ ''' Creates an instance of an admin operation parameter '''
+
+ self.name = name
+ self.type = param_type
+ self.value = value
+
+
# Set up callbacks
def admin_operation(oi_handle, c_invocation_id, c_name, c_operation_id,
c_params):
''' Callback for administrative operations '''
@@ -178,7 +190,9 @@ def admin_operation(oi_handle, c_invocat
value = saImm.unmarshalSaImmValue(paramBuffer, paramType)
- params.append(value)
+ parameter = AdminOperationParameter(paramName, paramType, value)
+
+ params.append(parameter)
# Invoke the operation
result = implementer_instance.admin_operation(operation_id, name, params)
@@ -548,7 +562,13 @@ class Constraints:
if parent_name in deleted:
continue
- parent_class = immoi.get_class_name_for_dn(parent_name)
+ # Avoid looking up the parent class in IMM if possible
+ parent_mos = filter(lambda x: x.dn == parent_name, all_instances)
+
+ if parent_mos:
+ parent_class = parent_mos[0].class_name
+ else:
+ parent_class = immoi.get_class_name_for_dn(parent_name)
# Ignore children where no constraint is defined for the child or
the parent
if not parent_class in self.containments and not \
@@ -569,7 +589,6 @@ class Constraints:
current_children = get_children_with_classname(parent_name,
all_instances,
mo.class_name)
-
# Validate the number of children of the specific class to the
given parent
lower, upper = self.cardinality[(parent_class, mo.class_name)]
diff --git a/python/samples/interface-handler-inheritance-version
b/python/samples/interface-handler-inheritance-impl
rename from python/samples/interface-handler-inheritance-version
rename to python/samples/interface-handler-inheritance-impl
--- a/python/samples/interface-handler-inheritance-version
+++ b/python/samples/interface-handler-inheritance-impl
@@ -92,7 +92,7 @@ class InterfaceImplementer(Implementer):
pass
# Go through existing objects
- for mo in InstanceIterator('InterfaceRO'):
+ for mo in InstanceIterator('InterfaceRO01'):
interface_name = self.get_interface_name_from_dn(mo.dn)
# Remove objects for deleted interfaces
diff --git a/python/samples/ping-pong b/python/samples/ping-pong
--- a/python/samples/ping-pong
+++ b/python/samples/ping-pong
@@ -14,13 +14,24 @@ class_name = "PingPong"
dn = "pingPongId=1"
+def print_admin_operation_info(dn, arguments):
+ print "INFO: I am %s" % dn
+
+ if arguments:
+ print "INFO: Received arguments"
+
+ for argument in arguments:
+ print " - %s: %s (%s)" % \
+ (argument.name, argument.value, argument.type)
+
+
def ping(dn, arguments):
print
print
print "Pong!"
print
- print "INFO: I am %s, received arguments %s" % (dn, arguments)
+ print_admin_operation_info(dn, arguments)
return eSaAisErrorT.SA_AIS_OK
@@ -31,7 +42,7 @@ def pong(dn, arguments):
print "Ping!"
print
- print "INFO: I am %s, received arguments %s" % (dn, arguments)
+ print_admin_operation_info(dn, arguments)
return eSaAisErrorT.SA_AIS_OK
diff --git a/python/samples/ping-pong-inheritance-impl
b/python/samples/ping-pong-inheritance-impl
--- a/python/samples/ping-pong-inheritance-impl
+++ b/python/samples/ping-pong-inheritance-impl
@@ -24,7 +24,8 @@ class PingPong(Implementer):
print
print "Pong!"
print
- print "INFO: I am %s, received arguments %s" % (dn, arguments)
+
+ self.print_admin_operation_info(dn, arguments)
@AdminOperation(class_name, 1)
def pong(self, dn, arguments):
@@ -32,8 +33,18 @@ class PingPong(Implementer):
print
print "Ping!"
print
- print "INFO: I am %s, received arguments %s" % (dn, arguments)
+ self.print_admin_operation_info(dn, arguments)
+
+ def print_admin_operation_info(self, dn, arguments):
+ print "INFO: I am %s" % dn
+
+ if arguments:
+ print "INFO: Received arguments"
+
+ for argument in arguments:
+ print " - %s: %s (%s)" % \
+ (argument.name, argument.value, argument.type)
if __name__ == '__main__':
------------------------------------------------------------------------------
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel