Overnight I got an auto-upgrade to WordPress 4.1.3 maintenance release and a notice telling me WordPress 4.2 “Powell” was released. The downloads are in the usual places, and of course available from the update screen in your blog.
The announcement page has a video explaining the new features, which seem to make it easier to repost other people’s content, where you would normally expect to just tweet a link. Not sure what I feel about this yet!
In this post, we’re going to perform a push button refresh of an Oracle Database, Application Express (APEX) installation, and Tomcat webserver.
“But Oracle Alchemist,” you’re probably thinking, “we know about that. You’ve told us about how Delphix can provision and refresh data.” And yes, you’d be right. But I wasn’t done yet.
We’re going to perform a refresh of an Oracle Database, APEX installation, and Tomcat running in Amazon Web Services, replicated from a local Delphix Engine, by pressing a physical button wired to a Raspberry Pi running a python app that communicates with the Delphix REST API in the cloud over wifi.
We’ll go over technical details and the Python code right after the video. Make sure you check it out so you can watch me excitedly press the button. I even did a refresh from Starbucks.
I Like Pi
I’ve wanted a Raspberry Pi for a long time now, and for whatever reason never got around to buying one. I finally did last week, and let me tell you this thing is such a beautiful little device, I nearly fried the logic board by weeping on it. The components, how tiny! The GPIO pins, how enticing! The Raspberry Pi really is the ultimate geek toy. I ended up going with the Raspberry Pi Model B. It has a 40 pin GPIO header (an I/O interface we’ll use for this article), four USB 2.0 ports, a push-button micro SD slot for the hard drive, and the standard HDMI port, ethernet port, and power via micro USB. I can power it using my iPhone charging block or even with a USB battery pack. The one I bought also came with NOOBS on an 8GB SD card, which was preloaded with Raspbian, ArchLinux, OpenELEC, Pidora, RaspBMC, and RiscOS. I opted for Raspbian.
As for extras, I also got a super sexy little case called a Zebra Case. It’s designed and built right here in the good ol’ US of A, is incredibly easy to assemble, has optional rubber feet, can be hung up on a wall, and has easy access to the GPIO pins. I also picked up an Edimax EW-7811Un 150Mbps 11n Wi-Fi USB Adapter because I don’t like being tied down.
I have Delphix 4.2 (the latest version) set up on my laptop with a bunch of data sources: Oracle, an APEX app in Tomcat, Sybase, Postgres, MS SQL Server, and a Delphix Agile Masking repository. I also have Delphix 4.2 installed in Amazon Web Services and am replicating the Oracle Database and application stack to it via Delphix replication. In Amazon, the database, Tomcat, and APEX library replicas have all been provisioned to a target Linux system as Virtual Databases (VDBs) and Virtual Files (vFiles). Delphix has a powerful GUI that can handle refresh, rewind, etc. operations but instead we’re going to do it programmatically through the Delphix REST API in Python. Why? Because alchemy, that’s why. Raspbian has Python already loaded with the GPIO library built in. So let’s take a look at the code.
Here’s the delphix.py code that connects to my Amazon Delphix Engine and performs the operations.
Define a VDBControl function that accepts an operation, either “refresh” or “undo”
Declares variables for the Delphix Engine and the Python urllib2 classes
Get a Delphix session via the API and put a cookie in the cookie jar
Log into Delphix
Get a list of Delphix objects with a REST call to /resources/json/delphix/source on the Delphix Engine
Loop through the list and find the objects that are either Virtual Databases or Virtual Files
Grab some auxiliary data we need to do the refresh, like the source object we’re refreshing from.
If a refresh is being called, do the refresh by passing the proper data to Delphix using the /resources/json/delphix/database/VDBNAME/refresh REST method.
If an undo is being called, do the undo by passing the proper data using the undo method.
Now that we’ve seen the code that interfaces with Delphix, let’s take a look at the code that interfaces with the GPIO.
import RPi.GPIO as GPIO
from delphix import VDBControl
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)
input_state18 = GPIO.input(18)
if input_state18 == False:
input_state24 = GPIO.input(24)
if input_state24 == False:
This code must be run as root on the Raspberry Pi to interface with the GPIO. I actually have it appended in my rc.local so it starts up automatically when the Raspberry Pi comes online. The code is really quite simple as long as everything is plugged in properly. On my breadboard I have two buttons, each slotted in across the middle gap. The gap is there to divide up the breadboard so circuits can be built from both sides while only certain designated components “bridge” the gap. Two jumper cables connect each button to the Raspberry Pi GPIO. My refresh button has a positive connection to GPIO pin 18, and a ground connection. The undo button has a positive connection to GPIO pin 24, and a ground connection. Then the python code simply:
Sets up pins 18 and 24 for monitoring
Runs an endless loop
If GPIO pin 18 is clicked, the state changes to False, triggering a call to my delphix.VDBControl function with the “refresh” operation. It then sleeps for a brief moment to make sure the button press doesn’t rapid fire a bunch of presses.
If GPIO pin 24 is clicked, the same thing happens except an “undo” operation is passed.
And that’s it! A real, honest to goodness push-button refresh, courtesy of the cutest little computer I’ve ever seen and a hobby board, wires, and buttons that made me feel nervous carrying it around in public. It wouldn’t take much to make it presentable though. In fact, given the right top and bottom coverings, we could make quite the button. That was easy.®
So, what could you do with a Raspberry Pi and a couple buttons? Let me know in the comments!
If you’ve been near oracle-base.com recently you will see things have changed a bit…
The Main Website
For a couple of weeks I’ve been playing with Bootstrap and Font Awesome to make the main body of the website mobile friendly. Last night I got a bit bored so I decided to shift the whole site to the responsive mobile template so it’s a single look and feel regardless of the device.
Less than 5% of my traffic is from mobiles and tablets, so that wasn’t really the motivation for doing this. Over the years I’ve accumulated a whole bunch of crappy code to deal with specific situations and it was getting a little hard to manage the basic framework of the website. The switch to using Bootstrap meant I could effectively throw a whole bunch of my code away, making my life much easier. The main goal has been to keep everything plain and clean and minimize the amount of time I spend on maintenance. That leaves me more time to work on content, which is the important thing. The whole responsive thing was an added bonus.
It’s a work-in-progress. There are still some things to neaten up a little.
There are some pages that are “less responsive” than they should be.
I keep tweaking font sizes and colours.
I’ve got to sort out the main image in the navigation bar.
Overall, I’m relatively happy with it and it seems to work fine in the browsers I’ve tried (IE, Chrome, Firefox, Opera, Safari) and the mobiles and tablets I’ve tried it on.
I switched the blog to the “Twenty Fifteen” theme a few days ago. The old theme was getting a bit long in the tooth and required an ugly plugin to be make it mobile enabled.
I’m not totally happy with the “Twenty Fifteen” theme, but it will do until I find something I prefer. My main criteria is it has to be really plain.
If anyone has any comments or suggestions I would be happy to hear them.
Praveen : Mentioned the lack of direct links to the version-specific article pages. I missed them too, so I put them back in for larger browsers. On smaller devices they don’t show as they make the page look messy.
Frankly : Noticed the copy/paste was not working correctly. It turned formatted text into a single line and added a site URL on to it. This was down to an incorrect ShareThis.com setting for my sharing buttons. I flipped the switch and copy/paste is working again now.