Skip to content

Commit

Permalink
Merge branch 'feature/multiple-tts-integrations-10909'
Browse files Browse the repository at this point in the history
resolves #10909
  • Loading branch information
lippserd committed Apr 13, 2016
2 parents 38e7e0a + 50836e1 commit dddccc4
Show file tree
Hide file tree
Showing 19 changed files with 876 additions and 135 deletions.
8 changes: 5 additions & 3 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.gitignore export-ignore
.gitattributes export-ignore
icingaexchange.yml export-ignore
# Exclude files related to git when creating an archive
.git* export-ignore

# Exclude Icinga Exchange control-file when creating an archive
icingaexchange.yml export-ignore
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Exclude all hidden files
.*

# Except those related to Git and .mailmap
!.git*
!.mailmap
4 changes: 4 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Eric Lippmann <eric.lippmann@netways.de>
Johannes Meyer <johannes.meyer@netways.de>
Marius Hein <marius.hein@netways.de>
Thomas Gelf <thomas@gelf.net>
4 changes: 4 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Eric Lippmann <eric.lippmann@netways.de>
Johannes Meyer <johannes.meyer@netways.de>
Marius Hein <marius.hein@netways.de>
Thomas Gelf <thomas@gelf.net>
339 changes: 339 additions & 0 deletions COPYING

Large diffs are not rendered by default.

39 changes: 20 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,44 @@
# Generic TTS - Icinga Web 2 module

This module is a basic sample implementation of the Icinga Web 2 ticket hook. In
contrast to specialised modules deeply integrating with specific trouble
ticketing systems (TTS), this module only wants to recognize specific patterns
(e.g. #12345) and replace them with a link pointing to the related ticket.
Generic TTS implements Icinga Web 2's ticket hook for replacing ticket patterns
with links to your trouble ticket system (TTS).
Icinga Web 2's core module `monitoring` for example uses the ticket hook for
acknowledgements, downtimes and comments.
Other modules may use the ticket hook for all kinds of text too.

## Installation

Like with any other Icinga Web 2 module just drop me to one of your module
folders and enable the `generictts` module in your web frontend or on CLI.
Of course the `monitoring` module needs to be enabled and that's it, we have no
farther dependencies.
Like with any other Icinga Web 2 module just drop `generictts` into the modules directory and enable
the module in your web frontend or via Web 2's CLI.

This module has no dependencies.

## Configuration

Once installed, nothing will happen, Icinga Web 2 continues to work as it did
before. Things change once you create a configuration in
After you've enabled `generictts` you reach its configuration in Icinga Web 2 via the module's configuration tab.
But you may also change its configuration manually.
`generictts` maintains a configuration file which is normally located at:

ICINGAWEB\_CONFIGDIR/modules/generictts/config.ini
```
/etc/icingaweb2/modules/generictts/config.ini
```

The following sample should perfectly explain all the available settings:

```ini
[ticket]
```
[my-ticket-system]
pattern = "/#([0-9]{4,6})/"
url = "https://my.ticket.system/tickets/id=$1"
```

You need to understand regular expressions for this configuration. What happens
here is that whenever we stumble over a text containing # followed by four to
You have to understand regular expressions for this configuration. What happens
here is that whenever we stumble over a text containing a # followed by four to
six digits, that number will be replaced by a link pointing to that specific
ticket in your TTS.

## TODO

This module has still alpha quality, but works fine so far. A dedicated config
tab with some hints and examples would be great, not everybody speaks regex.
I'd also like to see support for multiple patterns at once, allowing one to
support multiple TTS systems in parallel with a single Icinga Web installation.
Configuration hints and examples would be great because not everybody speaks regex.



Expand Down
23 changes: 0 additions & 23 deletions application/controllers/ConfigController.php

This file was deleted.

117 changes: 117 additions & 0 deletions application/controllers/IntegrationsController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?php
/* Icinga Web 2 | (c) 2016 Icinga Development Team | GPLv2+ */

namespace Icinga\Module\Generictts\Controllers;

use Icinga\Exception\NotFoundError;
use Icinga\Forms\ConfirmRemovalForm;
use Icinga\Module\Generictts\Forms\Config\TtsIntegrationConfigForm;
use Icinga\Web\Controller;
use Icinga\Web\Notification;

/**
* Manage trouble ticket system integrations
*/
class IntegrationsController extends Controller
{
/**
* List trouble ticket system integrations
*/
public function indexAction()
{
$this->getTabs()->add('integrations', array(
'active' => true,
'label' => $this->translate('Integrations'),
'url' => $this->getRequest()->getUrl()
));
$this->view->integrations = $this->Config();
}

/**
* Integrate a new trouble ticket system
*/
public function newAction()
{
$this->getTabs()->add('new-integration', array(
'active' => true,
'label' => $this->translate('New Integration'),
'url' => $this->getRequest()->getUrl()
));

$integrations = new TtsIntegrationConfigForm();
$integrations
->setIniConfig($this->Config())
->setRedirectUrl('generictts/integrations')
->handleRequest();

$this->view->form = $integrations;
}

/**
* Remove a trouble ticket system integration
*/
public function removeAction()
{
$integration = $this->params->getRequired('integration');

$this->getTabs()->add('remove-integration', array(
'active' => true,
'label' => $this->translate('Remove Integration'),
'url' => $this->getRequest()->getUrl()
));

$integrations = new TtsIntegrationConfigForm();
try {
$integrations
->setIniConfig($this->Config())
->bind($integration);
} catch (NotFoundError $e) {
$this->httpNotFound($e->getMessage());
}

$confirmation = new ConfirmRemovalForm(array(
'onSuccess' => function (ConfirmRemovalForm $confirmation) use ($integration, $integrations) {
$integrations->remove($integration);
if ($integrations->save()) {
Notification::success(mt('generictts', 'TTS integration removed'));
return true;
}
return false;
}
));
$confirmation
->setRedirectUrl('generictts/integrations')
->setSubmitLabel($this->translate('Remove Integration'))
->handleRequest();

$this->view->form = $confirmation;
}

/**
* Update a trouble ticket system integration
*/
public function updateAction()
{
$integration = $this->params->getRequired('integration');

$this->getTabs()->add('update-integration', array(
'active' => true,
'label' => $this->translate('Update Integration'),
'url' => $this->getRequest()->getUrl()
));

$integrations = new TtsIntegrationConfigForm();
try {
$integrations
->setIniConfig($this->Config())
->bind($integration);
} catch (NotFoundError $e) {
$this->httpNotFound($e->getMessage());
}
$integrations
->setRedirectUrl('generictts/integrations')
->handleRequest();

$this->view->form = $integrations;
}
}
63 changes: 0 additions & 63 deletions application/forms/Config/GeneralConfigForm.php

This file was deleted.

Loading

0 comments on commit dddccc4

Please sign in to comment.