Using BSA to provision and manage JBoss instancesx - BMC ...

idiotcanvasΑσφάλεια

17 Νοε 2013 (πριν από 3 χρόνια και 7 μήνες)

363 εμφανίσεις

Environment Introduction

The client is migrating J2EE middleware hosting platforms to Redhat JBoss application servers. There is currently
no process for provisioning or managing
JBoss.

The Objective

The solution must provide a framework for provisioning and managing all JBoss instances with a secured access
controlled environment.
Functionality should include JBoss binary deployment and install, JBoss instance creation,
instance
configuration capabilities and instance change tracking.

Outside of the JBoss automation, the client required a solution that did not depend on access to the BSA UI as
training for application developers and operations on BSA was not desirable or cost effe
ctive. The solution needs
to facilitate a self service capability to allow for tasks to be executed outside of the UI.

Design Summary

As JBoss application server can create multiple instances per host (RSCD target) then the solution was dependant
on creat
ing BSA Component objects with the necessary property values stored against that component. All jobs
execution should be against the Component and hence automatically map to Component property values.


The design
also
needed to ensure that users are able to execute jobs outside of the BSA console and hence NSH
scripts must be designed requiring a minimal number of arguments to be passed to the script. As a result, the
solution is based on
the application name and envir
onment as arguments in order for the self service scripts to
logically identify the correct BSA objects to create and use for all tasks. Additional arguments will be passed where
necessary.

RBAC requirements meant that a power RBAC Role could commission a
nd provision new environments, but
authorizations should be applied to the new environment objects that restrict access to
those objects

to AD groups
as specified in the commissioning process.

Scripts

Please note the following scripts were tested and func
tional but
are specific to customer RBAC requirements.

Script to
Commission a new JBoss environment



Takes a populated properties file as input



Creates all RBAC Roles if they do not exist based on the JBossUser specified



Creates users and maps this to the
JBossUser Roles.


Based on the AD groups properties and the
Environment.



Creates all Depot, Job and Component workspace and applies ACL Templates based on the
ApplicationName and JBossUser property



Creates an NSHScript Job that calls the JBossInstanceDeplo
yment script.


Populates all properties file
values.


Sets the ACL Template based on the Environment property



Creates an
Deploy

Job that calls the JBossInstanceStartStopThreads
BLPackage
.


Sets the ACL Template
based on the Environment property.



Creates an

Deploy

Job that calls the JBossInstanceStartStopThreads
BLPackage
.


Sets the ACL Template
based on the Environment property.


#!/bin/nsh


#######################################################################

#Script to commission a new JBoss environment
.

#

#Scott Dunbar 08/05/12

#Version 1.0

#######################################################################

#set
-
eE

#set
-
x


blcli_setoption serviceProfileName DEV

blcli_setoption roleName
APPAdmins

blcli_connect



_JHUAdminADGroup
=
"asdas"


fatal() {


echo

"$*"


exit

}


debug() {


echo

"DEBUG

:

$*"

}


#########


TMP_FILE
=
"/tmp/instanceCommission.$$"


#Check if props file exits


PROPS_FILE
=
$1


if

[ !
-
f
"${PROPS_FILE}"

] ;
then


fatal
"Props

file

(${PROPS_FILE})

does

not

exist"

else


source

${PROPS_FILE}


if

[ $?
-
ne 0 ];
then


fatal
"Can

not

find

the

specified

properties

file"


fi


debug
"Props

file

(${PROPS_FILE})

exists"

fi


if

[ $?
-
ne 0 ] ;
then


if

[
-
n
"
$3
"

] ;
then


blcred cred
-
acquire
-
username
"
$2
"

-
password
"
$3
"


else


blcred cred
-
acquire


fi

fi


# Check all required variables set

if

[
-
z
"$_ApplicationName"

] ;
then


fatal Missing required parameter _ApplicationName

fi


if

[
-
z
"$_
SUPP_TEAM1
"

] ;
then


fatal Missing required parameter _
SUPP_TEAM1

fi


if

[
-
z
"$_Environment"

] ;
then


fatal Missing required parameter _Environment

fi


if

[
-
z
"$_JavaHome"

] ;
then


fatal Missing required parameter _JavaHome

fi


if

[
-
z
"$_JavaXMS"

] ;
then


fatal Missing required parameter _JavaXMS

fi


if

[
-
z
"$_JBossUser"

]

;
then


fatal Missing required parameter _JBossUser

fi


if

[
-
z
"$_JBossVersion"

] ;
then


fatal Missing required parameter _JBossVersion

fi


if

[
-
z
"$_
SUPP_TEAM2
"

] ;
then


fatal Missing required parameter _
SUPP_TEAM2

fi

if

[
-
z
"$_JBossClusteringEnabled"

];
then


_JBossClusteringEnabled
=
false

fi

if

[
-
z
"$_JBossClusterMembers"

];
then


_JBossClusterMembers
=0

fi

if

[
-
z
"$_JBossClusterMulticastAddress"

];
then


_JBossClusterMulticastAddress
=0

fi

if

[
-
z
"$_JBo
ssClusterMulticastPort"

];
then


_JBossClusterMulticastPort
=0

fi

if

[
-
z
"$_JBossClusterName"

];
then


_JBossClusterName
=0

fi


_Environment
=
`echo $_Environment | tr '[:upper:]' '[:lower:]'`

_JBossUser
=
`echo $_JBossUser | tr '[:lower:]'
'[:upper:]'`

_BusinessAreaUser
=
`echo $_JBossUser | cut
-
c 1
-
7`



#######################################################################

# Set some expected paramerters

#######################################################################

#HOSTNAME=$1

#HOSTNAME=`print $HOSTNAME|tr '[ ]' '[]'`

#echo "The target is [${HOSTNAME}]"



NshScriptPath
=
"/JBoss/Common"

NshScriptName
=
"JBossInstanceDeployment"

NshScriptName2
=
"JBossInstanceStartStopThreads"

NshScriptName3
=
"JBossInstanceChangeSystem.sh"

BlPackageName1
=
"ChangeSystem.sh"

BlPackageName2
=
"StartStopThreads"

InstanceTemplatePath
=
"/JBoss/Instance"

InstanceTemplateName
=
"Instance"

JobPath
=
"/JBoss/ApplicationManagement"

DepotPath
=
"/JBoss/ApplicationManagement"

CommonDepotPath
=
"/JBoss/Common"


DevCo
mponentGroup
=
"/JBoss/Application/Development"

UatComponentGroup
=
"/JBoss/Application/UAT"

ProdComponentGroup
=
"/JBoss/Application/Production"


ProdDeploymentGroup
=
"/Production/Application

Deployment"

DevDeploymentGroup
=
"/Development/Application

Deployment"

U
atDeploymentGroup
=
"/UAT/Application

Deployment"


ldapConnectionName
=
"
aserver.adomain.com
"

automationPrincipalName
=
"AD_Read_User"

userQueryName
=
"UserQuery"


RepoServer
=
"
aserver.adomain.com
"

RepoPath
=
"/c/JAH"


#SQL Args

DbAdDomain
=
"INTRANET"

DbAdUser
=
"whiterob"

DbHost
=
"LDNDCM05673V05A"

DbPort
=
"10501"

DbUser
=
"sysbwaggui"

DbPassword
=
"pa55word"

DbName
=
"bWAGConsoleDev"


#########

#Ensure that the username matches the environment specified

#########

CheckEnv
=
$(echo ${_Environment} | tr '[:upper:]' '[:lower:
]' | cut
-
c 1)

CheckUser
=
$(echo ${_JBossUser} | tr '[:upper:]' '[:lower:]' | cut
-
c 8)

if

[
"x
$CheckEnv
"

!=
"x
$CheckUser
"

];
then


fatal
"The

JBossUser

you

have

specified

does

not

appear

to

match

the

Environment

that

you

are

creating

these

instances

for"

fi


check_already_exists()

{


blcli_execute NSHScriptJob isJobExistsByGroupAndName
"
$JobPath
/${_ApplicationName}"

"Create_ApplicationEnv_${_ApplicationName}_${_Environment}"

2>&1 >/dev/null

if

[ $?
-
eq 0 ] ;
then


debug
"blcli

check

for

$JobPath
/${_ApplicationName}

Create_ApplicationEnv_${_ApplicationName}_${_Environment}

succeeded"


blcli_storeenv CHECK_RESULT


if

[
"x
$CHECK
_RESULT"

=
"xtrue"

] ;
then


fatal
"The

application

already

exists.

Exiting"


fi


debug
"blcli

check

for

$JobP
ath
/${_ApplicationName}

Create_ApplicationEnv_${_ApplicationName}_${_Environment}

succeeded

but

was

false"

fi


}


check_role ()

{


for

ROLE
in

${_BusinessAreaUser}p ${_BusinessAreaUser}d
${_BusinessAreaUser}u ;
do


blcli_execute RBACRole getDBKeyByName
${ROLE}
_ADMIN 2>&1 >/dev/null


if

[ $?
-
ne 0 ];
then


fatal
"
${ROLE}
_ADMIN

already

exists,

adding

the

ADgroups

to

this

role...."


else


create_admin_role
$ROLE


fi

done


for

ROLE
in

${_BusinessAreaUser}d ;
do


ldap_
SUPP_TEAM3

$ROLE


ldap_
SUPP_TEAM1

$ROLE


ldap_
SUPP_TEAM2

$ROLE

done


for

ROLE
in

${_BusinessAreaUser}p ${_BusinessAreaUser}u ;
do


ldap_
SUPP_TEAM1

$ROLE


ldap_
SUPP_TEAM2

$ROLE

done


}


