Skip to content

Commit 51c14b9

Browse files
committed
Merge branch 'release/2.2'
2 parents 95362a7 + afbbf9e commit 51c14b9

File tree

96 files changed

+2767
-323
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+2767
-323
lines changed

documentation/index.xhtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102

103103
<p>Dessa sidor vänder sig främst till myndigheter som
104104
producerar rättsinformation som omfattas av <a
105-
href="http://62.95.69.15/cgi-bin/thw?%24{HTML}=sfst_lst&amp;%24{OOHTML}=sfst_dok&amp;%24{SNHTML}=sfst_err&amp;%24{BASE}=SFST&amp;%24{TRIPSHOW}=format%3DTHW&amp;BET=1999%3A175%24">Rättsinformationsförordningen (1999:175)</a>.
105+
href="http://rkrattsbaser.gov.se/cgi-bin/thw?%24%7BHTML%7D=sfst_lst&amp;%24%7BOOHTML%7D=sfst_dok&amp;%24%7BSNHTML%7D=sfst_err&amp;%24%7BMAXPAGE%7D=26&amp;%24%7BTRIPSHOW%7D=format%3DTHW&amp;%24%7BBASE%7D=SFST&amp;%24%7BFORD%7D=FIND&amp;%24%7BFREETEXT%7D=&amp;BET=1999%3A175&amp;RUB=&amp;ORG=&amp;INTE%28upph=%3C114-11-20+ELLER+bet%3Dn%24+ELLER+tidb%3C114-11-20%29&amp;%24%7BSORT%7D=%C5R%2CLPNR+">Rättsinformationsförordningen (1999:175) </a>.
106106
Letar du efter information om lagar och regler bör du
107107
istället besöka <a href="http://www.lagrummet.se/">portalen lagrummet.se</a>.</p>
108108

@@ -339,7 +339,7 @@
339339
<h2 id="verktyg">Verktyg</h2>
340340
<h3 id="verktyg-rinfo">Rättsinformationsprojektets verktyg</h3>
341341
<ul>
342-
<li><a href="http://checker.lagrummet.se/">Checker</a>
342+
<li><a href="http://checker.demo.lagrummet.se/">Checker</a>
343343
är ett verktyg för att kontrollera syntax och
344344
innehåll i det Atom-flöde som ska användas som
345345
postförteckning.</li>

manage/fabfile/app/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,4 @@ def _deploy_war_norestart(localwar, warname, headless=False):
2727
rsync_project("%(dist_dir)s/%(warname)s.war" % venv(), localwar, '--progress')
2828
run("chmod 644 %(dist_dir)s/%(warname)s.war" % venv())
2929
run("cp %(dist_dir)s/%(warname)s.war %(tomcat_webapps)s/." % venv())
30+
run("touch %(tomcat_webapps)s/%(warname)s.war" % venv())

manage/fabfile/app/service.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ def test():
259259
@roles('service')
260260
def ping_start_collect():
261261
_needs_targetenv()
262-
print 'http://rinfo.regression.lagrummet.se/feed/current'
263262
feed_url = "http://%s/feed/current" % env.roledefs['main'][0]
264263
collector_url = "http://%s/collector" % env.roledefs['service'][0]
265264
if not verify_url_content(" --data 'feed=%(feed_url)s' %(collector_url)s" % vars(), "Scheduled collect of"):

manage/fabfile/server.py

Lines changed: 115 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import time
88
from fabric.api import *
99
from os.path import expanduser
10+
import sys
1011

1112
from fabfile.util import install_public_key, role_is_active
1213
from util import venv, get_value_from_password_store, PASSWORD_FILE_FTP_USERNAME_PARAM_NAME, PASSWORD_FILE_FTP_PASSWORD_PARAM_NAME
@@ -157,15 +158,21 @@ def tar(filename, target_path, command='czvf', test=False):
157158
run('tar %s %s *' % (command, filename))
158159

159160

160-
def untar(filename, target_path, command='xzvf', use_sudo=False, test=False):
161+
def untar(filename, target_path, command='xzvf', use_sudo=False, test=False, is_local=False):
161162
tar_cmd = 'tar %s %s' % (command, filename)
162-
with cd(target_path):
163-
if test:
164-
print "Simulating tar command %s" % tar_cmd
165-
elif use_sudo:
166-
sudo(tar_cmd)
167-
else:
168-
run(tar_cmd)
163+
if test:
164+
print "Simulating tar command %s" % tar_cmd
165+
return
166+
167+
if is_local:
168+
with lcd(target_path):
169+
local(tar_cmd)
170+
else:
171+
with cd(target_path):
172+
if use_sudo:
173+
sudo(tar_cmd)
174+
else:
175+
run(tar_cmd)
169176

170177

171178
def ftp_push(filename, ftp_address, username, password, test=False):
@@ -176,14 +183,21 @@ def ftp_push(filename, ftp_address, username, password, test=False):
176183
run('curl -T %s %s --user %s:%s --ftp-create-dirs' % (filename, ftp_address, username, password))
177184

178185

