ps-voodoo 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ # bundler
2
+ .bundle
3
+
4
+ # miscellaneous
5
+ TODO.md
6
+ lib/voodoo/commands/test.rb
7
+ pkg
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ps-voodoo.gemspec
4
+ gemspec
@@ -0,0 +1,14 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ps-voodoo (0.0.1)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+
10
+ PLATFORMS
11
+ x86-mingw32
12
+
13
+ DEPENDENCIES
14
+ ps-voodoo!
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2011 JR
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,61 @@
1
+ VooDoo
2
+ ===========
3
+
4
+ VooDoo is a command line application to help automate some PeopleSoft administration activities. I originally wrote it as a way to automate migration of PeopleSoft projects between environments, but it has since been expanded to include additional functionality.
5
+
6
+ Features
7
+ --------
8
+
9
+ * TODO
10
+
11
+ Commands
12
+ --------
13
+
14
+ Requirements
15
+ ------------
16
+
17
+ * Ruby 1.9.2
18
+ * Working installation of PeopleSoft Application Designer, DataMover, SQR, Appengine
19
+ * Windows XP or higher (Developed using Windows 7, tested on XP)
20
+
21
+ Install
22
+ -------
23
+
24
+ * TODO
25
+
26
+ Miscellaneous
27
+ -------------
28
+
29
+ * TODO
30
+
31
+ Author
32
+ ------
33
+
34
+ Original author: JR Bing
35
+
36
+
37
+ License
38
+ -------
39
+
40
+ (The MIT License)
41
+
42
+ Copyright (c) 2011 JR Bing
43
+
44
+ Permission is hereby granted, free of charge, to any person obtaining
45
+ a copy of this software and associated documentation files (the
46
+ 'Software'), to deal in the Software without restriction, including
47
+ without limitation the rights to use, copy, modify, merge, publish,
48
+ distribute, sublicense, and/or sell copies of the Software, and to
49
+ permit persons to whom the Software is furnished to do so, subject to
50
+ the following conditions:
51
+
52
+ The above copyright notice and this permission notice shall be
53
+ included in all copies or substantial portions of the Software.
54
+
55
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
56
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
58
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
59
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
60
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
61
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,149 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require File.expand_path(
4
+ File.join(File.dirname(__FILE__), %w[.. lib voodoo]))
5
+ require 'rubygems'
6
+ require 'commander/import'
7
+
8
+ program :name, 'Voodoo'
9
+ program :version, Voodoo::VERSION
10
+ program :description, 'Black Magic Utility for PeopleSoft Administration'
11
+
12
+ command :add do |c|
13
+ c.syntax = 'voodoo add [environment name]'
14
+ c.summary = 'adds an environment to the configuration file'
15
+ c.description = 'Prompts for environment information and saves it to the environment configuration file'
16
+ c.example 'Prompt for setup values before adding VDDMO to the configuration file', 'voodoo add VDDMO'
17
+ c.action do |args|
18
+ Voodoo::Commands.add(args)
19
+ end
20
+ end
21
+
22
+ command :remove do |c|
23
+ c.syntax = 'voodoo remove [environment name]'
24
+ c.summary = 'removes an environment from the configuration file'
25
+ c.description = 'Deletes the specified environment from the configuration file'
26
+ c.example 'Removes the environment VDDMO from the configuration file', 'voodoo remove VDDMO'
27
+ c.action do |args|
28
+ Voodoo::Commands.remove(args)
29
+ end
30
+ end
31
+
32
+ command :list do |c|
33
+ c.syntax = 'voodoo list'
34
+ c.summary = 'Outputs a list of configured environments'
35
+ c.description = 'Shows a list of all environments in the configuration file'
36
+ c.example 'List all environments', 'voodoo list'
37
+ c.action do |args|
38
+ c.when_called Voodoo::Commands.list
39
+ end
40
+ end
41
+
42
+ command :show do |c|
43
+ c.syntax = 'voodoo show [environment name]'
44
+ c.summary = 'shows configuration details for an environment'
45
+ c.description = 'Outputs a table containing information about the specified environment'
46
+ c.example 'Show information about VDDMO', 'voodoo show VDDMO'
47
+ c.action do |args|
48
+ Voodoo::Commands.show(args)
49
+ end
50
+ end
51
+
52
+ command :config do |c|
53
+ c.syntax = 'voodoo config'
54
+ c.summary = 'create global configuration settings'
55
+ c.description = 'Prompts for global configuration information and saves it to the configuration file'
56
+ c.action do |args, options|
57
+ c.when_called Voodoo::Commands.config
58
+ end
59
+ end
60
+
61
+ command :compare do |c|
62
+ c.syntax = 'voodoo compare [project] [source] [target]'
63
+ c.summary = 'create a compare report for the specified project'
64
+ c.description = 'Creates an HTML compare report for the specified project and opens it in the default browser'
65
+ c.example 'Create a compare report between two environments', 'voodoo compare EXAMPLE_PROJECT VDDEV VDTEST'
66
+ c.action do |args|
67
+ Voodoo::Commands.compare(args)
68
+ end
69
+ end
70
+
71
+ command :build do |c|
72
+ c.syntax = 'voodoo build [project] [environment]'
73
+ c.summary = 'builds a project definition in the specified environment'
74
+ c.description = 'Builds a project definition script for the specified project using AppDesigner and executes it in the target database'
75
+ c.example 'Build specified project', 'voodoo build EXAMPLE_PROJECT VDTEST'
76
+ c.action do |args|
77
+ Voodoo::Commands.build(args)
78
+ end
79
+ end
80
+
81
+ command :migrate do |c|
82
+ c.syntax = 'voodoo migrate [project] [source] [target]'
83
+ c.summary = 'migrates a project between environments'
84
+ c.description = 'Migrates a project between two environments after running a compare report and copying the objects to file'
85
+ c.example 'Migrate project between environments', 'voodoo migrate EXAMPLE_PROJECT --source VDDEV --target VDTEST'
86
+ c.action do |args|
87
+ Voodoo::Commands.migrate(args)
88
+ end
89
+ end
90
+
91
+ # command :'run sqr' do |c|
92
+ # c.syntax = 'voodoo run sqr [sqr name] [environment]'
93
+ # c.summary = 'runs the specified sqr locally'
94
+ # c.description = 'Run the specified SQR locally using the sqr bin specified in the environment configuration.'
95
+ # c.example 'Run SQR', 'voodoo run sqr SETSPACE.sqr VDDEV'
96
+ # c.action do |args|
97
+ # Voodoo::Commands.run_sqr(args)
98
+ # end
99
+ # end
100
+
101
+ # command :'run appengine' do |c|
102
+ # c.syntax = 'voodoo run appengine [appengine name] [environment]'
103
+ # c.summary = 'runs the specified appengine locally'
104
+ # c.description = 'Run the specified AppEngine locally.'
105
+ # c.example 'Run AppEngine', 'voodoo run appengine XXXXX VDDEV'
106
+ # c.action do |args|
107
+ # Voodoo::Commands.run_appengine(args)
108
+ # end
109
+ # end
110
+
111
+ # command :shell do |c|
112
+ # c.syntax = 'voodoo shell'
113
+ # c.summary = 'start Voodoo in and interactive console mode'
114
+ # c.description = 'Starts Voodoo in a mode for entering multiple commands'
115
+ # c.action do
116
+ # loop do
117
+ # choose("") do |menu|
118
+ # menu.layout = ''
119
+ # # menu.layout = :menu_only
120
+ # menu.prompt = '>>> '
121
+ # menu.shell = true
122
+
123
+ # menu.choice(:list, "List configured environments") do |command, arguments|
124
+ # Voodoo::Commands.list
125
+ # end
126
+
127
+ # menu.choice(:show, "Show environment details") do |command, arguments|
128
+ # args = arguments.scan(/\w+/)
129
+ # Voodoo::Commands.show(args)
130
+ # end
131
+
132
+ # menu.choice(:quit, "Exit voodoo") { exit }
133
+
134
+ # end
135
+ # end
136
+ # end
137
+ # end
138
+
139
+ # command :test do |c|
140
+ # c.syntax = 'voodoo setup [options]'
141
+ # c.summary = ''
142
+ # c.description = ''
143
+ # c.example 'description', 'command example'
144
+ # c.option '--some-switch', 'Some switch that does something'
145
+ # c.action do |args, options|
146
+ # c.when_called Voodoo::Commands.test(args, options)
147
+ # end
148
+ # end
149
+
@@ -0,0 +1,96 @@
1
+ require 'ostruct'
2
+ require 'yaml'
3
+ require 'logger'
4
+
5
+ module Voodoo
6
+
7
+ extend self
8
+
9
+ LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
10
+ PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
11
+
12
+ # Log settings
13
+ LOG = Logger.new(STDOUT)
14
+ LOG.level = Logger::DEBUG
15
+
16
+ def self.libpath( *args )
17
+ rv = args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
18
+ if block_given?
19
+ begin
20
+ $LOAD_PATH.unshift LIBPATH
21
+ rv = yield
22
+ ensure
23
+ $LOAD_PATH.shift
24
+ end
25
+ end
26
+ return rv
27
+ end
28
+
29
+ def self.path( *args )
30
+ rv = args.empty? ? PATH : ::File.join(PATH, args.flatten)
31
+ if block_given?
32
+ begin
33
+ $LOAD_PATH.unshift PATH
34
+ rv = yield
35
+ ensure
36
+ $LOAD_PATH.shift
37
+ end
38
+ end
39
+ return rv
40
+ end
41
+
42
+ def self.require_all_libs_relative_to( fname, dir = nil )
43
+ dir ||= ::File.basename(fname, '.*')
44
+ search_me = ::File.expand_path(
45
+ ::File.join(::File.dirname(fname), dir, '**', '*.rb'))
46
+
47
+ Dir.glob(search_me).sort.each {|rb| require rb}
48
+ end
49
+
50
+ def home
51
+ @home ||= (ENV['HOME'] || ENV['USERPROFILE']) + '/.voodoo'
52
+ unless File.exists?(@home)
53
+ Dir.mkdir(@home)
54
+ end
55
+ return @home
56
+ end
57
+
58
+ def config_file
59
+ filename = File.join(Voodoo.home, 'configuration.yml')
60
+ File.open(filename, File::CREAT|File::RDWR)
61
+ end
62
+
63
+ def configuration
64
+ @configuration = YAML.load_file(Voodoo.config_file)
65
+ end
66
+
67
+ def write_config_file(settings)
68
+ Voodoo.config_file.write(settings.to_yaml)
69
+ end
70
+
71
+ def env_file
72
+ filename = File.join(Voodoo.home, 'environments.yml')
73
+ File.open(filename, File::CREAT|File::RDWR)
74
+ return filename
75
+ end
76
+
77
+ def environments
78
+ list = YAML.load_file(Voodoo.env_file)
79
+ if list
80
+ @environments = list
81
+ else
82
+ @environments = {}
83
+ end
84
+ end
85
+
86
+ def write_env_file
87
+ environment_file = File.open(Voodoo.env_file, 'w')
88
+ LOG.info("Writing environment configuration file.")
89
+ environment_file.write(ENVIRONMENTS.to_yaml)
90
+ end
91
+
92
+ end
93
+
94
+ Voodoo.require_all_libs_relative_to(__FILE__)
95
+ ENVIRONMENTS = Voodoo.environments
96
+ CONFIGURATION = OpenStruct.new(Voodoo.configuration)
@@ -0,0 +1,98 @@
1
+ require 'terminal-table/import'
2
+ Voodoo.require_all_libs_relative_to(__FILE__)
3
+
4
+ module Voodoo
5
+
6
+ module Commands
7
+ extend self
8
+
9
+ def setup?
10
+ if CONFIGURATION.ps_home == nil
11
+ LOG.warnA("Global configuration not defined...use <voodoo config>")
12
+ exit
13
+ end
14
+
15
+ if ENVIRONMENTS.empty?
16
+ puts "No environments defined....use <voodoo add [environment]>"
17
+ exit
18
+ end
19
+
20
+ end
21
+
22
+ def get_project
23
+ ask("Project name: ")
24
+ end
25
+
26
+ def get_env(name)
27
+ #TODO: fix this to throw an error message and exit if the environment isn't listed
28
+ OpenStruct.new(ENVIRONMENTS[name])
29
+ end
30
+
31
+ def get_source
32
+ choose("Environments") do |menu|
33
+ menu.index = :letter
34
+ menu.index_suffix = ") "
35
+ menu.prompt = "Specify the source environment: "
36
+ ENVIRONMENTS.keys.each do |x|
37
+ menu.choice(x) do |i|
38
+ env = OpenStruct.new(ENVIRONMENTS[i])
39
+ env.name = i
40
+ env.app_password = get_app_password(i)
41
+ return env
42
+ end
43
+ end
44
+ end
45
+ end
46
+
47
+ def get_target
48
+ choose("Environments") do |menu|
49
+ menu.index = :letter
50
+ menu.index_suffix = ") "
51
+ menu.prompt = "Specify the target environment: "
52
+ ENVIRONMENTS.keys.each do |x|
53
+ menu.choice(x) do |i|
54
+ env = OpenStruct.new(ENVIRONMENTS[i])
55
+ env.name = i
56
+ env.app_password = get_app_password(i)
57
+ return env
58
+ end
59
+ end
60
+ end
61
+ end
62
+
63
+ def get_migration
64
+ folder_name = ask("Name for output folder: ")
65
+ Migration.new(folder_name)
66
+ end
67
+
68
+ #TODO: validate that the SQR name and path is valid
69
+ def get_sqr
70
+ ask("SQR name: ")
71
+ end
72
+
73
+ #TODO: validate that the appengine name and path is valid
74
+ def get_appengine
75
+ ask("Appengine name: ")
76
+ end
77
+
78
+ def get_path(prompt)
79
+ ask("#{prompt}: ") do |q|
80
+ q.validate = %r=^(([a-zA-Z]:)|(\\{2}\w+)\$?)(\\(\w[\w ]*))=
81
+ q.responses[:not_valid] = "Please enter a valid folder path."
82
+ end
83
+ end
84
+
85
+ def dttm
86
+ Time.now.strftime("%m/%d/%Y %H:%M:%S") + " >>> "
87
+ end
88
+
89
+ private
90
+
91
+ def get_app_password(name)
92
+ ask("Password for #{name}: ") { |q| q.echo = "*" }
93
+ end
94
+
95
+ end
96
+
97
+ end
98
+
@@ -0,0 +1,24 @@
1
+
2
+ module Voodoo
3
+
4
+ module Commands
5
+
6
+ def self.add(args=nil)
7
+ settings = {}
8
+ if args.first.nil?
9
+ name = ask("Database name: ").upcase
10
+ else
11
+ name = args.first.upcase
12
+ end
13
+ settings['db_type'] = ask("Database type: ", %w{Oracle}) { |q| q.default = "Oracle" }
14
+ settings['app_username'] = ask("Application username: ")
15
+ settings['db_username'] = ask("Database username: ") { |q| q.default = "sysadm" }
16
+ settings['migration_archive'] = get_path("Archive destination")
17
+ new_env = {name => settings}
18
+ LOG.info("Adding #{name} to the list of configured environments")
19
+ ENVIRONMENTS.merge!(new_env)
20
+ Voodoo.write_env_file
21
+ end
22
+ end
23
+
24
+ end
@@ -0,0 +1,26 @@
1
+
2
+ module Voodoo
3
+
4
+ module Commands
5
+ extend self
6
+
7
+ def build(args=nil)
8
+ if args.first.nil?
9
+ project = get_project
10
+ else
11
+ project = args.first
12
+ end
13
+
14
+ source = get_source
15
+ migration = get_migration
16
+
17
+ ad = Voodoo::AppDesigner.new
18
+ dm = Voodoo::DataMover.new
19
+
20
+ ad.build_project(project, migration, source)
21
+ dm.run(migration, source, "PSBUILD.sql")
22
+ end
23
+
24
+ end
25
+
26
+ end
@@ -0,0 +1,37 @@
1
+
2
+ module Voodoo
3
+
4
+ module Commands
5
+ extend self
6
+
7
+ def compare(args=nil)
8
+ setup?
9
+
10
+ if args.first.nil?
11
+ project = get_project
12
+ else
13
+ project = args.first
14
+ end
15
+
16
+ if args[1].nil?
17
+ source = get_source
18
+ else
19
+ source = args[1].upcase
20
+ end
21
+
22
+ if args[2].nil?
23
+ target = get_target
24
+ else
25
+ target = args[2].upcase
26
+ end
27
+
28
+ migration = get_migration
29
+
30
+ ad = Voodoo::AppDesigner.new
31
+ ad.compare(project, migration, source, target)
32
+ end
33
+
34
+ end
35
+
36
+ end
37
+
@@ -0,0 +1,15 @@
1
+
2
+ module Voodoo
3
+
4
+ module Commands
5
+
6
+ def self.config
7
+ settings = {}
8
+ settings[:ps_home] = get_path("Local tools installation directory")
9
+ settings[:migration_output_dir] = get_path("Output directory for migration data")
10
+ Voodoo.write_config_file(settings)
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,17 @@
1
+ module Voodoo
2
+
3
+ module Commands
4
+
5
+ # TODO: add an error message if there are no environments configured
6
+ def self.list
7
+ env_table = table
8
+ env_table.headings = ['Configured Environments']
9
+ Voodoo.environments.keys.each do |env|
10
+ env_table << [env]
11
+ end
12
+ puts env_table
13
+ end
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,74 @@
1
+
2
+ module Voodoo
3
+
4
+ module Commands
5
+ extend self
6
+
7
+ def migrate(args=nil)
8
+ setup?
9
+
10
+ if args.first.nil?
11
+ project = get_project
12
+ else
13
+ project = args.first
14
+ end
15
+
16
+ if args[1].nil?
17
+ source = get_source
18
+ else
19
+ source = args[1].upcase
20
+ end
21
+
22
+ if args[2].nil?
23
+ target = get_target
24
+ else
25
+ target = args[2].upcase
26
+ end
27
+
28
+ # Check for source and target being the same
29
+ if source == target
30
+ says("Source and target cannot be the same")
31
+ exit
32
+ end
33
+
34
+ migration = get_migration
35
+ ad = Voodoo::AppDesigner.new
36
+
37
+ # Compare source to target
38
+ ad.compare(project, migration, source, target)
39
+ migration.continue?
40
+
41
+ # Copy source to file
42
+ ad.copy_to_file(project, migration, source)
43
+
44
+ # Copy definition only to database
45
+ ad.migrate_project_definition(project, migration, source, target)
46
+
47
+ # Copy target to file
48
+ ad.copy_to_file(project, migration, target)
49
+
50
+ # Copy full project
51
+ ad.migrate_full_project(project, migration, source, target)
52
+
53
+ # Run second compare report
54
+ ad.compare(project, migration, target,source)
55
+
56
+ # Build project in target database
57
+ if agree("Build project in target database? ") == true
58
+ dm = Voodoo::DataMover.new
59
+ ad.build_project(project, migration, target)
60
+ dm.run(migration, target, "PSBUILD.sql")
61
+ end
62
+
63
+ # Move output files to archive folder for the target
64
+ if agree("Copy output files to archive folder for #{target.name}? ") == true
65
+ migration.copy_to_archive(target.migration_archive)
66
+ end
67
+
68
+
69
+ end
70
+
71
+ end
72
+
73
+ end
74
+
@@ -0,0 +1,19 @@
1
+
2
+ module Voodoo
3
+
4
+ module Commands
5
+
6
+ def self.remove(args=nil)
7
+ if args[0].nil?
8
+ source = get_source
9
+ else
10
+ source = args[0].upcase
11
+ end
12
+ LOG.info("Removing #{source} from the list of configured environments")
13
+ ENVIRONMENTS.delete(source)
14
+ Voodoo.write_env_file
15
+ end
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,32 @@
1
+ module Voodoo
2
+
3
+ module Commands
4
+ extend self
5
+
6
+ def run_sqr(sqr_name=nil)
7
+ if sqr_name.nil?
8
+ sqr_name = get_sqr
9
+ end
10
+
11
+ target = get_target
12
+ migration = get_migration
13
+
14
+ instance = Voodoo::Sqr.new
15
+ instance.run(migration, target)
16
+ end
17
+
18
+ def run_appengine(ae_name=nil)
19
+ if ae_name.nil?
20
+ ae_name = get_appengine
21
+ end
22
+
23
+ target = get_target
24
+ migration = get_migration
25
+
26
+ instance = Voodoo::AppEngine.new
27
+ instance.run(migration, target)
28
+ end
29
+
30
+ end
31
+
32
+ end
@@ -0,0 +1,23 @@
1
+
2
+ module Voodoo
3
+
4
+ module Commands
5
+
6
+ def self.show(args=nil)
7
+ if args[0].nil?
8
+ source = ask("Environment name: ").upcase
9
+ else
10
+ source = args[0].upcase
11
+ end
12
+ env = Voodoo.environments[source]
13
+ user_table = table
14
+ user_table.headings = source.upcase, ' '
15
+ env.each do |key, value|
16
+ user_table << [key, value]
17
+ end
18
+ puts user_table
19
+ end
20
+
21
+ end
22
+
23
+ end
@@ -0,0 +1,58 @@
1
+
2
+ module Voodoo
3
+
4
+ class Migration
5
+
6
+ def initialize(name)
7
+ @migration_folder = create_folder(File.join(CONFIGURATION.migration_output_dir, name))
8
+ end
9
+
10
+ def log_folder
11
+ @log_folder = create_folder(File.join(@migration_folder, 'logs'))
12
+ end
13
+
14
+ def archive_folder
15
+ @archive_folder = create_folder(File.join(@migration_folder, 'archive'))
16
+ end
17
+
18
+ def sql_folder
19
+ @sql_folder = create_folder(File.join(@migration_folder, 'sql'))
20
+ end
21
+
22
+ def compare_folder(source, target)
23
+ create_folder(File.join(compare_base_folder, "#{source}_to_#{target}"))
24
+ end
25
+
26
+ def export_folder(source)
27
+ create_folder(File.join(project_folder, source))
28
+ end
29
+
30
+ def continue?
31
+ if agree("Continue? ") == false
32
+ exit
33
+ end
34
+ end
35
+
36
+ def copy_to_archive(archive_folder)
37
+ FileUtils.cp_r(@migration_folder, archive_folder, :verbose => true)
38
+ end
39
+
40
+ private
41
+
42
+ def project_folder
43
+ @project_folder = create_folder(File.join(@migration_folder, 'project'))
44
+ end
45
+
46
+ def compare_base_folder
47
+ @compare_base_folder = create_folder(File.join(@migration_folder, 'compares'))
48
+ end
49
+
50
+ def create_folder(folder_path)
51
+ Dir.mkdir(folder_path) unless File.exists?(folder_path)
52
+ return folder_path
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+
@@ -0,0 +1,83 @@
1
+ require 'fileutils'
2
+ require 'win32/registry'
3
+
4
+ module Voodoo
5
+
6
+ class PeopleTools
7
+
8
+ attr_accessor :command_line_options, :executable
9
+
10
+ def initialize
11
+ set_base_parameters
12
+ @tools_bin = File.join(Voodoo.configuration[:ps_home], %w{bin client winx86}).gsub!(File::SEPARATOR, File::ALT_SEPARATOR)
13
+ LOG.debug("Tools bin is set to #{@tools_bin}")
14
+ end
15
+
16
+ def append(args)
17
+ args.each_pair do |k, v|
18
+ @command_line_options.push case
19
+ when k == :db_type
20
+ '-CT ' + v
21
+ when k == :env_name
22
+ '-CD ' + v
23
+ when k == :env_username
24
+ '-CO ' + v
25
+ when k == :env_password
26
+ '-CP ' + v
27
+ when k == :compare_project
28
+ '-PJM ' + v
29
+ when k == :archive_project
30
+ '-PJTF ' + v
31
+ when k == :copy_project
32
+ '-PJC ' + v
33
+ when k == :build_project
34
+ '-PJB ' + v
35
+ when k == :target_name
36
+ '-TD ' + v
37
+ when k == :target_username
38
+ '-TO ' + v
39
+ when k == :target_password
40
+ '-TP ' + v
41
+ when k == :log_file
42
+ '-LF ' + v
43
+ when k == :tgt
44
+ '-TGT ' + v
45
+ when k == :cmxml
46
+ '-CMXML ' + v
47
+ when k == :compare_folder
48
+ '-ROD ' + v
49
+ when k == :exp
50
+ '-EXP ' + v
51
+ when k == :obj
52
+ '-OBJ ' + v
53
+ when k == :r
54
+ '-R ' + v
55
+ when k == :ae_name
56
+ '-AI ' + v
57
+ when k == :output_folder
58
+ '-FP ' + v
59
+ end
60
+ end
61
+ end
62
+
63
+ def call_executable
64
+ LOG.debug("Executable is set to #{@executable}")
65
+ LOG.debug("Command line options are set to #{@command_line_options.join(" ")}")
66
+ f = IO.popen(@executable + " " + @command_line_options.join(" "))
67
+ f.readlines.each { |line| LOG.info("#{line}")}
68
+ f.close
69
+ @command_line_options.clear
70
+ set_base_parameters
71
+ end
72
+
73
+ private
74
+
75
+ def set_base_parameters
76
+ @command_line_options = [].push("-HIDE -QUIET -SS NO")
77
+ end
78
+
79
+ end
80
+
81
+ end
82
+
83
+ Voodoo.require_all_libs_relative_to(__FILE__)
@@ -0,0 +1,147 @@
1
+
2
+ module Voodoo
3
+
4
+ class AppDesigner < PeopleTools
5
+
6
+ def initialize
7
+ super
8
+ @executable = File.join(@tools_bin, %w{pside.exe}).gsub!(File::SEPARATOR, File::ALT_SEPARATOR)
9
+ end
10
+
11
+ def compare(project, migration, source, target)
12
+ begin
13
+ LOG.info("Creating compare reports for #{project} between #{source.name} and #{target.name}")
14
+ append(:db_type => source.db_type)
15
+ append(:env_name => source.name)
16
+ append(:env_username => source.app_username)
17
+ append(:env_password => source.app_password)
18
+ append(:compare_project => project)
19
+ append(:target_name => target.name)
20
+ append(:target_username => target.app_username)
21
+ append(:target_password => target.app_password)
22
+ append(:log_file => File.join(migration.log_folder, "Compare_#{source.name}_to_#{target.name}.log"))
23
+ append(:tgt => '1')
24
+ append(:compare_folder => migration.compare_folder(source.name, target.name))
25
+ append(:cmxml => '1')
26
+ call_executable
27
+ view_compare_report(migration.compare_folder(source.name, target.name))
28
+ rescue
29
+ LOG.error("Compare report creation failed")
30
+ end
31
+ end
32
+
33
+ def copy_to_file(project, migration, source)
34
+ begin
35
+ LOG.info("Copying #{project} from #{source.name} to file")
36
+ append(:db_type => source.db_type)
37
+ append(:env_name => source.name)
38
+ append(:env_username => source.app_username)
39
+ append(:env_password => source.app_password)
40
+ append(:archive_project => project)
41
+ append(:output_folder => migration.export_folder(source.name))
42
+ append(:log_file => File.join(migration.log_folder, "Copy_#{source.name}_to_file.log"))
43
+ call_executable
44
+ LOG.info("Project copied to file successfully")
45
+ rescue
46
+ LOG.error("Project file copy failed")
47
+ end
48
+ end
49
+
50
+ def migrate_full_project(project, migration, source, target)
51
+ begin
52
+ LOG.info("Copying #{project} from #{source.name} to #{target.name}")
53
+ append(:db_type => source.db_type)
54
+ append(:env_name => source.name)
55
+ append(:env_username => source.app_username)
56
+ append(:env_password => source.app_password)
57
+ append(:copy_project => project)
58
+ append(:target_name => target.name)
59
+ append(:target_username => target.app_username)
60
+ append(:target_password => target.app_password)
61
+ append(:log_file => File.join(migration.log_folder, "Copy_project_#{project}_from_#{source.name}_to_#{target.name}.log"))
62
+ call_executable
63
+ LOG.info("Project migrated successfully")
64
+ rescue
65
+ LOG.error("Project migration failed")
66
+ end
67
+ end
68
+
69
+ def migrate_project_definition(project, migration, source, target)
70
+ begin
71
+ LOG.info("Copying #{project} definition from #{source.name} to #{target.name}")
72
+ append(:db_type => source.db_type)
73
+ append(:env_name => source.name)
74
+ append(:env_username => source.app_username)
75
+ append(:env_password => source.app_password)
76
+ append(:copy_project => project)
77
+ append(:target_name => target.name)
78
+ append(:target_username => target.app_username)
79
+ append(:target_password => target.app_password)
80
+ append(:log_file => File.join(migration.log_folder, "Copy_project_definition_#{project}_from_#{source.name}_to_#{target.name}.log"))
81
+ append(:exp => '1')
82
+ append(:obj => '16')
83
+ call_executable
84
+ LOG.info("Project migrated successfully")
85
+ rescue
86
+ LOG.error("Project definition migration failed")
87
+ end
88
+ end
89
+
90
+ def build_project(project, migration, source)
91
+ begin
92
+ LOG.info("Creating build SQL for #{project}")
93
+ append(:db_type => source.db_type)
94
+ append(:env_name => source.name)
95
+ append(:env_username => source.app_username)
96
+ append(:env_password => source.app_password)
97
+ append(:build_project => project)
98
+ update_build_settings(File.join(migration.log_folder, "PSBUILD.log"), File.join(migration.sql_folder, "PSBUILD.sql"))
99
+ call_executable
100
+ LOG.info("Project build SQL created successfully")
101
+ rescue
102
+ LOG.error("Project SQL build failed")
103
+ end
104
+
105
+ end
106
+
107
+ private
108
+
109
+ def view_compare_report(folder)
110
+ `start #{folder + "\\CompareViewer.html"}`
111
+ end
112
+
113
+ def update_build_settings(log_file, sql_file)
114
+ Win32::Registry::HKEY_CURRENT_USER.open('Software\PeopleSoft\PeopleTools\Release8.40\RDM Build Settings', Win32::Registry::KEY_WRITE) do |reg|
115
+ reg['AlterAdds', Win32::Registry::REG_DWORD] = 1
116
+ reg['AlterByTableRename', Win32::Registry::REG_DWORD] = 1
117
+ reg['AlterChanges', Win32::Registry::REG_DWORD] = 1
118
+ reg['AlterDeletes', Win32::Registry::REG_DWORD] = 1
119
+ reg['AlterDropOption', Win32::Registry::REG_DWORD] = 1
120
+ reg['AlterRenames', Win32::Registry::REG_DWORD] = 1
121
+ reg['AlterTables', Win32::Registry::REG_DWORD] = 1
122
+ reg['AlterTruncateOption', Win32::Registry::REG_DWORD] = 1
123
+ reg['AlwaysOverwrite', Win32::Registry::REG_DWORD] = 1
124
+ reg['CreateIndexes', Win32::Registry::REG_DWORD] = 1
125
+ reg['CreateTables', Win32::Registry::REG_DWORD] = 1
126
+ reg['CreateTrigger', Win32::Registry::REG_DWORD] = 1
127
+ reg['CreateViews', Win32::Registry::REG_DWORD] = 1
128
+ reg['ExecuteOption', Win32::Registry::REG_DWORD] = 2
129
+ reg['ForceAlterOption', Win32::Registry::REG_DWORD] = 1
130
+ reg['IndexOption', Win32::Registry::REG_DWORD] = 0
131
+ reg['LogComments', Win32::Registry::REG_DWORD] = 1
132
+ reg['LogErrors', Win32::Registry::REG_DWORD] = 1
133
+ reg['LogFilename', Win32::Registry::REG_SZ] = log_file
134
+ reg['LogSettings', Win32::Registry::REG_DWORD] = 1
135
+ reg['LogToScript', Win32::Registry::REG_DWORD] = 1
136
+ reg['LogToWindow', Win32::Registry::REG_DWORD] = 1
137
+ reg['OutputToSingleFile', Win32::Registry::REG_DWORD] = 1
138
+ reg['OutputToSingleFilename', Win32::Registry::REG_SZ] = sql_file
139
+ reg['TableOption', Win32::Registry::REG_DWORD] = 2
140
+ reg['UnicodeScript', Win32::Registry::REG_DWORD] = 0
141
+ reg['ViewOption', Win32::Registry::REG_DWORD] = 1
142
+ end
143
+ end
144
+
145
+ end
146
+
147
+ end
@@ -0,0 +1,22 @@
1
+
2
+ module Voodoo
3
+
4
+ class AppEngine < PeopleTools
5
+
6
+ def initialize
7
+ super
8
+ @executable = File.join(@tools_bin, %w{psae.exe})
9
+ end
10
+
11
+ def run(target, appengine_name)
12
+ append(:db_type => target.db_type)
13
+ append(:env_name => target.name)
14
+ append(:env_username => target.app_username)
15
+ append(:env_password => target.app_password)
16
+ append(:r => '1')
17
+ append(:ae_name => appengine_name)
18
+ call_executable
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,33 @@
1
+
2
+ module Voodoo
3
+
4
+ class DataMover < PeopleTools
5
+
6
+ def initialize
7
+ super
8
+ @executable = File.join(@tools_bin, %w{psdmtx.exe})
9
+ end
10
+
11
+ def run(migration, source, script_name)
12
+ append(:db_type => source.db_type)
13
+ append(:env_name => source.name)
14
+ append(:env_username => source.app_username)
15
+ append(:env_password => source.app_password)
16
+ append(:output_folder => File.join(migration.sql_folder, script_name).gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
17
+ update_dms_settings(migration.sql_folder, migration.log_folder)
18
+ call_executable
19
+ end
20
+
21
+ private
22
+
23
+ def update_dms_settings(io, logs)
24
+ Win32::Registry::HKEY_LOCAL_MACHINE.open('SOFTWARE\PeopleSoft\PeopleTools\Release8.40\Profiles\Default\Data Mover', Win32::Registry::KEY_WRITE) do |reg|
25
+ reg['InputDir', Win32::Registry::REG_SZ] = io
26
+ reg['OutputDir', Win32::Registry::REG_SZ] = io
27
+ reg['LogDir', Win32::Registry::REG_SZ] = logs
28
+ end
29
+ end
30
+
31
+ end
32
+
33
+ end
@@ -0,0 +1,112 @@
1
+
2
+ module Voodoo
3
+
4
+ class Sqr
5
+
6
+ def initialize
7
+ @sqr_bin = File.join(Voodoo.configuration[:ps_home], %w{bin sqr ORA BINW}).gsub!(File::SEPARATOR, File::ALT_SEPARATOR)
8
+ @executable = File.join(@tools_bin, %w{sqrw.exe})
9
+ end
10
+
11
+ def run(target, sqr_name)
12
+ append(:db_type => target.db_type)
13
+ append(:env_name => target.name)
14
+ append(:env_username => target.app_username)
15
+ append(:env_password => target.app_password)
16
+ append(:r => '1')
17
+ append(:sqr_name => sqr_name)
18
+ call_executable
19
+ end
20
+
21
+ # def run_sqr(executable_path, sqrbin_path, sqr_name, db_username, db_password, db_name, output_directory)
22
+ # executable = 'sqrw.exe'
23
+
24
+ # if File.exists?(sqrbin_path + sqr_name)
25
+ # s.run_sqr(SQR_BIN, database["ps_home"] + "\\sqr\\isc\\", sqr_name, database["db_username"], database["db_password"], db, BASE_DIRECTORY + "\\" + output_directory)
26
+ # elsif File.exists?(database["ps_home"] + "\\sqr\\" + sqr_name)
27
+ # s.run_sqr(SQR_BIN, database["ps_home"] + "\\sqr\\", sqr_name, database["db_username"], database["db_password"], db, BASE_DIRECTORY + "\\" + output_directory)
28
+ # else
29
+ # say("SQR not found...")
30
+ # end
31
+ # arguments = Array.new
32
+ # arguments << executable_path + executable
33
+ # arguments << sqrbin_path + sqr_name
34
+ # arguments << db_username + '/' + db_password + '@' + db_name
35
+ # arguments << '-I' + sqrbin_path
36
+ # arguments << '-F' + output_directory
37
+ # arguments << '-ZIF' + sqrbin_path + 'pssqr.ini'
38
+ # arguments << '-PRINTER:PD'
39
+ # Dir.mkdir(output_directory) unless File.exists?(output_directory)
40
+ # executable_string = arguments.join(" ")
41
+ # puts executable_string
42
+ # # `#{executable_string}`
43
+ # f = IO.popen(executable_string)
44
+ # f.readlines.each { |line| print "#{line}"}
45
+ # f.close
46
+ # end
47
+
48
+ def append(args)
49
+ args.each_pair do |k, v|
50
+ @command_line_options.push case
51
+ when k == :db_type
52
+ '-CT ' + v
53
+ when k == :env_name
54
+ '-CD ' + v
55
+ when k == :env_username
56
+ '-CO ' + v
57
+ when k == :env_password
58
+ '-CP ' + v
59
+ when k == :compare_project
60
+ '-PJM ' + v
61
+ when k == :archive_project
62
+ '-PJTF ' + v
63
+ when k == :copy_project
64
+ '-PJC ' + v
65
+ when k == :build_project
66
+ '-PJB ' + v
67
+ when k == :target_name
68
+ '-TD ' + v
69
+ when k == :target_username
70
+ '-TO ' + v
71
+ when k == :target_password
72
+ '-TP ' + v
73
+ when k == :log_file
74
+ '-LF ' + v
75
+ when k == :tgt
76
+ '-TGT ' + v
77
+ when k == :cmxml
78
+ '-CMXML ' + v
79
+ when k == :compare_folder
80
+ '-ROD ' + v
81
+ when k == :exp
82
+ '-EXP ' + v
83
+ when k == :obj
84
+ '-OBJ ' + v
85
+ when k == :r
86
+ '-R ' + v
87
+ when k == :ae_name
88
+ '-AI ' + v
89
+ when k == :output_folder
90
+ '-FP ' + v
91
+ end
92
+ end
93
+ end
94
+
95
+ def call_executable
96
+ LOG.debug("Executable is set to #{@executable}")
97
+ LOG.debug("Command line options are set to #{@command_line_options.join(" ")}")
98
+ f = IO.popen(@executable + " " + @command_line_options.join(" "))
99
+ f.readlines.each { |line| LOG.info("#{line}")}
100
+ f.close
101
+ @command_line_options.clear
102
+ set_base_parameters
103
+ end
104
+
105
+ private
106
+
107
+ def set_base_parameters
108
+ @command_line_options = [].push("-HIDE -QUIET -SS NO")
109
+ end
110
+ end
111
+
112
+ end
@@ -0,0 +1,3 @@
1
+ module Voodoo
2
+ VERSION = '0.0.2'
3
+ end
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "voodoo/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "ps-voodoo"
7
+ s.version = Voodoo::VERSION
8
+ s.authors = ["JR Bing"]
9
+ s.email = ["jrbing@gmail.com"]
10
+ s.homepage = "https://github.com/jrbing/ps-voodoo"
11
+ s.summary = %q{Black magic utility for PeopleSoft administration}
12
+ s.description = %q{A small command line utility for helping with PeopleSoft administration}
13
+
14
+ s.add_dependency("commander", [">= 4.0.4"])
15
+ s.add_dependency("terminal-table", [">= 1.4.2"])
16
+
17
+ s.rubyforge_project = "ps-voodoo"
18
+
19
+ s.files = `git ls-files`.split("\n")
20
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
21
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
22
+ s.require_paths = ["lib"]
23
+ end
metadata ADDED
@@ -0,0 +1,94 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ps-voodoo
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - JR Bing
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2011-06-13 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: commander
16
+ requirement: &15634116 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 4.0.4
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *15634116
25
+ - !ruby/object:Gem::Dependency
26
+ name: terminal-table
27
+ requirement: &15633804 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 1.4.2
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *15633804
36
+ description: A small command line utility for helping with PeopleSoft administration
37
+ email:
38
+ - jrbing@gmail.com
39
+ executables:
40
+ - voodoo
41
+ extensions: []
42
+ extra_rdoc_files: []
43
+ files:
44
+ - .gitignore
45
+ - Gemfile
46
+ - Gemfile.lock
47
+ - LICENSE.txt
48
+ - README.md
49
+ - Rakefile
50
+ - bin/voodoo
51
+ - lib/voodoo.rb
52
+ - lib/voodoo/commands.rb
53
+ - lib/voodoo/commands/add.rb
54
+ - lib/voodoo/commands/build.rb
55
+ - lib/voodoo/commands/compare.rb
56
+ - lib/voodoo/commands/config.rb
57
+ - lib/voodoo/commands/list.rb
58
+ - lib/voodoo/commands/migrate.rb
59
+ - lib/voodoo/commands/remove.rb
60
+ - lib/voodoo/commands/run.rb
61
+ - lib/voodoo/commands/show.rb
62
+ - lib/voodoo/migration.rb
63
+ - lib/voodoo/peopletools.rb
64
+ - lib/voodoo/peopletools/appdesigner.rb
65
+ - lib/voodoo/peopletools/appengine.rb
66
+ - lib/voodoo/peopletools/datamover.rb
67
+ - lib/voodoo/peopletools/sqr.rb
68
+ - lib/voodoo/version.rb
69
+ - ps-voodoo.gemspec
70
+ homepage: https://github.com/jrbing/ps-voodoo
71
+ licenses: []
72
+ post_install_message:
73
+ rdoc_options: []
74
+ require_paths:
75
+ - lib
76
+ required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
78
+ requirements:
79
+ - - ! '>='
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ requirements: []
89
+ rubyforge_project: ps-voodoo
90
+ rubygems_version: 1.8.5
91
+ signing_key:
92
+ specification_version: 3
93
+ summary: Black magic utility for PeopleSoft administration
94
+ test_files: []