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
Eric Zheng
slapos.core
Commits
6b18362a
Commit
6b18362a
authored
Sep 26, 2019
by
Łukasz Nowak
Committed by
Thomas Gambier
Oct 01, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos: Drop slapos.slap.util for slapos.util
parent
665d3896
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
26 deletions
+24
-26
slapos/slap/hateoas.py
slapos/slap/hateoas.py
+1
-1
slapos/slap/util.py
slapos/slap/util.py
+0
-25
slapos/util.py
slapos/util.py
+23
-0
No files found.
slapos/slap/hateoas.py
View file @
6b18362a
...
@@ -35,7 +35,7 @@ from uritemplate import expand
...
@@ -35,7 +35,7 @@ from uritemplate import expand
import
os
import
os
import
logging
import
logging
from
.util
import
_addIpv6Brackets
from
.
.
util
import
_addIpv6Brackets
from
.exception
import
ResourceNotReady
,
NotFoundError
,
\
from
.exception
import
ResourceNotReady
,
NotFoundError
,
\
AuthenticationError
,
ConnectionError
AuthenticationError
,
ConnectionError
...
...
slapos/slap/util.py
deleted
100644 → 0
View file @
665d3896
from
six.moves.urllib
import
parse
import
netaddr
def
_addIpv6Brackets
(
url
):
# if master_url contains an ipv6 without bracket, add it
# Note that this is mostly to limit specific issues with
# backward compatiblity, not to ensure generic detection.
api_scheme
,
api_netloc
,
api_path
,
api_query
,
api_fragment
=
parse
.
urlsplit
(
url
)
try
:
ip
=
netaddr
.
IPAddress
(
api_netloc
)
port
=
None
except
netaddr
.
AddrFormatError
:
try
:
ip
=
netaddr
.
IPAddress
(
':'
.
join
(
api_netloc
.
split
(
':'
)[:
-
1
]))
port
=
api_netloc
.
split
(
':'
)[
-
1
]
except
netaddr
.
AddrFormatError
:
ip
=
port
=
None
if
ip
and
ip
.
version
==
6
:
api_netloc
=
'[%s]'
%
ip
if
port
:
api_netloc
=
'%s:%s'
%
(
api_netloc
,
port
)
url
=
parse
.
urlunsplit
((
api_scheme
,
api_netloc
,
api_path
,
api_query
,
api_fragment
))
return
url
slapos/util.py
View file @
6b18362a
...
@@ -36,6 +36,7 @@ import sqlite3
...
@@ -36,6 +36,7 @@ import sqlite3
from
xml_marshaller.xml_marshaller
import
dumps
,
loads
from
xml_marshaller.xml_marshaller
import
dumps
,
loads
from
lxml
import
etree
from
lxml
import
etree
import
six
import
six
from
six.moves.urllib
import
parse
import
hashlib
import
hashlib
import
netaddr
import
netaddr
...
@@ -189,3 +190,25 @@ def calculate_dict_hash(d):
...
@@ -189,3 +190,25 @@ def calculate_dict_hash(d):
d
.
items
()
d
.
items
()
)
)
))).
hexdigest
()
))).
hexdigest
()
def
_addIpv6Brackets
(
url
):
# if master_url contains an ipv6 without bracket, add it
# Note that this is mostly to limit specific issues with
# backward compatiblity, not to ensure generic detection.
api_scheme
,
api_netloc
,
api_path
,
api_query
,
api_fragment
=
parse
.
urlsplit
(
url
)
try
:
ip
=
netaddr
.
IPAddress
(
api_netloc
)
port
=
None
except
netaddr
.
AddrFormatError
:
try
:
ip
=
netaddr
.
IPAddress
(
':'
.
join
(
api_netloc
.
split
(
':'
)[:
-
1
]))
port
=
api_netloc
.
split
(
':'
)[
-
1
]
except
netaddr
.
AddrFormatError
:
ip
=
port
=
None
if
ip
and
ip
.
version
==
6
:
api_netloc
=
'[%s]'
%
ip
if
port
:
api_netloc
=
'%s:%s'
%
(
api_netloc
,
port
)
url
=
parse
.
urlunsplit
((
api_scheme
,
api_netloc
,
api_path
,
api_query
,
api_fragment
))
return
url
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