Produced by Araxis Merge on 7/6/2017 8:23:27 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | OSCIF_CTT_v4_build 1.zip\rails_prisme\app\controllers | app_deployer_controller.rb | Wed May 31 03:59:06 2017 UTC |
| 2 | OSCIF_CTT_v4_build 1.zip\rails_prisme\app\controllers | app_deployer_controller.rb | Mon Jul 3 23:21:08 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 2 | 504 |
| Changed | 1 | 2 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | class AppD eployerCon troller < Applicatio nControlle r | |
| 2 | include TomcatConc ern | |
| 3 | include NexusConce rn | |
| 4 | ||
| 5 | before_a ction :rea d_only | |
| 6 | before_a ction :ens ure_servic es_configu red | |
| 7 | ||
| 8 | def inde x | |
| 9 | @komet _wars = ge t_nexus_wa rs(app: 'K OMET') | |
| 10 | @isaac _wars = ge t_nexus_wa rs(app: 'I SAAC') | |
| 11 | @isaac _dbs = get _isaac_cra dle_zips | |
| 12 | @tomca t_isaac_re st = [] | |
| 13 | ||
| 14 | tomcat _server_de ployments. each do |t sd| | |
| 15 | serv ice_name = tsd.first [:service_ name] | |
| 16 | ||
| 17 | tsd. last.each do |d| | |
| 18 | if (d.first =~ /isaac- rest/i) | |
| 19 | select_key = d.last[ :link] | |
| 20 | select_val ue = "#{se rvice_name }::#{d.fir st}" | |
| 21 | @tomcat_is aac_rest < < {select_ key: selec t_key, sel ect_value: select_va lue} | |
| 22 | en d | |
| 23 | end | |
| 24 | end | |
| 25 | ||
| 26 | if @ko met_wars.n il? || @is aac_wars.n il? | |
| 27 | rend er :file = > 'public/ nexus_not_ available. html' | |
| 28 | retu rn | |
| 29 | end | |
| 30 | ||
| 31 | @tomca t_servers = [] | |
| 32 | Servic e.where(se rvice_type : PrismeSe rvice::TOM CAT).each do |active _record| | |
| 33 | Pris meUtilitie s.get_prox y_contexts (tomcat_ar : active_r ecord, app lication_t ype: Prism eUtilities ::ISAAC_AP PLICATION) .each do | context| | |
| 34 | ha sh = {} | |
| 35 | ha sh[:tomcat _ar] = act ive_record | |
| 36 | ha sh[:contex t] = conte xt | |
| 37 | ac tive_recor d.define_s ingleton_m ethod(:sel ect_value) do | |
| 38 | active_rec ord.name | |
| 39 | en d | |
| 40 | ha sh.define_ singleton_ method(:se lect_value ) do | |
| 41 | active_rec ord.name + '--' + co ntext | |
| 42 | en d | |
| 43 | ha sh.define_ singleton_ method(:se lect_key) do | |
| 44 | active_rec ord.id.to_ s + '|' + context | |
| 45 | en d | |
| 46 | ac tive_recor d.define_s ingleton_m ethod(:sel ect_key) d o | |
| 47 | active_rec ord.id.to_ s | |
| 48 | en d | |
| 49 | @t omcat_serv ers << has h unless c ontext.nil ? | |
| 50 | end | |
| 51 | end | |
| 52 | $log.d ebug(@tomc at_servers .inspect) | |
| 53 | end | |
| 54 | ||
| 55 | def depl oy_app | |
| 56 | # Should l ook someth ing like t his: url = 'http:// URL . DNS : PORT | |
| 57 | # g a v r c war_ cookie_par ams | |
| 58 | tomcat _id, conte xt = nil, nil | |
| 59 | params .each do | k, v| | |
| 60 | if ( (k =~ /^#{ PrismeServ ice::TOMCA T}.*app_se rver$/) && !v.empty? ) | |
| 61 | to mcat_id, c ontext = v .split('|' ) | |
| 62 | br eak | |
| 63 | end | |
| 64 | end | |
| 65 | tomcat _ar = Serv ice.find_b y(id: tomc at_id) | |
| 66 | applic ation_type = params[ :applicati on] | |
| 67 | applic ation_name = params[ :applicati on_name] | |
| 68 | applic ation_desc ription = params[:ap plication_ descriptio n] | |
| 69 | war_pa ram = appl ication_ty pe.eql?('K OMET') ? p arams['kom et_war'] : params['i saac_war'] | |
| 70 | war_fi le = Nexus ArtifactSe lectOption .init_from _select_ke y(war_para m) | |
| 71 | war_na me = war_f ile.select _value | |
| 72 | war_co okie_param s = {} | |
| 73 | nexus_ query_para ms = {} | |
| 74 | ||
| 75 | nexus_ query_para ms[:g] = w ar_file.gr oupId | |
| 76 | nexus_ query_para ms[:a] = w ar_file.ar tifactId | |
| 77 | nexus_ query_para ms[:v] = w ar_file.ve rsion | |
| 78 | nexus_ query_para ms[:r] = w ar_file.re po | |
| 79 | nexus_ query_para ms[:c] = w ar_file.cl assifier u nless war_ file.class ifier.empt y? | |
| 80 | nexus_ query_para ms[:p] = w ar_file.pa ckage | |
| 81 | war_co okie_param s[:prisme_ root] = no n_proxy_ur l(path_str ing: root_ path) | |
| 82 | war_co okie_param s[:prisme_ roles_user _url] = no n_proxy_ur l(path_str ing: roles _get_user_ roles_path ) << '.jso n' | |
| 83 | war_co okie_param s[:prisme_ roles_ssoi _url] = no n_proxy_ur l(path_str ing: roles _get_ssoi_ roles_path ) << '.jso n' | |
| 84 | war_co okie_param s[:prisme_ roles_by_t oken_url] = non_prox y_url(path _string: r oles_get_r oles_by_to ken_path) << '.json' | |
| 85 | war_co okie_param s[:prisme_ config_url ] = non_pr oxy_url(pa th_string: utilities _prisme_co nfig_path) << '.json ' | |
| 86 | war_co okie_param s[:prisme_ all_roles_ url] = non _proxy_url (path_stri ng: roles_ get_all_ro les_path) << '.json' | |
| 87 | securi ty_token = TokenSupp ort.instan ce.generat e_security _token | |
| 88 | war_co okie_param s[:prisme_ all_servic e_props_ur l] = non_p roxy_url(p ath_string : all_serv ices_as_js on_path) < < '.json' << '?secur ity_token= ' + securi ty_token | |
| 89 | war_co okie_param s[:prisme_ notify_url ] = non_pr oxy_url(pa th_string: log_event _path) << '.json' << '?securit y_token=' + security _token | |
| 90 | war_co okie_param s[:war_gro up_id] = w ar_file.gr oupId | |
| 91 | war_co okie_param s[:war_art ifact_id] = war_file .artifactI d | |
| 92 | war_co okie_param s[:war_uui d] = Secur eRandom.uu id | |
| 93 | name_w ar(war_coo kie_params [:war_uuid ], applica tion_name, applicati on_descrip tion) | |
| 94 | war_co okie_param s[:war_ver sion] = wa r_file.ver sion | |
| 95 | war_co okie_param s[:war_rep o] = war_f ile.repo | |
| 96 | war_co okie_param s[:war_cla ssifier] = war_file. classifier unless wa r_file.cla ssifier.em pty? | |
| 97 | war_co okie_param s[:war_pac kage] = wa r_file.pac kage | |
| 98 | ||
| 99 | # chec k if isaac _db is pas sed to det ermine if this is a komet or a n isaac de ployment | |
| 100 | isaac_ db = param s['isaac_d b'] | |
| 101 | ||
| 102 | if isa ac_db.nil? || isaac_ db.empty? | |
| 103 | #we are komet! ! | |
| 104 | war_ cookie_par ams[:isaac _root] = p arams['tom cat_isaac_ rest'] | |
| 105 | else | |
| 106 | zip_ file = Nex usArtifact SelectOpti on.init_fr om_select_ key(isaac_ db) | |
| 107 | war_ cookie_par ams[:db_gr oup_id] = zip_file.g roupId | |
| 108 | war_ cookie_par ams[:db_ar tifact_id] = zip_fil e.artifact Id | |
| 109 | war_ cookie_par ams[:db_ve rsion] = z ip_file.ve rsion | |
| 110 | war_ cookie_par ams[:db_re po] = zip_ file.repo | |
| 111 | war_ cookie_par ams[:db_cl assifier] = zip_file .classifie r | |
| 112 | war_ cookie_par ams[:db_pa ckage] = z ip_file.pa ckage | |
| 113 | end | |
| 114 | ||
| 115 | job = AppDeploym entJob.per form_later (nexus_que ry_params, war_cooki e_params, war_name, tomcat_ar, context, {job_tag: PrismeCons tants::Job Tags::APP_ DEPLOYER}) | |
| 116 | Prisme BaseJob.up date_json_ data(job_i d: job.job _id, json_ data: {mes sage: "Dep loying #{w ar_name}.. .Please wa it"}) | |
| 117 | Prisme BaseJob.sa ve_user(jo b_id: job. job_id, us er: prisme _user.user _name) | |
| 118 | redire ct_to app_ deployer_p ath | |
| 119 | end | |
| 120 | ||
| 121 | def relo ad_deploym ents | |
| 122 | ret = [] | |
| 123 | ||
| 124 | begin | |
| 125 | row_ limit = pa rams[:row_ limit] ||= 15 | |
| 126 | data = PrismeJ ob.job_tag (PrismeCon stants::Jo bTags::APP _DEPLOYER) .is_root(t rue).orpha n(false).o rder(compl eted_at: : desc).limi t(row_limi t) | |
| 127 | ||
| 128 | data .each do | app_dep| | |
| 129 | ro w_data = a pp_dep.as_ json | |
| 130 | ro w_data['st arted_at'] = row_dat a['started _at'].to_i | |
| 131 | ro w_data['le af_data'] = leaf_dat a(app_dep) | |
| 132 | re t << row_d ata | |
| 133 | end | |
| 134 | rend er json: r et | |
| 135 | rescue => ex | |
| 136 | $log .error(ex. to_s) | |
| 137 | $log .error(ex. backtrace. join("\n") ) | |
| 138 | rais e ex | |
| 139 | end | |
| 140 | end | |
| 141 | ||
| 142 | def ajax _check_pol ling | |
| 143 | prisme _job_has_r unning_job s = Prisme Job.has_ru nning_jobs ?(PrismeCo nstants::J obTags::AP P_DEPLOYER , true) | |
| 144 | render json: {po ll: prisme _job_has_r unning_job s} | |
| 145 | end | |
| 146 | ||
| 147 | private | |
| 148 | ||
| 149 | def name _war(uuid, name, des cription) | |
| 150 | uuid_a ctive_reco rd = UuidP rop.uuid(u uid: uuid) | |
| 151 | begin | |
| 152 | uuid _active_re cord.save_ json_hash! (UuidProp: :Keys::NAM E => name, UuidProp: :Keys::DES CRIPTION = > descript ion, UuidP rop::Keys: :LAST_EDIT ED_BY => p risme_user .user_name ) | |
| 153 | rescue => ex | |
| 154 | $log .warn("The name war failed for uuid #{uu id}") | |
| 155 | $log .warn("The name woul d have bee n #{name}" ) | |
| 156 | $log .warn("The deploy wi ll continu e, the use r will hav e to name from the h ome screen ...") | |
| 157 | $log .warn(ex.m essage) | |
| 158 | $log .warn(ex.b acktrace.j oin("\n")) | |
| 159 | end | |
| 160 | end | |
| 161 | ||
| 162 | def leaf _data(row) | |
| 163 | ret_da ta = {} | |
| 164 | ||
| 165 | if row .status != PrismeJob Constants: :Status::S TATUS_HASH [:COMPLETE D] | |
| 166 | ar = row | |
| 167 | else | |
| 168 | leaf = row.des cendants.l eaves.firs t | |
| 169 | ar = leaf | |
| 170 | ret_ data = lea f.as_json | |
| 171 | end | |
| 172 | ||
| 173 | ret_da ta['orphan ed_leaf'] = ar['stat us'] == Pr ismeJobCon stants::St atus::STAT US_HASH[:O RPHANED] | |
| 174 | ret_da ta['runnin g'] = fals e | |
| 175 | ret_da ta['toolti p'] = '' | |
| 176 | ||
| 177 | case a r['status' ] | |
| 178 | when PrismeJob Constants: :Status::S TATUS_HASH [:FAILED] | |
| 179 | re t_data['ru nning_msg' ] = 'Job E xecution F ailed. See the toolt ip for the error mes sage.' | |
| 180 | re t_data['to oltip'] = ar['last_e rror'] | |
| 181 | when PrismeJob Constants: :Status::S TATUS_HASH [:ORPHANED ] | |
| 182 | re t_data['ru nning_msg' ] = 'Job w as orphane d. The app lication d eployment failed.' | |
| 183 | else | |
| 184 | re t_data['ru nning'] = !ret_data[ 'job_name' ].eql?(Dep loyWarJob. name) || a r['complet ed_at'].ni l? | |
| 185 | ||
| 186 | if ar['json_ data'].nil ? | |
| 187 | ret_data[' running_ms g'] = ar[' result'] | |
| 188 | el se | |
| 189 | ret_data[' running_ms g'] = JSON .parse(ar[ 'json_data '])['messa ge'] | |
| 190 | ret_data[' tooltip'] = JSON.par se(ar['jso n_data'])[ 'tooltip'] ||= '' | |
| 191 | en d | |
| 192 | end | |
| 193 | ||
| 194 | if row ['started_ at'] && !r et_data['o rphaned_le af'] | |
| 195 | ret_ data['comp leted_at'] = ret_dat a['complet ed_at'] || = Time.now .to_i | |
| 196 | ret_ data['elap sed_time'] = Applica tionHelper .convert_s econds_to_ time(ret_d ata['compl eted_at'] - row['sta rted_at']. to_i) | |
| 197 | else | |
| 198 | ret_ data['elap sed_time'] = '' | |
| 199 | end | |
| 200 | ||
| 201 | ret_da ta | |
| 202 | end | |
| 203 | ||
| 204 | def get_ nexus_wars (app:) | |
| 205 | url_st ring = $PR OPS['ENDPO INT.nexus_ lucene_sea rch'] | |
| 206 | params _hash = {' KOMET' => {g: 'gov.v ha.isaac.g ui.rails', a: 'rails _komet', r epositoryI d: 'releas es', p: 'w ar'}, | |
| 207 | ' ISAAC' => {g: 'gov.v ha.isaac.r est', a: ' isaac-rest ', reposit oryId: 're leases', p : 'war'}} | |
| 208 | params = params_ hash[app] | |
| 209 | conn = get_nexus _connectio n | |
| 210 | respon se = conn. get(url_st ring, para ms) | |
| 211 | json = nil | |
| 212 | ||
| 213 | begin | |
| 214 | json = JSON.pa rse respon se.body | |
| 215 | rescue JSON::Par serError = > ex | |
| 216 | if ( response.s tatus.eql? (200)) | |
| 217 | re turn respo nse.body | |
| 218 | end | |
| 219 | end | |
| 220 | ||
| 221 | return nil if js on.nil? | |
| 222 | ret = [] | |
| 223 | ||
| 224 | if (js on['totalC ount'].to_ i > 0) | |
| 225 | json ['data'].e ach do |ar tifact| | |
| 226 | g = artifact ['groupId' ] | |
| 227 | a = artifact ['artifact Id'] | |
| 228 | v = artifact ['version' ] | |
| 229 | lr = artifac t['latestR elease'] # use this for stylin g?? | |
| 230 | hi ts = artif act['artif actHits']. first | |
| 231 | re po = hits[ 'repositor yId'] | |
| 232 | li nks = hits ['artifact Links'] | |
| 233 | ||
| 234 | # only inclu de war fil es | |
| 235 | li nks.keep_i f { |h| h[ 'extension '] == 'war ' }.each d o |h| | |
| 236 | include_wa r = true | |
| 237 | if a =~ /k omet/i && h['classif ier'].eql? ('c') | |
| 238 | include_ envs = ($P ROPS['PRIS ME.komet_c _include_e nv']).spli t(',').map (&:strip) rescue [] | |
| 239 | include_ war = incl ude_envs.i nclude? PR ISME_ENVIR ONMENT | |
| 240 | end | |
| 241 | ||
| 242 | if include _war | |
| 243 | ret << N exusArtifa ctSelectOp tion.new(g roupId: g, artifactI d: a, vers ion: v, re po: repo, classifier : h['class ifier'], p ackage: h[ 'extension ']) | |
| 244 | end | |
| 245 | en d | |
| 246 | end | |
| 247 | else | |
| 248 | $log .info('no war files found!!!') | |
| 249 | end | |
| 250 | ret | |
| 251 | end | |
| 252 | ||
| 253 | end |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.