示例#1
0
    def get_object_names_for_class(class_name):
        """ Return instances of the given class

        Args:
            class_name (str): Class name

        Returns:
            list: List of object names
        """
        # Marshall the search parameter
        c_class_name = SaStringT(class_name)
        c_search_param = SaImmSearchParametersT_2()
        c_search_param.searchOneAttr.attrName = SaStringT("SaImmAttrClassName")
        c_search_param.searchOneAttr.attrValueType = \
            eSaImmValueTypeT.SA_IMM_ATTR_SASTRINGT
        c_search_param.searchOneAttr.attrValue = \
            cast(pointer(c_class_name), c_void_p)

        # Create the search iterator
        found_objs = SearchIterator(search_param=c_search_param,
                                    attribute_names=['SaImmAttrClassName'])
        found_objs.init()
        # Return the dn's of found objects
        object_names = []
        for obj in found_objs:
            object_names.append(obj.dn)

        return object_names
示例#2
0
    def _generate_log_stream_open_config(self):
        """ Configure the attributes and flag used to open (or create, if not
        yet existed) an application log stream

        If the stream to open is a config log stream, setting of attributes and
        flag is not allowed, and default values are enforced.

        Returns:
            SaLogFileCreateAttributesT_2: Log file create attributes
            SaLogStreamOpenFlagsT: Log stream open flag
        """
        # Return default values of 'None' for log file create attributes and
        # '0' for log stream open flag if the stream to open is a config stream
        if "safLgStrCfg" in self.logger_info.stream_name:
            return None, 0

        create_attrs = SaLogFileCreateAttributesT_2()
        create_attrs.logFileName = SaStringT(self.logger_info.log_file_name)
        create_attrs.logFilePathName = SaStringT(
            self.logger_info.log_file_path_name)
        create_attrs.maxLogFileSize = self.logger_info.max_log_file_size
        create_attrs.maxLogRecordSize = self.logger_info.max_log_record_size
        create_attrs.haProperty = self.logger_info.ha_property
        create_attrs.logFileFullAction = \
            self.logger_info.log_file_full_action
        create_attrs.maxFilesRotated = self.logger_info.max_files_rotated
        create_attrs.logFileFmt = SaStringT(self.logger_info.log_file_format)

        return create_attrs, saLog.SA_LOG_STREAM_CREATE
示例#3
0
 def __init__(self, class_name, root_name=None):
     name = SaStringT(class_name)
     search_param = SaImmSearchParametersT_2()
     search_param.searchOneAttr.attrName = SaStringT("SaImmAttrClassName")
     search_param.searchOneAttr.attrValueType = \
         eSaImmValueTypeT.SA_IMM_ATTR_SASTRINGT
     search_param.searchOneAttr.attrValue = cast(pointer(name), c_void_p)
     SearchIterator.__init__(self, root_name, search_param=search_param)
示例#4
0
文件: ccb.py 项目: garyclee/opensaf
def _value_to_ctype_ptr(value_type, value):
    """ Convert a value to a ctypes value ptr

    Args:
        value_type (eSaImmValueTypeT): Value type
        value (ptr): Value in pointer

    Returns:
        c_void_p: ctype pointer which points to value
    """
    if value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAINT32T:
        ctypeptr = cast(pointer(SaInt32T(value)), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAUINT32T:
        ctypeptr = cast(pointer(SaUint32T(value)), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAINT64T:
        ctypeptr = cast(pointer(SaInt64T(value)), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAUINT64T:
        ctypeptr = cast(pointer(SaUint64T(value)), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SATIMET:
        ctypeptr = cast(pointer(SaTimeT(value)), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SANAMET:
        ctypeptr = cast(pointer(SaNameT(value)), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAFLOATT:
        ctypeptr = cast(pointer(SaFloatT(value)), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SADOUBLET:
        ctypeptr = cast(pointer(SaDoubleT(value)), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SASTRINGT:
        ctypeptr = cast(pointer(SaStringT(value)), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAANYT:
        assert 0
    else:
        assert 0

    return ctypeptr
示例#5
0
def _value_to_ctype_ptr(value_type, value):
    ''' convert a value to a ctypes value ptr '''
    if value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAINT32T:
        ctypeptr = cast(pointer(SaInt32T(value)), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAUINT32T:
        ctypeptr = cast(pointer(SaUint32T(long(value))), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAINT64T:
        ctypeptr = cast(pointer(SaInt64T(long(value))), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAUINT64T:
        ctypeptr = cast(pointer(SaUint64T(long(value))), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SATIMET:
        ctypeptr = cast(pointer(SaTimeT(long(value))), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SANAMET:
        ctypeptr = cast(pointer(SaNameT(value)), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAFLOATT:
        ctypeptr = cast(pointer(SaFloatT(value)), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SADOUBLET:
        ctypeptr = cast(pointer(SaDoubleT(value)), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SASTRINGT:
        ctypeptr = cast(pointer(SaStringT(value)), c_void_p)
    elif value_type is eSaImmValueTypeT.SA_IMM_ATTR_SAANYT:
        assert 0
    else:
        assert 0

    return ctypeptr
示例#6
0
    def set_error_string(self, ccb_id, error_string):
        """ Set the error string
        This can only be called from within OI callbacks of a real implementer.

        Args:
            ccb_id (SaImmOiCcbIdT): CCB id
            error_string (str): Error string

        Returns:
            SaAisErrorT: Return code of OI CCB set error string
        """
        c_error_string = SaStringT(error_string)
        rc = saImmOiCcbSetErrorString(self.handle, ccb_id, c_error_string)

        if rc != eSaAisErrorT.SA_AIS_OK:
            log_err("saImmOiCcbSetErrorString FAILED - %s" %
                    eSaAisErrorT.whatis(rc))
        return rc
示例#7
0
文件: saImm.py 项目: garyclee/opensaf
	def __init__(self, name, ptype, val):
		pname = SaStringT(name)
		pval = cast(pointer(SaImmValueTypeMap[ptype](val)), SaVoidPtr)
		super(SaImmAdminOperationParamsT_2, self).__init__(
				pname, ptype, pval)