create_admin_role ()

{

#########

#Creates

the RBAC Role based on the _BusinessAreaUser

#########

AUTH_UNIX_USER
=
`echo $ROLE | tr '[:upper:]' '[:lower:]'`

AUTH_WINDOWS_USER
=
"SPSAdmin"


blcli_execute RBACRole createRole
${ROLE}
_ADMIN
"Role

for

Unix

SWEB

user

$ROLE
"

8
$AUTH
_UNIX_USER
$AUTH
_WINDOWS_USER

blcli_execute RBACRole addPermission
"
${ROLE}
_ADMIN"

RBACAdmins
"Role.*"

blcli_execute RBACRole addAuthProfileToRoleByName
"
${ROLE}
_ADMIN"

"ComplianceAuditManagement.

Analysis"

blcli_execute RBACRole addAuthProfileToRoleByName
"
${ROLE}
_ADMIN"

"ComplianceAuditManagement.

Discovery"

blcli_execute RBACRole addAuthProfileToRoleByName
"
${ROLE}
_ADMIN"

"ComplianceAuditManagement.

Remediation"

blcli_execute RBACRole addAuthProfileToRoleByName
"
${ROLE}
_ADMIN"

"ServerManagement"

blcli_execute

RBACRole addAuthProfileToRoleByName
"
${ROLE}
_ADMIN"

"SoftwareManagement.

Deployment"

blcli_execute RBACRole addAuthProfileToRoleByName
"
${ROLE}
_ADMIN"

"SoftwareManagement.

Packaging"

blcli_execute RBACRole addAuthProfileToRoleByName
"
${ROLE}
_ADMIN"

"Softw
areManagement.

Promotion"

blcli_execute RBACRole addAuthProfileToRoleByName
"
${ROLE}
_ADMIN"

"WorkspaceManagement"

#create ACL template and apply to objects

echo

"

${ROLE}
_ADMIN_DEFAULT default_ACL_template_for_role_$ROLE
"

|

grep

-
v

^$

|

grep

-
v

\
#

|

while

read

ARGS

;

do


blcli_execute BlAclTemplate createAclTemplate
$ARGS


blcli_execute BlAclTemplate addPermission
"
${ROLE}
_ADMIN_DEFAULT"

RBACAdmins
"ACLTemplate.*"


blcli_execute BlAclTemplate addTemplatePermissionProfile
${ROLE}
_ADMIN_D
EFAULT BLAdmins
"Perform

All

Operations

Except

Security"


blcli_execute BlAclTemplate addTemplatePermissionProfile
${ROLE}
_ADMIN_DEFAULT
APPAdmins

"Perform

All

Operations

Except

Security"


blcli_execute BlAclTemplate addTemplatePermissionProf
ile
${ROLE}
_ADMIN_DEFAULT
${ROLE}
_ADMIN
"Perform

All

Operations

Except

Security"

done

blcli_execute RBACRole setDefaultAclTemplateByName
${ROLE}
_ADMIN
${ROLE}
_ADMIN_DEFAULT


}


ldap_
SUPP_TEAM3
()

{

#########

#create the LDAP group query and sync

#########

blcli_execute Ldap showQuery ${_
SUPP_TEAM3
}_Group_Query

if

[ $? = 0 ];
then


echo

"
\
n${_
SUPP_TEAM3
}_Group_Query

already

exists...

skipping"

else


blcli_execute Ldap createQuery
"${_
SUPP_TEAM3
}_Group_Query"

"CN=${_
SUPP_TEAM3
},OU=Groups,OU=GLB,DC=INTRANET,DC=
DOMAIN
,DC=COM"

"(objectClass=group)"

"member"

"LDAP

Query

to

sync

users

from

$ADGROUP
"


blcli_execute Ldap addQueryPermission
"${_
SUPP_TEAM3
}_Group_Query"

RBACAdmins
"LdapQuery.*"


blcli_execute RBACRole addL
dapGroupMapping
${ROLE}
_ADMIN
$ldapConnectionName

$automationPrincipalName

"${_
SUPP_TEAM3
}_Group_Query"

$userQueryName


#blcli_execute RBACRole addLdapGroupMapping ${ROLE}_ADMIN
$ldapConnectionName $automationPrincipalName
"${_JHUAdminADGroup}_Group_Query" $userQueryName


blcli_execute RBACRole setLdapSyncOptions
${ROLE}
_ADMIN
true

false

false


blcli_execute RBACRole syncUsers
${ROLE}
_ADMIN

fi

}


ldap_
SUPP_TEAM1
()

{

#create the LDAP group query and sync

blcli_execute Ldap showQuery ${_
SUPP_TEAM1
}_Group_Query

if

[ $? = 0 ];
then


echo

"
\
n${_
SUPP_TEAM1
}_Group_Query

already

exists...

skipping"

else


blcli_execute Ldap createQuery
"${_
SUPP_TEAM1
}_Group_Query"

"CN=${_
SUPP_TEAM1
},OU=Groups,OU=GLB,
DC=INTRANET,DC=
DOMAIN
,DC=COM"

"(objectClass=group)"

"member"

"LDAP

Query

to

sync

users

from

$ADGROUP
"


blcli_execute Ldap addQueryPermission
"${_
SUPP_TEAM1
}_Group_Query"

RBACAdmins
"LdapQuery.*"


blcli_execute RBACRole addLdapGroupMapping
${ROLE}
_ADMIN
$ldapConnectionName

$automationPrincipalName

"${_
SUPP_TEAM1
}_Group_Query"

$userQueryName


#blcli_execute RBACRole addLdapGroupMapping ${ROLE}_ADMIN
$ldapConnectionName $automationPrincipalName
"${_JHUAdminADGroup}_Group_Query" $userQue
ryName


blcli_execute RBACRole setLdapSyncOptions
${ROLE}
_ADMIN
true

false

false


blcli_execute RBACRole syncUsers
${ROLE}
_ADMIN

fi

}


ldap_
SUPP_TEAM2
()

{

#create the LDAP group query and sync

blcli_execute Ldap showQuery ${_
SUPP_TEAM2
}_Group_Query

if

[ $? = 0 ];
then


echo

"
\
n${_
SUPP_TEAM2
}_Group_Query

already

exists...

skipping"

else


blcli_execute Ldap createQuery
"${_
SUPP_TEAM2
}_Group_Query"

"CN=${_
SUPP_TEAM2
},OU=Groups,OU=GLB,DC=INTRANET,DC=
DOMAIN
,DC=COM"

"(objectClass=group)"

"member"

"LDAP

Query

to

sync

users

from

$ADGROUP
"


blcli_execute Ldap addQueryPermission
"${_
SUPP_TEAM2
}_Group_Query"

RBACAdmins
"LdapQuery.*"


blcli_execute RBACRole addLdapGroupMapping
${ROLE}
_ADMIN
$ldapConnectionName

$automationPrincipalName

"${_
SUPP_TEAM2
}_Group_Query"

$userQueryName


#blcli_execute RBACRole addLdapGroupMapping ${ROLE}_ADMIN
$ldapConnectionName $automationPrincipalName
"${_JHUAdminADGroup}_Group_Query" $userQueryName


blcli_execute

RBACRole setLdapSyncOptions
${ROLE}
_ADMIN
true

false

false


blcli_execute RBACRole syncUsers
${ROLE}
_ADMIN

fi

}



#########

#Create the Job workspace

#########

create_workspace ()

