Example #1
0
    def delete(self, _object_name):
        ''' Adds a delete operation of the object with the given DN to the
            CCB'''

        if _object_name is None:
            raise SafException(eSaAisErrorT.SA_AIS_ERR_NOT_EXIST)

        object_name = SaNameT(_object_name)
        object_names = [object_name]

        immom.saImmOmAdminOwnerSet(self.owner_handle, object_names,
                                   eSaImmScopeT.SA_IMM_SUBTREE)

        immom.saImmOmCcbObjectDelete(self.ccb_handle, object_name)
Example #2
0
    def create(self, obj, _parent_name=None):
        ''' add to the CCB the object 'obj' '''
        if _parent_name is not None:
            parent_name = SaNameT(_parent_name)
            object_names = [parent_name]
            immom.saImmOmAdminOwnerSet(self.owner_handle, object_names,
                                       eSaImmScopeT.SA_IMM_SUBTREE)
        else:
            parent_name = None

        attr_values = []
        for attr_name, type_values in obj.attrs.iteritems():
            values = type_values[1]
            attr = SaImmAttrValuesT_2()
            attr.attrName = attr_name
            attr.attrValueType = type_values[0]
            attr.attrValuesNumber = len(values)
            attr.attrValues = marshal_c_array(attr.attrValueType, values)
            attr_values.append(attr)

        immom.saImmOmCcbObjectCreate_2(self.ccb_handle, obj.class_name,
                                       parent_name, attr_values)
Example #3
0
    def modify_value_add(self, object_name, attr_name, values):
        ''' add to the CCB an ADD modification of an existing object '''

        assert object_name

        # Make sure the values field is a list
        if not isinstance(values, list):
            values = [values]

        # first get class name to read class description to get value type...
        try:
            obj = immom.get(object_name)
        except SafException as err:
            print "failed: %s" % err
            return

        object_names = [SaNameT(object_name)]
        class_name = obj.SaImmAttrClassName
        value_type = None
        attr_def_list = immom.class_description_get(class_name)
        for attr_def in attr_def_list:
            if attr_def.attrName == attr_name:
                value_type = attr_def.attrValueType
                break

        if value_type is None:
            # means attribute name is invalid
            raise SafException(eSaAisErrorT.SA_AIS_ERR_NOT_EXIST,
                               "attribute '%s' does not exist" % attr_name)

        err = immom.saImmOmAdminOwnerSet(self.owner_handle, object_names,
                                         eSaImmScopeT.SA_IMM_ONE)

        attr_mods = []

        attr_mod = saImmOm.SaImmAttrModificationT_2()
        attr_mod.modType = \
            saImm.eSaImmAttrModificationTypeT.SA_IMM_ATTR_VALUES_ADD
        attr_mod.modAttr = SaImmAttrValuesT_2()
        attr_mod.modAttr.attrName = attr_name
        attr_mod.modAttr.attrValueType = value_type
        attr_mod.modAttr.attrValuesNumber = len(values)
        attr_mod.modAttr.attrValues = marshal_c_array(value_type, values)

        attr_mods.append(attr_mod)

        err = immom.saImmOmCcbObjectModify_2(self.ccb_handle, object_names[0],
                                             attr_mods)