Exemplo n.º 1
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
Exemplo n.º 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)
Exemplo n.º 3
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
Exemplo n.º 4
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
Exemplo n.º 5
0
    def strategy_delete(self, strategy_uuid, force):
        """
        Delete a software update strategy
        """
        if self.strategy is None:
            reason = "strategy not created"
            return False, reason

        if strategy_uuid != self.strategy.uuid:
            reason = "strategy does not exist"
            return False, reason

        if not force:
            if self.strategy.is_building():
                reason = "strategy is being built, can't delete"
                return False, reason

            if self.strategy.is_applying():
                reason = "strategy is being applied, can't delete"
                return False, reason

            if self.strategy.is_aborting():
                reason = "strategy is being aborted, can't delete"
                return False, reason

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

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

        del self._strategy
        self._strategy = None
        self._persist()

        return True, ''
Exemplo n.º 6
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