psadmin_plus 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/bin/psa +79 -0
  3. data/lib/psadmin_plus.rb +262 -0
  4. metadata +46 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1a9bddc67f558875f725ab1803cf2cd354d1d066
4
+ data.tar.gz: a38a484a73f2cf661ab4b9050609dc004df6a16a
5
+ SHA512:
6
+ metadata.gz: 73855abc830cb4aa4bb33dc7e6f827ce2128e82b77697eea960415fb7579415fb4257d290b05923522ed6f99ae5a3c8cd14b175489242eee80706058ed1a2f73
7
+ data.tar.gz: 9ae5bd3812fcb3d69b9f2b91fbcb924eca0a1ba626178c2066487d87aea1010a9b48e475e4102735bff0c78092d13fa6c52a6449048bf4458ca44a473dd7d160
data/bin/psa ADDED
@@ -0,0 +1,79 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'psadmin_plus'
4
+
5
+ # options
6
+ opts_c = ARGV.shift || "help"
7
+ opts_t = ARGV.shift || "all"
8
+ opts_d = ARGV.shift || "all"
9
+
10
+ commands = opts_c.split(',')
11
+ types = opts_t.split(',')
12
+ domains = opts_d.split(',')
13
+
14
+ if types.include? "all" then types = ['app','prcs','web'] end
15
+ if domains.include? "all" then all_domains = true end
16
+
17
+ # constants
18
+ OS_CONST = os
19
+ PS_RUNTIME_USER = "psadm2" # TODO
20
+ PS_POOL_MGMT = "on" # TODO
21
+ PS_HEALTH_FILE = "health.html" # TODO
22
+ PS_HEALTH_TIME = "60" # TODO
23
+ PS_PSA_SUDO = "on" # TODO
24
+ IS_RUNTIME_USER = false # TODO
25
+
26
+ # process
27
+ commands.each do |c|
28
+ case "#{c}"
29
+ when "help"
30
+ do_help
31
+ when "util"
32
+ do_util
33
+ when "list"
34
+ do_list
35
+ when "summary"
36
+ do_summary
37
+ else
38
+ types.each do |t|
39
+ if all_domains then
40
+ case "#{t}"
41
+ when "app"
42
+ domains = find_apps
43
+ when "prcs"
44
+ domains = find_prcss
45
+ when "web"
46
+ domains = find_webs
47
+ end
48
+ end
49
+ domains.each do |d|
50
+ case "#{c}"
51
+ when "status"
52
+ do_status(t,d)
53
+ when "start"
54
+ do_start(t,d)
55
+ when "stop"
56
+ do_stop(t,d)
57
+ when "kill"
58
+ do_kill(t,d)
59
+ when "configure"
60
+ do_configure(t,d)
61
+ when "purge"
62
+ do_purge(t,d)
63
+ when "flush"
64
+ do_flush(t,d)
65
+ when "restart"
66
+ do_restart(t,d)
67
+ when "bounce"
68
+ do_bounce(t,d)
69
+ when "pooladd"
70
+ do_pooladd(t,d)
71
+ when "poolrm"
72
+ do_poolrm(t,d)
73
+ else
74
+ puts "Not a valid command. See psa help"
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,262 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rbconfig'
4
+
5
+ def do_help
6
+ puts "Usage: psa [command] <type> <domain>"
7
+ puts " "
8
+ puts "Commands:"
9
+ puts " "
10
+ puts " help display this help message"
11
+ puts " list list domains"
12
+ puts " admin launch psadmin"
13
+ puts " summary PS_CFG_HOME summary, no type or domain needed"
14
+ puts " status status of the domain"
15
+ puts " start pooladd, if enabled, then start the domain"
16
+ puts " stop poolrm, if enabled, stop the domain"
17
+ puts " restart stop and start the domain"
18
+ puts " purge clear domain cache"
19
+ puts " bounce stop, flush, purge, configure and start the domain"
20
+ puts " kill force stop the domain"
21
+ puts " configure configure the domain"
22
+ puts " flush clear domain IPC"
23
+ puts " poolrm remove domain from load balanced pool "
24
+ puts " pooladd add domain to load balanced pool "
25
+ puts " "
26
+ puts "Types:"
27
+ puts " "
28
+ puts " app act on application domains"
29
+ puts " prcs act on process scheduler domains"
30
+ puts " web act on web domains"
31
+ puts " all,<blank> act on all types of domains"
32
+ puts " "
33
+ puts "Domains:"
34
+ puts " "
35
+ puts " dom act on specific domains"
36
+ puts " all,<blank> act on all domains"
37
+ puts " "
38
+ puts "Each parameter type can be enter in a comma separated list "
39
+ puts " "
40
+ end
41
+
42
+ def do_cmd(cmd)
43
+ case "#{OS_CONST}"
44
+ when "linux"
45
+ if IS_RUNTIME_USER
46
+ out = `"#{cmd}"`
47
+ else
48
+ if "#{PS_PSA_SUDO}" == "on"
49
+ out = `sudo su - $PS_RUNTIME_USER -c "#{cmd}"`
50
+ else
51
+ print "#{PS_RUNTIME_USER} "
52
+ out = `su - $PS_RUNTIME_USER -c "#{cmd}"`
53
+ end
54
+ end
55
+ when "windows"
56
+ out = `"#{cmd}"`
57
+ else
58
+ out = "Invalid OS"
59
+ end
60
+ puts out
61
+ end
62
+
63
+ def find_apps
64
+ apps = Dir.glob("#{ENV['PS_CFG_HOME']}/appserv/*/psappsrv.ubx")
65
+ apps.map! {|app| app.split("/")[-2]}
66
+ end
67
+
68
+ def find_prcss
69
+ prcss = Dir.glob("#{ENV['PS_CFG_HOME']}/appserv/prcs/*/psprcsrv.ubx")
70
+ prcss.map! {|prcs| prcs.split("/")[-2]}
71
+ end
72
+
73
+ def find_webs
74
+ webs = Dir.glob("#{ENV['PS_CFG_HOME']}/webserv/*/piaconfig")
75
+ webs.map! {|web| web.split("/")[-2]}
76
+ end
77
+
78
+ def do_util
79
+ puts "TODO: util"
80
+ end
81
+
82
+ def do_list
83
+ puts "---"
84
+ puts "hostname: TODO"
85
+ puts "ps-home: #{ENV['PS_HOME']}"
86
+ puts "ps-cfg-home: #{ENV['PS_CFG_HOME']}"
87
+ puts ""
88
+ puts "app:"
89
+ find_apps.each do |a|
90
+ puts " - #{a}"
91
+ end
92
+ puts ""
93
+ puts "prcs:"
94
+ find_prcss.each do |p|
95
+ puts " - #{p}"
96
+ end
97
+ puts ""
98
+ puts "web:"
99
+ find_webs.each do |w|
100
+ puts " - #{w}"
101
+ end
102
+ puts ""
103
+ end
104
+
105
+ def do_summary
106
+ do_cmd("psadmin -envsummary")
107
+ #do_status("web","all")
108
+ end
109
+
110
+ def do_status(type, domain)
111
+ puts "status - #{type} - #{domain}"
112
+ case type
113
+ when "app"
114
+ do_cmd("psadmin -c sstatus -d #{domain}")
115
+ do_cmd("psadmin -c cstatus -d #{domain}")
116
+ do_cmd("psadmin -c qstatus -d #{domain}")
117
+ do_cmd("psadmin -c pslist -d #{domain}")
118
+ when "prcs"
119
+ do_cmd("psadmin -p status -d #{domain}")
120
+ when "web"
121
+ do_cmd("psadmin -w status -d #{domain}")
122
+ else
123
+ puts "Invalid type, see psa help"
124
+ end
125
+ end
126
+
127
+ def do_start(type, domain)
128
+ case type
129
+ when "app"
130
+ do_cmd("psadmin -c boot -d #{domain}")
131
+ when "prcs"
132
+ do_cmd("psadmin -p start -d #{domain}")
133
+ when "web"
134
+ do_cmd("${PS_CFG_HOME?}/webserv/#{domain}/bin/startPIA.sh")
135
+ #psadmin -w start -d #{domain}") # TODO - this isn't working, do we want it?
136
+ else
137
+ puts "Invalid type, see psa help"
138
+ end
139
+ end
140
+
141
+ def do_stop(type, domain)
142
+ case type
143
+ when "app"
144
+ do_cmd("psadmin -c shutdown -d #{domain}")
145
+ when "prcs"
146
+ do_cmd("psadmin -p stop -d #{domain}")
147
+ when "web"
148
+ do_cmd("${PS_CFG_HOME?}/webserv/#{domain}/bin/stopPIA.sh")
149
+ else
150
+ puts "Invalid type, see psa help"
151
+ end
152
+ end
153
+
154
+ def do_kill(type, domain)
155
+ case type
156
+ when "app"
157
+ do_cmd("psadmin -c shutdown! -d #{domain}")
158
+ when "prcs"
159
+ do_cmd("psadmin -p kill -d #{domain}")
160
+ when "web"
161
+ return # web kill n/a
162
+ else
163
+ puts "Invalid type, see psa help"
164
+ end
165
+ end
166
+
167
+ def do_configure(type, domain)
168
+ case type
169
+ when "app"
170
+ do_cmd("psadmin -c configure -d #{domain}")
171
+ when "prcs"
172
+ do_cmd("psadmin -p configure -d #{domain}")
173
+ when "web"
174
+ return # web configure n/a
175
+ else
176
+ puts "Invalid type, see psa help"
177
+ end
178
+ end
179
+
180
+ def do_purge(type, domain)
181
+ case type
182
+ when "app"
183
+ do_cmd("psadmin -c purge -d #{domain}")
184
+ when "prcs"
185
+ do_cmd("echo purge todo")
186
+ when "web"
187
+ do_cmd("rm -rf ${PS_CFG_HOME?}/webserv/#{domain}/applications/peoplesoft/PORTAL*/*/cache*/")
188
+ puts "web cache purged"
189
+ else
190
+ puts "Invalid type, see psa help"
191
+ end
192
+ end
193
+
194
+ def do_flush(type, domain)
195
+ case type
196
+ when "app"
197
+ do_cmd("psadmin -c cleanipc -d #{domain}")
198
+ when "prcs"
199
+ do_cmd("psadmin -p cleanipc -d #{domain}")
200
+ when "web"
201
+ return # web flush n/a
202
+ else
203
+ puts "Invalid type, see psa help"
204
+ end
205
+ end
206
+
207
+ def do_restart(type, domain)
208
+ do_stop(type, domain)
209
+ do_start(type, domain)
210
+ end
211
+
212
+ def do_bounce(type, domain)
213
+ do_stop(type, domain)
214
+ do_purge(type, domain)
215
+ do_flush(type, domain)
216
+ do_configure(type, domain)
217
+ do_start(type, domain)
218
+ end
219
+
220
+ def do_pooladd(type, domain)
221
+ if PS_POOL_MGMT == "on" then
222
+ # Change this function to match your pool member addtion process
223
+ puts "Adding web domain to load balanced pool..."
224
+ do_cmd("echo 'true' > ${PS_CFG_HOME?}/webserv/#{domain}/applications/peoplesoft/PORTAL.war/${PS_HEALTH_FILE?}")
225
+ sleep(PS_HEALTH_TIME.to_i)
226
+ puts "...domain added to pool."
227
+ puts ""
228
+ else
229
+ puts "Skipping pool managment. To enable, set $PS_POOL_MGMT to 'on'."
230
+ end
231
+ end
232
+
233
+ def do_poolrm(type,domain)
234
+ if PS_POOL_MGMT == "on" then
235
+ # Change this function to match your pool member removal process
236
+ puts "Removing domain from load balanced pool..."
237
+ do_cmd("rm -f \${PS_CFG_HOME?}/webserv/#{domain}/applications/peoplesoft/PORTAL.war/${PS_HEALTH_FILE?}")
238
+ sleep(PS_HEALTH_TIME.to_i)
239
+ puts "...domain removed from pool."
240
+ puts ""
241
+ else
242
+ puts "Skipping pool managment. To enable, set $PS_POOL_MGMT to 'on'."
243
+ end
244
+ end
245
+
246
+ def os
247
+ @os ||= (
248
+ host_os = RbConfig::CONFIG['host_os']
249
+ case host_os
250
+ when /mswin|msys|mingw|cygwin|bccwin|wince|emc/
251
+ :windows
252
+ when /darwin|mac os/
253
+ :macosx
254
+ when /linux/
255
+ :linux
256
+ when /solaris|bsd/
257
+ :unix
258
+ else
259
+ raise Error::WebDriverError, "unknown os: #{host_os.inspect}"
260
+ end
261
+ )
262
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: psadmin_plus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Kyle Benson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-11-20 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: A psadmin helper tool
14
+ email: kyle@psadmin.io
15
+ executables:
16
+ - psa
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/psadmin_plus.rb
21
+ - bin/psa
22
+ homepage: https://github.com/psadmin-io/psadmin-plus
23
+ licenses:
24
+ - MIT
25
+ metadata: {}
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - '>='
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ required_rubygems_version: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '>='
38
+ - !ruby/object:Gem::Version
39
+ version: '0'
40
+ requirements: []
41
+ rubyforge_project:
42
+ rubygems_version: 2.0.14.1
43
+ signing_key:
44
+ specification_version: 4
45
+ summary: psadmin plus
46
+ test_files: []