Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Simplified enums#33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
enum for xlog_method in NodeBackup
  • Loading branch information
@Valeria1235
Valeria1235 committedFeb 14, 2018
commita731c20364eb910e70e184f4b25d5d2ef05c83e4
25 changes: 21 additions & 4 deletionstestgres/backup.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -5,12 +5,12 @@
import tempfile

from six import raise_from
from enum import Enum

from .consts import \
DATA_DIR, \
PG_CONF_FILE, \
BACKUP_LOG_FILE, \
DEFAULT_XLOG_METHOD
BACKUP_LOG_FILE

from .exceptions import BackupException

Expand All@@ -20,6 +20,16 @@
execute_utility


class XLogMethod(Enum):
"""
Available WAL methods for NodeBackup
"""

none = 'none'
fetch = 'fetch'
stream = 'stream'


class NodeBackup(object):
"""
Smart object responsible for backups
Expand All@@ -33,7 +43,7 @@ def __init__(self,
node,
base_dir=None,
username=None,
xlog_method=DEFAULT_XLOG_METHOD):
xlog_method=XLogMethod.fetch):
"""
Create a new backup.

Expand All@@ -47,6 +57,13 @@ def __init__(self,
if not node.status():
raise BackupException('Node must be running')

# Check arguments
if not isinstance(xlog_method, XLogMethod):
try:
xlog_method = XLogMethod(xlog_method)
except ValueError:
raise BackupException('Invalid xlog_method "{}"'.format(xlog_method))

# Set default arguments
username = username or default_username()
base_dir = base_dir or tempfile.mkdtemp()
Expand All@@ -68,7 +85,7 @@ def __init__(self,
"-h", node.host,
"-U", username,
"-D", data_dir,
"-X", xlog_method
"-X", xlog_method.value
]
execute_utility(_params, self.log_file)

Expand Down
3 changes: 0 additions & 3 deletionstestgres/consts.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,3 @@
PG_LOG_FILE = "postgresql.log"
UTILS_LOG_FILE = "utils.log"
BACKUP_LOG_FILE = "backup.log"

# default argument value
DEFAULT_XLOG_METHOD = "fetch"
12 changes: 7 additions & 5 deletionstestgres/node.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -27,8 +27,7 @@
HBA_CONF_FILE, \
RECOVERY_CONF_FILE, \
PG_LOG_FILE, \
UTILS_LOG_FILE, \
DEFAULT_XLOG_METHOD
UTILS_LOG_FILE

from .exceptions import \
CatchUpException, \
Expand All@@ -52,6 +51,10 @@
method_decorator, \
positional_args_hack

from .backup import \
XLogMethod, \
NodeBackup


class NodeStatus(IntEnum):
"""
Expand DownExpand Up@@ -838,7 +841,7 @@ def execute(self,

return res

def backup(self, username=None, xlog_method=DEFAULT_XLOG_METHOD):
def backup(self, username=None, xlog_method=XLogMethod.fetch):
"""
Perform pg_basebackup.

Expand All@@ -850,15 +853,14 @@ def backup(self, username=None, xlog_method=DEFAULT_XLOG_METHOD):
A smart object of type NodeBackup.
"""

from .backup import NodeBackup
return NodeBackup(node=self,
username=username,
xlog_method=xlog_method)

def replicate(self,
name=None,
username=None,
xlog_method=DEFAULT_XLOG_METHOD,
xlog_method=XLogMethod.fetch,
use_logging=False):
"""
Create a binary replica of this node.
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp