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
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
Dmitry Blinov
slapos
Commits
cf0991c8
Commit
cf0991c8
authored
Aug 04, 2011
by
Gabriel Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor code to use regex. The regex is used to get the host and port from url
parent
eaca6fe6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
13 deletions
+14
-13
slapos/recipe/apache/__init__.py
slapos/recipe/apache/__init__.py
+14
-13
No files found.
slapos/recipe/apache/__init__.py
View file @
cf0991c8
...
...
@@ -32,6 +32,7 @@ import sys
import
zc.buildout
import
zc.recipe.egg
import
ConfigParser
import
re
class
Recipe
(
BaseSlapRecipe
):
...
...
@@ -75,26 +76,26 @@ class Recipe(BaseSlapRecipe):
continue
rewrite_rule_list
.
append
(
"%s %s"
%
(
reference
.
replace
(
"-"
,
""
),
url
))
slave_dict
[
reference
]
=
"%s%s"
%
(
base_url
,
reference
.
replace
(
"-"
,
""
))
if
0
:
# XXX To be finished by Gabriel bellow
#if slave_instance.get("enable_cache") == 1:
enable_cache
=
slave_instance
.
get
(
"enable_cache"
,
""
)
if
enable_cache
.
upper
()
in
(
'1'
,
'TRUE'
):
# Varnish should use stunnel to connect to the backend
base_varnish_control_port
=
base_varnish_port
+
1
base_varnish_port
+=
2
# Use regex
slave_host
=
url
.
split
(
"://"
)[
1
].
split
(
":"
)[
0
].
split
(
"/"
)[
0
]
slave_port
=
url
.
split
(
"://"
)[
1
].
split
(
":"
)
if
len
(
slave_port
)
>
1
:
slave_port
=
slave_port
[
0
].
split
(
"/"
)[
0
]
host_regex
=
"((
\
[
\
w*|[0-9]+
\
.)(
\
:|)).*(
\
]|
\
.[0-9])"
slave_host
=
re
.
search
(
host_regex
,
url
).
group
(
0
)
port_regex
=
"
\
w+(
\
/|)$"
matcher
=
re
.
search
(
port_regex
,
url
)
if
matcher
is
not
None
:
slave_port
=
matcher
.
group
(
0
)
slave_port
=
slave_port
.
replace
(
"/"
,
""
)
elif
url
.
startswith
(
"https://"
):
slave_port
=
443
else
:
slave_port
=
80
self
.
installVarnishCache
(
name
=
id
,
self
.
installVarnishCache
(
name
=
"varnish"
,
ip
=
self
.
getLocalIPv4Address
(),
port
=
base_varnish_port
,
control_port
=
base_varnish_control_port
,
...
...
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