Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
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
Łukasz Nowak
slapos.core
Commits
fa924818
Commit
fa924818
authored
May 16, 2013
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always retrieve certificate and key, update files if content changed.
parent
1fc08717
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
14 deletions
+28
-14
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+28
-14
No files found.
slapos/grid/SlapObject.py
View file @
fa924818
...
...
@@ -294,19 +294,33 @@ class Partition(object):
self
.
_updateCertificate
()
def
_updateCertificate
(
self
):
if
not
os
.
path
.
exists
(
self
.
key_file
)
or
not
os
.
path
.
exists
(
self
.
cert_file
):
self
.
logger
.
info
(
'Certificate and key not found, downloading to %r and '
'%r'
%
(
self
.
cert_file
,
self
.
key_file
))
try
:
partition_certificate
=
self
.
computer_partition
.
getCertificate
()
except
NotFoundError
:
raise
NotFoundError
(
'Partition %s is not known from
SlapOS Master.'
%
raise
NotFoundError
(
'Partition %s is not known by
SlapOS Master.'
%
self
.
partition_id
)
open
(
self
.
key_file
,
'w'
).
write
(
partition_certificate
[
'key'
])
open
(
self
.
cert_file
,
'w'
).
write
(
partition_certificate
[
'certificate'
])
for
f
in
[
self
.
key_file
,
self
.
cert_file
]:
os
.
chmod
(
f
,
0o400
)
os
.
chown
(
f
,
*
self
.
getUserGroupId
())
uid
,
gid
=
self
.
getUserGroupId
()
for
name
,
path
in
[
(
'certificate'
,
self
.
cert_file
),
(
'key'
,
self
.
key_file
),
]:
new_content
=
partition_certificate
[
name
]
old_content
=
None
if
os
.
path
.
exists
(
path
):
old_content
=
open
(
path
).
read
()
if
old_content
!=
new_content
:
if
old_content
is
None
:
self
.
logger
.
info
(
'Missing %s file. Creating %r'
%
(
name
,
path
))
else
:
self
.
logger
.
info
(
'Changed %s content. Updating %r'
%
(
name
,
path
))
with
os
.
fdopen
(
os
.
open
(
path
,
os
.
O_CREAT
|
os
.
O_WRONLY
|
os
.
O_TRUNC
,
0o400
),
'wb'
)
as
fout
:
fout
.
write
(
new_content
)
os
.
chown
(
path
,
uid
,
gid
)
def
getUserGroupId
(
self
):
"""Returns tuple of (uid, gid) of partition"""
...
...
@@ -338,7 +352,7 @@ class Partition(object):
def
updateSymlink
(
self
,
sr_symlink
,
software_path
):
if
os
.
path
.
lexists
(
sr_symlink
):
if
not
os
.
path
.
islink
(
sr_symlink
):
self
.
logger
.
debug
(
'Not a symlink: %s, has been ignored'
%
(
sr_symlink
)
)
self
.
logger
.
debug
(
'Not a symlink: %s, has been ignored'
%
sr_symlink
)
return
os
.
unlink
(
sr_symlink
)
os
.
symlink
(
software_path
,
sr_symlink
)
...
...
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