Skip to content

Commit

Permalink
Deprecate old type-specific schedule downtime commands
Browse files Browse the repository at this point in the history
  • Loading branch information
nilmerg committed Dec 9, 2024
1 parent 464a440 commit f85f893
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 221 deletions.
9 changes: 9 additions & 0 deletions doc/05-Upgrading.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@
Specific version upgrades are described below. Please note that version upgrades are incremental.
If you are upgrading across multiple versions, make sure to follow the steps for each of them.

## Upgrading to Icinga DB Web v1.2

**Deprecations**

The following classes have been deprecated and will be removed in a future release:
* `\Icinga\Module\Icingadb\Command\Object\PropagateHostDowntimeCommand`
* `\Icinga\Module\Icingadb\Command\Object\ScheduleHostDowntimeCommand`
* `\Icinga\Module\Icingadb\Command\Object\ScheduleServiceDowntimeCommand`

## Upgrading to Icinga DB Web v1.1

**Breaking Changes**
Expand Down
19 changes: 9 additions & 10 deletions library/Icingadb/Command/Object/PropagateHostDowntimeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,12 @@

/**
* Schedule and propagate host downtime
*
* @deprecated Use {@see ScheduleDowntimeCommand} instead
*/
class PropagateHostDowntimeCommand extends ScheduleHostDowntimeCommand
{
/**
* Whether the downtime for child hosts are all set to be triggered by this' host downtime
*
* @var bool
*/
protected $triggered = false;
protected $childOption = ScheduleDowntimeCommand::SCHEDULE_CHILDREN;

/**
* Set whether the downtime for child hosts are all set to be triggered by this' host downtime
Expand All @@ -25,9 +22,11 @@ class PropagateHostDowntimeCommand extends ScheduleHostDowntimeCommand
*/
public function setTriggered(bool $triggered = true): self
{
$this->triggered = $triggered;

return $this;
return $this->setChildOption(
$triggered
? ScheduleDowntimeCommand::TRIGGER_CHILDREN
: ScheduleDowntimeCommand::SCHEDULE_CHILDREN
);
}

/**
Expand All @@ -37,6 +36,6 @@ public function setTriggered(bool $triggered = true): self
*/
public function getTriggered(): bool
{
return $this->triggered;
return $this->getChildOption() === ScheduleDowntimeCommand::TRIGGER_CHILDREN;
}
}
32 changes: 2 additions & 30 deletions library/Icingadb/Command/Object/ScheduleHostDowntimeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,9 @@

/**
* Schedule a host downtime
*
* @deprecated Use {@see ScheduleDowntimeCommand} instead
*/
class ScheduleHostDowntimeCommand extends ScheduleServiceDowntimeCommand
{
/**
* Whether to schedule a downtime for all services associated with a particular host
*
* @var bool
*/
protected $forAllServices = false;

/**
* Set whether to schedule a downtime for all services associated with a particular host
*
* @param bool $forAllServices
*
* @return $this
*/
public function setForAllServices(bool $forAllServices = true): self
{
$this->forAllServices = $forAllServices;

return $this;
}

/**
* Get whether to schedule a downtime for all services associated with a particular host
*
* @return bool
*/
public function getForAllServices(): bool
{
return $this->forAllServices;
}
}
184 changes: 3 additions & 181 deletions library/Icingadb/Command/Object/ScheduleServiceDowntimeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,189 +6,11 @@

/**
* Schedule a service downtime
*
* @deprecated Use {@see ScheduleDowntimeCommand} instead
*/
class ScheduleServiceDowntimeCommand extends AddCommentCommand
class ScheduleServiceDowntimeCommand extends ScheduleDowntimeCommand
{
/**
* Downtime starts at the exact time specified
*
* If `Downtime::$fixed' is set to false, the time between `Downtime::$start' and `Downtime::$end' at which a
* host or service transitions to a problem state determines the time at which the downtime actually starts.
* The downtime will then last for `Downtime::$duration' seconds.
*
* @var int Unix timestamp
*/
protected $start;

/**
* Downtime ends at the exact time specified
*
* If `Downtime::$fixed' is set to false, the time between `Downtime::$start' and `Downtime::$end' at which a
* host or service transitions to a problem state determines the time at which the downtime actually starts.
* The downtime will then last for `Downtime::$duration' seconds.
*
* @var int Unix timestamp
*/
protected $end;

/**
* Whether it's a fixed or flexible downtime
*
* @var bool
*/
protected $fixed = true;

/**
* ID of the downtime which triggers this downtime
*
* The start of this downtime is triggered by the start of the other scheduled host or service downtime.
*
* @var int|null
*/
protected $triggerId;

/**
* The duration in seconds the downtime must last if it's a flexible downtime
*
* If `Downtime::$fixed' is set to false, the downtime will last for the duration in seconds specified, even
* if the host or service recovers before the downtime expires.
*
* @var int|null
*/
protected $duration;

/**
* Set the time when the downtime should start
*
* @param int $start Unix timestamp
*
* @return $this
*/
public function setStart(int $start): self
{
$this->start = $start;

return $this;
}

/**
* Get the time when the downtime should start
*
* @return int Unix timestamp
*/
public function getStart(): int
{
if ($this->start === null) {
throw new \LogicException(
'You are accessing an unset property. Please make sure to set it beforehand.'
);
}

return $this->start;
}

/**
* Set the time when the downtime should end
*
* @param int $end Unix timestamp
*
* @return $this
*/
public function setEnd(int $end): self
{
$this->end = $end;

return $this;
}

/**
* Get the time when the downtime should end
*
* @return int Unix timestamp
*/
public function getEnd(): int
{
if ($this->start === null) {
throw new \LogicException(
'You are accessing an unset property. Please make sure to set it beforehand.'
);
}

return $this->end;
}

/**
* Set whether it's a fixed or flexible downtime
*
* @param boolean $fixed
*
* @return $this
*/
public function setFixed(bool $fixed = true): self
{
$this->fixed = $fixed;

return $this;
}

/**
* Is the downtime fixed?
*
* @return boolean
*/
public function getFixed(): bool
{
return $this->fixed;
}

/**
* Set the ID of the downtime which triggers this downtime
*
* @param int $triggerId
*
* @return $this
*/
public function setTriggerId(int $triggerId): self
{
$this->triggerId = $triggerId;

return $this;
}

/**
* Get the ID of the downtime which triggers this downtime
*
* @return int|null
*/
public function getTriggerId()
{
return $this->triggerId;
}

/**
* Set the duration in seconds the downtime must last if it's a flexible downtime
*
* @param int $duration
*
* @return $this
*/
public function setDuration(int $duration): self
{
$this->duration = $duration;

return $this;
}

/**
* Get the duration in seconds the downtime must last if it's a flexible downtime
*
* @return int|null
*/
public function getDuration()
{
return $this->duration;
}

public function getName(): string
{
return 'ScheduleDowntime';
Expand Down

0 comments on commit f85f893

Please sign in to comment.