This WLST script "VASDomainTemplateFinalV1.py" reads domain information from "VASDomainInfoV1.txt" and creates weblogic server domain template in the directory as mentioned in "VASDomainInfoV1.txt".

配置过程:

1)This python script reads the domain related information from "VASDomainInfoV1.txt" and creates the "Weblogic Domain" template(jar file) as mentioned in the "VASDomainInfoV1.txt".
2) Note this script assumes WL_HOME is set "c:\bea\wlserver_10.0" and location of default weblogic domain template is "C:\bea\wlserver_10.0\common\templates\domains\wls.jar"

执行过程:

1) set the classpath by executing "WL_HOME/server/bin/setWLSEnv.cmd" or "WL_HOME/server/bin/setWLSEnv.sh" for Unix.
2)Save the "VASDomainInfoV1.txt" file in any directory.
3)Modify the parameter values in "VASDomainInfoV1.txt" as per requirement. Please check out the sample info mentioned in the same file.
4)Change the directory location of "VASDomainInfoV1.txt" in line 72 of "VASDomainTemplateFinalV1.py" as per the location you saved in above step.
5)execute the script as below
    java weblogic.WLST VASDomainTemplateFinalV1.py

VASDomainInfoV1.txt:

#VASVASVAS
UserPassword::<Weblogic User Password>
AdminServerName::<Admin Server Name>
AdminServerListenAddress::<Admin Server IP Address>
AdminServerPort::<Admin Server Port>
TemplateDestinationDirectory::<Location where you want to store template>
TemplateName::<Domain Template Name>
Clusters::<Cluster Name 1>,<Cluster Name 2>
Machines::<Machine Name 1>,<Machine Name 2>
ManagedServers::"<Cluster Name1>,<Machine Name 1>,<Managed Server Name>,<ManagedServerIP:Port>;<Cluster Name1>,<Machine Name 1>,<Managed Server Name>,<ManagedServerIP:Port>"

#Sample DomainInfo File
#UserPassword::weblogic
#AdminServerName::VASAdminServer
#AdminServerListenAddress::127.0.0.1
#AdminServerPort::9999
#TemplateDestinationDirectory::C:\student\course_wlp_admin\work\templates\
#TemplateName::VASWLSTCluster
#Clusters::VASCluster1,VASCluster2
#Machines::VASMachine1,VASMachine2
#ManagedServers::"VASCluster1,VASMachine1,VASM1,127.0.0.1:9998;VASCluster2,VASMachine2,VASM2,127.0.0.1:9997"
#Please don't forget to mention double quotes for managed servers"

VASDomainTemplateFinalV1.py:

#=======================================================================================
# VASVASVAS
# Author : Vijay Bheemineni
# Creation Date :  11/27/2007
# This is an example of WLST offline domain template creation script. This example uses the Basic WebLogic
# Domain template to create a clustered domain using WLST offline configuration.
# All the values(  Example : password,admin server name etc) are mentioned in separate note pad file. This
# "python" script read values from the file and creates the weblogic resources. Below is the format of the
# file(VASDomainInfo.txt).
# Note : This script assumes "WL_HOME" is set to "c:\bea\wlserver_10.0" and location of default weblogic
# template is "C:\bea\wlserver_10.0\common\templates\domains\wls.jar"
#----------------------------------------------------------------------------------------------------------------------------------
#Userpassword::weblogic
#AdminServerName::VASAdminServer
#AdminServerListenAddress::127.0.0.1
#AdminServerPort::9999
#templateDestinationDirectory::C:\student\course_wlp_admin\work\templates\
#templateName::VASWLSTCluster
#clusters::VASCluster1,VASCluster2
#machines::VASMachine1,VASMachine2
#managedServers::"VASCluster1,VASMachine1,VASM1,127.0.0.1:9998;VASCluster2,VASMachine2,VASM2,127.0.0.1:9997"
#----------------------------------------------------------------------------------------------------------------------------------
# Please store the above lines in notepad file as "VASDomainInfo.txt" and domain template is created
# using values mentioned in this file.
#

