Jump to: navigation, search

Difference between revisions of "Senlin/webhook"

(DB model)
(DB model)
Line 15: Line 15:
 
* id: the uuid of webhook
 
* id: the uuid of webhook
 
* name: the name of webhook (optional)
 
* name: the name of webhook (optional)
* user: the user who created the webhook
+
* user: the id of user who created the webhook
 
* project: the project id of user who created the webhook.
 
* project: the project id of user who created the webhook.
 
* domain: the domain of the user who created the webhook
 
* domain: the domain of the user who created the webhook

Revision as of 05:31, 25 March 2015

Webhook

Webhook is used to trigger a specific action of a senlin entity, typically scaling out/in action of a cluster.

Design

Workflow

1. User create a webhook through webhook API. User need to specify what action and which senlin entity this webhook is linked to. Also for some specific actions, user can define the parameters they want to use when invoking the cluster action API, e.g. the adjustment of scaling operation;
2. Senlin service receives the request and 1)create a webhook object and generate a webhook url, like webhooks/$webhook_id/trigger; 2)make a trust with *senlin* user as trustee and cluster owner as trustor;
3. User get the url of webhook.
4. User trigger the webhook by post a http request to its url. No any credential is needed here.
5. Senlin service handles this post request and generate a new API request to cluster action. *senlin* user's credential is used in this new API request;
6. Senlin service receives the cluster action API request and perform cluster scaling operation;

Implementation

DB model

A webhook DB object includes the following properties:

  • id: the uuid of webhook
  • name: the name of webhook (optional)
  • user: the id of user who created the webhook
  • project: the project id of user who created the webhook.
  • domain: the domain of the user who created the webhook
  • created_time
  • deleted_time
  • obj_id: the id of senlin entity(cluster, or node) the webhook bound to
  • obj_type: the type of senlin entity(cluster, or node) the webhook bound to
  • action: action(scalingin, scalingout) of the target the webhook bound to
  • credential: credential the will be used to invoke target action API, e.g. clusters/$cluster_id/action
  • params: parameters that will be included when invoke the target action API, e.g. adjustment of scaling operation