-
Notifications
You must be signed in to change notification settings - Fork 146
/
Copy pathdeploy_app.py.txt
75 lines (69 loc) · 2.05 KB
/
deploy_app.py.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/python
# Author : Tim Hall
# Save Script as : deploy_app.py
#
# Requirements:
#
# Set the environment and start WLST
#
# export MW_HOME=/u01/app/oracle/middleware
# export DOMAIN_HOME=$MW_HOME/user_projects/domains/myDomain
# . $DOMAIN_HOME/bin/setDomainEnv.sh
# java weblogic.WLST
#
# Connect to the admin server and store the credentials.
#
# connect('weblogic', 'password1', 't3://myserver.localdomain:7001')
# configfile = '/home/oracle/scripts/appconfigfile.secure'
# keyfile = '/home/oracle/scripts/appkeyfile.secure'
# storeUserConfig(userConfigFile=configfile, userKeyFile=keyfile)
# disconnect()
# exit()
#
import time
import getopt
import sys
import re
# Get parameter values.
configfile = '/home/oracle/scripts/appconfigfile.secure'
keyfile = '/home/oracle/scripts/appkeyfile.secure'
adminurl = 't3://myserver.localdomain:7001'
app = ''
path = ''
targetlist = 'myServer_1'
try:
opts, args = getopt.getopt(sys.argv[1:],"p:a:t:h::",["path=","app=","targetlist="])
except getopt.GetoptError:
print 'deploy_birms_app.py -p <path-to-ear> [-a <application>] [-t <targetlist>]'
sys.exit(2)
for opt, arg in opts:
if opt == '-h':
print 'deploy_birms_app.py -p <path-to-ear> [-a <application>] [-t <targetlist>]'
sys.exit()
elif opt in ("-a", "--app"):
app = arg
elif opt in ("-p", "--path"):
path = arg
elif opt in ("-t", "--targetlist"):
targetlist = arg
if app == '':
app = os.path.basename(path)
app = os.path.splitext(app)[0]
print 'app=', app
print 'path=', path
print 'targetlist=', targetlist
# Undeploy then deploy the application.
connect(userConfigFile=configfile, userKeyFile=keyfile, url=adminurl)
#edit()
#startEdit()
try:
undeploy(app)
except:
print '**********************************************************'
print '***** Failed to undeploy. Is it a first-time deploy? *****'
print '**********************************************************'
deploy(app,path,targets=targetlist)
#save()
#activate()
disconnect()
exit()