Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos-caddy
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
Guillaume Hervier
slapos-caddy
Commits
c3f66128
Commit
c3f66128
authored
Dec 28, 2012
by
Marco Mariani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
further comments
parent
8eadcdc0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
14 deletions
+21
-14
slapos/recipe/postgres/__init__.py
slapos/recipe/postgres/__init__.py
+21
-14
No files found.
slapos/recipe/postgres/__init__.py
View file @
c3f66128
...
...
@@ -50,7 +50,7 @@ class Recipe(GenericBaseRecipe):
"""
def
fetch_ipv6_host
(
self
,
options
):
"""
"""
\
Returns a string represtation of ipv6_host.
May receive a regular string, a set or a string serialized by buildout.
"""
...
...
@@ -70,6 +70,8 @@ class Recipe(GenericBaseRecipe):
def
install
(
self
):
pgdata
=
self
.
options
[
'pgdata-directory'
]
# if the pgdata already exists, skip all steps, we don't need to do anything.
if
not
os
.
path
.
exists
(
pgdata
):
self
.
createCluster
()
self
.
createConfig
()
...
...
@@ -77,10 +79,12 @@ class Recipe(GenericBaseRecipe):
self
.
createSuperuser
()
self
.
createRunScript
()
return
[
# XXX should we really return something here?
# os.path.join(pgdata, 'postgresql.conf')
]
# install() methods usually return the pathnames of managed files.
# If they are missing, they will be rebuilt.
# In this case, we already check for the existence of pgdata,
# so we don't need to return anything here.
return
[]
def
check_exists
(
self
,
path
):
...
...
@@ -89,6 +93,13 @@ class Recipe(GenericBaseRecipe):
def
createCluster
(
self
):
"""
\
A Postgres cluster is "a collection of databases that is managed
by a single instance of a running database server".
Here we create an empty cluster. The authentication for this
command is through the unix socket.
"""
initdb_binary
=
os
.
path
.
join
(
self
.
options
[
'bin'
],
'initdb'
)
self
.
check_exists
(
initdb_binary
)
...
...
@@ -150,7 +161,7 @@ class Recipe(GenericBaseRecipe):
def
createSuperuser
(
self
):
"""
"""
\
Creates a Postgres superuser - other than "slapuser#" for use by the application.
"""
...
...
@@ -166,7 +177,7 @@ class Recipe(GenericBaseRecipe):
def
runPostgresCommand
(
self
,
cmd
):
"""
"""
\
Executes a command in single-user mode, with no daemon running.
Multiple commands can be executed by providing newlines,
...
...
@@ -190,7 +201,7 @@ class Recipe(GenericBaseRecipe):
def
createRunScript
(
self
):
"""
"""
\
Creates a script that runs postgres in the foreground.
'exec' is used to allow easy control by supervisor.
"""
...
...
@@ -207,14 +218,13 @@ class Recipe(GenericBaseRecipe):
class
ExportRecipe
(
GenericBaseRecipe
):
def
install
(
self
):
pgdata
=
self
.
options
[
'pgdata-directory'
]
wrapper
=
self
.
options
[
'wrapper'
]
self
.
createBackupScript
(
wrapper
)
return
[
wrapper
]
def
createBackupScript
(
self
,
wrapper
):
"""
"""
\
Create a script to backup the database in 'custom' format.
"""
content
=
textwrap
.
dedent
(
"""
\
...
...
@@ -233,14 +243,13 @@ class ExportRecipe(GenericBaseRecipe):
class
ImportRecipe
(
GenericBaseRecipe
):
def
install
(
self
):
pgdata
=
self
.
options
[
'pgdata-directory'
]
wrapper
=
self
.
options
[
'wrapper'
]
self
.
createRestoreScript
(
wrapper
)
return
[
wrapper
]
def
createRestoreScript
(
self
,
wrapper
):
"""
"""
\
Create a script to restore the database from 'custom' format.
"""
content
=
textwrap
.
dedent
(
"""
\
...
...
@@ -256,5 +265,3 @@ class ImportRecipe(GenericBaseRecipe):
self
.
createExecutable
(
wrapper
,
content
=
content
)
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