{

JOB_GROUP
=
"
$JobPath
/${_ApplicationName}"

blcli_execute JobGroup gr
oupExists
"${JOB_GROUP}"

2>&1 >/dev/null

blcli_storeenv CHECK_RESULT

if

[
"x
$CHECK
_RESULT"

=
"xfalse"

];
then


blcli_execute JobGroup createGroupWithParentName
"${_ApplicationName}"

"
$JobPath
"

2>&1 >/dev/null


if

[ $?
-
ne 0 ];
then


fatal
"Problem

Creating

the

Job

Group

Folder

:

$err
"


fi


blcli_storeenv JOBGROUP_ID


blcli_execute Group applyAclTemplate
"${JOB_GROUP}"

5005
${_BusinessAreaUser}p_ADMIN_DEFAULT
false

2>&1 >/dev/null


blcli_execute Group applyAclTemplate
"${JOB_GROUP}"

5005
${_
BusinessAreaUser}u_ADMIN_DEFAULT
false

2>&1 >/dev/null


blcli_execute Group applyAclTemplate
"${JOB_GROUP}"

5005
${_BusinessAreaUser}d_ADMIN_DEFAULT
false

2>&1 >/dev/null


echo

"Job

workspace

"
${_ApplicationName}
"

created"

else


blcli_execute

JobGroup groupNameToId
"${JOB_GROUP}"

2>&1 >/dev/null


blcli_storeenv JOBGROUP_ID

fi


#########

#Create the Depot workspace

#########

blcli_execute DepotGroup groupExists
$DepotPath
/${_ApplicationName} 2>&1
>/dev/null

blcli_storeenv CHECK_RESULT

if

[
"x
$CHECK
_RESULT"

=
"xfalse"

];
then


blcli_execute DepotGroup createGroupWithParentName ${_ApplicationName}
$DepotPath


if

[ $?
-
ne 0 ];
then


fatal
"Problem

Creating

the

Depot

Group

Folder

:

$err
"


fi


blcli_storeenv DEPOTGROUP_ID


blcli_execute Group applyAclTemplate
"
$DepotPath
/${_ApplicationName}"

5001
${_BusinessAreaUser}p_ADMIN_DEFAULT
false


blcli_execute Group applyAclTemplate
"
$DepotPath
/${_ApplicationName}"

5001
${_BusinessAreaUser}u_ADMIN_DEFAULT
false


blcli_execute Gr
oup applyAclTemplate
"
$DepotPath
/${_ApplicationName}"

5001
${_BusinessAreaUser}d_ADMIN_DEFAULT
false


echo

"Depot

workspace

"
${_ApplicationName}
"

created"



#########

#Create the Component workspace

#########


blcli_execute SmartComponentGroup

createGroup
"
$DevComponentGroup
"

"${_ApplicationName}"

"Dev

SmartGroup

for

${_ApplicationName}"

TEMPLATE.NAME
"equals"

Application


if

[ $? != 0 ];
then


echo

"
\
nProblem

Creating

the

Component

Group

Folder

:

$err
"


b
lcli_disconnect


exit 1


fi


blcli_execute SmartComponentGroup addCondition
"
$DevComponentGroup
/${_ApplicationName}"

_JBOSS_ENV
"equals"

Development


blcli_execute SmartComponentGroup addCondition
"
$DevComponentGroup
/${_ApplicationName}"

_JBOSS_APPLICATION_NAME
"equals"

"${_ApplicationName}"


blcli_execute SmartComponentGroup setMatchAll
"
$DevComponentGroup
/${_ApplicationName}"

true


blcli_execute Group applyAclTemplate
"
$DevComponentGroup
/${_Application
Name}"

5015
${_BusinessAreaUser}d_ADMIN_DEFAULT
false


blcli_execute SmartComponentGroup createGroup
"
$UatComponentGroup
"

"${_ApplicationName}"

"Uat

SmartGroup

for

${_ApplicationName}"

TEMPLATE.NAME
"equals"

Application


blcli_execute SmartCo
mponentGroup addCondition
"
$UatComponentGroup
/${_ApplicationName}"

_JBOSS_ENV
"equals"

UAT


blcli_execute SmartComponentGroup addCondition
"
$UatComponentGroup
/${_ApplicationName}"

_JBOSS_APPLICATION_NAME
"equals"

"${_ApplicationName}"


blcli_execute SmartComponentGroup setMatchAll
"
$UatComponentGroup
/${_ApplicationName}"

true


blcli_execute Group applyAclTemplate
"
$UatComponentGroup
/${_ApplicationName}"

5015
${_BusinessAreaUser}u_ADMIN_DEFAULT
false


blcli_execute SmartComp
onentGroup createGroup
"
$ProdComponentGroup
"

"${_ApplicationName}"

"Prod

SmartGroup

for

${_ApplicationName}"

TEMPLATE.NAME
"equals"

Application


blcli_execute SmartComponentGroup addCondition
"
$ProdComponentGroup
/${_ApplicationName}"

_JBOSS_ENV
"equ
als"

Production


blcli_execute SmartComponentGroup addCondition
"
$ProdComponentGroup
/${_ApplicationName}"

_JBOSS_APPLICATION_NAME
"equals"

"${_ApplicationName}"


blcli_execute SmartComponentGroup setMatchAll
"
$ProdComponentGroup
/${_Applicatio
nName}"

true


blcli_execute Group applyAclTemplate
"
$ProdComponentGroup
/${_ApplicationName}"

5015
${_BusinessAreaUser}p_ADMIN_DEFAULT
false

else


blcli_execute DepotGroup groupNameToId
$DepotPath
/${_ApplicationName}


blcli_storeenv DEPOTGROUP_ID

fi


}


run_sql_storedprocedure ()

{

COMMAND
=
$(cat << EOF

exec [INTRANET
\
\
whiterob].[TEST_JBOSS_COMMISSION_APP_ENV]


@
APPLICATION_NAME
=
"${_ApplicationName}"
,


@
SUPP_TEAM2
=
"${_
SUPP_TEAM2
}"
,


@
SUPP_TEAM3
=
"${_
SUPP_TEAM3
}"
,


@
SUPP_TEAM1
=
"${_
SUPP_TEAM1
}"
,


@
PRIMARY_SERVICE
=
"${_PrimaryService}"
,


@
GROUP_DISTRIBUTION_LIST
=
"${_GroupDistroList}"
,


@
INITIATOR
=
"${_Initiator}"
,


@
CDR
=
"${_Cdr}"
,


@
CR
=
"${_Cr}"
,


@
PROJECT_NAME
=
"${_ProjectName}"
,


@
PROJECT_DESCRIPTION
=
"${_ProjectDiscription}"
,


@
ENVIRONMENT
=
"${_Environment}"
,


@
JBOSS_USER
=
"${_JBossUser}"
,


@
JBOSS_VERSION
=
"${_JBossVersion}"
,


@
JAVA_HOME
=
"${_JavaHome}"
,


@
CLUSTER_ENABLED
=
"${_JBossClusteringEnabled}"
,


@
CLUSTER_NAME
=
"${_JBossClusterName}"
,


@
CLUSTER_MEMBERS
=
"${_JBossClusterMembers}"
,


@
XMS
=${_JavaXMS},


@
XMX
=${_JavaXMX},


@
FARM_GROUP_NAME
=
"jboss
-
ldn"
,


@
DEBUG
=
"true"

EOF

)


echo

-
e
"
$COMMAND
\
ngo"

| /apps/dbeng_build/freetds/version/0.82
-
3/bin/tsql
-
o fh
-
H LDNDCM05673V05A
-
p 10501
-
U sysbwaggui
-
P pa55word
-
D bWAGConsoleDev
1>
-

2>
$TMP
_FILE



_JBossBasePort
=
$(grep
-
e "Base Port .*" $TMP_FILE | cut
-
c 21
-
24)


if

[
-
z
"${_JBossBasePort}"

] ;
t
hen


fatal
"Base

port

not

returned

from

database"

fi


debug
"Base

Port

is

${_JBossBasePort}"


if

[ ${_JBossClusteringEnabled}=
"true"

-
a ${_Environment} !=
"development"

] ;
then


_JBossClusterMulticastPort
=
$(grep
-
e "Multicast Port .*" $TMP_FILE |

cut
-
c 21
-
24 )


_JBossClusterMulticastAddress
=
$(grep
-
e "Multicast Address .*"
$TMP_FILE | cut
-
c 21
-
36 | sed 's/ //g')



if

[
-
z
"${_JBossClusterMulticastPort}"

] ;
then


fatal
"Multicast

port

has

not

returned

from

database"



fi



if

[
-
z
"${_JBossClusterMulticastAddress}"

] ;
then


fatal
"Multicast

address

has

not

returned

from

database"


fi



debug
"Multicast

Port

is

${_JBossClusterMulticastPort}"


debug
"Multicast

Address

is

${_JBossClusterMulticastAddress}"

fi

rm

-
f
$TMP
_FILE


}



create_repo_space ()

{

# Create the directory and assign AD Groups to repository (for application
deployment)


cd //
$RepoServer$RepoPath

mkdir

${_ApplicationName}_${_Environment}

nexec

-
e icacls ./${_ApplicationName}_${_Environment} /inheritance:d

nexec
-
e icacls ./${_ApplicationName}_${_Environment} /remove:g Everyone

nexec
-
e icacls ./${_ApplicationName}_${_Environment} /grant
"fLDNwebengineering:(OI)(CI)F"

nexec
-
e icacls ./${_Applic
ationName}_${_Environment} /grant
"${_
SUPP_TEAM3
}:(OI)(CI)F"

nexec
-
e icacls ./${_ApplicationName}_${_Environment} /grant
"${_
SUPP_TEAM2
}:(OI)(CI)F"


cd //@


}


create_property_class ()

{



}


#########

# Create the NSHScript Job to create Environment from

existing Depot NSH
Scripts

#########

create_jobs()

