Exemple #1
0
    def strategy_abort_complete(self, success, reason):
        """
        Abort of a software update strategy complete
        """
        if success:
            event_log.sw_update_issue_log(
                self.event_id(SW_UPDATE_EVENT_IDS.APPLY_ABORTED))
        else:
            event_log.sw_update_issue_log(self.event_id(
                SW_UPDATE_EVENT_IDS.APPLY_ABORT_FAILED),
                                          reason=reason)

        if self._nfvi_timer_id is not None:
            timers.timers_reschedule_timer(self._nfvi_timer_id, 2)
Exemple #2
0
    def strategy_apply_complete(self, success, reason):
        """
        Apply of a software update strategy complete
        """
        if self._alarms:
            alarm.clear_sw_update_alarm(self._alarms)

        if success:
            event_log.sw_update_issue_log(
                self.event_id(SW_UPDATE_EVENT_IDS.APPLY_COMPLETED))
        else:
            self._alarms = \
                alarm.raise_sw_update_alarm(
                    self.alarm_type(SW_UPDATE_ALARM_TYPES.APPLY_FAILED))

            event_log.sw_update_issue_log(self.event_id(
                SW_UPDATE_EVENT_IDS.APPLY_FAILED),
                                          reason=reason)
Exemple #3
0
    def strategy_abort(self, strategy_uuid, stage_id):
        """
        Abort a software update strategy
        """
        success = False

        if self.strategy is None:
            reason = "strategy not created"

        elif strategy_uuid != self.strategy.uuid:
            reason = "strategy does not exist"

        else:
            event_log.sw_update_issue_log(
                self.event_id(SW_UPDATE_EVENT_IDS.APPLY_ABORT))
            success, reason = self.strategy.abort(stage_id)

        if success:
            if self._alarms:
                alarm.clear_sw_update_alarm(self._alarms)

            self._alarms = \
                alarm.raise_sw_update_alarm(
                    self.alarm_type(SW_UPDATE_ALARM_TYPES.APPLY_ABORTING))

            event_log.sw_update_issue_log(
                self.event_id(SW_UPDATE_EVENT_IDS.APPLY_ABORTING))
        else:
            event_log.sw_update_issue_log(self.event_id(
                SW_UPDATE_EVENT_IDS.APPLY_ABORT_REJECTED),
                                          reason=reason)

        return success, reason
Exemple #4
0
    def nfvi_update(self):
        """
        NFVI Update
        """
        if self._strategy is None:
            if self._alarms:
                alarm.clear_sw_update_alarm(self._alarms)
            return False

        if self.strategy.is_applying():
            if not self._alarms:
                self._alarms = \
                    alarm.raise_sw_update_alarm(
                        self.alarm_type(SW_UPDATE_ALARM_TYPES.APPLY_INPROGRESS))

                event_log.sw_update_issue_log(
                    self.event_id(SW_UPDATE_EVENT_IDS.APPLY_INPROGRESS))

        elif self.strategy.is_apply_failed(
        ) or self.strategy.is_apply_timed_out():
            for sw_patch_host in self._nfvi_sw_patch_hosts:
                if sw_patch_host.patch_current:
                    continue

                if not sw_patch_host.requires_reboot:
                    continue

                if not self._alarms:
                    self._alarms = \
                        alarm.raise_sw_update_alarm(
                            self.alarm_type(SW_UPDATE_ALARM_TYPES.APPLY_FAILED))

                    event_log.sw_update_issue_log(
                        self.event_id(SW_UPDATE_EVENT_IDS.APPLY_FAILED))
                break

            else:
                if self._alarms:
                    alarm.clear_sw_update_alarm(self._alarms)
                return False

        elif self.strategy.is_aborting():
            if not self._alarms:
                self._alarms = \
                    alarm.raise_sw_update_alarm(
                        self.alarm_type(SW_UPDATE_ALARM_TYPES.APPLY_ABORTING))

                event_log.sw_update_issue_log(
                    self.event_id(SW_UPDATE_EVENT_IDS.APPLY_ABORTING))

        else:
            if self._alarms:
                alarm.clear_sw_update_alarm(self._alarms)
            return False

        return True
Exemple #5
0
    def nfvi_update(self):
        """
        NFVI Update
        """
        if self._strategy is None:
            if self._alarms:
                alarm.clear_sw_update_alarm(self._alarms)
            return False

        if self.strategy.is_applying():
            if not self._alarms:
                self._alarms = \
                    alarm.raise_sw_update_alarm(
                        self.alarm_type(SW_UPDATE_ALARM_TYPES.APPLY_INPROGRESS))

                event_log.sw_update_issue_log(
                    self.event_id(SW_UPDATE_EVENT_IDS.APPLY_INPROGRESS))

        elif self.strategy.is_apply_failed(
        ) or self.strategy.is_apply_timed_out():
            if not self._alarms:
                self._alarms = \
                    alarm.raise_sw_update_alarm(
                        self.alarm_type(SW_UPDATE_ALARM_TYPES.APPLY_FAILED))

                event_log.sw_update_issue_log(
                    self.event_id(SW_UPDATE_EVENT_IDS.APPLY_FAILED))

        elif self.strategy.is_aborting():
            if not self._alarms:
                self._alarms = \
                    alarm.raise_sw_update_alarm(
                        self.alarm_type(SW_UPDATE_ALARM_TYPES.APPLY_ABORTING))

                event_log.sw_update_issue_log(
                    self.event_id(SW_UPDATE_EVENT_IDS.APPLY_ABORTING))

        else:
            if self._alarms:
                alarm.clear_sw_update_alarm(self._alarms)
            return False

        return True
Exemple #6
0
    def strategy_apply(self, strategy_uuid, stage_id):
        """
        Apply a software update strategy
        """
        success = False

        if self.strategy is None:
            reason = "strategy not created"

        elif strategy_uuid != self.strategy.uuid:
            reason = "strategy does not exist"

        else:
            event_log.sw_update_issue_log(
                self.event_id(SW_UPDATE_EVENT_IDS.APPLY_START))
            success, reason = self.strategy.apply(stage_id)

        if success:
            if self._alarms:
                alarm.clear_sw_update_alarm(self._alarms)

            self._alarms = \
                alarm.raise_sw_update_alarm(
                    self.alarm_type(SW_UPDATE_ALARM_TYPES.APPLY_INPROGRESS))

            event_log.sw_update_issue_log(
                self.event_id(SW_UPDATE_EVENT_IDS.APPLY_INPROGRESS))

            if self._nfvi_timer_id is not None:
                timers.timers_delete_timer(self._nfvi_timer_id)
                self._nfvi_timer_id = None

            self._nfvi_timer_id = \
                timers.timers_create_timer(self._nfvi_timer_name, 30, 30,
                                           self.nfvi_audit)
        else:
            event_log.sw_update_issue_log(self.event_id(
                SW_UPDATE_EVENT_IDS.APPLY_REJECTED),
                                          reason=reason)

        return success, reason