Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Guillaume Hervier
slapos.package
Commits
8baca1c5
Commit
8baca1c5
authored
Aug 25, 2014
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos.package: Run more often and upgrade from safe place
Restrict upgrade egg from a safe hardcoded source only
parent
db06e9d5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
8 deletions
+28
-8
slapos/package/autoupdate.py
slapos/package/autoupdate.py
+6
-4
slapos/package/template/update.cron.in
slapos/package/template/update.cron.in
+3
-2
slapos/package/test/test_promise_slappkgcron.py
slapos/package/test/test_promise_slappkgcron.py
+4
-2
slapos/package/update.py
slapos/package/update.py
+15
-0
No files found.
slapos/package/autoupdate.py
View file @
8baca1c5
...
...
@@ -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
)
...
...
slapos/package/template/update.cron.in
View file @
8baca1c5
...
...
@@ -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
slapos/package/test/test_promise_slappkgcron.py
View file @
8baca1c5
...
...
@@ -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
):
...
...
slapos/package/update.py
View file @
8baca1c5
...
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment