Alignak-monitoring-contrib / alignak-app

Desktop application in system tray for Alignak users.
GNU Affero General Public License v3.0
6 stars 2 forks source link

Allow to create a Glpi ticket for problems #297

Open mohierf opened 6 years ago

mohierf commented 6 years ago

As of now, when the App user manages the problems, he/she will acknowledge a problem to inform that the problem is managed. If the problem solution needs more operations, he/she will schedule a downtime to inform that the system is not fully functional.

It is often necessary to log an issue for a problem raised by the monitored system. The proposed solution for raising this issue would be to use the Glpi helpdesk to create a ticket. Several possibilites for this:

  1. Glpi mail collector (the simplest and most generic solution)

    • manage a list of mail templates
    • allow the user to choose a template to create a ticket with a title and problem description
    • send an email
  2. Glpi REST API

    • get the Glpi ticket information (categories, types, templates, ...)
    • allow the user to choose a template to create a ticket with a title and problem description
    • post a new ticket

My prefered one, the mail because it is the most generic solution that will suit to any helpdesk system (en not only Glpi).

The second solution would allow to get more information about the tickets created in Glpi and have some kind of ticket tracking system ... it should be nice also.

@algorys @ddurieux to be discussed

algorys commented 6 years ago

@mohierf I think it could be a good feature to add in the application.

I am not too aware of the difference between the two interfaces but the solution 1 seems to me well.

ddurieux commented 6 years ago

I prefer the API instead mail, because not need email server, creation is direct (mail can have latency)

mohierf commented 6 years ago

I prefer the mail solution because it will be available sooner and it will be usable with other ticketing system than Glpi ... but both solutions are interesting. Perharps, implementing mail first and then the GLPI API ?

algorys commented 6 years ago

To resume:

1. Glpi mail collector:

App will need following data:

Then, if mail is available, a new dialog will be show when user click on mail button. Else, App will turn off the mail button.

So this solution can be easily implemented and quickly :wink: ! It will not ask for any modification or intervention on a GLPI server (if I understood the principle correctly?)

2. Glpi REST API:

App will need following data:

For example:

#!/usr/bin/env python3

import requests

# GET Session Token
glpi_api_url = 'http://GLPI/apirest.php'
user_token = 'USR_TOKEN'
app_token = 'APP_TOKEN'
session_token = ''

headers = {
    'Content-Type': 'application/json',
    'Authorization': 'user_token %s' % user_token,
    'App-Token': '%s' % app_token
}

if not session_token:
    session = requests.get('/'.join([glpi_api_url, 'initSession']), headers=headers)
    session_token = session.json()['session_token']
    print(session_token)

# POST a ticket
headers.pop('Authorization')
headers['Session-Token'] = session_token

data = {
    'input': {
        'type': '1',
        'name': 'Schedule DOWNTIME for Host',
        'content': 'Because it does not work !'
    }
}
ticket = requests.post('/'.join([glpi_api_url, 'Ticket']), headers=headers, json=data)

Obviously, with more data than just the type, name and content. @ddurieux I think you have an idea of what might be interesting ?

I still have not found how to get ticket templates in GLPI...

Otherwise @mohierf and @ddurieux, ticket is created, GLPI add a notification and send it after without problem :wink: