ps-voodoo 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -5,3 +5,5 @@
5
5
  TODO.md
6
6
  lib/voodoo/commands/test.rb
7
7
  pkg
8
+
9
+ .DS_Store
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011 JR
1
+ Copyright (c) 2011 JR Bing
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,13 +1,21 @@
1
1
  VooDoo
2
2
  ===========
3
3
 
4
- VooDoo is a command line application to help automate some PeopleSoft administration activities that are typically performed locally.
4
+ VooDoo is a command line application to help automate some PeopleSoft
5
+ administration activities that are typically performed locally.
5
6
 
6
7
  Why?
7
- ----
8
- PeopleSoft installation and administration is tedious. Migrating projects, generating compare reports, and running SQR's locally is a pain.
8
+ ----
9
9
 
10
- VooDoo alleviates some of this by providing a simple command line interface for interacting with your local PeopleTools installation using predefined settings for each of your environments. For example, migrating a project between two environments using VooDoo is as simple as issuing the following command:
10
+ PeopleSoft installation and administration is tedious.
11
+ Migrating projects, generating compare reports, and running SQR's
12
+ locally is a pain.
13
+
14
+ VooDoo alleviates some of this by providing a simple command line
15
+ interface for interacting with your local PeopleTools installation
16
+ using predefined settings for each of your environments. For example,
17
+ migrating a project between two environments using VooDoo is as simple
18
+ as issuing the following command:
11
19
 
12
20
  C:\> voodoo migrate TEST_PROJECT HRDEV HRTEST
13
21
 
@@ -22,7 +30,7 @@ VooDoo alleviates some of this by providing a simple command line interface for
22
30
 
23
31
 
24
32
  Super. What are the requirements?
25
- ------------
33
+ ---------------------------------
26
34
 
27
35
  In order to run VooDoo, you'll first need the following:
28
36
 
@@ -82,7 +90,8 @@ To run a compare report:
82
90
  Name for output folder: VOODOO_TEST
83
91
  07/18/2011 13:09:54: Creating compare reports for SCRIPTING_TEST between FNDEV and FNSPTB
84
92
 
85
- If successful, the generated HTML output of the compare report will be opened in your default browser. To see what else you can do, run:
93
+ If successful, the generated HTML output of the compare report will be
94
+ opened in your default browser. To see what else you can do, run:
86
95
 
87
96
  C:\>voodoo help
88
97
  NAME:
@@ -107,6 +116,7 @@ If successful, the generated HTML output of the compare report will be opened in
107
116
  run appengine runs an appengine against the specified environment
108
117
  run sqr runs the specified sqr locally
109
118
  show shows configuration details for an environment
119
+ template datafix creates a datafix folder with template files
110
120
 
111
121
  GLOBAL OPTIONS:
112
122
 
@@ -124,9 +134,15 @@ If successful, the generated HTML output of the compare report will be opened in
124
134
  Sounds too easy. How does it work?
125
135
  ----------------------------------
126
136
 
127
- It's actually pretty simple. Global and environment configuration data is stored in YAML files under the .voodoo folder in the user's HOME directory. When commands are issued to VooDoo, it uses the environment configuration information to pass command line arguments to the local executable.
137
+ It's actually pretty simple. Global and environment configuration data
138
+ is stored in YAML files under the .voodoo folder in the user's HOME
139
+ directory. When commands are issued to VooDoo, it uses the environment
140
+ configuration information to pass command line arguments to the local
141
+ executable.
128
142
 
129
- In some situations the Windows registry is updated to set options that cannot be passed via the command line (project build output destinations, datamover output destinations).
143
+ In some situations the Windows registry is updated to set options
144
+ that cannot be passed via the command line (project build output
145
+ destinations, datamover output destinations).
130
146
 
131
147
 
132
148
  Who wrote this thing?
@@ -149,8 +165,8 @@ distribute, sublicense, and/or sell copies of the Software, and to
149
165
  permit persons to whom the Software is furnished to do so, subject to
150
166
  the following conditions:
151
167
 
152
- The above copyright notice and this permission notice shall be
153
- included in all copies or substantial portions of the Software.
168
+ The above copyright notice and this permission notice shall be included
169
+ in all copies or substantial portions of the Software.
154
170
 
155
171
  THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
156
172
  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
data/bin/voodoo CHANGED
@@ -9,9 +9,11 @@ program :name, 'Voodoo'
9
9
  program :version, Voodoo::VERSION
10
10
  program :description, 'Black Magic Utility for PeopleSoft Administration'
11
11
 
12
+ global_option('--debug') { Voodoo.show_debugging }
13
+
12
14
  command :add do |c|
13
15
  c.syntax = 'voodoo add [environment name]'
14
- c.summary = 'adds an environment to the configuration file'
16
+ c.summary = 'Adds an environment to the configuration file'
15
17
  c.description = 'Prompts for environment information and saves it to the environment configuration file'
16
18
  c.example 'Prompt for setup values before adding VDDMO to the configuration file', 'voodoo add VDDMO'
17
19
  c.action do |args|
@@ -21,7 +23,7 @@ end
21
23
 
22
24
  command :remove do |c|
23
25
  c.syntax = 'voodoo remove [environment name]'
24
- c.summary = 'removes an environment from the configuration file'
26
+ c.summary = 'Removes an environment from the configuration file'
25
27
  c.description = 'Deletes the specified environment from the configuration file'
26
28
  c.example 'Removes the environment VDDMO from the configuration file', 'voodoo remove VDDMO'
27
29
  c.action do |args|
@@ -41,7 +43,7 @@ end
41
43
 
42
44
  command :show do |c|
43
45
  c.syntax = 'voodoo show [environment name]'
44
- c.summary = 'shows configuration details for an environment'
46
+ c.summary = 'Shows configuration details for an environment'
45
47
  c.description = 'Outputs a table containing information about the specified environment'
46
48
  c.example 'Show information about VDDMO', 'voodoo show VDDMO'
47
49
  c.action do |args|
@@ -51,7 +53,7 @@ end
51
53
 
52
54
  command :config do |c|
53
55
  c.syntax = 'voodoo config'
54
- c.summary = 'create global configuration settings'
56
+ c.summary = 'Create global configuration settings'
55
57
  c.description = 'Prompts for global configuration information and saves it to the configuration file'
56
58
  c.action do |args, options|
57
59
  c.when_called Voodoo::Commands.config
@@ -60,7 +62,7 @@ end
60
62
 
61
63
  command :compare do |c|
62
64
  c.syntax = 'voodoo compare [project] [source] [target]'
63
- c.summary = 'create a compare report for the specified project'
65
+ c.summary = 'Create a compare report for the specified project'
64
66
  c.description = 'Creates an HTML compare report for the specified project and opens it in the default browser'
65
67
  c.example 'Create a compare report between two environments', 'voodoo compare EXAMPLE_PROJECT VDDEV VDTEST'
66
68
  c.action do |args|
@@ -70,7 +72,7 @@ end
70
72
 
71
73
  command :build do |c|
72
74
  c.syntax = 'voodoo build [project] [environment]'
73
- c.summary = 'builds a project definition in the specified environment'
75
+ c.summary = 'Builds a project definition in the specified environment'
74
76
  c.description = 'Builds a project definition script for the specified project using AppDesigner and executes it in the target database'
75
77
  c.example 'Build specified project', 'voodoo build EXAMPLE_PROJECT VDTEST'
76
78
  c.action do |args|
@@ -80,7 +82,7 @@ end
80
82
 
81
83
  command :archive do |c|
82
84
  c.syntax = 'voodoo archive [project] [environment]'
83
- c.summary = 'copies a project to file from the specified environment'
85
+ c.summary = 'Copies a project to file from the specified environment'
84
86
  c.description = 'Copies a project from the specified environment to file in the output directory'
85
87
  c.example 'Archive specified project', 'voodoo archive EXAMPLE_PROJECT VDTEST'
86
88
  c.action do |args|
@@ -90,7 +92,7 @@ end
90
92
 
91
93
  command :migrate do |c|
92
94
  c.syntax = 'voodoo migrate [project] [source] [target]'
93
- c.summary = 'migrates a project between environments'
95
+ c.summary = 'Migrates a project between environments'
94
96
  c.description = 'Migrates a project between two environments after running a compare report and copying the objects to file'
95
97
  c.example 'Migrate project between environments', 'voodoo migrate EXAMPLE_PROJECT VDDEV VDTEST'
96
98
  c.action do |args|
@@ -100,7 +102,7 @@ end
100
102
 
101
103
  command :'run appengine' do |c|
102
104
  c.syntax = 'voodoo run appengine [ae_name] [environment]'
103
- c.summary = 'runs an appengine against the specified environment'
105
+ c.summary = 'Runs an appengine against the specified environment'
104
106
  c.description = 'Runs an appengine against the specified PeopleSoft environment'
105
107
  c.example 'Run the VERSION appengine agains VDTEST', 'voodoo run appengine VERSION VDTEST'
