Commit 8baca1c5 by Rafael Monnerat

slapos.package: Run more often and upgrade from safe place

Restrict upgrade egg from a safe hardcoded source only
1 parent db06e9d5
......@@ -40,10 +40,12 @@ def do_update():
_run_command('slappkg-update-raw')
def _run_command(command):
if '--no-update' in sys.argv:
sys.argv.remove('--no-update')
else:
subprocess.call(['easy_install', '-U', 'slapos.package'])
if '--self-update' in sys.argv:
sys.argv.remove('--self-update')
subprocess.call(['easy_install', '-U',
"-f", "http://www.nexedi.org/static/packages/source/",
"--allow-hosts", "http://www.nexedi.org/static/packages/source/",
'slapos.package'])
args = [
os.path.join(os.path.dirname(sys.argv[0]), command)
......
......@@ -4,5 +4,6 @@ SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin:/usr/local/bin
MAILTO=root
# This file expects that
0 */6 * * * root slappkg-update --slapos-configuration=%(configuration_path)s -v >> %(slapos_location)s/log/slappkg-update.log 2>&1
# This file expects that
0 1 * * * root slappkg-update --self-update --slapos-configuration=%(configuration_path)s -v >> %(slapos_location)s/log/slappkg-update.log 2>&1
10 * * * * root slappkg-update --wait --slapos-configuration=%(configuration_path)s -v >> %(slapos_location)s/log/slappkg-update.log 2>&1
......@@ -38,8 +38,9 @@ SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin:/usr/local/bin
MAILTO=root
# This file expects that
0 */6 * * * root slappkg-update --slapos-configuration=/tmp/SOMEFILENAME -v >> /opt/slapos/log/slappkg-update.log 2>&1"""
# This file expects that
0 1 * * * root slappkg-update --self-update --slapos-configuration=/tmp/SOMEFILENAME -v >> /opt/slapos/log/slappkg-update.log 2>&1
10 * * * * root slappkg-update --wait --slapos-configuration=/tmp/SOMEFILENAME -v >> /opt/slapos/log/slappkg-update.log 2>&1"""
def _fake_call(self, *args, **kw):
self.last_call = (args, kw)
......@@ -47,6 +48,7 @@ def _fake_call(self, *args, **kw):
class testSlappkgCronTestCase(unittest.TestCase):
def setUp(self):
self.maxDiff = None
self.configuration_file_path = "/tmp/test_promise_testing_slappkg.cron"
slappkgcron.Promise._call = _fake_call
if os.path.exists(self.configuration_file_path):
......
......@@ -32,9 +32,17 @@ import datetime
import logging
from optparse import OptionParser, Option
import sys
import random
import time
from signature import Signature
from promise import promise_list
def _wait_before_run():
wait_period = random.randint(1, 50)
print "Sleep few seconds before start (%s) ..." % wait_period
time.sleep(wait_period)
class Parser(OptionParser):
"""
Parse all arguments.
......@@ -51,6 +59,10 @@ class Parser(OptionParser):
Option("--srv-file",
default='/srv/slapupdate',
help="Server status file."),
Option("--wait",
default=False,
action="store_true",
help="Wait random seconds to call upgrade."),
Option("-v", "--verbose",
default=False,
action="store_true",
......@@ -73,6 +85,9 @@ def do_update():
usage = "usage: %s [options] " % sys.argv[0]
config_dict = Parser(usage=usage).check_args()
if config_dict.wait:
_wait_before_run()
for promise_klass in promise_list:
# Parse arguments
upgrader = promise_klass(config_dict)
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!