{


JOB_GROUP
=
"
$JobPath
/${_ApplicationName}"

JOB_NAME
=
"Create_ApplicationEnv_${_ApplicationName}_${_Environment}"


blcli_execute NSHScriptJob createNSHScriptJob
"${JOB_GROUP}"

"${JOB_NAME}"

"Execute

Instance

Creation

script"

"
$NshScriptPath
"

"
$NshScriptName
"

aserver
.intranet.
DOMAIN
.com 40 2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

create

the

NSHScript

Job

:

$err
"

fi

blcli_storeenv SCRIPTJOB1_ID

blcli_execute

Job clearTargetServers
$SCRIPTJOB1
_ID 2>&1 >/dev/null

blcli_storeenv SCRIPTJOB1_ID


if

[ ${_Environment} = development ] ;
then


blcli_execute Job applyAclTemplate
$SCRIPTJOB1
_ID
${_BusinessAreaUser}d_ADMIN_DEFAULT
false

2>&1 >/dev/null


blc
li_storeenv SCRIPTJOB1_ID

fi

if

[ ${_Environment} = production ] ;
then


blcli_execute Job applyAclTemplate
$SCRIPTJOB1
_ID
${_BusinessAreaUser}p_ADMIN_DEFAULT
false

2>&1 >/dev/null


blcli_storeenv SCRIPTJOB1_ID

fi

if

[ ${_Environment} = uat ] ;
then


blcli_execute Job applyAclTemplate
$SCRIPTJOB1
_ID
${_BusinessAreaUser}u_ADMIN_DEFAULT
false

2>&1 >/dev/null


blcli_storeenv SCRIPTJOB1_ID

fi



blcli_execute NSHScriptJob clearNSHScriptParameterValuesByGroupA
ndName
"${JOB_GROUP}"

"${JOB_NAME}"

2>&1 >/dev/null


blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName
"${JOB_GROUP}"

"${JOB_NAME}"

0 $_
SUPP_TEAM3

2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

set

the

property

_
SUPP_TEAM3

:

$err
"

fi

blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName
"${JOB_GROUP}"

"${JOB_NAME}"

1 $_
SUPP_TEAM1

2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

set

the

property

_
SUPP_TEAM1

:

$err
"

fi

blcli_execute

NSHScriptJob addNSHScriptParameterValueByGroupAndName
"${JOB_GROUP}"

"${JOB_NAME}"

2 $_Environment 2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

set

the

property

_Environment

:

$err
"

fi

blcli_execute NSHScriptJob addNSHScriptParameterV
alueByGroupAndName
"${JOB_GROUP}"

"${JOB_NAME}"

3 $_JavaHome 2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

set

the

property

_JavaHome

:

$err
"

fi

blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName
"${JOB_GROUP}"

"${JOB_N
AME}"

4 $_JavaXMS 2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

set

the

property

_JavaXMS

:

$err
"

fi

blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName
"${JOB_GROUP}"

"${JOB_NAME}"

5 $_JavaXMX 2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

set

the

property

_JavaXMX

:

$err
"

fi

blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName
"${JOB_GROUP}"

"${JOB_NAME}"

6 $_JBossClusteringEnabled 2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

set

the

property

_JBossClusteringEnabled

:

$err
"

fi

blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName
"${JOB_GROUP}"

"${JOB_NAME}"

7 $_JBossClusterMembers 2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

t
o

set

the

property

_JBossClusterMembers

:

$err
"

fi

blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName
"${JOB_GROUP}"

"${JOB_NAME}"

8 $_JBossClusterMulticastAddress 2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

set

the

property

_JBossClusterMulticastAddress

:

$err
"

fi

blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName
"${JOB_GROUP}"

"${JOB_NAME}"

9 $_JBossClusterMulticastPort 2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

set

the

prope
rty

_JBossClusterMulticastPort

:

$err
"

fi

blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName
"${JOB_GROUP}"

"${JOB_NAME}"

10 $_JBossUser 2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

set

the

property

_JBossUser

:

$err
"

fi

blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName
"${JOB_GROUP}"

"${JOB_NAME}"

11 $_JBossVersion 2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

set

the

property

_JBossVersion

:

$err
"

fi

blcli_execute

NSHScriptJob addNSHScriptParameterValueByGroupAndName
"${JOB_GROUP}"

"${JOB_NAME}"

12 $_ApplicationName 2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

set

the

property

_ApplicationName

:

$err
"

fi

blcli_execute

NSHScriptJob addNSHScriptParameterValueByGroupAndName
"${JOB_GROUP}"

"${JOB_NAME}"

13 $_
SUPP_TEAM2

2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

set

the

property

_
SUPP_TEAM2

:

$err
"

fi

blcli_execute NSHScriptJob addNSHScriptParameterVa
lueByGroupAndName
"${JOB_GROUP}"

"${JOB_NAME}"

14 $_JBossClusterName 2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

set

the

property

_JBossClusterName

:

$err
"

fi

blcli_execute NSHScriptJob addNSHScriptParameterValueByGroupAndName
"${JOB_GROUP}"

"${JOB_NAME}"

15 $_JBossBasePort 2>&1 >/dev/null

if

[ $?
-
ne 0 ]

then


fatal
"
\
nUnable

to

set

the

property

_JBossBasePort

:

$err
"

fi


echo

"Job

Create_ApplicationEnv_${_ApplicationName}_${_Environment}

created"

echo

""

echo

"
\
nScript

Job

"
$JobPath
/${_ApplicationName}/Create_ApplicationEnv_${_ApplicationName}_${_En
vironment}
"

has

been

created"



#########

#Create ChangeSystem.sh Deploy Job

#########

blcli_execute BlPackage getDBKeyByGroupAndName
$CommonDepotPath

$BlPackageName1

if

[ $? != 0 ]

then


fatal
"
\
nUnable

to

find

instance

BLPackage

:

$err
"

fi

blcli_storeenv BLPACKAGE1_ID



blcli_execute DeployJob createDeployJob
"ChangeSystem.sh_${_ApplicationName}_${_Environment}"

$JOBGROUP
_ID
$BLPACKAGE1
_ID
aserver
.intranet.
DOMAIN
.com
false

true

false

2>&1 >/dev/null

if

[ $? != 0 ]

then


fatal
"
\
nUnable

to

create

the

Deploy

Job

:

$err
"

fi

blcli_storeenv DEPLOYJOB1_ID

blcli_execute Job clearTargetServers
$DEPLOYJOB1
_ID

blcli_storeenv DEPLOYJOB1_ID


if

[ ${_Environment} = development ] ;
then


blcli_execute Job applyAclTemplate
$DEPLOYJOB1
_ID
${_BusinessAreaUser}d_ADMIN_DEFAULT
false


blcli_storeenv DEPLOYJOB1_ID

fi

if

[ ${_Environment} = production ] ;
then


blcli_execute Job apply
AclTemplate
$DEPLOYJOB1
_ID
${_BusinessAreaUser}p_ADMIN_DEFAULT
false


blcli_storeenv DEPLOYJOB1_ID

fi

if

[ ${_Environment} = uat ] ;
then


blcli_execute Job applyAclTemplate
$DEPLOYJOB1
_ID
${_BusinessAreaUser}u_ADMIN_DEFAULT
false


blcli_storeenv DEPLOYJOB1_ID

fi

echo

"Job

ChangeSystem.sh_${_ApplicationName}_${_Environment}

created"


#########

#Create StartStopThreads Deploy Job

#########

blcli_execute BlPackage getDBKeyByGroupAndName
$CommonDepotPath

$BlPackageName2

if

[ $? != 0 ]

then


fatal
"
\
nUnable

to

find

instance

BLPackage

:

$err
"

fi

blcli_storeenv BLPACKAGE2_ID



blcli_execute DeployJob createDeployJob
"StartStopThreads_${_ApplicationName}_${_Environment}"

$JOBGROUP
_ID
$BLPACKAGE2
_ID
aserver
.intranet.
DOMA
IN
.com
false

true

false

2>&1 >/dev/null

if

[ $? != 0 ]

then


fatal
"
\
nUnable

to

create

the

Deploy

Job

:

$err
"

fi

blcli_storeenv DEPLOYJOB2_ID

blcli_execute Job clearTargetServers
$DEPLOYJOB2
_ID

blcli_storeenv DEPLOYJOB2_ID


if

[ ${_Environment} = development ] ;
then


blcli_execute Job applyAclTemplate
$DEPLOYJOB2
_ID
${_BusinessAreaUser}d_ADMIN_DEFAULT
false


blcli_storeenv DEPLOYJOB2_ID

fi

if

[ ${_Environment} = production ] ;
then


blcli_execute

Job applyAclTemplate
$DEPLOYJOB2
_ID
${_BusinessAreaUser}p_ADMIN_DEFAULT
false


blcli_storeenv DEPLOYJOB2_ID

fi

if

[ ${_Environment} = uat ] ;
then


blcli_execute Job applyAclTemplate
$DEPLOYJOB2
_ID
${_BusinessAreaUser}u_ADMIN_DEFAULT
false


blcli_storeenv DEPLOYJOB2_ID

fi

echo

"StartStopThreads_${_ApplicationName}_${_Environment}

created"


echo

"
\
nPlease

run

the

instanceDeployment

script

to

assign

targets

and

execute

the

deployment"

echo

""


}



#########

# MAIN SCRIPT

#########


run_sql_storedprocedure


check_already_exists


check_role


create_workspace


create_repo_space


create_property_class


create_jobs



Script to Provision

a Commissioned
JBoss
environment (as JHUAadmins)



Takes the Application Name, Environment and a Server
“Deployment Group” name as input



Executes the JBossInstanceDeployment script after passing a target group to the job.


#!/bin/nsh


#######################################################################

#Script to execute JBoss instance provision once Comm
ission phase complete

#

#Scott Dunbar 23/05/12

