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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Nicolas Wavrant
slapos
Commits
579cf79d
Commit
579cf79d
authored
Oct 24, 2016
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
free_port: updates recipe to use getValueFromPreviousRun from GenericBaseRecipe
parent
6009e5ac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
13 deletions
+10
-13
slapos/recipe/free_port.py
slapos/recipe/free_port.py
+10
-13
No files found.
slapos/recipe/free_port.py
View file @
579cf79d
...
@@ -25,12 +25,13 @@
...
@@ -25,12 +25,13 @@
#
#
##############################################################################
##############################################################################
import
ConfigParser
import
os
import
os
import
netaddr
import
netaddr
import
socket
import
socket
class
Recipe
(
object
):
from
slapos.recipe.librecipe.generic
import
GenericBaseRecipe
class
Recipe
(
GenericBaseRecipe
):
"""
"""
Uses the socket python standard library to get an unused port.
Uses the socket python standard library to get an unused port.
...
@@ -48,17 +49,13 @@ class Recipe(object):
...
@@ -48,17 +49,13 @@ class Recipe(object):
# If this check isn't done, a new port would be picked for every upgrade
# If this check isn't done, a new port would be picked for every upgrade
# of the software release
# of the software release
try
:
try
:
parser
=
ConfigParser
.
RawConfigParser
()
port
=
self
.
getValueFromPreviousRun
(
name
,
'port'
)
if
os
.
path
.
exists
(
buildout
[
'buildout'
][
'installed'
]):
# Port can be 0 in case of upgrade: some old service still runs on port,
with
open
(
buildout
[
'buildout'
][
'installed'
])
as
config_file
:
# so 0 is returned by default. Then, on next run, this recipe is processed
parser
.
readfp
(
config_file
)
# again until a correct value is returned
port
=
parser
.
get
(
name
,
'port'
)
if
port
!=
'0'
:
# Port can be 0 in case of upgrade: some old service still runs on port,
self
.
options
[
'port'
]
=
port
# so 0 is returned by default. Then, on next run, this recipe is processed
return
# again until a correct value is returned
if
port
!=
'0'
:
self
.
options
[
'port'
]
=
port
return
except
(
IOError
,
ConfigParser
.
NoSectionError
,
ConfigParser
.
NoOptionError
):
except
(
IOError
,
ConfigParser
.
NoSectionError
,
ConfigParser
.
NoOptionError
):
pass
pass
...
...
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