Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.libnetworkcache
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
slapos.libnetworkcache
Commits
f495132e
Commit
f495132e
authored
Sep 23, 2015
by
Kazuhiko Shiozaki
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add shacache-ca-file and shadir-ca-file options.
parent
85644b7b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
6 deletions
+16
-6
slapos/libnetworkcache.py
slapos/libnetworkcache.py
+16
-6
No files found.
slapos/libnetworkcache.py
View file @
f495132e
...
@@ -16,9 +16,11 @@ import argparse
...
@@ -16,9 +16,11 @@ import argparse
import
ConfigParser
import
ConfigParser
import
hashlib
import
hashlib
import
httplib
import
httplib
import
inspect
import
json
import
json
import
logging
import
logging
import
os
import
os
import
ssl
import
shutil
import
shutil
import
sys
import
sys
import
tarfile
import
tarfile
...
@@ -149,14 +151,22 @@ class NetworkcacheClient(object):
...
@@ -149,14 +151,22 @@ class NetworkcacheClient(object):
headers
[
'Authorization'
]
=
'Basic %s'
%
(
'%s:%s'
%
(
headers
[
'Authorization'
]
=
'Basic %s'
%
(
'%s:%s'
%
(
parsed_url
.
username
,
parsed_url
.
password
)).
encode
(
'base64'
).
strip
()
parsed_url
.
username
,
parsed_url
.
password
)).
encode
(
'base64'
).
strip
()
headers
[
"Connection"
]
=
"close"
headers
[
"Connection"
]
=
"close"
connection_kw
=
{
'host'
:
parsed_url
.
hostname
,
'port'
:
parsed_url
.
port
,
'timeout'
:
timeout
,
}
if
parsed_url
.
scheme
==
'https'
:
if
parsed_url
.
scheme
==
'https'
:
connection
=
httplib
.
HTTPSConnection
(
parsed_url
.
hostname
,
parsed_url
.
port
,
connection_kw
[
'cert_file'
]
=
self
.
config
[
'sha%s-cert-file'
%
where
]
cert_file
=
self
.
config
.
get
(
'sha%s-cert-file'
%
where
),
connection_kw
[
'key_file'
]
=
self
.
config
[
'sha%s-key-file'
%
where
]
key_file
=
self
.
config
.
get
(
'sha%s-key-file'
%
where
),
if
'context'
in
inspect
.
getargspec
(
timeout
=
timeout
)
httplib
.
HTTPSConnection
.
__init__
).
args
:
connection_kw
[
'context'
]
=
ssl
.
create_default_context
(
cafile
=
self
.
config
.
get
(
'sha%s-ca-file'
%
where
)
)
connection
=
httplib
.
HTTPSConnection
(
**
connection_kw
)
else
:
else
:
connection
=
httplib
.
HTTPConnection
(
parsed_url
.
hostname
,
parsed_url
.
port
,
connection
=
httplib
.
HTTPConnection
(
**
connection_kw
)
timeout
=
timeout
)
try
:
try
:
connection
.
request
(
method
,
parsed_url
.
path
,
data
,
headers
)
connection
.
request
(
method
,
parsed_url
.
path
,
data
,
headers
)
r
=
connection
.
getresponse
()
r
=
connection
.
getresponse
()
...
...
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