#   Usage:
#        1) first set the path. This can be done by executing "WL_HOME\common\bin\setWLSEnv" script
#       2)
#  <Windows> = java weblogic.WLST VASDomainTemplate.py
#         <Unix>    = java weblogic.WLST VASDomainTemplate.py>
#=======================================================================================

from java.util import HashMap
import os
import re

#===============================================================================================================
# defining Global Variables
#===============================================================================================================
templateLocation = ""
password=""
adminName=""
adminListenAddress=""
adminPort=""
templateDestination=""
templateName=""
adminServerPath="/Server/"
clusters=""
machines=""
managedServersList=[]
managedServers=""

#===============================================================================================================
# Using map to store the variables
#===============================================================================================================
hm = HashMap()

#===============================================================================================================
# This function reads the values defined in the "VASDomainInfo.txt" and stores them in a map.
# In this program "VASDomainInfo.txt" is located in "C:\VASVijay\VASPersonalTechnical\VASWeblogic\VASWLST".
# Change the directory and file name as per your directory structure and choice.
#===============================================================================================================

def readParameters():

print "------------------Entering readParameters function-----------------"
  print

try :
# read the "VASDomainInfo" file, this file consists of all the information required to create the template
   readFile = open(r'C:\VASVijay\VASPersonalTechnical\VASWeblogic\VASWLST\VASDomainInfo.txt','rb')
   doublecolon = re.compile(r'::')
   comment=re.compile(r'#')
   for line in readFile.readlines():
# This if condition helps to read only lines which contains the character "::", this if condition avoids the trap of reading empty lines.
    if not comment.search(line) and doublecolon.search(line) :
     hm.put(str(line.rstrip().split('::')[0]),str(line.rstrip().split('::')[1]))
# IOError exception is caught here
  except IOError :
   print "Not able to read the information in the VASDomainInfo file"
# We get IndexError when the logic reads empty lines or it reads lines which don't contain the character '::'
  except IndexError :
   print "Array Index Error"
  else :
   print "Sucesfully read domain info file"
  
  print  
  print "------------------Leaving readParameters function-----------------"
  print
  return
   
#===============================================================================================================
# This function reads fetches the values of resources defined in "VASDomainFile" from the map and assign them to global variables
# defined in the section above.
#===============================================================================================================

def assignParameters():

print "------------------Entering assignParameters function-----------------"
  print
# defining global parameters
  global password
  password = hm.get("UserPassword")
  global adminName
  adminName = hm.get("AdminServerName")
  global adminListenAddress
  adminListenAddress = hm.get("AdminServerListenAddress")
  global adminPort
  adminPort = hm.get("AdminServerPort")
  global templateDestination
  templateDestination = hm.get("TemplateDestinationDirectory")
  global templateName
  templateName = hm.get("TemplateName")
  global clusters
  clusters = hm.get("Clusters")
  global machines
  machines = hm.get("Machines")
  global managedServers
  managedServers=hm.get("ManagedServers").replace('"','')
 
  print "password :",password
  print "adminName :",adminName
  print "adminListenAddress :",adminListenAddress
  print "adminPort :",adminPort
  print "templateDestination :",templateDestination
  print "templateName :",templateName
  print "clusters :",clusters
  print "machines :",machines
  print "managedServers :",managedServers
  
  print
  print "------------------Leaving readParameters function-----------------"
  print
  return
#===============================================================================================================
# This function read the basic domain template "wls.jar". This function assumes that WL_HOME parameter is set to "C:\bea\
# wlserver_10.0". Change the path as per location of WL_HOME.
#===============================================================================================================
   
def readBasicTemplate() :
 print "------------------Entering readBasicTemplate function-----------------"
 print
# Reading the basic weblogic domain template
 try:
  readTemplate(r'C:\bea\wlserver_10.0\common\templates\domains\wls.jar')
  print "Sucessfully read the basic template"
 except WLSTException:
  print " There is issue reading the basic template, please check the location"
 
 print
 print "------------------Leaving readBasicTemplate function-----------------"
 print
 return
 
