admin_module 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.rspec +3 -0
  4. data/Gemfile +14 -0
  5. data/Guardfile +24 -0
  6. data/LICENSE +22 -0
  7. data/README.md +281 -0
  8. data/Rakefile +98 -0
  9. data/admin_module.gemspec +34 -0
  10. data/bin/admin_module +13 -0
  11. data/lib/admin_module.rb +260 -0
  12. data/lib/admin_module/cli.rb +54 -0
  13. data/lib/admin_module/cli/cli_guideline.rb +80 -0
  14. data/lib/admin_module/cli/cli_lock.rb +149 -0
  15. data/lib/admin_module/cli/cli_parameter.rb +66 -0
  16. data/lib/admin_module/cli/cli_task.rb +149 -0
  17. data/lib/admin_module/cli_old.rb +92 -0
  18. data/lib/admin_module/client.rb +146 -0
  19. data/lib/admin_module/command.rb +25 -0
  20. data/lib/admin_module/command/client_access.rb +43 -0
  21. data/lib/admin_module/command/config.rb +310 -0
  22. data/lib/admin_module/command/dc.rb +110 -0
  23. data/lib/admin_module/command/gdl.rb +71 -0
  24. data/lib/admin_module/command/lock.rb +110 -0
  25. data/lib/admin_module/command/ppm.rb +142 -0
  26. data/lib/admin_module/command/rule.rb +77 -0
  27. data/lib/admin_module/command/ruleset.rb +56 -0
  28. data/lib/admin_module/command/snapshot.rb +110 -0
  29. data/lib/admin_module/command/stage.rb +131 -0
  30. data/lib/admin_module/command/task.rb +110 -0
  31. data/lib/admin_module/config_helper.rb +33 -0
  32. data/lib/admin_module/dc.rb +133 -0
  33. data/lib/admin_module/guideline.rb +86 -0
  34. data/lib/admin_module/locks.rb +142 -0
  35. data/lib/admin_module/page_factory.rb +55 -0
  36. data/lib/admin_module/pages.rb +120 -0
  37. data/lib/admin_module/pages/dc_definitions_page.rb +73 -0
  38. data/lib/admin_module/pages/dc_detail_page.rb +187 -0
  39. data/lib/admin_module/pages/guideline_page.rb +35 -0
  40. data/lib/admin_module/pages/guideline_version_page.rb +140 -0
  41. data/lib/admin_module/pages/guidelines_page.rb +59 -0
  42. data/lib/admin_module/pages/guidelines_version_all_page.rb +116 -0
  43. data/lib/admin_module/pages/lock_definition_page.rb +178 -0
  44. data/lib/admin_module/pages/lock_definitions_page.rb +69 -0
  45. data/lib/admin_module/pages/login_page.rb +75 -0
  46. data/lib/admin_module/pages/parameter_page.rb +62 -0
  47. data/lib/admin_module/pages/parameters_page.rb +46 -0
  48. data/lib/admin_module/pages/ppms_page.rb +110 -0
  49. data/lib/admin_module/pages/rule_page.rb +68 -0
  50. data/lib/admin_module/pages/rules_page.rb +74 -0
  51. data/lib/admin_module/pages/ruleset_page.rb +64 -0
  52. data/lib/admin_module/pages/rulesets_page.rb +60 -0
  53. data/lib/admin_module/pages/select_list_syncable.rb +64 -0
  54. data/lib/admin_module/pages/snapshot_definitions_page.rb +73 -0
  55. data/lib/admin_module/pages/snapshot_detail_page.rb +246 -0
  56. data/lib/admin_module/pages/workflow_detail_page.rb +451 -0
  57. data/lib/admin_module/pages/workflow_detail_task_addl_detail_page.rb +172 -0
  58. data/lib/admin_module/pages/workflow_detail_task_mappings_page.rb +163 -0
  59. data/lib/admin_module/pages/workflow_detail_task_screens_page.rb +75 -0
  60. data/lib/admin_module/pages/workflow_details_page.rb +67 -0
  61. data/lib/admin_module/pages/workflow_task_page.rb +107 -0
  62. data/lib/admin_module/pages/workflow_tasks_page.rb +111 -0
  63. data/lib/admin_module/ppms.rb +78 -0
  64. data/lib/admin_module/rake.rb +22 -0
  65. data/lib/admin_module/rake/dc_tasks.rb +185 -0
  66. data/lib/admin_module/rake/deploy_task.rb +59 -0
  67. data/lib/admin_module/rake/gdl_tasks.rb +189 -0
  68. data/lib/admin_module/rake/lock_tasks.rb +189 -0
  69. data/lib/admin_module/rake/parameter_task.rb +86 -0
  70. data/lib/admin_module/rake/ppm_tasks.rb +248 -0
  71. data/lib/admin_module/rake/rule_tasks.rb +157 -0
  72. data/lib/admin_module/rake/snapshot_tasks.rb +223 -0
  73. data/lib/admin_module/rake/stage_tasks.rb +197 -0
  74. data/lib/admin_module/rake/stages_task.rb +197 -0
  75. data/lib/admin_module/rake/task_tasks.rb +189 -0
  76. data/lib/admin_module/rules.rb +50 -0
  77. data/lib/admin_module/rulesets.rb +42 -0
  78. data/lib/admin_module/snapshots.rb +133 -0
  79. data/lib/admin_module/stages.rb +171 -0
  80. data/lib/admin_module/tasks.rb +147 -0
  81. data/lib/admin_module/version.rb +3 -0
  82. data/old_spec/lib/admin_module/cli_configuration_spec.rb +126 -0
  83. data/old_spec/lib/admin_module/cli_create_stage_spec.rb +89 -0
  84. data/old_spec/lib/admin_module/cli_delete_rule_spec.rb +57 -0
  85. data/old_spec/lib/admin_module/cli_deploy_spec.rb +57 -0
  86. data/old_spec/lib/admin_module/cli_export_locks_spec.rb +62 -0
  87. data/old_spec/lib/admin_module/cli_export_stages_spec.rb +62 -0
  88. data/old_spec/lib/admin_module/cli_guidelines_version_all_spec.rb +58 -0
  89. data/old_spec/lib/admin_module/cli_import_locks_spec.rb +153 -0
  90. data/old_spec/lib/admin_module/cli_import_stages_spec.rb +173 -0
  91. data/old_spec/lib/admin_module/cli_modify_locks_spec.rb +128 -0
  92. data/old_spec/lib/admin_module/cli_modify_stages_spec.rb +88 -0
  93. data/old_spec/lib/admin_module/cli_rename_rule_spec.rb +53 -0
  94. data/old_spec/lib/admin_module/cli_rename_ruleset_spec.rb +53 -0
  95. data/old_spec/lib/admin_module/cli_var_spec.rb +41 -0
  96. data/old_spec/lib/admin_module/rake/deploy_task_spec.rb +85 -0
  97. data/old_spec/lib/admin_module/rake/parameter_task_spec.rb +58 -0
  98. data/old_spec/lib/admin_module/rake/rules_task_spec.rb +75 -0
  99. data/spec/data/build/test1.xml +0 -0
  100. data/spec/data/build/test2.xml +1 -0
  101. data/spec/data/import_dcs.yml +31 -0
  102. data/spec/data/import_locks.yml +4 -0
  103. data/spec/data/import_snapshots.yml +35 -0
  104. data/spec/data/import_stages.yml +4 -0
  105. data/spec/data/import_tasks.yml +25 -0
  106. data/spec/data/patch-test.xml +1 -0
  107. data/spec/data/remove_test_del_rule.xml +1 -0
  108. data/spec/data/stages.yml +518 -0
  109. data/spec/data/test_del_rule.xml +1 -0
  110. data/spec/lib/admin_module/admin_module_spec.rb +175 -0
  111. data/spec/lib/admin_module/cli_spec.rb +36 -0
  112. data/spec/lib/admin_module/client_spec.rb +158 -0
  113. data/spec/lib/admin_module/command/config_spec.rb +477 -0
  114. data/spec/lib/admin_module/command/dc_spec.rb +202 -0
  115. data/spec/lib/admin_module/command/gdl_spec.rb +139 -0
  116. data/spec/lib/admin_module/command/lock_spec.rb +207 -0
  117. data/spec/lib/admin_module/command/rule_spec.rb +163 -0
  118. data/spec/lib/admin_module/command/ruleset_spec.rb +124 -0
  119. data/spec/lib/admin_module/command/snapshot_spec.rb +202 -0
  120. data/spec/lib/admin_module/command/stage_spec.rb +259 -0
  121. data/spec/lib/admin_module/command/task_spec.rb +207 -0
  122. data/spec/lib/admin_module/dc_spec.rb +192 -0
  123. data/spec/lib/admin_module/guideline_spec.rb +177 -0
  124. data/spec/lib/admin_module/locks_spec.rb +188 -0
  125. data/spec/lib/admin_module/rules_spec.rb +110 -0
  126. data/spec/lib/admin_module/rulesets_spec.rb +85 -0
  127. data/spec/lib/admin_module/snapshot_spec.rb +192 -0
  128. data/spec/lib/admin_module/stages_spec.rb +179 -0
  129. data/spec/lib/admin_module/tasks_spec.rb +196 -0
  130. data/spec/spec_helper.rb +54 -0
  131. data/spec/support/asserts.rb +13 -0
  132. data/spec/support/data_clearing.rb +28 -0
  133. data/spec/support/dirs.rb +54 -0
  134. data/spec/support/helpers.rb +83 -0
  135. data/spec/support/lock.rb +23 -0
  136. data/spec/support/mocks.rb +213 -0
  137. data/spec/support/snapshot.rb +28 -0
  138. data/spec/support/stage.rb +22 -0
  139. data/spec/support/stage_factory.rb +138 -0
  140. data/spec/support/task.rb +23 -0
  141. metadata +381 -0