179-
def ftp_fetch(filename, ftp_address, target_path, username, password, test=False):
180-
with cd(target_path):
181-
if test:
182-
print "ftp fetch %s from %s to %s" % (filename, ftp_address, target_path)
183-
else:
186+
def ftp_fetch(filename, ftp_address, target_path, username, password, test=False, is_local=False):
187+
if test:
188+
print "ftp fetch %s from %s to %s" % (filename, ftp_address, target_path)
189+
return
190+
191+
cmd = 'curl %s/%s --user %s:%s --ftp-create-dirs -o %s' % (
192+
ftp_address, filename, username, password, filename)
193+
if is_local:
194+
with lcd(target_path):
195+
local(cmd)
196+
else:
197+
with cd(target_path):
184198
with hide('output','running'):
185-
run('curl %s/%s --user %s:%s --ftp-create-dirs -o %s' % (ftp_address, filename, username, password,
186-
filename))
199+
run(cmd)
200+
187201

188202

189203
def tar_and_ftp_push(snapshot_name, name, password, source_tar_path, target_path, username, test=False):
@@ -193,52 +207,74 @@ def tar_and_ftp_push(snapshot_name, name, password, source_tar_path, target_path
193207
test=test)
194208

195209

196-
def ftp_fetch_and_untar(snapshot_name, name, tmp_path, target_tar_unpack_path, username, password, test=False):
210+
def ftp_fetch_and_untar(snapshot_name, name, tmp_path, target_tar_unpack_path, username, password, test=False, is_local=False):
197211
file_to_download = '%s.tar.gz' % name
198-
ftp_fetch(file_to_download, "%s/%s" % (env.ftp_server_url, snapshot_name), tmp_path, username, password, test=test)
199-
clean_path(target_tar_unpack_path, use_sudo=True, test=test)
200-
untar('%s/%s.tar.gz' % (tmp_path, name), target_tar_unpack_path, use_sudo=True, test=test)
212+
ftp_fetch(file_to_download, "%s/%s" % (env.ftp_server_url, snapshot_name), tmp_path, username, password, test=test, is_local=is_local)
213+
clean_path(target_tar_unpack_path, use_sudo=True, test=test, is_local=is_local)
214+
untar('%s/%s.tar.gz' % (tmp_path, name), target_tar_unpack_path, use_sudo=True, test=test, is_local=is_local)
201215

202216

203-
@parallel
204217
@roles('main')
205218
def take_main_snapshot_and_push_to_ftp(snapshot_name, target_path, username, password, test=False):
206219
if not role_is_active('main'):
207220
return
221+
if not test:
222+
tomcat_stop()
223+
208224
tar_and_ftp_push(snapshot_name, 'depot', password, '/opt/rinfo/store/', target_path, username, test=test)
209225

226+
if not test:
227+
tomcat_start()
210228

211-
@parallel
212229
@roles('service')
213230
def take_service_snapshot_and_push_to_ftp(snapshot_name, target_path, username, password, use_sesame=True,
214231
use_elasticsearch=True, test=False):
215232
if not role_is_active('service'):
216233
return
234+
235+
if not test:
236+
tomcat_stop()
237+
try:
238+
sudo("/etc/init.d/elasticsearch stop")
239+
except:
240+
e = sys.exc_info()[0]
241+
print "WARNING! Problems stopping elastic search because %s" % e
242+
243+
217244
if use_sesame:
218245
tar_and_ftp_push(snapshot_name, 'sesame', password, '/opt/rinfo/sesame-repo/', target_path, username,
219246
test=test)
220247
if use_elasticsearch:
221248
tar_and_ftp_push(snapshot_name, 'elasticsearch', password, '/opt/elasticsearch/var/data/', target_path,
222249
username, test=test)
223250

251+
if not test:
252+
tomcat_start()
253+
sudo("/etc/init.d/elasticsearch start")
224254

225-
def clean_path(tar_target_path, use_sudo=False, test=False):
255+
def clean_path(tar_target_path, use_sudo=False, test=False, is_local=False):
256+
cmd = "rm -rf %s*" % tar_target_path
226257
if test:
227258
print "remove files %s" % tar_target_path
259+
elif is_local:
260+
local(cmd)
228261
elif use_sudo:
229-
sudo("rm -rf %s*" % tar_target_path)
262+
sudo(cmd)
230263
else:
231-
run("rm -rf %s*" % tar_target_path)
264+
run(cmd)
232265

233266

234-
def create_path(target_path, test=False, use_sudo=False):
267+
def create_path(target_path, test=False, use_sudo=False, is_local=False):
235268
if test:
236269
print "Make directory: %s" % target_path
237270
return
238-
if use_sudo:
239-
sudo("mkdir -p %s" % target_path)
271+
cmd = "mkdir -p %s" % target_path
272+
if is_local:
273+
local(cmd)
274+
elif use_sudo:
275+
sudo(cmd)
240276
else:
241-
run("mkdir -p %s" % target_path)
277+
run(cmd)
242278

243279