#===============================================================================================================
# This function changes the name of "AdminServer". By default name of the Admin Server in "wls.jar" is "AdminServer". If
# different admin server name is mentioned in "VASDomainInfo.txt" then this function will be called to change the Admin Server name
#===============================================================================================================

def needToChangeAdminServerName():
  print "------------------Entering needToChangeAdminServerName function-----------------"
  print
# Changing the admin server name if its not "AdminServer".
  if not adminName == "AdminServer" :
   print "AdminServer name needs to be changed"
   cd('/')
   cd('/Server/AdminServer')
   cmo.setName(adminName)
   print " New Admin Server Name : " + str(cmo.getName())

print  
  print "------------------Leaving needToChangeAdminServerName function-----------------"
  print
  return
#===============================================================================================================
# This function reads the password mentioned for the default user "weblogic" in "VASDomainInfo.txt" and sets the password for the
# user "weblogic" as mentioned in the the file.
#===============================================================================================================

def setUserPassword():
 print "------------------Entering setUserPassword function-----------------"
 print
# Setting up of new password for the default user "weblogic".
 try :
   cd('/')
   cd('/Security/base_domain/User/weblogic')
   print "password :",password
   cmo.setUserPassword(password)
 except WLSTException :
   print " Exception raise while setting the password for the user"

print
 print "------------------Leaving setUserPassword function-----------------"
 print
 return

#===============================================================================================================
#  This function sets properties of the Admin Server such as "Admin Server Listen Port" and "Admin Server Listen Address.
#===============================================================================================================
 
def adminServerConfiguration():
 print "------------------Entering adminServerConfiguration function-----------------"
 print
 try :
  cd('/')
  global adminServerPath
  adminServerPath = adminServerPath + adminName
  cd(adminServerPath)
  print "adminName :",adminName
# Setting the admin server properties such as listen address and listen port
  print "adminListenAddress :",adminListenAddress
  print "adminPort :",adminPort
  set('ListenAddress',adminListenAddress)
  set('ListenPort',int(adminPort))
 except WLSTException :
   print "Exception caught while settings the properties of the Admin Server"
  
 print  
 print "------------------Leaving adminServerConfiguration function-----------------"
 print
 return

#===============================================================================================================
# This function checks if template "jar" file already exists in the directory as mentioned in the variable "TemplateDestinationDirectory" 
#  in the "VASDomainInfo.txt", if yes returns "Yes" else return "No"
#===============================================================================================================

def validateTemplatePath(fname):
 print "------------------Entering validateTemplatePath function-----------------"
 print
 
 FileExists="No"
# if already teamplate exists with the same name in the directory mentioned this function return "yes" and asks for user input. 
 if os.path.exists(fname) :
  FileExists="Yes"
  
 print
 print "------------------Leaving validateTemplatePath function-----------------"
 print
 return  FileExists

#===============================================================================================================
# This function creates the clusters as mentioned in "VASDomainInfo.txt.
#===============================================================================================================

def createclusters() :
 print "------------------Entering createClusters function-----------------"
 print
 cd('/')
 for cluster in clusters.split(','):
# creating clusters
  create(cluster,'Cluster')
  print "Cluster : " , cluster
   
 print "Cluster had been created sucessfully"
 
 print
 print "------------------Leaving createClusters function-----------------"
 print
 return
#===============================================================================================================
# This function creates the machines as mentioned in "VASDomainInfo.txt.
#===============================================================================================================

def createmachines() :
 print "------------------Entering createMachines function-----------------"
 print
 cd('/')
 for machine in machines.split(','):
# creating Machines
  create(machine,'Machine')
  print "Machine : ", machine
 
 print "Machines have been created sucessfully"
 
 print
 print "------------------Leaving createMachines function-----------------"
 print
 return

#===============================================================================================================
# This function creates managed servers and assigns them to respective clusters and machines as mentioned in "VASDomainInfo.txt".
# This function also set properties of the managed servers such as "Managed Server IP"and "Managed Server  Port" as mentioned in
# "VASDomainInfo.txt".
#===============================================================================================================

def createmanagedServers():

print "------------------Entering createManagedServers function-----------------"
 print
 
