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
Ophélie Gagnard
slapos.package
Commits
47ea4458
Commit
47ea4458
authored
Jun 04, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
whitespace
parent
74d4eb97
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
23 deletions
+22
-23
upload-update.py
upload-update.py
+22
-23
No files found.
upload-update.py
View file @
47ea4458
...
...
@@ -51,11 +51,11 @@ class Parser(OptionParser):
Option
(
"--upgrade-file"
,
default
=
'/etc/slapos-cache/slapos-upgrade'
,
help
=
"File use as reference to upgrade."
),
Option
(
"-u"
,
"--upgrade"
,
Option
(
"-u"
,
"--upgrade"
,
default
=
False
,
action
=
"store_true"
,
help
=
"If selected will update tomorrow."
),
Option
(
"-r"
,
"--reboot"
,
Option
(
"-r"
,
"--reboot"
,
default
=
False
,
action
=
"store_true"
,
help
=
"If selected will reboot tomorrow."
),
...
...
@@ -65,7 +65,6 @@ class Parser(OptionParser):
action
=
"store_true"
),
])
def
check_args
(
self
):
"""
Check arguments
...
...
@@ -74,14 +73,14 @@ class Parser(OptionParser):
return
options
# Utility fonction to get yes/no answers
def
get_yes_no
(
prompt
):
def
get_yes_no
(
prompt
):
while
True
:
answer
=
raw_input
(
prompt
+
" [y,n]: "
)
if
answer
.
upper
()
in
[
'Y'
,
'YES'
]:
return
True
if
answer
.
upper
()
in
[
'N'
,
'NO'
]:
return
False
answer
=
raw_input
(
prompt
+
" [y,n]: "
)
if
answer
.
upper
()
in
[
'Y'
,
'YES'
]:
return
True
if
answer
.
upper
()
in
[
'N'
,
'NO'
]:
return
False
def
upload_network_cached_from_file
(
path
,
networkcache_options
):
...
...
@@ -94,7 +93,7 @@ def upload_network_cached_from_file(path, networkcache_options):
metadata_dict
=
{
# XXX: we set date from client side. It can be potentially dangerous
# as it can be badly configured.
'timestamp'
:
time
.
time
(),
'timestamp'
:
time
.
time
(),
}
try
:
if
helper_upload_network_cached_from_file
(
...
...
@@ -115,14 +114,16 @@ def upload_network_cached_from_file(path, networkcache_options):
except
Exception
:
print
'Unable to upload to cache:
\
n
%s.'
%
traceback
.
format_exc
()
def
save_current_state
(
current_state
,
config
):
def
save_current_state
(
current_state
,
config
):
"""
Will save ConfigParser to config file
"""
file
=
open
(
config
.
upgrade_file
,
"w"
)
file
=
open
(
config
.
upgrade_file
,
"w"
)
current_state
.
write
(
file
)
file
.
close
()
# Class containing all parameters needed for configuration
class
Config
:
def
setConfig
(
self
,
option_dict
):
...
...
@@ -137,16 +138,16 @@ class Config:
self
.
tomorrow
=
self
.
today
+
datetime
.
timedelta
(
days
=
1
)
def
new_upgrade
(
config
):
def
new_upgrade
(
config
):
upgrade_info
=
ConfigParser
.
RawConfigParser
()
upgrade_info
.
read
(
config
.
upgrade_file
)
if
config
.
reboot
:
upgrade_info
.
set
(
'system'
,
'reboot'
,
config
.
tomorrow
)
if
config
.
upgrade
:
upgrade_info
.
set
(
'system'
,
'upgrade'
,
config
.
tomorrow
)
save_current_state
(
upgrade_info
,
config
)
if
config
.
reboot
:
upgrade_info
.
set
(
'system'
,
'reboot'
,
config
.
tomorrow
)
if
config
.
upgrade
:
upgrade_info
.
set
(
'system'
,
'upgrade'
,
config
.
tomorrow
)
save_current_state
(
upgrade_info
,
config
)
print
" You will update this :"
print
open
(
config
.
upgrade_file
,
'r'
).
read
()
print
open
(
config
.
upgrade_file
).
read
()
if
not
get_yes_no
(
"Do you want to continue? "
):
sys
.
exit
(
0
)
...
...
@@ -154,8 +155,7 @@ def new_upgrade (config):
networkcache_info
.
read
(
'/etc/slapos-cache/slapos.cfg'
)
networkcache_info_dict
=
dict
(
networkcache_info
.
items
(
'networkcache'
))
if
not
config
.
dry_run
:
upload_network_cached_from_file
(
config
.
upgrade_file
,
networkcache_info_dict
)
upload_network_cached_from_file
(
config
.
upgrade_file
,
networkcache_info_dict
)
def
main
():
...
...
@@ -168,6 +168,5 @@ def main():
sys
.
exit
()
if
__name__
==
'__main__'
:
main
()
main
()
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