#Version 1.0

#######################################################################

#set
-
eE

#set x


usage() {


echo

"Usage:

$0

<target>

<environment

[development|uat|production}>

<appname>"


exit

}


fatal(
) {


echo

$*


blcli_disconnect


exit 1

}


if

[ $
#
-
ne 3
-
a $#
-
ne 5 ] ; then


usage

fi


TARGET
=
$1

ENVIRONMENT
=
$2

APPNAME
=
$3


JobPath
=
"/JBoss/ApplicationManagement"


ENVIRONMENT_NOCASE
=
`echo $ENVIRONMENT | tr '[:upper:]' '[:lower:]'`


case

${ENVIRONMENT_NOCASE}
in


production )
DeploymentGroup
=
"/Production/Application

Deployment"


;;


uat )
DeploymentGroup
=
"/UAT/Application

Deployment"


;;


development )
DeploymentGroup
=
"/Development/Application

Dep
loyment"


;;


* ) usage


;;

esac


JOB_NAME
=
"Create_ApplicationEnv_
${APPNAME}
_
${ENVIRONMENT}
"


blcli_setoption serviceProfileName DEV

blcli_setoption roleName
APPAdmins

blcli_connect


if

[ $?
-
ne 0 ] ;
then


if

[
-
n
"
$5
"

] ;
then


blcred cred
-
acquire
-
profile DEV
-
username
"
$4
"

-
password
"
$5
"


else


blcred cred
-
acquire
-
profile DEV


fi

fi


blcli_execute NSHScriptJob getDBKeyByGroupAndName
$JobPath
/
$APPNAME

"${JOB_NAME}"

if

[ $?
-
ne 0 ]

then


f
atal
"Can

not

find

the

NSHScriptJob

Specified

:

${JOB_NAME}

:

$err
"

fi

blcli_storeenv SCRIPTJOBRUN1_ID


blcli_execute Job addTargetGroup
$SCRIPTJOBRUN1
_ID
"
$DeploymentGroup
/
$TARGET
"

if

[ $?
-
ne 0 ]

then


fatal
"Target

Server

Group

$TARGET

cound

not

be

found

and

was

not

added

to

${JOB_NAME}

:

$err
"

else


echo

"Target

Server

Group

$TARGET

added

to

${JOB_NAME}"


blcli_storeenv SCRIPTJOBRUN1_ID

fi


blcli_execute NSHScriptJob executeJobAndWait
$SCRIPTJOBRUN1
_ID

if

[ $?
-
ne 0 ]

then


fatal
"Problem

executing

the

deploy

job

:

$err
"

fi


#Execute the Job

blcli_execute NSHScriptJob getDBKeyByGroupAndName
$JobPath
/
$APPNAME

"${JOB_NAME}"

if

[ $?
-
ne 0 ]

then


fatal
"Script

Job

could

not

be

found

${JOB_NAME}

:

$err
"

else


blcli_storeenv SCRIPTJOBRUN1_ID

fi

blcli_execute JobRun findLastRunKeyByJobKey
$SCRIPTJOBRUN1
_ID

blcli_storeenv RUNKEY

blcli_execute JobRun getJobRunHadErrors
$RUNKEY

blcli_storeenv RESULT

blcli_execute JobRun jobRunKeyToJobRunId
$RUNKEY

blcli_stor
eenv JOBID

DATE
=
`date +%d%m%Y
-
%H%M%s`

blcli_execute Utility exportNSHScriptRun
$JOBID

$0
_${DATE}.$$.csv

echo

"The

Script

Job

encountered

an

error

=

$RESULT
"


Script to d
eploy an application payload to all instances of an environment (as a Developer user)

/Depot/Sandbox/Scott/ NonUI_applicationDeployment



Takes and
application name and environment as input

(assumes application payload is already in the
correct location)



Adds a specified
payload

to a BLPackage



Creates a Deploy Job for that Package



Adds the
appropriate environment Component Smart Group as the target for the Deploy Job



Executes the deploy job


#!/nsh


#######################################################################

#Script to execute deploy job of JBoss install binaries

#

#Scott Dunbar
28/05/12

#Version 1.0

#######################################################################

#set
-
eE

set
-
x


# ONLY NEEDED IF RUNNING OUTSIDE OF THE GUI

#blcred cred
-
acquire
-
profile DEV
-
username RBACAdmin
-
password password

blcli_setoption serviceProf
ileName DEV

#blcli_setoption roleName





#should be set by NSH
Proxy

blcli_connect


#Process

# 1.



#######################################################################

# Set some expected paramerters

#######################################################################

#SOURCEHOST=`fqdn`

#HOSTNAME=`print $HOSTNAME|tr '[ ]' '[]'`

#echo "The target is [${HOSTNAME}]"


#FILE_PATH=$1


#the source files for the job. Must be in NSH format

APPNAME
=
$1

ENVIRONMENT
=
$2


EXPECTED_ARGS
=2

if

[ $
#
-
ne $EXPECTED_ARGS ]

then


echo

"Usage:

`basename $0`

<Application

Name>

<Environment

[development|uat|production]>"


blcli_disconnect


exit 1

fi


DATE
=
`date +%d%m%Y
-
%H%M`

JobName
=
"Deploy_AppFiles_
${APPNAME}
_
${ENVIRONMENT}
_
$DATE
"

PackageName
=
"
${APPNAME}
_
${ENVIRONMENT}
_Payload_
$DATE
"

JobGroup
=/JBoss/ApplicationManagement

DeployFolderPath
=
/apps/middleware
/applications/jboss
-
as
/content/
$APPNAME

Template
=DeployApplication

TemplateGroup
=/JBoss/Common


RepoServer
=
aserver.adomain.com

RepoPath
=/c/JAH


ENVIRONMENT
=
`echo $ENVIRONMENT | tr '[:upper:]' '[:lower:]'`

case

${ENVIRONMENT}

in


production )
ComponentGroup
=
"/JBoss/Application/Production"


;;


uat )
ComponentGroup
=
"/JBoss/Application/UAT"


;;


development )
ComponentGroup
=
"/JBoss/Application/Development"


;;


* ) usage


;;

esac



create_package ()

{


blcli_execute DepotGroup groupExists
$JobGroup
/
$APPNAME

blcl
i_storeenv CHECK_RESULT

if

[
$CHECK
_RESULT =
false

];
then


echo
"
\
nIt

looks

like

the

Application

Enviornment

$APPNAME

has

not

been

commissioned

yet.

Stopping

script"


blcli_disconnect


exit 1

else


blcli_execute DepotGroup groupNameToId
$JobGroup
/
$APPNAME


blcli_storeenv DEPOTGROUP_ID


fi


blcli_execute Template setLocalParameterDefaultValue
$Template

$TemplateGroup

_SourcePayload
"
$RepoPath
/
${APPNAME}
_
${ENVIRONMENT}
"

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

set

the

_SourcePayload

property"


blcli_disconnect


exit 1

fi


blcli_execute Template getDBKeyByGroupAndName
$TemplateGroup

$Template

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

find

the

template

specified"


blcli_disconnect


exit 1

fi

blcli_storeenv TEMPLATE_DBKEY


blcli_execute BlPackage crea
tePackageFromAsset
"
$PackageName
"

$DEPOTGROUP
_ID
false

false

false

true

false

$TEMPLATE
_DBKEY
$RepoServer

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

create

a

BLPackage

of

your

payload.

Please

check

the

source

and

try

again"


blcli_disconnect


exit 1

fi

blcli_storeenv BLPACKAGE_ID


echo

"rm

-
rf

??_SourcePayload??/*

"

>> /tmp/ExCmdStart.txt

echo

"find

??_SourcePayload??

-
type

f

-
exec

chmod

g+r

{}

\
;

"

>>
/tmp/ExCmdEnd.txt

echo

"n/a"

>> /tmp/UndoCmd.txt


blcli_execute BlPackage addExternalCmdToStart
$BLPACK
AGE
_ID
"Clear

$APPNAME

Directory"

/tmp/ExCmdStart.txt /tmp/UndoCmd.txt
"Abort"

if

[ $? != 0 ]

then


echo

"
\
nWarning:

Could

not

clear

the

contents

of

directory"

fi


blcli_execute BlPackage addExternalCmdToEnd
$BLPACKAGE
_ID
"Chmod

of

files"

/tmp/ExCmdEnd.txt /tmp/UndoCmd.txt
"Abort"

if

[ $? != 0 ]

then


echo

"
\
nWarning:

The

permissions

of

the

payload

could

not

be

changed"

fi


rm

/tmp/ExCmdStart.txt

rm

/tmp/ExCmdEnd.txt

rm

/tmp/UndoCmd.txt


}


create_deploy_job ()

{


blcli_execute

JobGroup groupNameToId
$JobGroup
/
$APPNAME

blcli_storeenv JOBGROUP_ID


blcli_execute DeployJob createDeployJob
"
$JobName
"

$JOBGROUP
_ID
$BLPACKAGE
_ID
aserver
.intranet.
DOMAIN
.com
false

true

false

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

create

the

Deploy

Job

:

$err
"


blcli_disconnect


exit 1

fi

blcli_storeenv DEPLOYJOB1_ID

blcli_execute Job clearTargetServers
$DEPLOYJOB1
_ID

blcli_storeenv DEPLOYJOB1_ID


blcli_execute Job addTargetComponentGroup
$DEPLOYJOB1
_ID
"
$ComponentGroup
/
$APPNAME
"

if

[ $? != 0 ]

then


echo

"
\
nCould

not

find

a

target

Component

Smart

Group

by

name

$APPNAME

and

Environment

$ENVIRONMENT
:

$err
"


blcli_disconnect


exit 1

fi

#blcli_execute Job addTargetServer $DEPLOYJOB1_ID
nykpsr0161.intranet.
DOMAIN
.com

blcli_storeenv DEPLOYJOB1_ID



#change the payload path to new destination

blcli_execute DeployJob setOverriddenParameterValue
"
$JobGroup
/
$APPNAME
"

"
$JobName
"

_SourcePayload
$DeployFolderPath

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

set

the

_SourcePayload

property"


blcli_disconnect


exit 1

fi


}


execute_job ()

{

blcli_execute DeployJob executeJobAndWait
$DEPLOYJOB1
_ID

if

[ $? != 0 ]

then


echo

"
\
nProblem

executing

the

Deploy

Job:

$err
"


blcli_disconnect


exit 1

else




echo

"
\
nJob

Executed"

fi

blcli_execute DeployJob getDBKeyByGroupAndName
$JobGroup
/
$APPNAME

"
$JobName
"

if

[ $? != 0 ]

then


echo

"
\
nTarget

Server

Group

cound

not

be

found

:

$err
"


blcli_disconnect


exit 1

fi

blcli_storeenv DEPLOYJOB1_
ID


blcli_execute JobRun findLastRunKeyByJobKey
$DEPLOYJOB1
_ID

blcli_storeenv RUNKEY

blcli_execute JobRun getJobRunHadErrors
$RUNKEY

blcli_storeenv RESULT

blcli_execute DeployJobRun findLastRunIdByJobKey
$DEPLOYJOB1
_ID

blcli_storeenv JOBKEY


blcli_execute

Utility exportDeployRun
$JobGroup
/
$APPNAME

"
$JobName
"

$JOBKEY

$0
_${DATE}.$$.csv

echo

"The

Deploy

Job

encountered

an

error

=

$RESULT
"



}


#

#MAIN SCRIPT

#


create_package


create_deploy_job


execute_job


Script to start, stop or thread dump all JBoss
instances of an environment (as a Developer user)

/Depot/Sandbox/Scott/ NonUI_JBossInstanceStartStopThreads



Takes Application Name, Environment and desired action as input.



Adds Component Smart Group target based on Environment and Application Name logic



Creates a deploy job from an existing BLPackage that contains the external commads for start, stop or
threads of the jbctrl.sh script



Pass required parameters to JBoss
InstanceStartStopThreads BLPackage deploy job



Executes the updated JBossInstanceStartStop
Threads script.


#!/bin/nsh


#######################################################################

#Script to execute deploy job of JBoss install binaries

#

#Scott Dunbar 06/06/12

#Version 1.0

#######################################################################

#set
-
eE

set
-
x


# ONLY NEEDED IF RUNNING OUTSIDE OF THE GUI

#blcred cred
-
acquire
-
profile DEV
-
username RBACAdmin
-
password password

blcli_setoption serviceProfileName DEV

blcli_conn
ect


#Process

# 1. C



#######################################################################

# Set some expected paramerters

#######################################################################

#TARGET=`fqdn`

#TARGET=`print $TARGET|tr '[ ]' '[]'`

#echo "The target is [${TARGET}]"


APPNAME
=
$1

ENVIRONMENT
=
$2

ACTION
=
$3


EXPECTED_ARGS
=3

if

[ $
#
-
ne $EXPECTED_ARGS ]

then


echo

"Usage:

`basename $0`

<Application

Name>

<Environment>

<start/stop/threads>"


blcli_disconnect


exit 1

fi



ENVIRONMENT
=
`echo
$ENVIRONMENT | tr '[:upper:]' '[:lower:]'`


JobGroup
=/JBoss/ApplicationManagement

DeployFolderPath
=
/apps/middleware
/applications/jboss
-
as
/content/
$APPNAME


ProdComponentGroup
=
"/JBoss/Application/Production"

DevComponentGroup
=
"/JBoss/Application/Development
"

UatComponentGroup
=
"/JBoss/Application/UAT"


if

[
${ENVIRONMENT}

= production ] ;
then

ComponentGroup
=
$ProdComponentGroup

fi

if

[
${ENVIRONMENT}

= development ] ;
then

ComponentGroup
=
$DevComponentGroup

fi

if

[
${ENVIRONMENT}

= uat ] ;
then

ComponentGroup
=
$UatComponentGroup

fi



blcli_execute DeployJob getDBKeyByGroupAndName
$JobGroup
/
$APPNAME

"StartStopThreads_
${APPNAME}
_
${ENVIRONMENT}
"

if

[ $? != 0 ]

then


echo

"
\
nCan

not

find

the

DeployJob

Specified

StartStopThreads_
${APPNAME}
_
${ENVIRONMENT}

:

$err
"


blcli_disconnect


exit 1

fi

blcli_storeenv DEPLOYJOB1_ID

blcli_execute Job clearTargetServers
$DEPLOYJOB1
_ID

blcli_execute Job addTargetComponentGroup
$DEPLOYJOB1
_ID
"
$ComponentGroup
/
$APPNAME
"

if

[ $? != 0 ]

then


echo

"
\
nTarget

Server

Group

cound

not

be

found

and

was

not

added

to

StartStopThreads_
${APPNAME}
_
${ENVIRONMENT}

:

$err
"


blcli_disconnect


exit 1

else


echo

"
\
nTarget

Server

Group

added

to

StartStopThreads_
${APPNAME}
_
${ENVIRONMENT}
"


blcli_storeenv DEPLOYJOB1_ID

fi


#Set DeployJob Values

blcli_execute DeployJob setOverriddenParameterValue
"
$JobGroup
/
$APPNAME
"

"StartStopThreads_
${APPNAME}
_
${ENVIRONMENT}
"

_Action
$ACTION

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

set

the

_SourcePayload

property"


blcli_disconnect


exit 1

fi

blcli_execute DeployJob setOverriddenParameterValue
"
$JobGroup
/
$APPNAME
"

"StartStopThreads_
${APPNAME}
_
${ENVIRONMENT}
"

_ApplicationName
$APPNAME

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

set

the

_SourcePayload

property"


blcli_disconnect


exit 1

fi

blcli_execute DeployJob setOverriddenParameterValue
"
$JobGroup
/
$APPNAME
"

"StartStopThreads_
${APPNAME}
_
${ENVIRONMENT}
"

_Environment
$ENVIRONMENT

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

set

the

_SourcePayload

property"


blcli_disconnect


exit 1

fi


#Execute the Job

blcli_execute DeployJob executeJobAndWait
$DEPLOYJOB1
_ID

if

[ $? != 0 ]

then


echo

"
\
nProblem

executing

the

deploy

job

:

$err
"


blcli_disconnect


exit 1

fi

blcli_execute DeployJob getDBKeyByGroupAndName
$JobGroup
/
$APPNAME

"StartStopThreads_
${APPNAME}
_
${ENVIRONMENT}
"

if

[ $? != 0 ]

then


echo

"
\
nScript

Job

cound

not

be

found

StartStopThreads_
${APPNAME}
_
${ENVIRONMENT}

:

$err
"


blcli_disconnect


exit 1

else


blcli_storeenv DEPLOYJOB1_ID

fi

blcli_execute JobRun findLastRunKeyByJobKey
$DEPLOYJOB1
_ID

blcli_storeenv RUNKEY

blcli_execute DeployJobRun findLastRunIdByJobKey
$DEPLOYJOB1
_ID

blcli_storeenv JOBKEY

blcli_execute

JobRun getJobRunHadErrors
$RUNKEY

blcli_storeenv RESULT


DATE
=
`date +%d%m%Y
-
%H%M%s`

blcli_execute Utility exportDeployRun
$JobGroup
/
$APPNAME

"StartStopThreads_
${APPNAME}
_
${ENVIRONMENT}
"

$JOBKEY

./
$0
_${DATE}.$$.csv

echo

"The

Script

Job

encountered

an

error

=

$RESULT
"



/Depot/JBoss/Common/JBossInstanceDeployment



Called from NonUI_instanceCommission and executed by NonUI_executeInstanceDeploymentNSHScript



Creates components for Instance and Application



Sets correct ACL Template



Executes
jboss
-
utils/bin/new
-
jboss
-
instance.sh script passing all parameters from instanceCommission
properties file


#!bin/nsh


#######################################################################

#Script to execute deploy job of JBoss install binaries

#

#Scott

Dunbar 22/05/12

#Version 1.0

#######################################################################

#set
-
eE

#set
-
x


# ONLY NEEDED IF RUNNING OUTSIDE OF THE GUI

#blcred cred
-
acquire
-
profile DEV
-
username RBACAdmin
-
password password

#blcli_setoption s
erviceProfileName DEV

#blcli_setoption roleName
APPAdmins

#blcli_connect


#Process

# 1. Capture Job ID of existing instance deployment job

# 2. Pass in Deployment Group

# 3. Execute job and return job run results



#######################################################################

# Set some expected paramerters

#######################################################################

TARGET
=
`fqdn`

TARGET
=
`print $TARGET|tr '[ ]' '[]'`

echo

"The

target

is

[
${TARGET}
]"


_
SUPP_TEAM3
=
$1

_
SUPP_TEAM1
=
$2

_Environment
=
$3

_JavaHome
=
$4

_JavaXMS
=
$5

_JavaXMX
=
$6

_JBossClusteringEnabled
=
$7

_JBossClusterMembers
=
$8

_JBossClusterMulticastAddress
=
$9

_JBossClusterMulticastPort
=
$10

_JBossUser
=
$11

_JBossVersion
=
$12

_ApplicationName
=
$13

_
SUPP_TEAM2
=
$14

_JBossClusterName
=
$15

_JBossBasePort
=
$16

_JBossInstanceName
=$_ApplicationName


echo

"${_
SUPP_TEAM3
}"

echo

"${_
SUPP_TEAM1
}"

echo

"${_Environment}"

echo

"${_JavaHome}"

echo

"${_JavaXMS}"

echo

"${_JavaXMX}"

echo

"${_JBossClusteringEnabled}"

echo

"${_JBossClusterMembers}"

echo

"${_JBossClusterMulticastAddress}"

echo

"${_JBossClusterMulticastPort}"

echo

"${_JBossUser}"

echo

"${_JBossVersion}"

echo

"${_ApplicationName}"

echo

"${_
SUPP_TEAM2
}"

echo

"${_JBossClusterName
}"

echo

"{$_JBossBasePort}"

echo

"${_JBossInstanceName}"


ProdDeploymentGroup
=
"/Production/Application

Deployment"

UatDeploymentGroup
=
"/UAT/Application

Deployment"

DevDeploymentGroup
=
"/Development/Application

Deployment"


InstanceTemplatePath
=/JBoss/Instance

InstanceTemplateName
=Instance

ApplicationTemplatePath
=/JBoss/Application

ApplicationTemplateName
=Application

TrackChangeTemplatePath
=/JBoss/TrackChange

TrackChangeTemplateName
=TrackChange


CommonJobPath
=/JBoss/Common


_Environment
=
`echo
$_Environment | tr '[:upper:]' '[:lower:]'`

case

${_Environment}
in


production )
AclPushJob
=
"ACLPushProduction"


_EnvironmentCaseSensitive
=
"production"


;;


uat )
AclPushJob
=
"ACLPushUAT"


_EnvironmentCaseSensitive
=
"UAT"


;;


development )
AclPushJob
=
"ACLPushDevelopment"


_EnvironmentCaseSensitive
=
"development"


;;

esac


create_component ()

{


blcli_execute Template getDBKeyByGroupAndName
$Instan
ceTemplatePath

$InstanceTemplateName

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

find

the

Component

Template

:

$err
"


blcli_disconnect


exit 1

fi

blcli_storeenv INSTANCE_TEMPLATE_ID


blcli_execute Template getDBKeyByGroupAndName
$ApplicationTemplatePath

$ApplicationTemplateName

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

find

the

Component

Template

:

$err
"


blcli_disconnect


exit 1

fi

blcli_storeenv APPLICATION_TEMPLATE_ID


blcli_execute Template getDBKeyByGroupAn
dName
$TrackChangeTemplatePath

$TrackChangeTemplateName

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

find

the

Component

Template

:

$err
"


blcli_disconnect


exit 1

fi

blcli_storeenv TRACKCHANGE_TEMPLATE_ID


blcli_execute

Server getServerIdByName
$TARGET

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

find

the

target

Server

ID

:

$err
"


blcli_disconnect


exit 1

fi

blcli_storeenv SERVER_ID


##########

#Create the Instance Component


blcli_execute

Component createComponent
"Instance:

${_ApplicationName}_${_Environment}(
$TARGET
)"

$INSTANCE
_TEMPLATE_ID
$SERVER
_ID

blcli_storeenv COMPONENT_ID1


blcli_execute Component applyAclTemplate
$COMPONENT
_ID1
${_JBossUser}_ADMIN_DEFAULT
false

blcli_storeenv COM
PONENT_ID1


blcli_execute Component setPropertyValue
$COMPONENT
_ID1
_JBOSS_APPLICATION_NAME ${_ApplicationName}

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

set

the

Component

value

_JBOSS_APPLICATION_NAME

:

$err
"


blcli_disconnect


exit 1

fi

#blcli_execute Component getComponentKeyByTemplateKeyAndServerId
$INSTANCE_TEMPLATE_ID $SERVER_ID 0

#blcli_storeenv COMPONENT_ID1


blcli_execute Component getAllComponentKeysByTemplateKeyAndServerId
$INSTANCE
_TEMPLATE_ID
$SERVER
_ID

blcli_storeenv COMPON
ENTKEYLIST


for

KEY
in

$COMPONENTKEYLIST

;
do


blcli_execute Component componentKeyToName
$KEY


blcli_storeenv COMPNAME


if

[
"
$COMPNAME
"
=
"Instance:

${_ApplicationName}_${_Environment}(
$TARGET
)"

]


then



COMPONENT_ID1
=
$KEY



#break


fi

done


blcli_execute

Component setPropertyValue
$COMPONENT
_ID1 _JBOSS_ENV
${_Environment}

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

set

the

Component

value

_JBOSS_ENV

:

$err
"


blcli_disconnect


exit 1

fi

blcli_execute

Component getComponentKeyByTemplateKeyAndServerId
$INSTANCE
_TEMPLATE_ID
$SERVER
_ID 0

blcli_storeenv COMPONENT_ID1


##########

#Create the Application Component


blcli_execute Component createComponent
"Application:

${_ApplicationName}_${_Environment}(
$TAR
GET
)"

$APPLICATION
_TEMPLATE_ID
$SERVER
_ID

blcli_storeenv COMPONENT_ID2


blcli_execute Component applyAclTemplate
$COMPONENT
_ID2
${_JBossUser}_ADMIN_DEFAULT
false

blcli_storeenv COMPONENT_ID2


blcli_execute Component setPropertyValue
$COMPONENT
_ID2
_JBOSS_
APPLICATION_NAME ${_ApplicationName}

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

set

the

Component

value

_JBOSS_APPLICATION_NAME

:

$err
"


blcli_disconnect


exit 1

fi

#blcli_execute Component getComponentKeyByTemplateKeyAndServerId
$APPLICATION_TEMPLATE_ID $SERVER_ID 0

#blcli_storeenv COMPONENT_ID2


blcli_execute Component getAllComponentKeysByTemplateKeyAndServerId
$APPLICATION
_TEMPLATE_ID
$SERVER
_ID

blcli_storeenv COMPONENTKEYLIST


for

KEY
in

$COMPONENTKEYLIST

;
do


blcli_execute C
omponent componentKeyToName
$KEY


blcli_storeenv COMPNAME


if

[
"
$COMPNAME
"
=
"Application:

${_ApplicationName}_${_Environment}(
$TARGET
)"

]


then



COMPONENT_ID2
=
$KEY



#with the break added then this fails
-

unknown why. would

make
sense to break out of the loop to save time



#break


fi

done


blcli_execute Component setPropertyValue
$COMPONENT
_ID2 _JBOSS_ENV
${_Environment}

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

set

the

Component

value

_JBOSS_ENV

:

$err
"


blcli_disconnect


exit 1

fi

blcli_execute Component getComponentKeyByTemplateKeyAndServerId
$APPLICATION
_TEMPLATE_ID
$SERVER
_ID 0

blcli_storeenv COMPONENT_ID2


##########

#Create the TrackChange Component


blcli_execute

Component createComponent
"TrackChange:

${_ApplicationName}_${_Environment}(
$TARGET
)"

$TRACKCHANGE
_TEMPLATE_ID
$SERVER
_ID

blcli_storeenv COMPONENT_ID3


blcli_execute Component applyAclTemplate
$COMPONENT
_ID3
${_JBossUser}_ADMIN_DEFAULT
false

blcli_storee
nv COMPONENT_ID3


blcli_execute Component setPropertyValue
$COMPONENT
_ID3
_JBOSS_APPLICATION_NAME ${_ApplicationName}

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

set

the

Component

value

_JBOSS_APPLICATION_NAME

:

$err
"


blcli_disconnect


exit 1

fi

#blcli_execute Component getComponentKeyByTemplateKeyAndServerId
$TRACKCHANGE_TEMPLATE_ID $SERVER_ID 0

#blcli_storeenv COMPONENT_ID3


blcli_execute Component getAllComponentKeysByTemplateKeyAndServerId
$TRACKCHANGE
_TEMPLATE_ID
$SERVER
_ID

blcli_st
oreenv COMPONENTKEYLIST


for

KEY
in

$COMPONENTKEYLIST

;
do


blcli_execute Component componentKeyToName
$KEY


blcli_storeenv COMPNAME


if

[
"
$COMPNAME
"
=
"TrackChange:

${_ApplicationName}_${_Environment}(
$TARGET
)"

]


then



COMPONENT_ID3
=
$KEY



#break


fi

done


blcli_execute Component setPropertyValue
$COMPONENT
_ID3 _JBOSS_ENV
${_Environment}

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

set

the

Component

value

_JBOSS_ENV

:

$err
"


blcli_disconnect


exit 1

fi

blcli_execute

Component getComponentKeyByTemplateKeyAndServerId
$TRACKCHANGE
_TEMPLATE_ID
$SERVER
_ID 0

blcli_storeenv COMPONENT_ID3



}


add_target_acls ()

{


blcli_execute Server applyAclTemplate
$TARGET

${_JBossUser}_ADMIN_DEFAULT
false

blcli_execute AclPushJob getDBK
eyByGroupAndName
"
$CommonJobPath
"

"
$AclPushJob
"

if

[ $? != 0 ]

then


echo

"
\
nCan

not

find

the

ACL

Push

Job

for

$_Environment

:

$err
"


blcli_disconnect


exit 1

fi

blcli_storeenv ACLJOB_ID

blcli_execute AclPushJob executeJobAndWait
$ACLJOB
_ID

}




deploy_jboss_instance ()

{

_JBossUser
=
`echo $_JBossUser | tr '[:upper:]' '[:lower:]'`

echo

"sudo

-
u

${_JBossUser}

/apps/middleware
/jboss
-
utils/bin/new
-
jboss
-
instance.sh

--
name=${_JBossInstanceName}

--
jboss
-
version=${_JBossVersion}

--
java
-
home=${_JavaHome}

--
xms=${_JavaXMS}

--
xmx=${_JavaXMX}

--
admin
-
group=${_
SUPP_TEAM2
}

--
read
-
group=${_
SUPP_TEAM3
}

--
breakglass
-
group=${_
SUPP_TEAM1
}

--
base
-
port=${_JBossBasePort}

--
environment=${_EnvironmentCaseSensitive}

--
cluster
-
enabled=${_JBossClust
eringEnabled}

--
cluster
-
mcast
-
ip=${_JBossClusterMulticastAddress}

--
cluster
-
mcast
-
port=${_JBossClusterMulticastPort}

--
cluster
-
members=${_JBossClusterMembers}

--
fail
-
on
-
missing"

nexec
-
e
sudo

-
u ${_JBossUser}
/apps/middleware
/jboss
-
utils/bin/new
-
jboss
-
inst
ance.
sh

--
name
=
"${_JBossInstanceName}"

--
jboss
-
version
=
"${_JBossVersion}"

--
java
-
home
=
"${_JavaHome}"

--
xms
=
"${_JavaXMS}"

--
xmx
=
"${_JavaXMX}"

--
admin
-
group
=
"${_
SUPP_TEAM2
}"

--
read
-
group
=
"${_
SUPP_TEAM3
}"

--
breakglass
-
group
=
"${_
SUPP_TEAM1
}"

--
base
-
port
=
"${_JBossBasePort}"

--
environment
=
"${_EnvironmentCaseSensitive}"

--
cluster
-
enabled
=
"${_JBossClusteringEnabled}"

--
cluster
-
mcast
-
ip
=
"${_JBossClusterMulticastAddress}"

--
cluster
-
mcast
-
port
=
"${_JBossClusterMulticastPort}"

--
cluster
-
members
=
"${_JBossClusterMem
bers}"

--
fail
-
on
-
missing


}


#

# MAIN SCRIPT

#



create_component


add_target_acls


deploy_jboss_instance

/Depot/JBoss/Common/
changeSystemShFile



Uses application name, environment, value and property as parameters



Calls a BLPackage that runs a SED command

on the System.sh file that will make a change to the value
specified in the property argument





#!bin/nsh


#######################################################################

#

#

#Scott Dunbar 12/06/12

#Version 1.0

##################################
#####################################

#set
-
eE

set
-
x


# ONLY NEEDED IF RUNNING OUTSIDE OF THE GUI

#blcred cred
-
acquire
-
profile DEV
-
username RBACAdmin
-
password password

blcli_setoption serviceProfileName DEV

#blcli_setoption roleName
APPAdmins

blcli_connect


#Process

# 1.


#######################################################################

# Set some expected paramerters

#######################################################################

#TARGET=`fqdn`

#TARGET=`print $TARGET|tr '[ ]'
'[]'`

#echo "The target is [${TARGET}]"


APPNAME
=
$1

ENVIRONMENT
=
$2

NAME
=
$3

VALUE
=
$4


EXPECTED_ARGS
=4

if

[ $
#
-
ne $EXPECTED_ARGS ]

then


echo

"Usage:

`basename $0`

<Application

Name>

<Environment>

<Name

of

value

to

change>

<New

value>"


blcli_disconnect


exit 1

fi


ENVIRONMENT
=
`echo $ENVIRONMENT | tr '[:upper:]' '[:lower:]'`


JobGroup
=/JBoss/ApplicationManagement

DeployFolderPath
=
/apps/middleware
/applications/jboss
-
as
/content/
$APPNAME


ProdComponentGroup
=
"/JBoss/Application/Production"

DevComponentGroup
=
"/JBoss/Application/Development"

UatComponentGroup
=
"/JBoss/Application/UAT"


if

[
${ENVIRONMENT}

= production ] ;
then

ComponentGroup
=
$ProdComponentGroup

fi

if

[
${ENVIRONMENT}

= development ] ;
then

ComponentGroup
=
$DevComponentGroup

fi

if

[
${ENVIRONMENT}

= uat ] ;
then

ComponentGroup
=
$UatComponentGroup

fi



blcli_execute DeployJob getDBKeyByGroupAndName
$JobGroup
/
$APPNAME

"ChangeSystem.sh_
${APPNAME}
_
${ENVIRONMENT}
"

if

[ $? != 0 ]

then


echo

"
\
nCan

not

find

the

DeployJob

Specified

ChangeSystem.sh_{APPNAME}_
${ENVIRONMENT}

:

$err
"


blcli_disconnect


exit 1

fi

blcli_storeenv DEPLOYJOB1_ID

blcli_execute Job clearTargetServers
$DEPLOYJOB1
_ID

blcli_execute Job addTargetComponentGroup
$DEPLOYJOB1
_ID
"
$ComponentGroup
/
$APPNAM
E
"

if

[ $? != 0 ]

then


echo

"
\
nTarget

Server

Group

cound

not

be

found

and

was

not

added

to

ChangeSystem.sh_
${APPNAME}
_
${ENVIRONMENT}

:

$err
"


blcli_disconnect


exit 1

else


echo

"
\
nTarget

Server

Group

added

to

ChangeSystem.sh_
${APPNAME}
_
${ENVIRONMENT}
"


blcli_storeenv DEPLOYJOB1_ID

fi


#Set DeployJob Values

blcli_execute DeployJob setOverriddenParameterValue
"
$JobGroup
/
$APPNAME
"

"ChangeSystem.sh_
${APPNAME}
_
${ENVIRONMENT}
"

_ApplicationName
$APPNAME

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

set

the

_SourcePayload

property"


blcli_disconnect


exit 1

fi

blcli_execute DeployJob setOverriddenParameterValue
"
$JobGroup
/
$APPNAME
"

"ChangeSystem.sh_
${APPNAME}
_
${ENVIRONMENT}
"

_Name
$NAME

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

set

the

_SourcePayload

property"


blcli_disconnect


exit 1

fi

blcli_execute DeployJob setOverriddenParameterValue
"
$JobGroup
/
$APPNAME
"

"ChangeSystem.sh_
${APPNAME}
_
${ENVIRONMENT}
"

_Value
$VALUE

if

[ $? != 0 ]

then


echo

"
\
nUnable

to

set

the

_SourcePayload

property"


blcli_disconnect


exit 1

fi


#Execute the Job

blcli_execute DeployJob executeJobAndWait
$DEPLOYJOB1
_ID

if

[ $? != 0 ]

then


echo

"
\
nProblem

executing

the

deploy

job

:

$err
"


blcli_disconnect


exit 1

fi

blcli_execute DeployJob getDBKeyByGroupAndName
$JobGroup
/
$APPNAME

"ChangeSystem.sh_
${APPNAME}
_
${ENVIRONMENT}
"

if

[ $? != 0 ]

then


echo

"
\
nScript

Job

cound

not

be

found

ChangeSystem.sh_
${APPNAME}
_
${ENVIRONMENT}

:

$err
"


blcli_disconnect


exit 1

else


blcli_storeenv DEPLOYJOB1_ID

fi

blcli_execute JobRun findLastRunKeyByJobKey
$DEPLOYJOB1
_ID

blcli_storeenv RUNKEY

blcli_execute JobRun getJobRunHadErrors
$RUNKEY

blcli_storeenv RESULT

blcli_execute

DeployJobRun findLastRunIdByJobKey
$DEPLOYJOB1
_ID

blcli_storeenv JOBKEY

DATE
=
`date +%d%m%Y
-
%H%M%s`

blcli_execute Utility exportDeployRun
$JobGroup
/
$APPNAME

"ChangeSystem.sh_
${APPNAME}
_
${ENVIRONMENT}
"

$JOBKEY

$0
_${DATE}.$$.csv

echo

"The

Script

Job

encounte
red

an

error

=

$RESULT
"