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
0fbf5df3
Commit
0fbf5df3
authored
Oct 05, 2023
by
Titouan Soulard
Committed by
Romain Courteaud
Nov 27, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos: use Software Instance certificate/key pair for request
parent
4b165dea
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
29 additions
and
18 deletions
+29
-18
slapos/grid/slapgrid.py
slapos/grid/slapgrid.py
+10
-1
slapos/slap/hateoas.py
slapos/slap/hateoas.py
+4
-6
slapos/slap/slap.py
slapos/slap/slap.py
+15
-11
No files found.
slapos/grid/slapgrid.py
View file @
0fbf5df3
...
...
@@ -1630,6 +1630,15 @@ stderr_logfile_backups=1
# even if something is terribly wrong while processing an instance, it
# won't prevent processing other ones.
if
not
self
.
api_backward_compatibility
:
# Try to use partition certificate
# TODO: find a clean way to request the certificate
partition_certificate_file
=
os
.
path
.
join
(
self
.
certificate_repository_path
,
computer_partition
[
"compute_partition_id"
]
+
".crt"
)
partition_key_file
=
os
.
path
.
join
(
self
.
certificate_repository_path
,
computer_partition
[
"compute_partition_id"
]
+
".key"
)
if
os
.
path
.
exists
(
partition_certificate_file
)
and
os
.
path
.
exists
(
partition_key_file
):
computer_partition
=
self
.
slap
.
jio_api_connector
.
get
(
computer_partition
[
"get_parameters"
],
cert_key
=
(
partition_certificate_file
,
partition_key_file
))
else
:
computer_partition
=
self
.
slap
.
jio_api_connector
.
get
(
computer_partition
[
"get_parameters"
])
try
:
# Process the partition itself
...
...
slapos/slap/hateoas.py
View file @
0fbf5df3
...
...
@@ -87,7 +87,7 @@ class ConnectionHelper:
cache
=
FileCache
(
os
.
path
.
expanduser
(
"~/.slapos_cached_get"
)))
def
do_request
(
self
,
method
,
path
,
params
=
None
,
data
=
None
,
headers
=
None
,
expect_json_error
=
False
):
expect_json_error
=
False
,
cert_key
=
None
):
url
=
parse
.
urljoin
(
self
.
slapgrid_uri
,
path
)
if
headers
is
None
:
headers
=
{}
...
...
@@ -97,10 +97,8 @@ class ConnectionHelper:
# raise ValueError('method path should be relative: %s' % path)
try
:
if
url
.
startswith
(
'https'
):
cert
=
(
self
.
cert_file
,
self
.
key_file
)
else
:
cert
=
None
if
url
.
startswith
(
'https'
)
and
cert_key
is
None
:
cert_key
=
(
self
.
cert_file
,
self
.
key_file
)
# XXX TODO: handle host cert verify
...
...
@@ -114,7 +112,7 @@ class ConnectionHelper:
req
=
method
(
url
=
url
,
params
=
params
,
cert
=
cert
,
cert
=
cert
_key
,
verify
=
False
,
data
=
data
,
headers
=
headers
,
...
...
slapos/slap/slap.py
View file @
0fbf5df3
...
...
@@ -796,30 +796,34 @@ def json_loads_byteified(json_text):
)
class
JioAPIConnectionHelper
(
ConnectionHelper
):
def
apiCall
(
self
,
path
,
data
):
def
apiCall
(
self
,
path
,
data
,
cert_key
=
None
):
req
=
self
.
do_request
(
requests
.
post
,
path
=
path
,
data
=
json
.
dumps
(
data
),
headers
=
{
'Content-type'
:
'application/json'
},
expect_json_error
=
True
)
expect_json_error
=
True
,
cert_key
=
cert_key
)
return
json_loads_byteified
(
req
.
text
)
def
get
(
self
,
data
):
def
get
(
self
,
data
,
cert_key
=
None
):
return
self
.
apiCall
(
path
=
"get/"
,
data
=
data
)
data
=
data
,
cert_key
=
cert_key
)
def
post
(
self
,
data
):
def
post
(
self
,
data
,
cert_key
=
None
):
return
self
.
apiCall
(
path
=
"post/"
,
data
=
data
)
data
=
data
,
cert_key
=
cert_key
)
def
put
(
self
,
data
):
def
put
(
self
,
data
,
cert_key
=
None
):
return
self
.
apiCall
(
path
=
"put/"
,
data
=
data
)
data
=
data
,
cert_key
=
cert_key
)
def
allDocs
(
self
,
data
):
def
allDocs
(
self
,
data
,
cert_key
=
None
):
return
self
.
apiCall
(
path
=
"allDocs/"
,
data
=
data
)
data
=
data
,
cert_key
=
cert_key
)
getHateoasUrl_cache
=
{}
getjIOAPI_cache
=
{}
...
...
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