On 20.11.2017 it was time again: All colleagues of ATIX AG – from consultants to developers to marketing and support – met for the ATIX #CrewDay to exchange ideas and work together on various projects. Of course, everything revolved around LINUX & Open Source.
At #CrewDay, colleagues from Marketing are of course not left out. It is therefore important to find topics that are relevant for all departments. With this in mind, some time ago a colleague had the idea of using voice control to create a new host with the help of orcharhino to create a new host. A perfect project for #CrewDay! So we didn’t have to wait long, but rather teach our Rhino to speak. Rhino? Is that a colleague at ATIX? Almost – Rhino is the “mascot” of our product orcharhino. It can be used to further automate data centers and implement the deployment, configuration and patch management of Linux servers under a uniform interface. But back to our small Alexa project: First of all, we had to explore the available options. Option one would be to write our own Alexa skill. Option two is the one we initially opted for: As a communication mediator between Amazon Echo Dot and orcharhino we used Node-RED. Node-RED was initially designed by IBM and is available under an open source license. This allows scenarios in the Internet of Things to be put together directly in the browser like a modular system. In addition to Alexa, other modules are available for Google services, IRC, social media platforms and for controlling smart home devices. This gave rise to another idea: Why not use a tweet to build a new server via orcharhino build a new server? After installing Node-RED using “npm”, you can access it directly from your browser via http://127.0.0.1:1880. Additional modules can be searched for and installed using “Manage Palette” via the menu on the right-hand side next to “Deploy”. Here we have added the node-red-contrib-alexa-home-skill [1] module. This module uses a server [2] on the Internet with which it communicates between Alexa and Node-RED. We actually wanted to avoid this and implement everything locally. But then we realized that other modules [3] that make do with the local network were out of the question. This is because Node-RED, Alexa and orcharhino are not on the same network. It took a few minutes to establish successful communication between Alexa and Node-RED. We were now able to receive the first voice commands via Node-RED. The next step was to orcharhino to connect. Node-RED has a module for sending HTTP requests. The API of orcharhino allows almost everything to be controlled via corresponding API calls. This includes creating content views, deleting compute resources and starting a deployment process for new hosts.
This was done in no time and we were able to start Alexa with “Alexa, rhino on” (we use rhino instead of orcharhino because, as developers, we know that “brevity is the spice of life”;) ) to build a new host. Now the resolution for all those who are wondering why we used “orcharhino ein” as a command: This node-red-contrib-alexa-home-skill internally maps smart home functionalities like lamp control. The Sytax and voice command skill is therefore unsuitable for our use case. But that’s just a side note, now back to the essentials: Creating new hosts via tweet and posting a message to an IRC channel as soon as a new host is available ? The finished Node-RED flow looks like this:
To control the orcharhino API, we had to define the header and the HTTPS post body. We used the following method for this:
//set headers and payload var payload = { "host": { "enabled": true, "compute_resource_id":"1", "hostgroup_id":"1", "location_id":"2", "organization_id":"1", "compute_attributes": { "start":"1" }, "interfaces_attributes": { "0":{ "subnet_id":"1" } } }}; // construct the result msg.payload= JSON.stringify(payload); msg.headers = {}; msg.headers["Content-Type"] = "application/json"; msg.headers["Accept"] = "application/json"; return msg;
After the message has been sent via “Send orcharhino HTTPS Post”, Node-RED receives the response to the HTTPS Post request in “Set New Host Msg”. In this Javascript function we extract the name of the new host:
//Set New Host Msg var hostname = msg.payload.match(/"name":"([a-zA-Z-\.]*).stage.atix"/); var msg = {}; if (hostname !== null{ msg.payload = "New Host created: " + hostname[1]; } return msg;
In the remaining time, we thought about how we could design our own Alexa skill in such a way that we could dispense with the remote server and also give real commands ร la “Alexa, build a medium-sized host with orcharhino a medium-sized host”. Here we again had the problem with different network segments. Unfortunately, we ran out of time to find an adequate solution. At one of the next ATIX #CrewDays, however, we want to take this up again and design our own Alexa skill.
What have we learned?
– Voice control via Alexa is pretty good! – Node-RED as a tool for networking Internet of Things components is very powerful! – It’s fun with orcharhino implementing unusual ideas! [1] https://www.npmjs.com/package/node-red-contrib-alexa-home-skill [2] https://alexa-node-red.bm.hardill.me.uk/ [3] https://www.npmjs.com/package/node-red-contrib-alexa-local Amazon has set standards with Alexa and Echo (Dot). It can be assumed that our project can also be implemented with other systems such as Google Home Assistant or Apple HomePod.
What is orcharhino?
orcharhino is THE tool for automatically deploying servers in a data center, performing configuration management and always being up to date with patch management. In orcharhino several open source technologies are combined to achieve the goals of automation and standardization. It offers orcharhino three core functions; Deployment, Patch Management, Configuration Management and much more. All enterprise-ready, of course.