Posted by vele1655 | Posted in Automation, Powershell | Posted on 31-01-2012
One of the great things that I get to do as part of the vSpecialist group at EMC on a day to day basis to work on larger solutions and sometimes making things function in ways that they weren’t designed. The posts I throw out there are really bandaids and educational with the hope that there is enough demand for what was shown that we can get product groups to adopt the functionality into a formal software release. The following is a link to some Powershell work I did for Adobe AMF messaging (explained below) and basically exposes a “hidden API” for an application. I mean this because with a bit of reverse engineering and AMF you can simulate the exact calls a Flash/Flex client is making. I will be following this up with a real example of automating a VMware application that didn’t quite have automation as a first thought.
It’s a first, I have my first post to Github!
These scripts are about 1,000 lines of code to accomplish AMF remoting calls with Powershell. I have to say it was definitely the most challenging thing I have ever done and really provided some good insight into Powershell and true user-friendliness and what that does to negatively move it away from a WYSIWYG environment. The work done involves endianess, bitwise operations, bytestreams, and all kinds of cool stuff that I really hadn’t needed to be deep with before. I had some good working models to go from so a lot of the work was transposing between 3 or so different languages into PS.
For those of you that don’t know what Adobe AMF is, here is a bit of a primer. When building a web based application that is Flex or Flash based there are many options for populating content into a client. Let’s break this out a bit to understand where AMF fits.
If I create a Flex interface that contains something like a table that needs to be populated with data from a database I might have an ODBC call to the database to do this. Another example might be where I am pulling more static information that is unrelated to a database that might populate some of my look and feel which might leverage a JSP/PHP call. In the situation where we are pulling data such as from a database another option could be to use Adobe AMF (Action Message Format) instead of ODBC.
http://ojitha.blogspot.com/2010/04/spring-3-integration-with-blazeds-32.html (BlazeDS is another implementation of AMF)
Now you might ask, why would I use AMF if I can talk to the database directly? I’m no expert here but here are a few thoughts. If I look at the methods to securely communicate from a client to a server, I believe the easiest methods (and compatible with stateful inspection, load balancers, etc) is to leverage the built in capabilities of HTTPS and SSL. AMF as a format is meant to ride on top of a RESTful architecture such as HTTP. By way of this you can hide any of the database services from the outside world and simply filter and process requests once they come in from the AMF services. Along with this AMF can serve as another layer of authentication between client and server with cookie and ticket verifications above and beyond HTTP authentication.
The concept of where the code lives is pretty important. In the case without AMF, would you include the database calls and ODBC logic directly in a client distributable application? Wouldn’t a better idea be to include that logic on the server side and simply have the client call a single method from the server which then does the database calls? This is very similar to having something like PHP locally make requests to a database, however in the case of AMF it is a rich client (Flash) passing objects back and forth. Anyways.. enough this conversation can go on forever. The important thing to know about AMF from my perspective is that it is RESTful so it relies of HTTP/S architecture, and allows the remote execution of methods.
Below are a handful of places to get information and existing assemblies that allow for AMF calls. I wrote my own implementation because I couldn’t find anything out there that worked correctly from Powershell. What I have done is pretty focused towards a certain application and it’s limited scope of objects it required to pass with AMF. Adding new types of objects is a matter of 6-8 lines of code now. Others out there like FlourineFX seem to be very mature in the breadth of capabilities.