Wednesday, 13 June 2012

Deployment framework

The deployment is a completely different operation than the development. Well I haven't told a big truth... :)
The important statement behind this thought is that usually the developer is not the person who will deploy the components but an other expert who hasn't got any idea about the development and similar stuff so we have to provide a framework for them.

The deployment expert needs the source of OSB components, the environment dependant values (see previous blog) and information about OSB server (e.g. admin user name, password, etc.). They can create an installation package and execute it on the development, test, production, ... server.

What does this installation package consist of? How can it be created? Well this is the reason why we need a framework which can be customized.
The OSB components must be deployed onto different environment:
 - during development we use a local machine or a development server
 - for testing we have to use test servers
 - we deploy the components onto the production servers too
 - ...
In these cases we should get the framework from the version control system, add the source of OSB components to it and customize the property files. This package will be our installation package that we just have to copy to the OSB server or to a computer from where the OSB server is accessible.

And a warning: this is my idea of the deployment framework so it may contain errors or bad ideas. :)

Directory structure

└───deploy_framework
    ├───dist
    ├───env.all
    │   │   build-change.xml
    │   │   change-System.xml
    │   │
    │   └───System
    │       ├───JNDI_Providers
    │       ├───Operator_Settings
    │       ├───Proxy_Servers
    │       ├───SMTP_Servers
    │       └───UDDI
    ├───env.dev
    ├───env.local
    │       build.properties
    │       change.properties
    │       run_all.bat
    │       run_build.bat
    │
    ├───env.prod
    ├───env.test
    ├───libs
    │       xmltask.jar
    │
    ├───scripts
    │       build.xml
    │       import.py
    │
    └───src


dist: The sbconfig.jar (this file will be deployed onto the OSB server) can be found here after building. It will be created by the framework.
env.all: Those settings can be found here which are valid for every environments. They have to be modified on project level but not on a given environment level.
For example: we define here where the OSB component source file should be modified (e.g. XPath definitions).
env.dev: It contains the settings which are valid for the development environment. We can start the deployment onto the development server by executing the file run_***.bat. It may contain the same files as there are in folder env.local.
env.local: It contains the settings which are valid for the local (localhost) environment. We can start the deployment onto the local server by executing the file run_***.bat.
env.prod: It contains the settings which are valid for the production environment. We can start the deployment onto the production server by executing the file run_***.bat. It may contain the same files as there are in folder env.local.
env.test: It contains the settings which are valid for the test environment. We can start the deployment onto the test server by executing the file run_***.bat. It may contain the same files as there are in folder env.local.
libs: JAR files which are needed for the framework.
scripts: Script files (ant, python) which are needed for executing the framework
src: Folder for the source files of OSB components. We have to copy the OSP projects which are in configuration project which we want to deploy and the we have to copy the configuration project itself too.

Property files

The following files must be overridden before the deployment.

Project level settings

build-change.xml: These settings define the values which must be modifed according to the given environment (e.g. we can specify here where the URL of the SMTP server has to be overridden according to value in file changes.properties). These settings must be specified just once. This is an ANT build file in my case. For example:
<project>
    <target name="_change.values">
        <xmltask source="../${env.BUILD_ENVIRONMENT}/tmp/System/SMTP_Servers/EmailServer.SMTPServer" dest="../${env.BUILD_ENVIRONMENT}/tmp/System/SMTP_Servers/EmailServer.SMTPServer">
            <replace path="/xml-fragment/*[local-name(.)='serverURL']/text()" withText="${EmailServer.smtp.Server_URL}"/>
            <replace path="/xml-fragment/*[local-name(.)='portNumber']/text()" withText="${EmailServer.smtp.Port_Number}"/>
        </xmltask>
        ...
    </target>
     ...
 </project>

Environment dependant settings

build.properties: These settings are needed for creating the sbconfig.jar and deploying it onto the server. An example:
middleware.home=E:/Oracle/Middleware
osb.home=${middleware.home}/Oracle_OSB1
wls.username=weblogic
wls.password=weblogic1
wls.server=t3://192.168.1.156:7001
config.project=All-ConfigurationProject
config.jar=E:/work/MAVIR/SOA/deploy/dist/sbconfig.jar
config.subprojects=CommonResources,EmailManager
config.includeDependencies=true
workspace.dir=e:/work/MAVIR/SOA/deploy/src
import.project= None
import.jar=E:/work/MAVIR/SOA/deploy/dist/sbconfig.jar
import.customFile=None

changes.properties: Defining the values which must be written in the OSB source files (e.g. endpoint URLs, usernames, passwords, etc.).
EmailServer.smtp.Server_URL=mailserver.acme.hu
EmailServer.smtp.Port_Number=25
...

run_***.bat: We can start the build/deploy by this scripts.
@ECHO OFF
rem ******************* this value mut be modified *******************
set FMW_HOME=E:\Oracle\Middleware
rem ******************* this value mut be modified *******************
set OSB_HOME_VALUE=Oracle_OSB1
set ANT_HOME=%FMW_HOME%\modules\org.apache.ant_1.7.1
set PATH=%ANT_HOME%\bin;%PATH%
set JAVA_HOME=%FMW_HOME%\jdk160_18
set CLASSPATH=%FMW_HOME%/wlserver_10.3/server/lib/weblogic.jar;%FMW_HOME%/%OSB_HOME_VALUE%/lib/alsb.jar;%FMW_HOME%/%OSB_HOME_VALUE%/modules/com.bea.common.configfwk_1.3.0.0.jar;..\libs\xmltask.jar
SET BUILD_ENVIRONMENT=env.dev
call ant -buildfile ../scripts/build.xml download build change deploy -verbose
pause



We can build and deploy the OSB components automatically by executing the script run_all.bat. It is possible to create the file sbconfig.jar only by executing the script run_build.bat and deploy it manually.

No comments:

Post a Comment