Ejemplo n.º 1
0
def get_available_classes_in_imm():
    ''' Returns a list of all available classes in IMM

        Safe to call from OI callbacks
    '''

    opensaf_imm = immom.get(OPENSAF_IMM_OBJECT)

    return opensaf_imm.opensafImmClassNames
Ejemplo n.º 2
0
def get_class_name_for_dn(dn):
    ''' returns the class name for an instance with the given dn '''

    obj = immom.get(dn, ["SaImmAttrClassName"])

    if obj:
        return obj.SaImmAttrClassName
    else:
        return None
Ejemplo n.º 3
0
def get_object_no_runtime(dn):
    ''' returns the IMM object with the given DN

        this is safe to call from OI callbacks as only the config attributes
        will be read

        the function needs to query the class to find config attributes. If
        the class name is known by the caller it can be passed in. Otherwise
        it will be looked up.
    '''

    return immom.get(dn, ['SA_IMM_SEARCH_GET_CONFIG_ATTR'])
Ejemplo n.º 4
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)