106
108
  c.action do |args|
@@ -110,7 +112,7 @@ end
110
112
 
111
113
  command :'run sqr' do |c|
112
114
  c.syntax = 'voodoo run sqr [sqr name] [environment]'
113
- c.summary = 'runs the specified sqr locally'
115
+ c.summary = 'Runs the specified sqr locally'
114
116
  c.description = 'Run the specified SQR locally using the sqr bin specified in the environment configuration.'
115
117
  c.example 'Run SQR', 'voodoo run sqr SETSPACE.sqr VDDEV'
116
118
  c.action do |args|
@@ -118,3 +120,13 @@ command :'run sqr' do |c|
118
120
  end
119
121
  end
120
122
 
123
+ command :'template datafix' do |c|
124
+ c.syntax = 'voodoo template datafix [output folder]'
125
+ c.summary = 'Creates a datafix folder with sample files'
126
+ c.description = 'Create a folder and populate sample files to be updated with datafix SQL.'
127
+ c.example 'Create datafix folder', 'voodoo template datafix SAMPLE_DATAFIX'
128
+ c.action do |args|
129
+ Voodoo::Commands.template_datafix(args)
130
+ end
131
+ end
132
+
@@ -15,6 +15,10 @@ module Voodoo
15
15
  "#{Time.now.strftime("%m/%d/%Y %H:%M:%S")}: #{msg}\n"
16
16
  }
17
17
 
18
+ def self.show_debugging
19
+ LOG.level = Logger::DEBUG
20
+ end
21
+
18
22
  def self.libpath( *args )
19
23
  rv = args.empty? ? LIBPATH : ::File.join(LIBPATH, args.flatten)
20
24
  if block_given?
@@ -1,4 +1,5 @@
1
1
  require 'terminal-table/import'
2
+ require 'mail'
2
3
  Voodoo.require_all_libs_relative_to(__FILE__)
3
4
 
4
5
  module Voodoo
@@ -5,7 +5,7 @@ module Voodoo
5
5
 
6
6
  def self.add(args=nil)
7
7
  settings = {}
8
- puts "\n### Appdesigner/Datamover/AppEngine Settings ###"
8
+ puts "\n----Appdesigner/Datamover/AppEngine Settings------"
9
9
  if args.first.nil?
10
10
  name = ask("Database name: ").upcase
11
11
  else
@@ -13,11 +13,13 @@ module Voodoo
13
13
  end
14
14
  settings['db_type'] = ask("Database type: ", %w{ORACLE}) { |q| q.default = "ORACLE" }
15
15
  settings['app_username'] = ask("Application username: ")
16
+
17
+ puts "\n----Output Archive Settings-----------------------"
16
18
  if agree("\nWould you like to archive migration output files for this environment? (y/n) ") == true
17
19
  settings['migration_archive'] = get_path("Archive destination")
18
20
  end
19
21
 
20
- puts "\n### SQR Settings ###"
22
+ puts "\n----SQR Settings----------------------------------"
21
23
  settings['db_username'] = ask("Database username: ") { |q| q.default = "sysadm" }
22
24
  settings['ps_home'] = get_path("PS_HOME directory")
23
25
 
@@ -5,9 +5,15 @@ module Voodoo
5
5
 
6
6
  def self.config
7
7
  settings = {}
8
- puts "\n### Global Configuration Settings ###"
8
+ puts "\n----Global Configuration Settings-----------------"
9
9
  settings[:ps_home] = get_path("Local tools directory")
10
10
  settings[:migration_output_dir] = get_path("Default output directory for migration data")
11
+
12
+ if agree("\nWould you like to define email notification settings? (y/n) ") == true
13
+ settings[:mail_server] = ask("SMTP server: ")
14
+ settings[:smtp_port] = ask("SMTP port: ") { |q| q.default = "587" }
15
+ settings[:email_from] = ask("Email from address: ")
16
+ end
11
17
  Voodoo.write_config_file(settings)
12
18
  end
13
19
 
@@ -19,6 +19,7 @@ module Voodoo
19
19
  end
20
20
 
21
21
  migration = get_migration
22
+ puts migration.log_folder
22
23
 
23
24
  instance = Voodoo::Sqr.new
24
25
  instance.run(migration, target, sqr_name)
