Thursday, October 10, 2013

Creating a new SQLServer 2012 Provisioning Engine

After getting the Microsoft SQLServer 2012 installed I was able to turn my attention to the code to integrate to UCDT.

The first step is to get your IDE up and running and create a new project to build the engine you want.

For me, I created a Java structure to hold a class you need to start with, and then a package to hold my code.

Now, be sure to keep track of any Jar's you need to get your product working because you will need to drop them into the UCDT WebApps Lib folder in order for it to work.

Ok, so the first thing to know is that there is an Inteface class you need to use and adhere to: GenericProvisionInterface.class.  There is a Jar file in the lib path of UCDT and you can get it from there, any system will allow you to open a Jar file and pull the files out, but I am including the interface definition here so we can talk about it:

package com.cisco.ucspt;

public interface GenericProvisionInterface {
public boolean setupConnection(String hostIP, 
                                       String portNumber, 
                                       String userId,
                                       String password, 
                                       String dbName,
                                       String version);
public boolean releaseConnection();
public String provision(String template);

}

There are three public class you need to design. First, setupConnection(); Second, releaseConnection(); and third provision().

The method setupConnection, as you can see, has all the data being passed in dealing with connection information. You might not need all of these, but they are there for your use. The origin of this information is found within the UCDT application on the Enterprise/Application menu item:


Notice that there is a tab titled "Third Party", this is where you will define all your server information. Also, note the column headers for the data, left to right you have Enterprise Name, Server Name, IP Address, User Name, Port, Version, Database Name, Throttle Speed and Test Status. We drill into each of these later, but, for now just know that you need to define the Server Name, the IP and Port if necessary and you will need to supply the User ID and Password. Also, notice that Test Status reports that no connectivity test is available, that is because this is a third party engine and not a native engine to UCDT. If we really like your OEM engine we might integrate it into the product thereby making it native.

Now, writing the code is a simple matter of creating an abstract class that will implement GenericProvisionInterface. And, of course, you can create any support class you might need to actually create your OEM solution.

My recommendation is that your package should be at the high level of WebApps/classes, since that is where all the other provisioning classes are stored.

So, just two more things to update and you are ready to start testing your code.

First, you need to update the provision.xml file, and that is located in WEV-INF/provision. Here is the contents of that file along with an edit that I made to support my MS SQLServer entry:


Line 9 contains the entry for the MS SQL Server entry that I added. The important thing to note here is that the provisionProduct field must be "ThirdParty"  and the provisionProductVersion field must match the database table entry for this server type. Finally, the provisionClass must be the name of the class that contains your code. 

The database table that needs to be updated is the ucsystems table, within that table you need to add an entry must also have a ucproduct value of "ThirdParty" and the version you add must match the provisionProductVersion added to the provisionxml file.

Ok, that is all you need to integrate, next we will talk about testing.

UCDT's Plug and Play Provisioning Engine - MS SQLServer 2012 Setup


I thought I would spend some time to work with the UCDT provisioning engine's plug-n-play architecture. I designed this a couple of years ago with another developer and the development team implemented it. So, it is really long over-due to have a look under the covers.


What I found is that it is that our design was spot-on! It is extremely easy to write OEM code and plug it into UCDT although I do have to perform a couple minor manual steps to make it work properly. That's not a problem because I am sure there will be future changes made by the development team so that it will be a smooth, 100% effortless process to plug new code into the system.


For my first OEM UCDT engine, I brushed off some old code that I had laying around for provisioning to a MSSQL Server database. I went ahead and installed SQLServer 2012 Express on my PC and set it up so that I could access it from remote application. In hind-sight this was easy, but, finding everything that had to be turned on was a bit of a pain in the backside.

First, I had to make sure the proper services were running, the SQL Server and SQL Server Browser. After installed they were set to 'Disabled', I only had to right mouse-click on them to set them to 'Automatic':



Next, I had to turn on Named Pipes and TCP/IP. I found that this had to be set up in the SQL Server Configuration Manager:

After I did that (and don't forget you have to restart the SQL Service). I had to set the TCP Port. For me, I just set all of these "TCP Port" entries to 1433, but, there is an entry at the bottom titled "IP All" which I assume means I can just set it once there and move on. I had been struggling to get this to work for so long I didn't want to leave anything to chance so I set them all.


Now, with that set I could build the MSSQL 2012 Provision Engine Code, this was simply a matter of writing code that would take a template body and then process it. I will share that code shortly, but, for now that is all I will update in this post.