# Appending the managed server information to the list
 for managedServer in managedServers.split(';') :
  managedServersList.append(managedServer)
 
 hm.put("managedServersList",managedServersList)

for managedServer in managedServersList:
  managedServerInfo=managedServer.split(',')
  cd('/')
  
  clusterName=managedServerInfo[0]
  print "Cluster Name : ", clusterName
  machineName=managedServerInfo[1]
  print "Machine Name : ", machineName
  managedServerName=managedServerInfo[2]
  print "Managed Server Name : ", managedServerName
  managedServerIP=managedServerInfo[3].split(':')[0]
  print "Managed Server IP : ", managedServerIP
  managedServerPort=managedServerInfo[3].split(':')[1]
  print "Managed Server Port : ", managedServerPort
  
# creating managed server
  create(managedServerName,'Server')
# assigning the managed server to the cluster
  assign('Server', managedServerName,'Cluster',clusterName)
# assiging the managed server to the machine
  assign('Server',managedServerName,'Machine',machineName)
   
  ManagedServerLocation="/Server/" + managedServerName
  cd(ManagedServerLocation)
# setting the properties of the managed server

set('ListenPort', int(managedServerPort))
  set('ListenAddress', managedServerIP)
  
  print
  print "------------------Leaving createManagedServer function-----------------"
  print
  return
#===============================================================================================================
# This function first checks if the template exists in the directory mentioned in "VASDomainInfo.txt", if it exists it asks you 
#  whether you want to over write template file, if answered "Yes" then it overwrites the template file else it asks you to change the
# template name. Finally it closes the template.
#===============================================================================================================
  
 
def writeBasicDomainTemplate():
  print "------------------Entering writeBasicDomainTemplate function-----------------"
  print
  try :
   global templateLocation
# storing the template location in "templateLocation" variable
   templateLocation = str(templateDestination) + str(templateName) + ".jar"
   print " Template Location : " + templateLocation
   print

# This while loop prompts user to new template name if template already exists in the directory and user doesn't want to override the old template
   while 1:
    FileExists = validateTemplatePath(templateLocation)
    if FileExists == "Yes" :
     print "File : ", templateLocation,"already exists !"
     UserInput = raw_input('Do you want to overwrite the above file? enter "Yes" or "No" : ')
# Ignoring the case of what ever user enters, now user can enter "Yes","YEs","YES","No","NO","no"
     keyword = re.compile(UserInput,re.I)
    
     if keyword.search("yes") :
      print "Overwriting the existing domain template ...."
      break
     else :
      newTemplate = raw_input("Please enter the new template name : ")
      templateLocation = templateDestination + newTemplate + '.jar'
    else :
     break
        
# Writing the template     
   writeTemplate(templateLocation)
# Closing the template
   closeTemplate()
  except WLSTException :
   print " Exception caught in writeBasicDomainTemplate function"
   
  print
  print "------------------Leaving writeBasicDomainTemplate function-----------------"
  print
  return 
#===============================================================================================================
# This function just displays the properties of the objects which we have created.
#===============================================================================================================
  
def displayProperties():
  print "------------------Entering displayProperties function-----------------"
  print
# reading the template
  readTemplate(templateLocation)
  cd('/')
  print "AdminServerPath : ",adminServerPath
  cd(adminServerPath)
# displaying few of the properties
  print " Admin Server Name : " + cmo.getName()
  print " Admin Server Listen Address : " + cmo.getListenAddress()
  print " Admin Server Listen Port : " + str(cmo.getListenPort())
  print " Template Location : " + templateLocation
  
  print
  print "------------------Leaving displayProperties function-----------------"
  print
  return
#===============================================================================================================
# main function which calls other functions
#===============================================================================================================

if __name__=="main":
   readParameters()
   assignParameters()
   readBasicTemplate()
   needToChangeAdminServerName()
   setUserPassword()
   adminServerConfiguration()
   createclusters()
   createmachines()
   createmanagedServers()
   writeBasicDomainTemplate()
   displayProperties()

转载于:https://www.cnblogs.com/mengheyun/archive/2010/12/27/1962988.html

