brpm_content_framework 0.1.55

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 (77) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +38 -0
  3. data/.travis.yml +17 -0
  4. data/Gemfile +3 -0
  5. data/LICENSE +21 -0
  6. data/README.md +308 -0
  7. data/Rakefile +23 -0
  8. data/TO_BE_MIGRATED.txt +9 -0
  9. data/architecture.png +0 -0
  10. data/automations/direct_execute.meta +10 -0
  11. data/automations/direct_execute.rb +10 -0
  12. data/automations/install_module.meta +10 -0
  13. data/automations/install_module.rb +13 -0
  14. data/bin/brpm_install +30 -0
  15. data/bin/brpm_uninstall +30 -0
  16. data/bin/event_handler +63 -0
  17. data/bin/webhook_receiver +49 -0
  18. data/brpm_content.gemspec +31 -0
  19. data/config.yml +8 -0
  20. data/infrastructure/.bashrc +6 -0
  21. data/infrastructure/.brpm +2 -0
  22. data/infrastructure/config/customer_include.rb +26 -0
  23. data/infrastructure/config/server.yml +3 -0
  24. data/infrastructure/log.html +39 -0
  25. data/infrastructure/scripts/backup_database.sh +19 -0
  26. data/infrastructure/scripts/ddns.sh +10 -0
  27. data/infrastructure/scripts/install_brpm.sh +63 -0
  28. data/infrastructure/scripts/maintenance.sh +4 -0
  29. data/infrastructure/scripts/patch_brpm.sh +90 -0
  30. data/infrastructure/scripts/restore_database.sh +33 -0
  31. data/infrastructure/scripts/run_event_handler.cmd +19 -0
  32. data/infrastructure/scripts/run_event_handler.sh +20 -0
  33. data/infrastructure/scripts/run_webhook_receiver.cmd +15 -0
  34. data/infrastructure/scripts/run_webhook_receiver.sh +15 -0
  35. data/infrastructure/silent_install_options_4.6.txt +93 -0
  36. data/infrastructure/silent_install_options_upgrade_4.6.txt +92 -0
  37. data/infrastructure/smtp_settings.rb +42 -0
  38. data/lib/brpm_auto.rb +358 -0
  39. data/lib/brpm_script_executor.rb +80 -0
  40. data/lib/logging/brpm_logger.rb +39 -0
  41. data/lib/logging/logger_base.rb +36 -0
  42. data/lib/logging/simple_logger.rb +27 -0
  43. data/lib/module_installer.rb +483 -0
  44. data/lib/params/all_params.rb +80 -0
  45. data/lib/params/integration_settings.rb +27 -0
  46. data/lib/params/params.rb +174 -0
  47. data/lib/params/params_base.rb +81 -0
  48. data/lib/params/request_params.rb +38 -0
  49. data/lib/rest_api.rb +155 -0
  50. data/lib/semaphore.rb +79 -0
  51. data/lib/utilities.rb +317 -0
  52. data/lib/version_control/git.rb +192 -0
  53. data/lib/version_control/svn.rb +221 -0
  54. data/lib/write_to.rb +1 -0
  55. data/tests/all_params_spec.rb +116 -0
  56. data/tests/brpm_auto_spec.rb +84 -0
  57. data/tests/customer_include/config/customer_include.rb +10 -0
  58. data/tests/customer_include/config/server.yml +3 -0
  59. data/tests/customer_include_spec.rb +29 -0
  60. data/tests/gemspec_spec.rb +11 -0
  61. data/tests/module_installer_spec.rb +46 -0
  62. data/tests/params_spec.rb +172 -0
  63. data/tests/request_params_spec.rb +86 -0
  64. data/tests/server_yaml_spec.rb +19 -0
  65. data/tests/spec_helper.rb +64 -0
  66. data/to_be_migrated/brpm_framework.rb +88 -0
  67. data/to_be_migrated/customer_include_default.rb +25 -0
  68. data/to_be_migrated/local_jirb.rb +15 -0
  69. data/to_be_migrated/resource_framework.rb +211 -0
  70. data/transport/dispatch_baa.rb +355 -0
  71. data/transport/dispatch_base.rb +345 -0
  72. data/transport/dispatch_nsh.rb +248 -0
  73. data/transport/dispatch_ssh.rb +154 -0
  74. data/transport/transport_baa.rb +1095 -0
  75. data/transport/transport_nsh.rb +359 -0
  76. data/transport/transport_ssh.rb +220 -0
  77. metadata +204 -0
@@ -0,0 +1,154 @@
1
+ # dispatch_srun.rb
2
+ # Module for action dispatch with nsh protocol
3
+ libDir = File.expand_path(File.dirname(__FILE__))
4
+ require "#{libDir}/dispatch_base"
5
+
6
+
7
+ class DispatchSSH < DispatchBase
8
+ # Initialize the class
9
+ #
10
+ # ==== Attributes
11
+ #
12
+ # * +nsh_object+ - handle to an NSH object
13
+ # * +options+ - hash of options to use, send "output_file" to point to the logging file
14
+ # * +test_mode+ - true/false to simulate commands instead of running them
15
+ #
16
+ def initialize(ssh_object, options = {}, compat_options = {})
17
+ self.extend Utilities
18
+ if options.has_key?("SS_output_dir")
19
+ BrpmAuto.log "Load for this class has changed, no longer necessary to send params as 2nd argument"
20
+ options = compat_options
21
+ end
22
+ @ssh = ssh_object
23
+ @verbose = get_option(options, "verbose", false)
24
+ @output_dir = BrpmAuto.params("SS_output_dir")
25
+ end
26
+
27
+ # Wrapper to run a shell action
28
+ # opens passed script path, or executes passed text
29
+ # processes the script in erb first to allow param substitution
30
+ # note script may have keyword directives (see additional docs)
31
+ # ==== Attributes
32
+ #
33
+ # * +script_file+ - the path to the script or the text of the script
34
+ # * +options+ - hash of options, includes: servers to override step servers
35
+ # ==== Returns
36
+ #
37
+ # action output
38
+ #
39
+ def execute_script(script_file, options = {})
40
+ # get the body of the action
41
+ content = File.open(script_file).read
42
+ seed_servers = get_option(options, "servers")
43
+ transfer_properties = get_option(options, "transfer_properties",{})
44
+ keyword_items = get_keyword_items(content)
45
+ params_filter = keyword_items.has_key?("RPM_PARAMS_FILTER") ? keyword_items["RPM_PARAMS_FILTER"] : DEFAULT_PARAMS_FILTER
46
+ transfer_properties.merge!(get_transfer_properties(params_filter, strip_prefix = true))
47
+ BrpmAuto.log "#----------- Executing Script on Remote Hosts -----------------#"
48
+ BrpmAuto.log "# Script: #{script_file}"
49
+ result = "No servers to execute on"
50
+ # Loop through the platforms
51
+ OS_PLATFORMS.each do |os, os_details|
52
+ servers = BrpmAuto.params.get_servers_by_os_platform(os) if seed_servers == ""
53
+ servers = BrpmAuto.params.get_servers_by_os_platform(os, seed_servers) if seed_servers != ""
54
+ BrpmAuto.message_box "OS Platform: #{os_details["name"]}"
55
+ BrpmAuto.log "No servers selected for: #{os_details["name"]}" if servers.size == 0
56
+ next if servers.size == 0
57
+ BrpmAuto.log "# #{os_details["name"]} - Targets: #{servers.inspect}"
58
+ BrpmAuto.log "# Setting Properties:"
59
+ add_channel_properties(transfer_properties, servers, os)
60
+ brpd_compatibility(transfer_properties)
61
+ transfer_properties.each{|k,v| BrpmAuto.log "\t#{k} => #{v}" }
62
+ shebang = read_shebang(os, content)
63
+ BrpmAuto.log "Shebang: #{shebang.inspect}"
64
+ wrapper_path = build_wrapper_script(os, shebang, transfer_properties, {"script_target" => File.basename(script_file)})
65
+ BrpmAuto.log "# Wrapper: #{wrapper_path}"
66
+ target_path = transfer_properties["RPM_CHANNEL_ROOT"]
67
+ BrpmAuto.log "# Copying script to target: "
68
+ clean_line_breaks(os, script_file, content)
69
+ @ssh.set_servers(server_dns_names(servers))
70
+ result = @ssh.copy_files([script_file], target_path)
71
+ BrpmAuto.log @ssh.display_result(result)
72
+ BrpmAuto.log "# Executing script on target via wrapper:"
73
+ result = @ssh.script_exec(wrapper_path, target_path)
74
+ BrpmAuto.log @ssh.display_result(result)
75
+ end
76
+ result
77
+ end
78
+
79
+ # Copies remote files to a local staging repository
80
+ #
81
+ # ==== Attributes
82
+ #
83
+ # * +file_list+ - array of nsh-style paths (//server/path)
84
+ # * +options+ - hash of options includes: source_server
85
+ # ==== Returns
86
+ #
87
+ # hash of instance_path and md5 - {"instance_path" => "", "md5" => ""}
88
+ #
89
+ def package_artifacts(file_list, options = {})
90
+ version = get_option(options, "version", "")
91
+ version = "#{get_param("SS_request_number")}_#{precision_timestamp}" if version == ""
92
+ staging_path = get_staging_dir(version, true)
93
+ BrpmAuto.message_box "Copying Files to Staging via SSH"
94
+ ans = @ssh.split_nsh_path(file_list.first)
95
+ raise "Command_Failed: staging/build server not found, use nsh-style paths" if ans[0].length < 2
96
+ @ssh.set_servers(ans[0])
97
+ BrpmAuto.log "\t StagingPath: #{staging_path}"
98
+ file_list.each do |file_path|
99
+ BrpmAuto.log "\t #{file_path}"
100
+ result = @ssh.download_files(file_path, staging_path)
101
+ BrpmAuto.log "\tCopy Result: #{@ssh.display_result(result)}"
102
+ end
103
+ package_staged_artifacts(staging_path, version)
104
+ end
105
+
106
+ # Deploys a packaged instance based on staging info
107
+ # staging info is generated by the stage_files routine
108
+ # ==== Attributes
109
+ #
110
+ # * +staging_info+ - hash returned by stage_files
111
+ # * +options+ - hash of options, includes allow_md5_mismatch(true/false) and target_path to override server channel_root
112
+ # ==== Returns
113
+ #
114
+ # action output
115
+ #
116
+ def deploy_package_instance(staging_info, options = {})
117
+ mismatch_ok = get_option(options, "allow_md5_mismatch", false)
118
+ target_path = get_option(options, "target_path")
119
+ instance_path = staging_info["instance_path"]
120
+ BrpmAuto.message_box "Deploying Files to Targets via SSH"
121
+ raise "Command_Failed: no artifacts staged in #{File.dirname(instance_path)}" if Dir.entries(File.dirname(instance_path)).size < 3
122
+ BrpmAuto.log "\t StagingArchive: #{instance_path}"
123
+ md5 = Digest::MD5.file(instance_path).hexdigest
124
+ md5_match = md5 == staging_info["md5"]
125
+ BrpmAuto.log "\t Checksum: expected: #{staging_info["md5"]} - actual: #{md5}#{md5_match ? " MATCHED" : " NO MATCH"}"
126
+ raise "Command_Failed: bad md5 checksum match" if !md5_match && !allow_md5_mismatch
127
+ result = "No servers to execute on"
128
+ # Loop through the platforms
129
+ OS_PLATFORMS.each do |os, os_details|
130
+ servers = BrpmAuto.params.get_servers_by_os_platform(os)
131
+ BrpmAuto.message_box "OS Platform: #{os_details["name"]}"
132
+ BrpmAuto.log "No servers selected for: #{os_details["name"]}" if servers.size == 0
133
+ next if servers.size == 0
134
+ BrpmAuto.log "# #{os_details["name"]} - Targets: #{servers.inspect}"
135
+ target_path = servers.first[1].has_key?("CHANNEL_ROOT") ? servers.first[1]["CHANNEL_ROOT"] : os_details["tmp_dir"] if target_path == ""
136
+ BrpmAuto.log "# Deploying package on target:"
137
+ @ssh.set_servers(server_dns_names(servers))
138
+ result = @ssh.copy_files(instance_path, target_path)
139
+ BrpmAuto.log @ssh.display_result(result)
140
+ BrpmAuto.log "# Unzipping package on target:"
141
+ wrapper_path = create_command_wrapper("unzip -o", os, instance_path, target_path)
142
+ result = @ssh.script_exec(wrapper_path, target_path)
143
+ BrpmAuto.log @ssh.display_result(result)
144
+ end
145
+ @ssh.display_result(result)
146
+ end
147
+
148
+ end
149
+
150
+ @rpm.BrpmAuto.log "Initializing ssh transport"
151
+ debug = defined?(@debug) ? @debug : false
152
+ options = {"debug" => debug}
153
+ @ssh = TransportSSH.new([], options)
154
+ @transport = DispatchSSH.new(@ssh, options)