@@ -0,0 +1,49 @@
1
+ require 'erb'
2
+
3
+ module Voodoo
4
+
5
+ module Commands
6
+ extend self
7
+
8
+ class ErbBinding < OpenStruct
9
+ def get_binding
10
+ return binding()
11
+ end
12
+ end
13
+
14
+ def template_datafix(args=nil)
15
+
16
+ if args[0].nil?
17
+ datafix = get_migration
18
+ else
19
+ datafix = Migration.new(args.first.upcase)
20
+ end
21
+
22
+ records = ask("Records to be affected: ", Array)
23
+
24
+ backup_template = File.read(File.join((File.dirname(__FILE__)), '/templates/backup.dms').gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
25
+ script_template = File.read(File.join((File.dirname(__FILE__)), '/templates/script.sql').gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
26
+
27
+ vars = ErbBinding.new
28
+ vars.name = datafix.migration_name
29
+ vars.folder = datafix.migration_folder
30
+ vars.records = records
31
+ vars_binding = vars.send(:get_binding)
32
+
33
+ generated_backup = ERB.new(backup_template, 0, "%<>")
34
+ generated_script = ERB.new(script_template, 0, "%<>")
35
+
36
+ backup_file = File.join(datafix.migration_folder, 'backup.dms').gsub!(File::SEPARATOR, File::ALT_SEPARATOR)
37
+ puts "Creating file #{backup_file}"
38
+ File.open(backup_file, 'w') {|f| f.write(generated_backup.result(vars_binding))}
39
+
40
+ script_file = File.join(datafix.migration_folder, 'script.sql').gsub!(File::SEPARATOR, File::ALT_SEPARATOR)
41
+ puts "Creating file #{script_file}"
42
+ File.open(script_file, 'w') {|f| f.write(generated_script.result(vars_binding))}
43
+
44
+ # puts File.expand_path(__FILE__)
45
+ end
46
+
47
+ end
48
+
49
+ end
@@ -0,0 +1,10 @@
1
+ -- Datafix <%= name %>
2
+ -- Created on: <%= Time.now.localtime.strftime("%m/%d/%Y") %>
3
+
4
+ SET OUTPUT <%= folder %>\backup.dat;
5
+ SET LOG <%= folder %>\backup.log;
6
+
7
+ % records.each do |record|
8
+ EXPORT <%= record.upcase %> WHERE ... ;
9
+ % end
10
+
@@ -0,0 +1,20 @@
1
+
2
+ <!DOCTYPE html>
3
+ <html>
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
6
+ <title>VooDoo Migration Email</title>
7
+ </head>
8
+ <body>
9
+ <h2>This is a header</h2>
10
+ <p>This is some text telling you about the migration that just happened. </p>
11
+ <p>Here are the steps from the migration: </p>
12
+ <ol>
13
+ <li>step one</li>
14
+ <li>step two</li>
15
+ <li>step three</li>
16
+ </ol>
17
+ <p>This is some additional information regarding the migration.</p>
18
+ <p><strong>VooDoo</strong></p>
19
+ </body>
20
+ </html>
@@ -0,0 +1,4 @@
1
+ -- Datafix <%= name %>
2
+ -- Created on: <%= Time.now.localtime.strftime("%m/%d/%Y") %>
3
+
4
+ -- Insert sql inserts/updates/deletes here
@@ -3,28 +3,32 @@ module Voodoo
3
3
 
4
4
  class Migration
5
5
 
6
+ attr_reader :migration_folder
7
+ attr_reader :migration_name
8
+
6
9
  def initialize(name)
10
+ @migration_name = name
7
11
  @migration_folder = create_folder(File.join(CONFIGURATION.migration_output_dir, name))
8
12
  end
9
13
 
10
14
  def log_folder
11
- @log_folder = create_folder(File.join(@migration_folder, 'logs').gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
15
+ @log_folder = create_folder(File.join(@migration_folder, 'logs'))
12
16
  end
13
17
 
14
18
  def archive_folder
15
- @archive_folder = create_folder(File.join(@migration_folder, 'archive').gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
19
+ @archive_folder = create_folder(File.join(@migration_folder, 'archive'))
16
20
  end
17
21
 
18
22
  def sql_folder
19
- @sql_folder = create_folder(File.join(@migration_folder, 'sql').gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
23
+ @sql_folder = create_folder(File.join(@migration_folder, 'sql'))
20
24
  end
21
25
 
22
26
  def compare_folder(source, target)
23
- create_folder(File.join(compare_base_folder, "#{source}_to_#{target}").gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
27
+ @compare_folder = create_folder(File.join(compare_base_folder, "#{source}_to_#{target}"))
24
28
  end
25
29
 
26
30
  def export_folder(source)
27
- create_folder(File.join(project_folder, source).gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
31
+ @export_folder = create_folder(File.join(project_folder, source))
28
32
  end
29
33
 
30
34
  def continue?
@@ -34,22 +38,23 @@ module Voodoo
34
38
  end
35
39
 
36
40
  def copy_to_archive(archive_folder)
41
+ # add error handling
37
42
  FileUtils.cp_r(@migration_folder, archive_folder, :verbose => true)
38
43
  end
39
44
 
40
45
  private
41
46
 
42
47
  def project_folder
43
- @project_folder = create_folder(File.join(@migration_folder, 'project').gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
48
+ @project_folder = create_folder(File.join(@migration_folder, 'project'))
44
49
  end
45
50
 
46
51
  def compare_base_folder
47
- @compare_base_folder = create_folder(File.join(@migration_folder, 'compares').gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
52
+ @compare_base_folder = create_folder(File.join(@migration_folder, 'compares'))
48
53
  end
49
54
 
50
55
  def create_folder(folder_path)
51
56
  Dir.mkdir(folder_path) unless File.exists?(folder_path)
52
- return folder_path
57
+ return folder_path.gsub!(File::SEPARATOR, File::ALT_SEPARATOR)
53
58
  end
54
59
 
55
60
  end
@@ -66,7 +66,7 @@ module Voodoo
66
66
  LOG.debug("Command line options are set to #{@command_line_options.join(" ")}")
67
67
 
68
68
  f = IO.popen(@executable + " " + @command_line_options.join(" "))
69
- f.readlines.each { |line| LOG.info("#{line.chomp}")}
69
+ f.readlines.each { |line| puts ("#{line.chomp}")}
70
70
  f.close
71
71
 
72
72
  @command_line_options.clear
@@ -12,6 +12,7 @@ module Voodoo
12
12
  end
13
13
 
14
14
  def run(migration, target, sqr_name)
15
+ @sqr_name = sqr_name
15
16
  append(:sqr => File.join(target.ps_home, 'sqr', sqr_name).gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
16
17
  append(:db_login => target.db_username + '/' + target.db_password + '@' + target.name)
17
18
  append(:input => File.join(target.ps_home, 'sqr').gsub!(File::SEPARATOR, File::ALT_SEPARATOR))
@@ -56,8 +57,9 @@ module Voodoo
56
57
  LOG.debug("Executable is set to #{@executable}")
57
58
  LOG.debug("Command line options are set to #{@command_line_options.join(" ")}")
58
59
 
60
+ puts "Running #{@sqr_name}..."
59
61
  f = IO.popen(@executable + " " + @command_line_options.join(" "))
60
- f.readlines.each { |line| LOG.info("#{line.chomp}")}
62
+ f.readlines.each { |line| puts ("#{line.chomp}")}
61
63
  f.close
62
64
 
63
65
  @command_line_options.clear
@@ -1,3 +1,3 @@
1
1
  module Voodoo
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ps-voodoo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-07-18 00:00:00.000000000Z
12
+ date: 2011-08-08 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander
16
- requirement: &21806580 !ruby/object:Gem::Requirement
16
+ requirement: &20414196 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 4.0.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *21806580
24
+ version_requirements: *20414196
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: terminal-table
27
- requirement: &21806256 !ruby/object:Gem::Requirement
27
+ requirement: &20413884 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,7 +32,7 @@ dependencies:
32
32
  version: 1.4.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *21806256
35
+ version_requirements: *20413884
36
36
  description: A small command line utility for helping with PeopleSoft administration
37
37
  email:
38
38
  - jrbing@gmail.com
@@ -60,6 +60,10 @@ files:
60
60
  - lib/voodoo/commands/remove.rb
61
61
  - lib/voodoo/commands/run.rb
62
62
  - lib/voodoo/commands/show.rb
63
+ - lib/voodoo/commands/template.rb
64
+ - lib/voodoo/commands/templates/backup.dms
65
+ - lib/voodoo/commands/templates/migration_email.erb
66
+ - lib/voodoo/commands/templates/script.sql
63
67
  - lib/voodoo/migration.rb
64
68
  - lib/voodoo/peopletools.rb
65
69
  - lib/voodoo/peopletools/appdesigner.rb
@@ -88,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
92
  version: '0'
89
93
  requirements: []
90
94
  rubyforge_project: ps-voodoo
91
- rubygems_version: 1.8.5
95
+ rubygems_version: 1.8.7
92
96
  signing_key:
93
97
  specification_version: 3
94
98
  summary: Black magic utility for PeopleSoft administration