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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
1a92d625
Commit
1a92d625
authored
Sep 22, 2022
by
Cédric Le Ninivin
Committed by
Romain Courteaud
Nov 27, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapgrid: Update retrieve certificate to specific record
parent
b89bc1e7
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
30 deletions
+56
-30
slapos/grid/SlapObject.py
slapos/grid/SlapObject.py
+2
-12
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+17
-4
slapos/tests/test_slapgrid.py
slapos/tests/test_slapgrid.py
+37
-14
No files found.
slapos/grid/SlapObject.py
View file @
1a92d625
...
...
@@ -501,25 +501,15 @@ class Partition(object):
available
=
bytes2human
(
available
),
required
=
bytes2human
(
required
)))
def
_updateCertificate
(
self
):
def
_updateCertificate
(
self
,
partition_certificates
):
if
not
self
.
key_file
or
not
self
.
cert_file
:
# Certificate files are unset, skip.
return
if
self
.
api_backward_compatibility
:
try
:
partition_certificate
=
self
.
computer_partition
[
"slap_partition"
].
getCertificate
()
self
.
computer_partition
[
"X509"
]
=
{}
self
.
computer_partition
[
"X509"
][
"certificate"
]
=
partition_certificate
[
"certificate"
]
self
.
computer_partition
[
"X509"
][
"key"
]
=
partition_certificate
[
"key"
]
except
NotFoundError
:
raise
NotFoundError
(
'Partition %s is not known by SlapOS Master.'
%
self
.
partition_id
)
uid
,
gid
=
self
.
getUserGroupId
()
for
name
,
path
in
[(
'certificate'
,
self
.
cert_file
),
(
'key'
,
self
.
key_file
)]:
new_content
=
self
.
computer_partition
[
"X509"
]
[
name
]
new_content
=
partition_certificates
[
name
]
old_content
=
None
if
os
.
path
.
exists
(
path
):
with
open
(
path
)
as
f
:
...
...
slapos/grid/slapgrid.py
View file @
1a92d625
...
...
@@ -1175,6 +1175,19 @@ stderr_logfile_backups=1
self
.
_checkAddFirewallRules
(
computer_partition
.
get
(
"compute_partition_id"
),
cmd_list
,
add
=
add_rules
)
def
retrieveCertificates
(
self
,
computer_partition
):
if
not
self
.
api_backward_compatibility
:
partition_certificates
=
self
.
slap
.
jio_api_connector
.
get
({
"portal_type"
:
"Software Instance Certificate Record"
,
"reference"
:
computer_partition
.
get
(
"reference"
),
})
else
:
try
:
partition_certificates
=
computer_partition
[
"slap_partition"
].
getCertificate
()
except
NotFoundError
:
raise
NotFoundError
(
'Partition %s is not known by SlapOS Master.'
%
computer_partition
.
get
(
"reference"
))
return
partition_certificates
def
_checkPromiseAnomaly
(
self
,
local_partition
,
computer_partition
):
partition_access_status
=
computer_partition
.
get
(
"access_status_message"
,
""
)
status_error
=
False
...
...
@@ -1187,11 +1200,11 @@ stderr_logfile_backups=1
except
PromiseError
as
e
:
self
.
logger
.
error
(
e
)
if
partition_access_status
is
None
or
not
status_error
:
local_partition
.
_updateCertificate
()
local_partition
.
_updateCertificate
(
self
.
retrieveCertificates
(
computer_partition
)
)
self
.
sendPartitionError
(
computer_partition
,
e
,
logger
=
self
.
logger
)
else
:
if
partition_access_status
is
None
or
status_error
:
local_partition
.
_updateCertificate
()
local_partition
.
_updateCertificate
(
self
.
retrieveCertificates
(
computer_partition
)
)
if
not
self
.
api_backward_compatibility
:
self
.
slap
.
jio_api_connector
.
put
({
"portal_type"
:
"Software Instance"
,
...
...
@@ -1408,7 +1421,7 @@ stderr_logfile_backups=1
self
.
logger
.
info
(
' jIO API used: %s'
%
(
not
self
.
api_backward_compatibility
))
# Update certifcate at late as possible
local_partition
.
_updateCertificate
()
local_partition
.
_updateCertificate
(
self
.
retrieveCertificates
(
computer_partition
)
)
# XXX this line breaks 37 tests
# self.logger.info(' Instance type: %s' % computer_partition.get("software_type"))
...
...
@@ -2085,7 +2098,7 @@ stderr_logfile_backups=1
api_backward_compatibility
=
self
.
api_backward_compatibility
,
)
local_partition
.
stop
()
local_partition
.
_updateCertificate
()
local_partition
.
_updateCertificate
(
self
.
retrieveCertificates
(
computer_partition
)
)
try
:
if
not
self
.
api_backward_compatibility
:
self
.
slap
.
jio_api_connector
.
put
({
...
...
slapos/tests/test_slapgrid.py
View file @
1a92d625
This diff is collapsed.
Click to expand it.
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