244280
def take_ownership(target_path, test=False, use_sudo=False):
@@ -273,39 +309,62 @@ def take_snapshot_and_push_to_ftp(name='snapshot', username='', password='', tes
273309
username = get_value_from_password_store(PASSWORD_FILE_FTP_USERNAME_PARAM_NAME, username)
274310
password = get_value_from_password_store(PASSWORD_FILE_FTP_PASSWORD_PARAM_NAME, password)
275311

276-
if not test:
277-
tomcat_stop()
278-
clean_path(tar_target_path, test=test)
279-
create_path(tar_target_path, test=test)
312+
clean_path(tar_target_path, test=False)
313+
create_path(tar_target_path, test=False)
314+
280315
try:
281316
take_main_snapshot_and_push_to_ftp(snapshot_name, tar_target_path, username, password, test=test)
282317
take_service_snapshot_and_push_to_ftp(snapshot_name, tar_target_path, username, password, test=test)
283318
finally:
284-
clean_path(tar_target_path, test=test)
285-
if not test:
286-
tomcat_start()
287-
319+
clean_path(tar_target_path, test=False)
288320

289321
@parallel
290322
@roles('main')
291-
def fetch_main_snapshot_from_ftp_and_install(snapshot_name, tar_target_path, username, password, test=False):
323+
def fetch_main_snapshot_from_ftp_and_install(snapshot_name, tar_target_path, username, password, test=False,
324+
is_local=False):
292325
if not role_is_active('main'):
293326
return
294-
ftp_fetch_and_untar(snapshot_name, 'depot', tar_target_path, '/opt/rinfo/store/', username, password, test=test)
327+
if not test:
328+
tomcat_stop()
329+
330+
clean_path(tar_target_path, test=test)
331+
create_path(tar_target_path, test=test)
332+
333+
ftp_fetch_and_untar(snapshot_name, 'depot', tar_target_path, '/opt/rinfo/store/', username, password, test=test,
334+
is_local=is_local)
335+
336+
if not test:
337+
tomcat_start()
295338

296339

297340
@parallel
298341
@roles('service')
299342
def fetch_service_snapshot_from_ftp_and_install(snapshot_name, tar_target_path, username, password, use_sesame=True,
300-
use_elasticsearch=True, test=False):
343+
use_elasticsearch=True, test=False, is_local=False):
301344
if not role_is_active('service'):
302345
return
346+
347+
if not test:
348+
tomcat_stop()
349+
try:
350+
sudo("/etc/init.d/elasticsearch stop")
351+
except:
352+
e = sys.exc_info()[0]
353+
print "Warning: problems stopping elastic search because %s" % e
354+
355+
clean_path(tar_target_path, test=test)
356+
create_path(tar_target_path, test=test)
357+
303358
if use_sesame:
304359
ftp_fetch_and_untar(snapshot_name, 'sesame', tar_target_path, '/opt/rinfo/sesame-repo/', username, password,
305-
test=test)
360+
test=test, is_local=is_local)
306361
if use_elasticsearch:
307362
ftp_fetch_and_untar(snapshot_name, 'elasticsearch', tar_target_path, '/opt/elasticsearch/var/data/', username,
308-
password, test=test)
363+
password, test=test, is_local=is_local)
364+
365+
if not test:
366+
tomcat_start()
367+
sudo("/etc/init.d/elasticsearch start")
309368

310369

311370
@task
@@ -320,20 +379,27 @@ def fetch_snapshot_from_ftp_and_install(name='snapshot' ,username='', password='
320379
username = get_value_from_password_store(PASSWORD_FILE_FTP_USERNAME_PARAM_NAME, username)
321380
password = get_value_from_password_store(PASSWORD_FILE_FTP_PASSWORD_PARAM_NAME, password)
322381

323-
if not test:
382+
is_local = env.target in ['dev_unix']
383+
384+
print "is_local %s" % is_local
385+
386+
if not test and not is_local:
324387
tomcat_stop()
325-
clean_path(tar_target_path, test=test)
326-
create_path(tar_target_path, test=test)
388+
389+
clean_path(tar_target_path, test=test, is_local=is_local)
390+
create_path(tar_target_path, test=test, is_local=is_local)
391+
327392
try:
328-
fetch_main_snapshot_from_ftp_and_install(snapshot_name, tar_target_path, username, password, test=test)
329-
fetch_service_snapshot_from_ftp_and_install(snapshot_name, tar_target_path, username, password, test=test)
393+
fetch_main_snapshot_from_ftp_and_install(snapshot_name, tar_target_path, username, password, test=test,
394+
is_local=is_local)
395+
fetch_service_snapshot_from_ftp_and_install(snapshot_name, tar_target_path, username, password, test=test,
396+
is_local=is_local)
330397
finally:
331-
clean_path(tar_target_path, test=test)
398+
clean_path(tar_target_path, test=test, is_local=is_local)
332399
# todo empty varnish cache
333-
if not test:
400+
if not test and not is_local:
334401
tomcat_start()
335402

336-
337403
def prefere_ipv4_to_speed_up_debian_updates():
338404
sudo('echo "precedence ::ffff:0:0/96 100" >> /etc/gai.conf')
339405

0 commit comments

Comments
 (0)