On Thursday March 19 the NLVMUG UserCon 2015 took place at the 1931 Conference Center in Den Bosch, The Netherlands.Barista as a Service
Erik thought it would be cool to do something different with vRealize Orchestrator as s a showcase since he was presenting at the NLVMUG together with Martijn Baecke.

Ingredients:

  • Raspberry Pi.
  • soldering iron.
  • relay board with four relays.
  • Twitter functioning as a service bus.
  • some wicked Python skills.
  • a coffee machine, in this case the Philips Senseo Sarista.
  • and of course some slow roast coffee, Mocca d’Or.

Barista as a Service (BaaS)

What do you want when you have to work on a server? Yes, that’s correct: Coffee. Lots of it.

The idea of Coffee as a Service isn’t new. Rob Shaw published an article in January 2015 showcasing an Arduino combined with vRealize Orchestrator.

Our Coffee as a Service, or rather Barista as a Service (BaaS), is based on a vRealize Orchestrator workflow and a Raspberry Pi. When a host is put into maintenance mode, it instructs the Senseo Sarista to produce one or two cups of coffee. It accomplishes that by using a REST API to send messages to Twitter, effectively using Twitter as kind of a service bus. The Raspberry Pi then reads the Twitter account and activates a switch on the Senseo Sarista through the relay board.

Screen Shot 2015-03-27 at 12.02.09

Maintenance mode + cofee

The setup

In an earlier article Erik introduced us to his new home lab, which has four VMware nodes. The cluster contains vCenter, vRealize Orchestrator, as well as a couple of generic virtual servers and desktops.

The setup consists of four Shuttle DS81’s with the the following config.

  • Shuttle DS81
  • Intel Core i3-4160, 3.6GHz, LGA1150
  • HGST Travelstar 7K1000 1TB, 2.5inch, SATA600, 7.200rpm
  • SanDisk X110 128GB SSD mSATA
  • Kingston ValueRAM, 16GB DDR3 (2 x 8GB) SODIMM, 1.600MHz
  • SanDisk Standard 8GB SD-card, class 2, SDHC

Twitter as a message bus

Because we did not want to move the entire lab setup to Den Bosch, vRealize Orchestrator used Twitter as a message bus to relay the message from the setup at home to the coffee machine at the NLVMUG. To achieve this, the workflow uses the REST API to put specific messages on Twitter with specific hashtags.

The Python code on the Raspberry Pi reads the messages from Twitter and which switches the relays that control the Senseo.

api = tweepy.API(auth)
class listener(StreamListener):

    def on_data(self, data):
        jsonData=json.loads(data)
        text=jsonData['text']
        text2=jsonData['entities']['hashtags']
        for hashtag in text2:
             text2=hashtag['text']
             if text2=="alarmon":
                switchaction (9,"on")
             if text2=="coffee1":
                GPIO.output(7, GPIO.HIGH)
                time.sleep (1)
                GPIO.output(7, GPIO.LOW)
             if text2=="coffee2":
                GPIO.output(11, GPIO.HIGH)
                time.sleep (1)
                GPIO.output(11, GPIO.LOW)
        return True

    def on_error(self, status):
        print status

twitterStream = Stream(auth, listener())
twitterStream.filter(track=["coffee1","coffee2","coffeepower","alarmon","alarmoff","coffeehelp"], async=True)

The end result

IMG_0568

 

Other things you can do

Of course you can do other things as well. We had one unused connection on the relay board, which would be a terrible shame to waste ;-). In the example below an alert is generated when a VM generates more than 90% CPU load. This alert turns on the alarm light.

Screen Shot 2015-03-27 at 12.01.47

Perhaps this is VMware’s best kept secret, but you already got it in your toolbox, since it is available with each VMware vCenter Server.  This demo showed you that you can do more than do interactions in the VMware environment. You can do lots more, for example:

  • When a host is shutdown or powered off, the electronic lock of the 19″ rack will be opened.
  • When a harddisk fails, submit the name of the technician to the allowed list which may enter the datacenter.
  • Create a new Active Directory account when a VM is created.

The possibilities are endless, and that for a product you already own. Let us know in the comments below what you are doing with vRealize Orchestrator.