Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
francois
slapos
Commits
299f8da0
Commit
299f8da0
authored
Sep 27, 2011
by
Antoine Catton
Committed by
Cédric de Saint Martin
Oct 13, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adding setConnectionUrl in librecipe to return url in parameter xml.
parent
5a384d9c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
slapos/recipe/librecipe/__init__.py
slapos/recipe/librecipe/__init__.py
+33
-0
No files found.
slapos/recipe/librecipe/__init__.py
View file @
299f8da0
...
@@ -33,6 +33,8 @@ from hashlib import md5
...
@@ -33,6 +33,8 @@ from hashlib import md5
import
stat
import
stat
import
netaddr
import
netaddr
import
time
import
time
import
re
import
urlparse
class
BaseSlapRecipe
:
class
BaseSlapRecipe
:
"""Base class for all slap.recipe.*"""
"""Base class for all slap.recipe.*"""
...
@@ -256,3 +258,34 @@ class BaseSlapRecipe:
...
@@ -256,3 +258,34 @@ class BaseSlapRecipe:
promise_path
=
os
.
path
.
join
(
self
.
promise_directory
,
promise_name
)
promise_path
=
os
.
path
.
join
(
self
.
promise_directory
,
promise_name
)
self
.
_writeExecutable
(
promise_path
,
file_content
)
self
.
_writeExecutable
(
promise_path
,
file_content
)
return
promise_path
return
promise_path
def
setConnectionUrl
(
self
,
scheme
,
host
,
path
=
''
,
params
=
''
,
query
=
''
,
fragment
=
''
,
port
=
None
,
auth
=
None
):
"""Set the ConnectionDict to a dict with only one Universal Resource
Locator.
auth can be either a login string or a tuple (login, password).
"""
# XXX-Antoine: I didn't find any standard module to join an url with
# login, password, ipv6 host and port.
# So instead of copy and past in every recipe I factorized it right here.
netloc
=
''
if
auth
is
not
None
:
auth
=
tuple
(
auth
)
netloc
=
str
(
auth
[
0
])
# Login
if
len
(
auth
)
>
1
:
netloc
+=
':%s'
%
auth
[
1
]
# Password
netloc
+=
'@'
# host is an ipv6 address whithout brackets
if
':'
in
host
and
not
re
.
match
(
r'^\
[.*
\]$'
,
host
):
netloc
+=
'[%s]'
%
host
else
:
netloc
+=
str
(
host
)
if
port
is
not
None
:
netloc
+=
':%s'
%
port
url
=
urlparse
.
urlunparse
((
scheme
,
netloc
,
path
,
params
,
query
,
fragment
))
self
.
setConnectionDict
(
dict
(
url
=
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