Exemplo n.º 1
0
    def initialize(self, track_func=None, node_get_func=None):
        """ Initialize the CLM agent library

        Args:
            track_func (callback): Cluster track callback function
            node_get_func (callback): Cluster node get function

        Returns:
            SaAisErrorT: Return code of the saClmInitialize_4() API call
        """
        self.track_function = track_func
        self.node_get_function = node_get_func

        self.callbacks = saClm.SaClmCallbacksT_4()
        self.callbacks.saClmClusterTrackCallback = \
            saClm.SaClmClusterTrackCallbackT_4(self._track_callback)
        self.callbacks.saClmClusterNodeGetCallback = \
            saClm.SaClmClusterNodeGetCallbackT_4(
                self._node_get_callback)

        self.handle = saClm.SaClmHandleT()
        self.version = deepcopy(self.init_version)
        rc = saClmInitialize_4(self.handle, self.callbacks, self.version)
        if rc != eSaAisErrorT.SA_AIS_OK:
            log_err("saClmInitialize_4 FAILED - %s" % eSaAisErrorT.whatis(rc))

        return rc
Exemplo n.º 2
0
    def _re_init(self):
        """ Internal function to re-initialize the CLM agent in case of getting
        BAD_HANDLE during an operation

        Returns:
            SaAisErrorT: Return code of the corresponding CLM API call(s)
        """
        self.finalize()
        self.handle = saClm.SaClmHandleT()
        self.version = deepcopy(self.init_version)
        rc = saClmInitialize_4(self.handle, self.callbacks, self.version)
        if rc != eSaAisErrorT.SA_AIS_OK:
            log_err("saClmInitialize_4 FAILED - %s" % eSaAisErrorT.whatis(rc))
        else:
            rc = self._fetch_sel_obj()

        return rc
Exemplo n.º 3
0
saClmInitialize_4 = decorate(saClm.saClmInitialize_4)
saClmSelectionObjectGet = decorate(saClm.saClmSelectionObjectGet)
saClmDispatch = decorate(saClm.saClmDispatch)
saClmFinalize = decorate(saClm.saClmFinalize)
saClmClusterTrack = decorate(saClm.saClmClusterTrack)
saClmClusterNodeGet = decorate(saClm.saClmClusterNodeGet)
saClmClusterNotificationFree = decorate(saClm.saClmClusterNotificationFree)
saClmClusterTrack_4 = decorate(saClm.saClmClusterTrack_4)
saClmClusterTrackStop = decorate(saClm.saClmClusterTrackStop)
saClmClusterNotificationFree_4 = decorate(saClm.saClmClusterNotificationFree_4)
saClmClusterNodeGet_4 = decorate(saClm.saClmClusterNodeGet_4)
saClmClusterNodeGetAsync = decorate(saClm.saClmClusterNodeGetAsync)
saClmResponse_4 = decorate(saClm.saClmResponse_4)

# Create the handle
HANDLE = saClm.SaClmHandleT()

track_function = None


def track_callback(c_notification_buffer, c_number_of_members, c_invocation_id,
                   c_root_cause_entity, c_correlation_ids, c_step,
                   c_time_supervision, c_error):

    if track_function:
        added = []
        removed = []

        step = c_step

        if step == saClm.eSaClmChangeStepT.SA_CLM_CHANGE_COMPLETED: