Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos-mynij-dev
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
Mynij
slapos-mynij-dev
Commits
2e4bfd30
Commit
2e4bfd30
authored
Sep 27, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor
parent
7c009f67
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
slapos/recipe/postgres/__init__.py
slapos/recipe/postgres/__init__.py
+19
-6
No files found.
slapos/recipe/postgres/__init__.py
View file @
2e4bfd30
...
@@ -34,7 +34,7 @@ from zc.buildout import UserError
...
@@ -34,7 +34,7 @@ from zc.buildout import UserError
from
slapos.recipe.librecipe
import
GenericBaseRecipe
from
slapos.recipe.librecipe
import
GenericBaseRecipe
# TODO: read ipv6 host without calling loads()
in createConfig()
# TODO: read ipv6 host without calling loads()
class
Recipe
(
GenericBaseRecipe
):
class
Recipe
(
GenericBaseRecipe
):
...
@@ -51,9 +51,25 @@ class Recipe(GenericBaseRecipe):
...
@@ -51,9 +51,25 @@ class Recipe(GenericBaseRecipe):
The URL can be used as-is (ie. in sqlalchemy) or by the _urlparse.py recipe.
The URL can be used as-is (ie. in sqlalchemy) or by the _urlparse.py recipe.
"""
"""
def
fetch_host
(
self
,
options
):
"""
Returns a string represtation of ipv6_host.
May receive a regular string, a set or a string serialized by buildout.
"""
from
zc.buildout
import
buildout
ipv6_host
=
options
[
'ipv6_host'
]
if
ipv6_host
.
startswith
(
buildout
.
SERIALISED_VALUE_MAGIC
):
return
buildout
.
loads
(
ipv6_host
).
pop
()
elif
isinstance
(
ipv6_host
,
set
):
return
ipv6_host
.
pop
()
else
:
return
ipv6_host
def
_options
(
self
,
options
):
def
_options
(
self
,
options
):
options
[
'password'
]
=
self
.
generatePassword
()
options
[
'password'
]
=
self
.
generatePassword
()
options
[
'url'
]
=
'postgresql://%(user)s:%(password)s@[%(host)s]:%(port)s/%(dbname)s'
%
dict
(
options
,
host
=
options
[
'ipv6_host'
].
pop
(
))
options
[
'url'
]
=
'postgresql://%(user)s:%(password)s@[%(host)s]:%(port)s/%(dbname)s'
%
dict
(
options
,
host
=
self
.
fetch_host
(
options
))
def
install
(
self
):
def
install
(
self
):
...
@@ -88,9 +104,6 @@ class Recipe(GenericBaseRecipe):
...
@@ -88,9 +104,6 @@ class Recipe(GenericBaseRecipe):
def
createConfig
(
self
):
def
createConfig
(
self
):
from
zc.buildout
import
buildout
host
=
buildout
.
loads
(
self
.
options
[
'ipv6_host'
]).
pop
()
# XXX ugly hack
pgdata
=
self
.
options
[
'pgdata-directory'
]
pgdata
=
self
.
options
[
'pgdata-directory'
]
with
open
(
os
.
path
.
join
(
pgdata
,
'postgresql.conf'
),
'wb'
)
as
cfg
:
with
open
(
os
.
path
.
join
(
pgdata
,
'postgresql.conf'
),
'wb'
)
as
cfg
:
...
@@ -106,7 +119,7 @@ class Recipe(GenericBaseRecipe):
...
@@ -106,7 +119,7 @@ class Recipe(GenericBaseRecipe):
lc_numeric = 'en_US.UTF-8'
lc_numeric = 'en_US.UTF-8'
lc_time = 'en_US.UTF-8'
lc_time = 'en_US.UTF-8'
default_text_search_config = 'pg_catalog.english'
default_text_search_config = 'pg_catalog.english'
"""
%
host
))
"""
%
self
.
fetch_host
(
self
.
options
)
))
with
open
(
os
.
path
.
join
(
pgdata
,
'pg_hba.conf'
),
'wb'
)
as
cfg
:
with
open
(
os
.
path
.
join
(
pgdata
,
'pg_hba.conf'
),
'wb'
)
as
cfg
:
...
...
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