Learning OpenStack Message (Zaqar) with authenticating Token and sending requests to API, Hostripples Web Hosting

Learning OpenStack Message (Zaqar) with authenticating Token and sending requests to API

OpenStack Message (Zaqar) is one of the components of OpenStack. Today we are going to learn the concept of Zaqar as well as how to authenticate Token and how to send a request to API.

Concept of Zaqar:

Zaqar is a multi-project cloud messaging as well as notification service which is helpful to the web developers and also to the mobile developers.

With the help of different types of communication methods, the web and mobile developers use REST API for sending messages among the several components of SaaS and various applications of mobile. The concept of “REST API” is based on an effective messaging engine which is designed and developed by keeping in mind flexibility and safety. Zaqar service makes available one more API known as “Websocket”.

Zaqar integrates with some other components of OpenStack for external tasks related to end users and also for communicating with the agents which work in the over-cloud layer.

Main features of Zaqar are as follows:

  1. Zaqar provides two options to choose from two different communication channels or transports. Both of them are supported by Keystone:
  2. Favorable for firewall, RESTful API based on HTTP. A lot of current developers give preference to the HTTP API which is web friendly. These developers like the features offered by this service like the easiness and the clarity of this protocol, its nature of firewall friendliness and a large medium of tools, balancing out loads and substitutes.
  3. API based on WebSocket is required for constant connections. This protocol makes it possible to communicate over constant connections. In contrast to WebSocket protocol which is able to transfer more than one request/response through one TCP connection, the HTTP protocol, makes fresh connections open for every request/response pair. Thus it helps to save the network traffic and also decreases the slowdowns or the delays.
  4. Multi projects form a queue depending upon their keystone project IDs.
  5. Provides support to different similar methods which include broadcasting events, distributing tasks and messaging point to point.
  6. Zaqar has an architecture which is component based and it also supports custom backends as well as the message filters.
  7. Depending upon the backend, Zaqar provides effective resource implementation by maintaining minimum latency and maximum output.
  8. Zaqar offers support to the subscriptions for the queues. Following types of notifications are available:
  9. Websocket notifications.
  10. Email notifications.
  11. Webhook notifications.

Also read,

Scope of Zaqar project:

Zaqar never preplans for message brokers and it never reveals those messages directly to the clients, because the Zaqar API is data oriented. The Zaqar API rather than acting as a bond between the client and single or multiple backends, a preplanning service of the message brokers like RabbitMQ, ActiveMQ, despite helpful, acts as a relatively separate market from the one which Zaqar is aiming at today. Taking this into account, if any user is interested in preplanning a message broker service then the Zaqar community must think about beginning a fresh project for addressing that requirement or need.

Guidelines for designing Zaqar:

Following guidelines are required to keep in mind while designing Zaqar same as with all OpenStack projects:

  1. As mentioned earlier, the first guideline is component-based architecture for immediately adding new actions.
  2. We have already discussed that Zaqar is highly available as well as versatile for scaling to very critical workloads.
  3. It is fault resistant so that separate tasks can exclude the failures due to overflowing.
  4. Failures are recoverable as well as easy to identify, compile and provide a solution.
  5. Maintaining open standards, providing a resource implementation for an environment which is community driven.

How to generate an authentication token:

For generating an authentication token you can take help of cURL for trying out the authentication process in only 2 steps as follows:

  1. Getting a token and then
  2. Sending a token to the service.

Now we are going to see how these two steps are carried out:

  1. You can get an authentication token either by providing your user name or either by providing your AP key or by providing your password.

Let’s see an example of requesting a token by giving your user name and password as follows:

$ curl -X POST https://localhost:5000/v2.0/tokens -d ‘{“auth”:{“passwordCredentials”:{“username”: “joecool”, “password”:”coolword”}, “tenantId”:”5″}}’ -H ‘Content-type: application/json’

A token will be returned to you on successful authentication, which can be used as proof that the identity of yourself has been authenticated earlier. For using the token, transfer it to another service like an X-Auth-Token header.

The authentication will also return a catalog of services mentioning or listing all the endpoints which can be useful to you for cloud services.

  • The authentication token can also be used for sending a GET to any service which you wish to use. These tokens are usually valid for 24 hours and it is also important to design all the applications in such a way that they will re-authenticate if they receive a “401 Unauthorized response” from any service endpoint.

Important Note:

It is important to note that if you have programmed to break down any authentication response, and then beware that the names of the services remain constant or stable for the duration of that specific service and it can also be used as keys. You should also keep in mind that a service catalog of a user may consist of more than one distinctly names services which carry out the same functions.

How to Send Requests to the API?

For sending requests via an API, you can take help of any of the following options:

  • There is a command line tool cURL, which is present at the http://curl.haxx.se/ can be preferred by the developers and testers. By using cURL, it is possible to send HTTP based requests and it is also possible to receive back the responses through the command line.
  • If you want to use a graphical interface, i.e. the REST, the users of Firefox will run better for trying and testing out the commands.
  • It is possible to download and install a REST client, which is a Java application for testing the RESTful web applications.

Let’s see how to send API requests with the help of cURL:

As mentioned earlier, cURL is a command line tool which is present in UNIX system based environments and also in Apple Mac OS X systems. And it can also be downloaded for the Microsoft Windows for interacting with the REST interfaces.

cURL permits you to send and receive the HTTP requests as well as responses through command line interface or by using a shell script. Due to which you will be directly able to work with the REST API without a need of any client APIs.

Following are the cURL command line options which are being used for running the examples:

  1. –d: This option is used for sending particular data to the HTTP server using a POST request.
  2. –i:  This option contains the HTTP header in the output.
  3. – H HEADER: This option states an HTTP header in the request.
  4. –X: This option instructs the request method to be used while communicating with the HTTP server. The instructed request is then used rather than the default method, i.e. GET.

Important Note:

If you have the required toolset then it is possible for you to run the examples related to cURL JSON request with the help of several options as shown below for formatting the output from cURL:

<curl JSON request example> | python –mjson.tool

Let’s see how to copy/paste cURL request examples in a terminal window:

Perform the following steps for running the cURL examples on Linux or Mac systems:

  1. The first step you need to perform is to copy/paste every example from the HTML version into a text editor, (ASCII), for instance, vi or TextEdit. For selecting the request example, you can click on the small icon of the document present to the right side of the request example.
  2. Edit every example as per your needed account information and so on.
  3. Once you finish editing the text for the cURL request example with your required information, paste that into your terminal window.
  4. Then press the enter key for running the cURL command.

Important Note:

The values returned in the cURL request examples which are the part of cURL syntax are skipped along with a backslash so as to stay away from the beforehand terminating a command. Despite this, you must not avoid the return values in the JSON message inside the command.


If you are facing trouble while copy and pasting the cURL examples as described above, then you can try entering or typing the complete cURL examples on a single long line by removing all the backslash by lining continuation characters.

That’s all for today! I hope you find this information helpful. Please do not forget to leave a comment in the comment section below. Thank you for reading the blog. See you soon with another interesting blog!

Learning OpenStack Message (Zaqar) with authenticating Token and sending requests to API, Hostripples Web Hosting
Vishwajit Kale
Vishwajit Kale blazed onto the digital marketing scene back in 2015 and is the digital marketing strategist of Hostripples, a company that aims to provide affordable web hosting solutions. Vishwajit is experienced in digital and content marketing along with SEO. He's fond of writing technology blogs, traveling and reading.