@@ -0,0 +1,25 @@
1
+ ##############################################################################
2
+ # File:: command.rb
3
+ # Purpose:: CLI command classes
4
+ #
5
+ # Author:: Jeff McAffee 04/05/2015
6
+ #
7
+ ##############################################################################
8
+
9
+
10
+ module AdminModule
11
+ module Command
12
+ # Module code here
13
+ end # module
14
+ end
15
+
16
+ require_relative 'command/client_access'
17
+ require_relative 'command/config'
18
+ require_relative 'command/gdl'
19
+ require_relative 'command/lock'
20
+ require_relative 'command/dc'
21
+ require_relative 'command/rule'
22
+ require_relative 'command/ruleset'
23
+ require_relative 'command/stage'
24
+ require_relative 'command/snapshot'
25
+ require_relative 'command/task'
@@ -0,0 +1,43 @@
1
+ ##############################################################################
2
+ # File:: client_access.rb
3
+ # Purpose:: Module providing client access helper methods for CLI classes.
4
+ #
5
+ # Author:: Jeff McAffee 07/17/2014
6
+ #
7
+ ##############################################################################
8
+
9
+ module AdminModule
10
+ module Command
11
+ module ClientAccess
12
+ private
13
+ def credentials
14
+ config = AdminModule.configuration
15
+ user, pass = config.user_credentials
16
+ if user.nil? || pass.nil?
17
+ user = ask "username for #{config.current_env} environment:"
18
+ pass = ask "password:", echo: false
19
+ # Force a new line - hiding the echo on the password eats the new line.
20
+ say "\n"
21
+ end
22
+ [user, pass]
23
+ end
24
+
25
+ def client
26
+ return @client unless @client.nil?
27
+
28
+ @client = AdminModule.client
29
+ @client.env = options[:environment] unless options[:environment].nil?
30
+
31
+ user, pass = credentials
32
+ if user.empty? || pass.empty?
33
+ say "aborting deploy", :red
34
+ return
35
+ end
36
+
37
+ @client.user = user
38
+ @client.password = pass
39
+ @client
40
+ end
41
+ end # ClientAccess
42
+ end
43
+ end # AdminModule
@@ -0,0 +1,310 @@
1
+ ##############################################################################
2
+ # File:: config.rb
3
+ # Purpose:: Config command
4
+ #
5
+ # Author:: Jeff McAffee 06/29/2014
6
+ #
7
+ ##############################################################################
8
+
9
+ module AdminModule
10
+ module Command
11
+ class Config < Thor
12
+
13
+ class Add < Thor
14
+
15
+ desc "env <envname> <url>", "add a environment url"
16
+ def env(envname, url)
17
+ with_loaded_config do
18
+ unless AdminModule.configuration.base_urls.key? envname.to_sym
19
+ AdminModule.configuration.base_urls[envname.to_sym] = url
20
+ else
21
+ say "environment '#{envname}' already exists", :red
22
+ end
23
+ end
24
+ end
25
+
26
+ desc "xmlmap <xmlfile> <gdlname>", "map an xml file name to a guideline"
27
+ def xmlmap(xmlfile, gdlname)
28
+ with_loaded_config do
29
+ xmlfile = File.basename(xmlfile, '.xml')
30
+
31
+ unless AdminModule.configuration.xmlmaps.key? xmlfile
32
+ AdminModule.configuration.xmlmaps[xmlfile] = gdlname
33
+ else
34
+ say "a mapping already exists for '#{xmlfile}'", :red
35
+ say "delete and re-add the mapping to change it"
36
+ end
37
+ end
38
+ end
39
+
40
+ desc "credentials <envname> <username> <pass>", "add login credentials for an environment"
41
+ def credentials(envname, username, pass)
42
+ with_loaded_config do
43
+ if AdminModule.configuration.base_urls.key? envname.to_sym
44
+ unless AdminModule.configuration.credentials.key? envname.to_sym
45
+ AdminModule.configuration.credentials[envname.to_sym] = [username, pass]
46
+ else
47
+ say "credentials already exist for environment '#{envname}'", :red
48
+ end
49
+ else
50
+ say "environment '#{envname}' doesn't exist", :red
51
+ say "create environment before adding credentials"
52
+ end
53
+ end
54
+ end
55
+
56
+ private
57
+
58
+ def with_loaded_config &block
59
+ fail "expecting block" unless block_given?
60
+
61
+ unless AdminModule.load_configuration
62
+ say "Configuration file not found!", :red
63
+ say "Have you tried 'config init' first?"
64
+ return
65
+ end
66
+
67
+ yield
68
+
69
+ AdminModule.save_configuration
70
+ end
71
+ end
72
+
73
+ desc "add [CATEGORY]", "add a configuration value"
74
+ subcommand "add", Add
75
+
76
+
77
+ class Show < Thor
78
+
79
+ desc "envs", "display configured environments"
80
+ def envs
81
+ with_loaded_config do
82
+ say "Environments:"
83
+
84
+ output = []
85
+ AdminModule.configuration.base_urls.each do |env, url|
86
+ output << [env, url]
87
+ end
88
+ print_table output, indent: 8
89
+ end
90
+ end
91
+
92
+ desc "xmlmaps", "display configured xmlmaps"
93
+ def xmlmaps
94
+ with_loaded_config do
95
+ say "xmlmaps:"
96
+
97
+ output = []
98
+ AdminModule.configuration.xmlmaps.each do |file, gdl|
99
+ output << [file, gdl]
100
+ end
101
+ print_table output, indent: 8
102
+ end
103
+ end
104
+
105
+ desc "credentials <envname>", "display configured credentials for an environment"
106
+ long_desc <<-LD
107
+ Display configured credentials for an environment.
108
+
109
+ If an environment name is not provided, credentials for all
110
+ environments will be displayed.
111
+ LD
112
+ def credentials(envname=nil)
113
+ with_loaded_config do
114
+ say "credentials:"
115
+
116
+ output = []
117
+ AdminModule.configuration.credentials.each do |env, cred|
118
+ if envname.nil? || env == envname.to_sym
119
+ output << [env, cred.first, cred.last]
120
+ end
121
+ end
122
+ print_table output, indent: 8
123
+ end
124
+ end
125
+
126
+ private
127
+
128
+ def with_loaded_config &block
129
+ fail "expecting block" unless block_given?
130
+
131
+ unless AdminModule.load_configuration
132
+ say "Configuration file not found!", :red
133
+ say "Have you tried 'config init' first?"
134
+ return
135
+ end
136
+
137
+ yield
138
+ end
139
+ end
140
+
141
+ desc "show [CATEGORY]", "display configuration values for [CATEGORY]"
142
+ subcommand "show", Show
143
+
144
+
145
+ class Del < Thor
146
+
147
+ desc "env <envname>", "delete an environment configuration"
148
+ def env(envname)
149
+ with_loaded_config do
150
+ if AdminModule.configuration.base_urls.key?(envname.to_sym)
151
+ AdminModule.configuration.base_urls.delete(envname.to_sym)
152
+ end
153
+ end
154
+
155
+ credentials(envname)
156
+ end
157
+
158
+ desc "xmlmap <xmlfile>", "delete an xml file to guideline mapping"
159
+ def xmlmap(xmlfile)
160
+ xmlfile = File.basename(xmlfile, '.xml')
161
+
162
+ with_loaded_config do
163
+ if AdminModule.configuration.xmlmaps.key?(xmlfile)
164
+ AdminModule.configuration.xmlmaps.delete(xmlfile)
165
+ end
166
+ end
167
+ end
168
+
169
+ desc "credentials <envname>", "delete credentials for an environment"
170
+ def credentials(envname)
171
+ with_loaded_config do
172
+ if AdminModule.configuration.credentials.key?(envname.to_sym)
173
+ AdminModule.configuration.credentials.delete(envname.to_sym)
174
+ end
175
+ end
176
+ end
177
+
178
+ private
179
+
180
+ def with_loaded_config &block
181
+ fail "expecting block" unless block_given?
182
+
183
+ unless AdminModule.load_configuration
184
+ say "Configuration file not found!", :red
185
+ say "Have you tried 'config init' first?"
186
+ return
187
+ end
188
+
189
+ yield
190
+
191
+ AdminModule.save_configuration
192
+ end
193
+ end
194
+
195
+ desc "del [CATEGORY]", "delete a configuration value for [CATEGORY]"
196
+ subcommand "del", Del
197
+
198
+
199
+ desc "init <filedir>", "create a configuration file"
200
+ long_desc <<-LD
201
+ Initialize and write a configuration file to disk.
202
+
203
+ If <filedir> is provided, config file will be written to the
204
+ given directory.
205
+
206
+ If <filedir> is not given, the configuration file will be
207
+ written to the current working directory.
208
+
209
+ If you do not yet have a configuration file, this command
210
+ should be run before any other modifications so your config
211
+ changes are safely stored.
212
+ LD
213
+ option :quiet, :type => :boolean, :default => false, :aliases => :q
214
+ def init(filedir = nil)
215
+ outpath = AdminModule.save_configuration filedir
216
+ say("configuration written to #{outpath.to_s}", :green) unless options[:quiet]
217
+ end
218
+
219
+
220
+ desc "timeout <seconds>", "show or set the browser timeout period"
221
+ long_desc <<-LD
222
+ Show or set the browser timeout period.
223
+ Default value is 360.
224
+
225
+ If <seconds> is not provided, display the current setting.
226
+
227
+ <seconds> must be an integer value.
228
+ LD
229
+ def timeout(seconds=nil)
230
+ if seconds.nil?
231
+ with_loaded_config do
232
+ say "browser timeout: #{AdminModule.configuration.browser_timeout}"
233
+ end
234
+ else
235
+ seconds = Integer(seconds)
236
+ with_loaded_config(true) do
237
+ AdminModule.configuration.browser_timeout = seconds
238
+ end
239
+ end
240
+ rescue ArgumentError => e
241
+ say 'argument error: seconds must be an integer', :red
242
+ end
243
+
244
+
245
+ desc "defenv <envname>", "show or set the default environment"
246
+ long_desc <<-LD
247
+ Show or set the default environment.
248
+
249
+ If <envname> is not provided, display the current setting.
250
+
251
+ <envname> must be an existing environment.
252
+ LD
253
+ def defenv(envname=nil)
254
+ if envname.nil?
255
+ with_loaded_config do
256
+ say "default environment: #{AdminModule.configuration.default_environment}"
257
+ end
258
+ return
259
+ end
260
+
261
+ with_loaded_config(true) do
262
+ if AdminModule.configuration.base_urls.key? envname.to_sym
263
+ AdminModule.configuration.default_environment = envname.to_sym
264
+ else
265
+ say "argument error: environment '#{envname}' has not been configured", :red
266
+ end
267
+ end
268
+ end
269
+
270
+
271
+ desc "defcomment '<comment>'", "show or set the default comment"
272
+ long_desc <<-LD
273
+ Show or set the default comment.
274
+
275
+ The default comment will be applied to deployments and versions when
276
+ no comment is provided.
277
+
278
+ A good example of a default comment would be your initials.
279
+ LD
280
+ def defcomment(comment=nil)
281
+ if comment.nil?
282
+ with_loaded_config do
283
+ say "default comment: #{AdminModule.configuration.default_comment}"
284
+ end
285
+ return
286
+ end
287
+
288
+ with_loaded_config(true) do
289
+ AdminModule.configuration.default_comment = comment
290
+ end
291
+ end
292
+
293
+ private
294
+
295
+ def with_loaded_config save = false
296
+ fail "expecting block" unless block_given?
297
+
298
+ unless AdminModule.load_configuration
299
+ say "Configuration file not found!", :red
300
+ say "Have you tried 'config init' first?"
301
+ return
302
+ end
303
+
304
+ yield
305
+
306
+ AdminModule.save_configuration if save
307
+ end
308
+ end # Config
309
+ end
310
+ end # AdminModule
@@ -0,0 +1,110 @@
1
+ ##############################################################################
2
+ # File:: dc.rb
3
+ # Purpose:: DC command line interface
4
+ #
5
+ # Author:: Jeff McAffee 04/01/2015
6
+ #
7
+ ##############################################################################
8
+
9
+ module AdminModule
10
+ module Command
11
+ class Dc < Thor
12
+ include AdminModule::Command::ClientAccess
13
+
14
+ class_option :environment, :banner => "dev", :aliases => :e
15
+
16
+ desc "list",
17
+ "List data clearing definitions"
18
+ long_desc <<-LD
19
+ List all data clearing definitions
20
+
21
+ With -e <env>, sets the environment to work with
22
+ LD
23
+ def list
24
+ cl = client.dcs
25
+ list = cl.list
26
+
27
+ list.each { |item| say item; }
28
+
29
+ ensure
30
+ client.logout
31
+ end
32
+
33
+ desc "import <filepath>",
34
+ "Import a Data Clearing definition file into the environment"
35
+ long_desc <<-LD
36
+ Import a data clearing definition file into the environment.
37
+
38
+ <filepath> is a path to a YAML definition file to import.
39
+
40
+ With -e <env>, sets the environment to work with.
41
+ LD
42
+ def import filepath
43
+ cl = client.dcs
44
+ cl.import filepath
45
+
46
+ ensure
47
+ client.logout
48
+ end
49
+
50
+ desc "export <filepath>",
51
+ "Export a data clearing definition file from the environment"
52
+ long_desc <<-LD
53
+ Export a data clearing definition file from the environment.
54
+
55
+ <filepath> path to location YAML definition file will be exported to.
56
+
57
+ With -e <env>, sets the environment to work with.
58
+ LD
59
+ def export filepath
60
+ cl = client.dcs
61
+ cl.export filepath
62
+
63
+ ensure
64
+ client.logout
65
+ end
66
+
67
+ desc "rename <srcname> <destname>",
68
+ "Rename a data clearing definition from <srcname> to <destname>"
69
+ long_desc <<-LD
70
+ Rename a data clearing definition from <srcname> to <destname>.
71
+
72
+ With -e <env>, sets the environment to work with.
73
+
74
+ This operation will fail if the source definition does not exist or
75
+ if the destination definition name already exists.
76
+ LD
77
+ def rename src, dest
78
+ cl = client.dcs
79
+
80
+ cl.rename src, dest
81
+
82
+ rescue ArgumentError => e
83
+ say e.message, :red
84
+
85
+ ensure
86
+ client.logout
87
+ end
88
+
89
+ desc "read <name>",
90
+ "Emit a data clearing definition from the environment in YAML format"
91
+ long_desc <<-LD
92
+ Emit a data clearing's definition from the environment in YAML format.
93
+
94
+ <name> of data clearing definition to dump.
95
+
96
+ With -e <env>, sets the environment to work with.
97
+ LD
98
+ def read name
99
+ cl = client.dcs
100
+ data = cl.read name
101
+ output = Hash.new
102
+ output[name] = data
103
+ $stdout << output.to_yaml
104
+
105
+ ensure
106
+ client.logout
107
+ end
108
+ end
109
+ end
110
+ end