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
Kwabena Antwi-Boasiako
slapos
Commits
034b5ec7
Commit
034b5ec7
authored
Sep 20, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
don't do anything if data directory exists; fix ipv6 url
parent
b8fe2e7c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
16 deletions
+15
-16
slapos/recipe/postgres/__init__.py
slapos/recipe/postgres/__init__.py
+15
-16
No files found.
slapos/recipe/postgres/__init__.py
View file @
034b5ec7
...
...
@@ -38,17 +38,18 @@ class Recipe(GenericBaseRecipe):
def
_options
(
self
,
options
):
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
=
options
[
'ipv6_host'
].
pop
())
def
install
(
self
):
self
.
createCluster
()
self
.
createConfig
()
self
.
createDatabase
()
self
.
createRunScript
()
pgdata
=
self
.
options
[
'pgdata-directory'
]
if
not
os
.
path
.
exists
(
pgdata
):
self
.
createCluster
()
self
.
createConfig
()
self
.
createDatabase
()
self
.
createRunScript
()
return
[
os
.
path
.
join
(
pgdata
,
'postgresql.conf'
)
]
...
...
@@ -57,18 +58,16 @@ class Recipe(GenericBaseRecipe):
def
createCluster
(
self
):
initdb_binary
=
os
.
path
.
join
(
self
.
options
[
'bin'
],
'initdb'
)
pgdata
=
self
.
options
[
'pgdata-directory'
]
if
not
os
.
path
.
exists
(
pgdata
):
try
:
subprocess
.
check_call
([
initdb_binary
,
'-D'
,
pgdata
,
'-A'
,
'ident'
,
'-E'
,
'UTF8'
,
])
except
subprocess
.
CalledProcessError
:
raise
UserError
(
'Could not create cluster directory in %s'
%
pgdata
)
try
:
subprocess
.
check_call
([
initdb_binary
,
'-D'
,
pgdata
,
'-A'
,
'ident'
,
'-E'
,
'UTF8'
,
])
except
subprocess
.
CalledProcessError
:
raise
UserError
(
'Could not create cluster directory in %s'
%
pgdata
)
def
createConfig
(
self
):
...
...
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