Weblogic Domain Template Creation Script相关推荐

  1. weblogic domain creation

    管理服务器 URL: http://CICI-ThinkPad:7001 Domain Path: D:\Program Files\DEV\Oracle\Middleware\user_projec ...

  2. template和script标签

    templte标签 把模板代码放在component的template里,不好排版,看着难受..... 可以把代码用template标签单独拎出来. 步骤 1.注册组件 <template id ...

  3. 解决安装Weblogic domain卡住问题(Primeton BPS)

    这两天一直有一个问题困扰我,在suse10+weblogic(920,923,100,103)上安装bpm产品失败.有些版本是创建domain的时候卡在create security informat ...

  4. vue项目目录结构分析、过滤器、vue文件中基础template、script、style

    项目目录结构: 1.在一个项目中一般的目录结构为:my_project------------项目文件夹|____src--------------------------------存放人可以看懂的 ...

  5. Vue组件的三大部分-template、script、style

    分享一个大牛的人工智能教程.零基础!通俗易懂!风趣幽默!希望你也加入到人工智能的队伍中来!请轻击http://www.captainbed.net vue 是一个完全支持组件化开发的框架.vue 中规 ...

  6. weblogic管理1——创建 和 删除一个domain

    说明本文环境  WLS_HOME=/home/weblogic/Oracle/Middleware 创建一个domian   第一种方法通过console 创建> [weblogic@11g M ...

  7. Vue.js 使用script或template标签创建组件模板内容

    为了使HTML代码和JavaScript代码是分离的,便于以后的阅读和维护,我们可以并建议使用<script>或<template>标签创建组件模板内容. <!DOCTY ...

  8. Domain Driven Design and Development In Practice--转载

    原文地址:http://www.infoq.com/articles/ddd-in-practice Background Domain Driven Design (DDD) is about ma ...

  9. 【系列5】使用Dockerfile创建带weblogic的Centos Docker镜像

    Weblogic是一个基于Java EE架构的中间件(应用服务器),WebLogic由Oracle公司维护. WebLogic是用于开发.集成.部署和管理大型分布式Web应用.网络应用和数据库应用的J ...

最新文章

  1. bzoj 1731 [Usaco2005 dec]Layout 排队布局——差分约束
  2. oracle右对齐,Oracle 学习笔记(基础)
  3. 三大框架整合教程(Spring+SpringMVC+MyBatis)
  4. 三个角度来解决无线路由故障
  5. C++ 语法都不会怎么写代码? 03
  6. 计算机网络——标准化工作及相关组织
  7. 【OpenCV 例程200篇】64. 图像锐化——Sobel 算子
  8. 关于urlEncode
  9. JSP 的“4379”
  10. matlab lbp特征,lbp特征(lbp纹理特征提取)
  11. uniyu 雷达波束_Unity使用TUIO协议接入雷达
  12. 国内可访问的免费离线下载网站 摘录
  13. 李嘉诚的经典名言,年轻人如何理财
  14. webx参数注入、bean创建总结
  15. Re:从零开始的 RTL-SDR 折腾记
  16. 计算机JAVA相关说课稿_面向对象程序设计-java说课稿
  17. 虚拟机Vmware安装Ubuntu系统
  18. brain怎么读_brain是什么意思_brain怎么读_brain翻译_用法_发音_词组_同反义词_脑-新东方在线英语词典...
  19. CSS-BEM命名规范
  20. java tag文件_Tag文件使用

热门文章

  1. 数组和指针:超过一半的数字;水王发帖
  2. 2018蓝桥杯A组:星期一(年份判断)
  3. 下载并搭建VauditDemo
  4. bzoj 1833: [ZJOI2010]count 数字计数(数字0-9的个数)
  5. 使用色彩追踪和形态学运算得到图像中感兴趣区域
  6. C++ STL string类的compare函数使用
  7. python机器学习案例系列教程——k均值聚类、k中心点聚类
  8. python爬虫案例——csdn数据采集
  9. 分享:Fedora 删除旧内核
  10. vs下qt的信号与槽实现