Guest User

Untitled

a guest
Jan 4th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.86 KB | None | 0 0
  1. import time
  2. import getopt
  3. import sys
  4. import re
  5.  
  6.  
  7. def conn():
  8. connect(USERNAME, PASSWORD, ADMINURL)
  9. def usage():
  10. toprint = '''
  11. ========================================================================================================================================
  12. ------------------------------------------------------
  13. TO CUSTOMIZE KEYFILE AND CONFIGFILE CREATION LOCATION
  14. ------------------------------------------------------
  15. java weblogic.WLST storeuserconfig.py -u <value> -p <value> -c <value> -k <value> -a <adminurl>
  16. {or}
  17. java weblogic.WLST storeuserconfig.py --username=<value> --password=<value> --configfile=<value> --keyfile=<value> --adminurl=<value>
  18.  
  19. Here
  20.  
  21. -u represents "username"
  22. -p represents "password"
  23. -c represents "configfile"
  24. -k represents "keyfile"
  25. -a represents "adminurl"
  26.  
  27. --------
  28. Example:
  29. --------
  30. java weblogic.WLST storeuserconfig.py -u weblogic -p weblogic1 -c /tmp/weblogic_configfile.secure -k /tmp/weblogic_keyfile.secure -a t3://localhost:17001
  31. ========================================================================================================================================
  32. ------------------------------------------------------
  33. TO CREATE KEYFILE, CONFIGFILE IN DEFAULT LOCATION
  34. ------------------------------------------------------
  35. Note*: This will create a configfile and keyfile in the home location of current user
  36.  
  37. java weblogic.WLST storeuserconfig.py --default -u <value> -p <value> -a <adminurl>
  38. {or}
  39. java weblogic.WLST storeuserconfig.py --default --username=<value> --password=<value> --adminurl=<value>
  40.  
  41. Here
  42.  
  43. --default represents "default" switch
  44. -u represents "username"
  45. -p represents "password"
  46. -a represents "adminurl"
  47.  
  48. --------
  49. Example:
  50. --------
  51. java weblogic.WLST storeuserconfig.py --default -u weblogic -p weblogic1 -a t3://localhost:17001
  52. =======================================================================================================================================
  53. '''
  54. print toprint
  55.  
  56. def store_custom():
  57. storeUserConfig(CONFIGFILE,KEYFILE)
  58.  
  59. def store_default():
  60. storeUserConfig()
  61.  
  62. # MAIN
  63. try:
  64. opts, args = getopt.getopt(sys.argv[1:], "h:u:p:c:k:a:", ["username=", "password=", "configfile=","keyfile=", "help", "adminurl=", "default"])
  65. except getopt.GetoptError:
  66. print "ERROR: Aw! Snap Some error Occured"
  67. print "ERROR: Some Required Parameters and Key is missing, Please Read the Usage before executing"
  68. print "java weblogic.WLST storeuserconfig.py help "
  69.  
  70. sys.exit(2)
  71.  
  72. DEFAULTFLAG = ""
  73.  
  74.  
  75. for o, a in opts:
  76. if o == "-v":
  77. verbose = True
  78. if o in ("-d", "--default"):
  79. DEFAULTFLAG="ON"
  80. elif o in ("-h", "--help"):
  81. usage()
  82. sys.exit()
  83. elif o in ("-c", "--configfile") and (DEFAULTFLAG != "ON"):
  84. print "INFO: Config file set to =>",a
  85. CONFIGFILE=a
  86. elif o in ("-k", "--keyfile") and (DEFAULTFLAG != "ON"):
  87. print "INFO: Key file set to =>",a
  88. KEYFILE=a
  89. elif o in ("-u", "--username"):
  90. print "INFO: UserName set to =>",a
  91. USERNAME=a
  92. elif o in ("-p", "--password"):
  93. print "INFO: Password set to =>",a
  94. PASSWORD=a
  95. elif o in ("-a", "--adminurl"):
  96. print "INFO: AdminUrl set to =>",a
  97. ADMINURL=a
  98. match = re.match(r'(t3|t3s)(\:)(\/\/)(.*:)(\d+)', ADMINURL)
  99. if not match:
  100. print "\nERROR: AdminURL is wrong, Make sure you are using t3/t3s protocol"
  101. print "Sample AdminURL: t3://localhost:17001"
  102. sys.exit()
  103. else:
  104. assert False, "ERROR: Option is not supported"
  105. sys.exit()
  106.  
  107. try:
  108. if (DEFAULTFLAG != "ON"):
  109. if (CONFIGFILE and KEYFILE and USERNAME and PASSWORD and ADMINURL):
  110. print "\nINFO: Values have been set properly"
  111. conn()
  112. store_custom()
  113. else:
  114. print "\nERROR: Some Essential Keys are missing";
  115. else:
  116. if (USERNAME and PASSWORD and ADMINURL):
  117. print "\nValues have been set properly"
  118. conn()
  119. store_default()
  120. else:
  121. print "\nERROR: Some Essential Keys are missing";
  122. usage()
  123. except:
  124. print "\nERROR: Got Some Error! Please make sure you are executing the script right",sys.exc_info()[0]
  125. usage()
Add Comment
Please, Sign In to add comment