python3-cyberfusion-queue-support 2.0__tar.gz → 2.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/PKG-INFO +7 -1
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/README.md +4 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/pyproject.toml +11 -1
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/database.py +16 -4
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/__init__.py +1 -1
- python3_cyberfusion_queue_support-2.2.1/src/cyberfusion/QueueSupport/items/database_create.py +65 -0
- python3_cyberfusion_queue_support-2.2.1/src/cyberfusion/QueueSupport/items/database_drop.py +65 -0
- python3_cyberfusion_queue_support-2.2.1/src/cyberfusion/QueueSupport/items/database_user_drop.py +81 -0
- python3_cyberfusion_queue_support-2.2.1/src/cyberfusion/QueueSupport/items/database_user_ensure_state.py +100 -0
- python3_cyberfusion_queue_support-2.2.1/src/cyberfusion/QueueSupport/items/database_user_grant_grant.py +104 -0
- python3_cyberfusion_queue_support-2.2.1/src/cyberfusion/QueueSupport/items/database_user_grant_revoke.py +104 -0
- python3_cyberfusion_queue_support-2.2.1/src/cyberfusion/QueueSupport/migrations/__init__.py +0 -0
- python3_cyberfusion_queue_support-2.2.1/src/cyberfusion/QueueSupport/migrations/env.py +49 -0
- python3_cyberfusion_queue_support-2.2.1/src/cyberfusion/QueueSupport/migrations/versions/571e55ab5ed5_initial_migration.py +82 -0
- python3_cyberfusion_queue_support-2.2.1/src/cyberfusion/QueueSupport/migrations/versions/__init__.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/outcomes.py +201 -4
- python3_cyberfusion_queue_support-2.2.1/src/cyberfusion/QueueSupport/settings.py +13 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/python3_cyberfusion_queue_support.egg-info/PKG-INFO +7 -1
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/python3_cyberfusion_queue_support.egg-info/SOURCES.txt +12 -0
- python3_cyberfusion_queue_support-2.2.1/src/python3_cyberfusion_queue_support.egg-info/entry_points.txt +2 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/python3_cyberfusion_queue_support.egg-info/requires.txt +2 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/setup.cfg +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/__init__.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/exceptions/__init__.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/interfaces.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/chmod.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/chown.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/command.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/copy.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/mkdir.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/move.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/rmtree.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/systemd_daemon_reload.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/systemd_tmp_files_create.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/systemd_unit_disable.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/systemd_unit_enable.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/systemd_unit_reload.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/systemd_unit_restart.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/systemd_unit_start.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/systemd_unit_stop.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/items/unlink.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/cyberfusion/QueueSupport/utilities.py +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/python3_cyberfusion_queue_support.egg-info/dependency_links.txt +0 -0
- {python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/src/python3_cyberfusion_queue_support.egg-info/top_level.txt +0 -0
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python3-cyberfusion-queue-support
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: Library to queue actions.
|
|
5
5
|
Author-email: Cyberfusion <support@cyberfusion.io>
|
|
6
6
|
Project-URL: Source, https://github.com/CyberfusionIO/python3-cyberfusion-queue-support
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
Requires-Dist: python3-cyberfusion-systemd-support~=2.1
|
|
9
|
+
Requires-Dist: python3-cyberfusion-database-support~=3.0
|
|
9
10
|
Requires-Dist: alembic==1.8.1
|
|
10
11
|
Requires-Dist: SQLAlchemy==1.4.46
|
|
12
|
+
Requires-Dist: pydantic[dotenv]==1.10.4
|
|
11
13
|
|
|
12
14
|
# python3-cyberfusion-queue-support
|
|
13
15
|
|
|
@@ -48,6 +50,10 @@ Run the following command to install the package from PyPI:
|
|
|
48
50
|
|
|
49
51
|
pip3 install python3-cyberfusion-queue-support
|
|
50
52
|
|
|
53
|
+
Then, run database migrations:
|
|
54
|
+
|
|
55
|
+
bin/queue-support-migrate
|
|
56
|
+
|
|
51
57
|
## Debian
|
|
52
58
|
|
|
53
59
|
Run the following commands to build a Debian package:
|
|
@@ -37,6 +37,10 @@ Run the following command to install the package from PyPI:
|
|
|
37
37
|
|
|
38
38
|
pip3 install python3-cyberfusion-queue-support
|
|
39
39
|
|
|
40
|
+
Then, run database migrations:
|
|
41
|
+
|
|
42
|
+
bin/queue-support-migrate
|
|
43
|
+
|
|
40
44
|
## Debian
|
|
41
45
|
|
|
42
46
|
Run the following commands to build a Debian package:
|
{python3_cyberfusion_queue_support-2.0 → python3_cyberfusion_queue_support-2.2.1}/pyproject.toml
RENAMED
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "python3-cyberfusion-queue-support"
|
|
7
|
-
version = "2.
|
|
7
|
+
version = "2.2.1"
|
|
8
8
|
description = "Library to queue actions."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
@@ -12,9 +12,19 @@ authors = [
|
|
|
12
12
|
]
|
|
13
13
|
dependencies = [
|
|
14
14
|
"python3-cyberfusion-systemd-support~=2.1",
|
|
15
|
+
"python3-cyberfusion-database-support~=3.0",
|
|
15
16
|
"alembic==1.8.1",
|
|
16
17
|
"SQLAlchemy==1.4.46",
|
|
18
|
+
"pydantic[dotenv]==1.10.4",
|
|
17
19
|
]
|
|
18
20
|
|
|
19
21
|
[project.urls]
|
|
20
22
|
"Source" = "https://github.com/CyberfusionIO/python3-cyberfusion-queue-support"
|
|
23
|
+
|
|
24
|
+
[project.scripts]
|
|
25
|
+
queue-support-migrate = "cyberfusion.QueueSupport.database:run_migrations"
|
|
26
|
+
|
|
27
|
+
[tool.coverage.run]
|
|
28
|
+
omit = [
|
|
29
|
+
"*/migrations/*"
|
|
30
|
+
]
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
from alembic.config import Config
|
|
1
2
|
import os
|
|
3
|
+
from alembic import command
|
|
2
4
|
import sqlite3
|
|
3
5
|
from datetime import datetime, timezone
|
|
4
6
|
from sqlalchemy.pool.base import _ConnectionRecord
|
|
@@ -10,6 +12,8 @@ from sqlalchemy.engine import Engine
|
|
|
10
12
|
from sqlalchemy import event
|
|
11
13
|
from sqlalchemy.types import JSON
|
|
12
14
|
|
|
15
|
+
from cyberfusion.QueueSupport.settings import settings
|
|
16
|
+
|
|
13
17
|
|
|
14
18
|
@event.listens_for(Engine, "connect") # type: ignore[misc]
|
|
15
19
|
def set_sqlite_pragma(
|
|
@@ -28,14 +32,22 @@ def set_sqlite_pragma(
|
|
|
28
32
|
cursor.close()
|
|
29
33
|
|
|
30
34
|
|
|
31
|
-
def
|
|
32
|
-
"""
|
|
33
|
-
|
|
35
|
+
def run_migrations() -> None:
|
|
36
|
+
"""Upgrade database schema to latest version."""
|
|
37
|
+
alembic_config = Config()
|
|
38
|
+
|
|
39
|
+
alembic_config.set_main_option("sqlalchemy.url", settings.database_path)
|
|
40
|
+
alembic_config.set_main_option(
|
|
41
|
+
"script_location",
|
|
42
|
+
os.path.join(os.path.dirname(os.path.realpath(__file__)), "migrations"),
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
command.upgrade(alembic_config, "head")
|
|
34
46
|
|
|
35
47
|
|
|
36
48
|
def make_database_session() -> Session:
|
|
37
49
|
engine = create_engine(
|
|
38
|
-
|
|
50
|
+
settings.database_path, connect_args={"check_same_thread": False}
|
|
39
51
|
)
|
|
40
52
|
|
|
41
53
|
return sessionmaker(bind=engine)()
|
|
@@ -18,7 +18,7 @@ class _Item(ItemInterface, ABC):
|
|
|
18
18
|
*,
|
|
19
19
|
reference: Optional[str] = None,
|
|
20
20
|
hide_outcomes: bool = False,
|
|
21
|
-
) -> None:
|
|
21
|
+
) -> None: # pragma: no cover
|
|
22
22
|
"""Set attributes."""
|
|
23
23
|
self._reference = reference
|
|
24
24
|
self._hide_outcomes = hide_outcomes
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Item."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import List, Optional
|
|
5
|
+
|
|
6
|
+
from cyberfusion.QueueSupport.items import _Item
|
|
7
|
+
from cyberfusion.QueueSupport.outcomes import DatabaseCreateItemCreateOutcome
|
|
8
|
+
|
|
9
|
+
from cyberfusion.DatabaseSupport.databases import Database
|
|
10
|
+
from cyberfusion.DatabaseSupport import DatabaseSupport
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class DatabaseCreateItem(_Item):
|
|
16
|
+
"""Represents item."""
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
*,
|
|
21
|
+
server_software_name: str,
|
|
22
|
+
name: str,
|
|
23
|
+
reference: Optional[str] = None,
|
|
24
|
+
hide_outcomes: bool = False,
|
|
25
|
+
) -> None:
|
|
26
|
+
"""Set attributes."""
|
|
27
|
+
self.server_software_name = server_software_name
|
|
28
|
+
self.name = name
|
|
29
|
+
self._reference = reference
|
|
30
|
+
self._hide_outcomes = hide_outcomes
|
|
31
|
+
|
|
32
|
+
self.database = Database(
|
|
33
|
+
support=DatabaseSupport(server_software_names=[self.server_software_name]),
|
|
34
|
+
name=self.name,
|
|
35
|
+
server_software_name=self.server_software_name,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def outcomes(self) -> List[DatabaseCreateItemCreateOutcome]:
|
|
40
|
+
"""Get outcomes of item."""
|
|
41
|
+
outcomes = []
|
|
42
|
+
|
|
43
|
+
if not self.database.exists:
|
|
44
|
+
outcomes.append(DatabaseCreateItemCreateOutcome(database=self.database))
|
|
45
|
+
|
|
46
|
+
return outcomes
|
|
47
|
+
|
|
48
|
+
def fulfill(self) -> List[DatabaseCreateItemCreateOutcome]:
|
|
49
|
+
"""Fulfill outcomes."""
|
|
50
|
+
outcomes = self.outcomes
|
|
51
|
+
|
|
52
|
+
for outcome in outcomes:
|
|
53
|
+
outcome.database.create()
|
|
54
|
+
|
|
55
|
+
return outcomes
|
|
56
|
+
|
|
57
|
+
def __eq__(self, other: object) -> bool:
|
|
58
|
+
"""Get equality based on attributes."""
|
|
59
|
+
if not isinstance(other, DatabaseCreateItem):
|
|
60
|
+
return False
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
other.server_software_name == self.server_software_name
|
|
64
|
+
and other.name == self.name
|
|
65
|
+
)
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"""Item."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import List, Optional
|
|
5
|
+
|
|
6
|
+
from cyberfusion.QueueSupport.items import _Item
|
|
7
|
+
from cyberfusion.QueueSupport.outcomes import DatabaseDropItemDropOutcome
|
|
8
|
+
|
|
9
|
+
from cyberfusion.DatabaseSupport.databases import Database
|
|
10
|
+
from cyberfusion.DatabaseSupport import DatabaseSupport
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class DatabaseDropItem(_Item):
|
|
16
|
+
"""Represents item."""
|
|
17
|
+
|
|
18
|
+
def __init__(
|
|
19
|
+
self,
|
|
20
|
+
*,
|
|
21
|
+
server_software_name: str,
|
|
22
|
+
name: str,
|
|
23
|
+
reference: Optional[str] = None,
|
|
24
|
+
hide_outcomes: bool = False,
|
|
25
|
+
) -> None:
|
|
26
|
+
"""Set attributes."""
|
|
27
|
+
self.server_software_name = server_software_name
|
|
28
|
+
self.name = name
|
|
29
|
+
self._reference = reference
|
|
30
|
+
self._hide_outcomes = hide_outcomes
|
|
31
|
+
|
|
32
|
+
self.database = Database(
|
|
33
|
+
support=DatabaseSupport(server_software_names=[self.server_software_name]),
|
|
34
|
+
name=self.name,
|
|
35
|
+
server_software_name=self.server_software_name,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
@property
|
|
39
|
+
def outcomes(self) -> List[DatabaseDropItemDropOutcome]:
|
|
40
|
+
"""Get outcomes of item."""
|
|
41
|
+
outcomes = []
|
|
42
|
+
|
|
43
|
+
if self.database.exists:
|
|
44
|
+
outcomes.append(DatabaseDropItemDropOutcome(database=self.database))
|
|
45
|
+
|
|
46
|
+
return outcomes
|
|
47
|
+
|
|
48
|
+
def fulfill(self) -> List[DatabaseDropItemDropOutcome]:
|
|
49
|
+
"""Fulfill outcomes."""
|
|
50
|
+
outcomes = self.outcomes
|
|
51
|
+
|
|
52
|
+
for outcome in outcomes:
|
|
53
|
+
outcome.database.drop()
|
|
54
|
+
|
|
55
|
+
return outcomes
|
|
56
|
+
|
|
57
|
+
def __eq__(self, other: object) -> bool:
|
|
58
|
+
"""Get equality based on attributes."""
|
|
59
|
+
if not isinstance(other, DatabaseDropItem):
|
|
60
|
+
return False
|
|
61
|
+
|
|
62
|
+
return (
|
|
63
|
+
other.server_software_name == self.server_software_name
|
|
64
|
+
and other.name == self.name
|
|
65
|
+
)
|
python3_cyberfusion_queue_support-2.2.1/src/cyberfusion/QueueSupport/items/database_user_drop.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"""Item."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import List, Optional
|
|
5
|
+
|
|
6
|
+
from cyberfusion.DatabaseSupport.database_users import DatabaseUser
|
|
7
|
+
from cyberfusion.DatabaseSupport.servers import Server
|
|
8
|
+
|
|
9
|
+
from cyberfusion.QueueSupport.items import _Item
|
|
10
|
+
from cyberfusion.QueueSupport.outcomes import (
|
|
11
|
+
DatabaseUserDropItemDropOutcome,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
from cyberfusion.DatabaseSupport import DatabaseSupport
|
|
15
|
+
|
|
16
|
+
logger = logging.getLogger(__name__)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class DatabaseUserDropItem(_Item):
|
|
20
|
+
"""Represents item."""
|
|
21
|
+
|
|
22
|
+
def __init__(
|
|
23
|
+
self,
|
|
24
|
+
*,
|
|
25
|
+
server_software_name: str,
|
|
26
|
+
name: str,
|
|
27
|
+
host: Optional[str] = None,
|
|
28
|
+
reference: Optional[str] = None,
|
|
29
|
+
hide_outcomes: bool = False,
|
|
30
|
+
) -> None:
|
|
31
|
+
"""Set attributes."""
|
|
32
|
+
self.server_software_name = server_software_name
|
|
33
|
+
self.name = name
|
|
34
|
+
self._host = host
|
|
35
|
+
self._reference = reference
|
|
36
|
+
self._hide_outcomes = hide_outcomes
|
|
37
|
+
|
|
38
|
+
self.database_user = DatabaseUser(
|
|
39
|
+
server=Server(
|
|
40
|
+
support=DatabaseSupport(
|
|
41
|
+
server_software_names=[self.server_software_name]
|
|
42
|
+
)
|
|
43
|
+
),
|
|
44
|
+
name=self.name,
|
|
45
|
+
server_software_name=self.server_software_name,
|
|
46
|
+
host=self._host,
|
|
47
|
+
)
|
|
48
|
+
|
|
49
|
+
@property
|
|
50
|
+
def outcomes(
|
|
51
|
+
self,
|
|
52
|
+
) -> List[DatabaseUserDropItemDropOutcome]:
|
|
53
|
+
"""Get outcomes of item."""
|
|
54
|
+
outcomes = []
|
|
55
|
+
|
|
56
|
+
if self.database_user.exists:
|
|
57
|
+
outcomes.append(
|
|
58
|
+
DatabaseUserDropItemDropOutcome(database_user=self.database_user)
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
return outcomes
|
|
62
|
+
|
|
63
|
+
def fulfill(self) -> List[DatabaseUserDropItemDropOutcome]:
|
|
64
|
+
"""Fulfill outcomes."""
|
|
65
|
+
outcomes = self.outcomes
|
|
66
|
+
|
|
67
|
+
for outcome in outcomes:
|
|
68
|
+
outcome.database_user.drop()
|
|
69
|
+
|
|
70
|
+
return outcomes
|
|
71
|
+
|
|
72
|
+
def __eq__(self, other: object) -> bool:
|
|
73
|
+
"""Get equality based on attributes."""
|
|
74
|
+
if not isinstance(other, DatabaseUserDropItem):
|
|
75
|
+
return False
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
other.server_software_name == self.server_software_name
|
|
79
|
+
and other.name == self.name
|
|
80
|
+
and other._host == self._host
|
|
81
|
+
)
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"""Item."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import List, Optional
|
|
5
|
+
|
|
6
|
+
from cyberfusion.DatabaseSupport.database_users import DatabaseUser
|
|
7
|
+
from cyberfusion.DatabaseSupport.servers import Server
|
|
8
|
+
|
|
9
|
+
from cyberfusion.QueueSupport.items import _Item
|
|
10
|
+
from cyberfusion.QueueSupport.outcomes import (
|
|
11
|
+
DatabaseUserEnsureStateItemCreateOutcome,
|
|
12
|
+
DatabaseUserEnsureStateItemEditPasswordOutcome,
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
from cyberfusion.DatabaseSupport import DatabaseSupport
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class DatabaseUserEnsureStateItem(_Item):
|
|
21
|
+
"""Represents item."""
|
|
22
|
+
|
|
23
|
+
def __init__(
|
|
24
|
+
self,
|
|
25
|
+
*,
|
|
26
|
+
server_software_name: str,
|
|
27
|
+
name: str,
|
|
28
|
+
password: str,
|
|
29
|
+
host: Optional[str] = None,
|
|
30
|
+
reference: Optional[str] = None,
|
|
31
|
+
hide_outcomes: bool = False,
|
|
32
|
+
) -> None:
|
|
33
|
+
"""Set attributes."""
|
|
34
|
+
self.server_software_name = server_software_name
|
|
35
|
+
self.name = name
|
|
36
|
+
self.password = password
|
|
37
|
+
self._host = host
|
|
38
|
+
self._reference = reference
|
|
39
|
+
self._hide_outcomes = hide_outcomes
|
|
40
|
+
|
|
41
|
+
self.database_user = DatabaseUser(
|
|
42
|
+
server=Server(
|
|
43
|
+
support=DatabaseSupport(
|
|
44
|
+
server_software_names=[self.server_software_name]
|
|
45
|
+
)
|
|
46
|
+
),
|
|
47
|
+
name=self.name,
|
|
48
|
+
server_software_name=self.server_software_name,
|
|
49
|
+
password=self.password,
|
|
50
|
+
host=self._host,
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
@property
|
|
54
|
+
def outcomes(
|
|
55
|
+
self,
|
|
56
|
+
) -> List[
|
|
57
|
+
DatabaseUserEnsureStateItemCreateOutcome
|
|
58
|
+
| DatabaseUserEnsureStateItemEditPasswordOutcome
|
|
59
|
+
]:
|
|
60
|
+
"""Get outcomes of item."""
|
|
61
|
+
outcomes = []
|
|
62
|
+
|
|
63
|
+
if not self.database_user.exists:
|
|
64
|
+
outcomes.append(
|
|
65
|
+
DatabaseUserEnsureStateItemCreateOutcome(
|
|
66
|
+
database_user=self.database_user
|
|
67
|
+
)
|
|
68
|
+
)
|
|
69
|
+
elif self.database_user._get_password() != self.password:
|
|
70
|
+
outcomes.append(
|
|
71
|
+
DatabaseUserEnsureStateItemEditPasswordOutcome(
|
|
72
|
+
database_user=self.database_user
|
|
73
|
+
)
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
return outcomes
|
|
77
|
+
|
|
78
|
+
def fulfill(self) -> List[DatabaseUserEnsureStateItemCreateOutcome]:
|
|
79
|
+
"""Fulfill outcomes."""
|
|
80
|
+
outcomes = self.outcomes
|
|
81
|
+
|
|
82
|
+
for outcome in outcomes:
|
|
83
|
+
if isinstance(outcome, DatabaseUserEnsureStateItemCreateOutcome):
|
|
84
|
+
outcome.database_user.create()
|
|
85
|
+
else:
|
|
86
|
+
outcome.database_user.edit()
|
|
87
|
+
|
|
88
|
+
return outcomes
|
|
89
|
+
|
|
90
|
+
def __eq__(self, other: object) -> bool:
|
|
91
|
+
"""Get equality based on attributes."""
|
|
92
|
+
if not isinstance(other, DatabaseUserEnsureStateItem):
|
|
93
|
+
return False
|
|
94
|
+
|
|
95
|
+
return (
|
|
96
|
+
other.server_software_name == self.server_software_name
|
|
97
|
+
and other.name == self.name
|
|
98
|
+
and other._host == self._host
|
|
99
|
+
and other.password == self.password
|
|
100
|
+
)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""Item."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import List, Optional
|
|
5
|
+
|
|
6
|
+
from cyberfusion.DatabaseSupport.database_user_grants import DatabaseUserGrant
|
|
7
|
+
from cyberfusion.DatabaseSupport.database_users import DatabaseUser
|
|
8
|
+
from cyberfusion.DatabaseSupport.servers import Server
|
|
9
|
+
from cyberfusion.DatabaseSupport.tables import Table
|
|
10
|
+
|
|
11
|
+
from cyberfusion.QueueSupport.items import _Item
|
|
12
|
+
from cyberfusion.QueueSupport.outcomes import DatabaseUserGrantGrantItemGrantOutcome
|
|
13
|
+
|
|
14
|
+
from cyberfusion.DatabaseSupport.databases import Database
|
|
15
|
+
from cyberfusion.DatabaseSupport import DatabaseSupport
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class DatabaseUserGrantGrantItem(_Item):
|
|
21
|
+
"""Represents item."""
|
|
22
|
+
|
|
23
|
+
def __init__(
|
|
24
|
+
self,
|
|
25
|
+
*,
|
|
26
|
+
server_software_name: str,
|
|
27
|
+
database_name: str,
|
|
28
|
+
database_user_name: str,
|
|
29
|
+
database_user_host: Optional[str] = None,
|
|
30
|
+
privilege_names: List[str],
|
|
31
|
+
table: Optional[Table],
|
|
32
|
+
reference: Optional[str] = None,
|
|
33
|
+
hide_outcomes: bool = False,
|
|
34
|
+
) -> None:
|
|
35
|
+
"""Set attributes."""
|
|
36
|
+
self.server_software_name = server_software_name
|
|
37
|
+
self.database_name = database_name
|
|
38
|
+
self.database_user_name = database_user_name
|
|
39
|
+
self.database_user_host = database_user_host
|
|
40
|
+
self.privilege_names = privilege_names
|
|
41
|
+
self.table = table
|
|
42
|
+
self._reference = reference
|
|
43
|
+
self._hide_outcomes = hide_outcomes
|
|
44
|
+
|
|
45
|
+
self._database = Database(
|
|
46
|
+
support=DatabaseSupport(server_software_names=[self.server_software_name]),
|
|
47
|
+
name=self.database_name,
|
|
48
|
+
server_software_name=self.server_software_name,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
self._database_user = DatabaseUser(
|
|
52
|
+
server=Server(
|
|
53
|
+
support=DatabaseSupport(
|
|
54
|
+
server_software_names=[self.server_software_name]
|
|
55
|
+
)
|
|
56
|
+
),
|
|
57
|
+
name=self.database_user_name,
|
|
58
|
+
server_software_name=self.server_software_name,
|
|
59
|
+
host=self.database_user_host,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
self.database_user_grant = DatabaseUserGrant(
|
|
63
|
+
database=self._database,
|
|
64
|
+
database_user=self._database_user,
|
|
65
|
+
privilege_names=self.privilege_names,
|
|
66
|
+
table=self.table,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def outcomes(self) -> List[DatabaseUserGrantGrantItemGrantOutcome]:
|
|
71
|
+
"""Get outcomes of item."""
|
|
72
|
+
outcomes = []
|
|
73
|
+
|
|
74
|
+
if not self.database_user_grant.exists:
|
|
75
|
+
outcomes.append(
|
|
76
|
+
DatabaseUserGrantGrantItemGrantOutcome(
|
|
77
|
+
database_user_grant=self.database_user_grant
|
|
78
|
+
)
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
return outcomes
|
|
82
|
+
|
|
83
|
+
def fulfill(self) -> List[DatabaseUserGrantGrantItemGrantOutcome]:
|
|
84
|
+
"""Fulfill outcomes."""
|
|
85
|
+
outcomes = self.outcomes
|
|
86
|
+
|
|
87
|
+
for outcome in outcomes:
|
|
88
|
+
outcome.database_user_grant.grant()
|
|
89
|
+
|
|
90
|
+
return outcomes
|
|
91
|
+
|
|
92
|
+
def __eq__(self, other: object) -> bool:
|
|
93
|
+
"""Get equality based on attributes."""
|
|
94
|
+
if not isinstance(other, DatabaseUserGrantGrantItem):
|
|
95
|
+
return False
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
other.server_software_name == self.server_software_name
|
|
99
|
+
and other.database_user_name == self.database_user_name
|
|
100
|
+
and other.database_user_host == self.database_user_host
|
|
101
|
+
and other.database_name == self.database_name
|
|
102
|
+
and other.privilege_names == self.privilege_names
|
|
103
|
+
and getattr(other.table, "name", None) == getattr(self.table, "name", None)
|
|
104
|
+
)
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"""Item."""
|
|
2
|
+
|
|
3
|
+
import logging
|
|
4
|
+
from typing import List, Optional
|
|
5
|
+
|
|
6
|
+
from cyberfusion.DatabaseSupport.database_user_grants import DatabaseUserGrant
|
|
7
|
+
from cyberfusion.DatabaseSupport.database_users import DatabaseUser
|
|
8
|
+
from cyberfusion.DatabaseSupport.servers import Server
|
|
9
|
+
from cyberfusion.DatabaseSupport.tables import Table
|
|
10
|
+
|
|
11
|
+
from cyberfusion.QueueSupport.items import _Item
|
|
12
|
+
from cyberfusion.QueueSupport.outcomes import DatabaseUserGrantRevokeItemRevokeOutcome
|
|
13
|
+
|
|
14
|
+
from cyberfusion.DatabaseSupport.databases import Database
|
|
15
|
+
from cyberfusion.DatabaseSupport import DatabaseSupport
|
|
16
|
+
|
|
17
|
+
logger = logging.getLogger(__name__)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
class DatabaseUserGrantRevokeItem(_Item):
|
|
21
|
+
"""Represents item."""
|
|
22
|
+
|
|
23
|
+
def __init__(
|
|
24
|
+
self,
|
|
25
|
+
*,
|
|
26
|
+
server_software_name: str,
|
|
27
|
+
database_name: str,
|
|
28
|
+
database_user_name: str,
|
|
29
|
+
database_user_host: Optional[str] = None,
|
|
30
|
+
privilege_names: List[str],
|
|
31
|
+
table: Optional[Table],
|
|
32
|
+
reference: Optional[str] = None,
|
|
33
|
+
hide_outcomes: bool = False,
|
|
34
|
+
) -> None:
|
|
35
|
+
"""Set attributes."""
|
|
36
|
+
self.server_software_name = server_software_name
|
|
37
|
+
self.database_name = database_name
|
|
38
|
+
self.database_user_name = database_user_name
|
|
39
|
+
self.database_user_host = database_user_host
|
|
40
|
+
self.privilege_names = privilege_names
|
|
41
|
+
self.table = table
|
|
42
|
+
self._reference = reference
|
|
43
|
+
self._hide_outcomes = hide_outcomes
|
|
44
|
+
|
|
45
|
+
self._database = Database(
|
|
46
|
+
support=DatabaseSupport(server_software_names=[self.server_software_name]),
|
|
47
|
+
name=self.database_name,
|
|
48
|
+
server_software_name=self.server_software_name,
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
self._database_user = DatabaseUser(
|
|
52
|
+
server=Server(
|
|
53
|
+
support=DatabaseSupport(
|
|
54
|
+
server_software_names=[self.server_software_name]
|
|
55
|
+
)
|
|
56
|
+
),
|
|
57
|
+
name=self.database_user_name,
|
|
58
|
+
server_software_name=self.server_software_name,
|
|
59
|
+
host=self.database_user_host,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
self.database_user_grant = DatabaseUserGrant(
|
|
63
|
+
database=self._database,
|
|
64
|
+
database_user=self._database_user,
|
|
65
|
+
privilege_names=self.privilege_names,
|
|
66
|
+
table=self.table,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
@property
|
|
70
|
+
def outcomes(self) -> List[DatabaseUserGrantRevokeItemRevokeOutcome]:
|
|
71
|
+
"""Get outcomes of item."""
|
|
72
|
+
outcomes = []
|
|
73
|
+
|
|
74
|
+
if self.database_user_grant.exists:
|
|
75
|
+
outcomes.append(
|
|
76
|
+
DatabaseUserGrantRevokeItemRevokeOutcome(
|
|
77
|
+
database_user_grant=self.database_user_grant
|
|
78
|
+
)
|
|
79
|
+
)
|
|
80
|
+
|
|
81
|
+
return outcomes
|
|
82
|
+
|
|
83
|
+
def fulfill(self) -> List[DatabaseUserGrantRevokeItemRevokeOutcome]:
|
|
84
|
+
"""Fulfill outcomes."""
|
|
85
|
+
outcomes = self.outcomes
|
|
86
|
+
|
|
87
|
+
for outcome in outcomes:
|
|
88
|
+
outcome.database_user_grant.revoke()
|
|
89
|
+
|
|
90
|
+
return outcomes
|
|
91
|
+
|
|
92
|
+
def __eq__(self, other: object) -> bool:
|
|
93
|
+
"""Get equality based on attributes."""
|
|
94
|
+
if not isinstance(other, DatabaseUserGrantRevokeItem):
|
|
95
|
+
return False
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
other.server_software_name == self.server_software_name
|
|
99
|
+
and other.database_user_name == self.database_user_name
|
|
100
|
+
and other.database_user_host == self.database_user_host
|
|
101
|
+
and other.database_name == self.database_name
|
|
102
|
+
and other.privilege_names == self.privilege_names
|
|
103
|
+
and getattr(other.table, "name", None) == getattr(self.table, "name", None)
|
|
104
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
from logging.config import fileConfig
|
|
2
|
+
|
|
3
|
+
from sqlalchemy import engine_from_config
|
|
4
|
+
from sqlalchemy import pool
|
|
5
|
+
|
|
6
|
+
from alembic import context
|
|
7
|
+
|
|
8
|
+
from cyberfusion.QueueSupport import database
|
|
9
|
+
|
|
10
|
+
config = context.config
|
|
11
|
+
|
|
12
|
+
if config.config_file_name is not None:
|
|
13
|
+
fileConfig(config.config_file_name)
|
|
14
|
+
|
|
15
|
+
target_metadata = database.metadata
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def run_migrations_offline() -> None:
|
|
19
|
+
url = config.get_main_option("sqlalchemy.url")
|
|
20
|
+
|
|
21
|
+
context.configure(
|
|
22
|
+
url=url,
|
|
23
|
+
target_metadata=target_metadata,
|
|
24
|
+
literal_binds=True,
|
|
25
|
+
dialect_opts={"paramstyle": "named"},
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
with context.begin_transaction():
|
|
29
|
+
context.run_migrations()
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
def run_migrations_online() -> None:
|
|
33
|
+
connectable = engine_from_config(
|
|
34
|
+
config.get_section(config.config_ini_section),
|
|
35
|
+
prefix="sqlalchemy.",
|
|
36
|
+
poolclass=pool.NullPool,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
with connectable.connect() as connection:
|
|
40
|
+
context.configure(connection=connection, target_metadata=target_metadata)
|
|
41
|
+
|
|
42
|
+
with context.begin_transaction():
|
|
43
|
+
context.run_migrations()
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
if context.is_offline_mode():
|
|
47
|
+
run_migrations_offline()
|
|
48
|
+
else:
|
|
49
|
+
run_migrations_online()
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"""Initial migration
|
|
2
|
+
|
|
3
|
+
Revision ID: 571e55ab5ed5
|
|
4
|
+
Revises:
|
|
5
|
+
Create Date: 2025-04-09 18:46:38.122919
|
|
6
|
+
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from alembic import op
|
|
10
|
+
import sqlalchemy as sa
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
# revision identifiers, used by Alembic.
|
|
14
|
+
revision = "571e55ab5ed5"
|
|
15
|
+
down_revision = None
|
|
16
|
+
branch_labels = None
|
|
17
|
+
depends_on = None
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def upgrade() -> None:
|
|
21
|
+
op.create_table(
|
|
22
|
+
"queues",
|
|
23
|
+
sa.Column("id", sa.Integer(), nullable=False),
|
|
24
|
+
sa.Column("created_at", sa.DateTime(), nullable=False),
|
|
25
|
+
sa.PrimaryKeyConstraint("id", name=op.f("pk_queues")),
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
op.create_table(
|
|
29
|
+
"queue_items",
|
|
30
|
+
sa.Column("id", sa.Integer(), nullable=False),
|
|
31
|
+
sa.Column("created_at", sa.DateTime(), nullable=False),
|
|
32
|
+
sa.Column("queue_id", sa.Integer(), nullable=False),
|
|
33
|
+
sa.Column("type", sa.String(length=255), nullable=False),
|
|
34
|
+
sa.Column("reference", sa.String(length=255), nullable=True),
|
|
35
|
+
sa.Column("hide_outcomes", sa.Boolean(), nullable=False),
|
|
36
|
+
sa.Column("deduplicated", sa.Boolean(), nullable=False),
|
|
37
|
+
sa.Column("attributes", sa.JSON(), nullable=False),
|
|
38
|
+
sa.ForeignKeyConstraint(
|
|
39
|
+
["queue_id"], ["queues.id"], name=op.f("fk_queue_items_queue_id_queues")
|
|
40
|
+
),
|
|
41
|
+
sa.PrimaryKeyConstraint("id", name=op.f("pk_queue_items")),
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
op.create_table(
|
|
45
|
+
"queue_processes",
|
|
46
|
+
sa.Column("id", sa.Integer(), nullable=False),
|
|
47
|
+
sa.Column("created_at", sa.DateTime(), nullable=False),
|
|
48
|
+
sa.Column("queue_id", sa.Integer(), nullable=False),
|
|
49
|
+
sa.Column("preview", sa.Boolean(), nullable=False),
|
|
50
|
+
sa.ForeignKeyConstraint(
|
|
51
|
+
["queue_id"], ["queues.id"], name=op.f("fk_queue_processes_queue_id_queues")
|
|
52
|
+
),
|
|
53
|
+
sa.PrimaryKeyConstraint("id", name=op.f("pk_queue_processes")),
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
op.create_table(
|
|
57
|
+
"queue_item_outcomes",
|
|
58
|
+
sa.Column("id", sa.Integer(), nullable=False),
|
|
59
|
+
sa.Column("created_at", sa.DateTime(), nullable=False),
|
|
60
|
+
sa.Column("queue_item_id", sa.Integer(), nullable=False),
|
|
61
|
+
sa.Column("queue_process_id", sa.Integer(), nullable=False),
|
|
62
|
+
sa.Column("type", sa.String(length=255), nullable=False),
|
|
63
|
+
sa.Column("attributes", sa.JSON(), nullable=False),
|
|
64
|
+
sa.ForeignKeyConstraint(
|
|
65
|
+
["queue_item_id"],
|
|
66
|
+
["queue_items.id"],
|
|
67
|
+
name=op.f("fk_queue_item_outcomes_queue_item_id_queue_items"),
|
|
68
|
+
),
|
|
69
|
+
sa.ForeignKeyConstraint(
|
|
70
|
+
["queue_process_id"],
|
|
71
|
+
["queue_processes.id"],
|
|
72
|
+
name=op.f("fk_queue_item_outcomes_queue_process_id_queue_processes"),
|
|
73
|
+
),
|
|
74
|
+
sa.PrimaryKeyConstraint("id", name=op.f("pk_queue_item_outcomes")),
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def downgrade() -> None:
|
|
79
|
+
op.drop_table("queue_item_outcomes")
|
|
80
|
+
op.drop_table("queue_processes")
|
|
81
|
+
op.drop_table("queue_items")
|
|
82
|
+
op.drop_table("queues")
|
python3_cyberfusion_queue_support-2.2.1/src/cyberfusion/QueueSupport/migrations/versions/__init__.py
ADDED
|
File without changes
|
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
from typing import List, Optional
|
|
4
4
|
|
|
5
|
+
from cyberfusion.DatabaseSupport.database_user_grants import DatabaseUserGrant
|
|
6
|
+
from cyberfusion.DatabaseSupport.database_users import DatabaseUser
|
|
7
|
+
from cyberfusion.DatabaseSupport.databases import Database
|
|
8
|
+
|
|
5
9
|
from cyberfusion.QueueSupport.interfaces import OutcomeInterface
|
|
6
10
|
from cyberfusion.SystemdSupport.units import Unit
|
|
7
11
|
|
|
@@ -10,7 +14,11 @@ class CopyItemCopyOutcome(OutcomeInterface):
|
|
|
10
14
|
"""Represents outcome."""
|
|
11
15
|
|
|
12
16
|
def __init__(
|
|
13
|
-
self,
|
|
17
|
+
self,
|
|
18
|
+
*,
|
|
19
|
+
source: str,
|
|
20
|
+
destination: str,
|
|
21
|
+
changed_lines: Optional[list[str]] = None,
|
|
14
22
|
) -> None:
|
|
15
23
|
"""Set attributes."""
|
|
16
24
|
self.source = source
|
|
@@ -24,9 +32,7 @@ class CopyItemCopyOutcome(OutcomeInterface):
|
|
|
24
32
|
else:
|
|
25
33
|
changed_lines = ""
|
|
26
34
|
|
|
27
|
-
return
|
|
28
|
-
f"Copy {self.source} to {self.destination}.{changed_lines}"
|
|
29
|
-
)
|
|
35
|
+
return f"Copy {self.source} to {self.destination}.{changed_lines}"
|
|
30
36
|
|
|
31
37
|
def __eq__(self, other: object) -> bool:
|
|
32
38
|
"""Get equality based on attributes."""
|
|
@@ -376,3 +382,194 @@ class SystemdUnitStopItemStopOutcome(OutcomeInterface):
|
|
|
376
382
|
return False
|
|
377
383
|
|
|
378
384
|
return other.unit.name == self.unit.name
|
|
385
|
+
|
|
386
|
+
|
|
387
|
+
class DatabaseCreateItemCreateOutcome(OutcomeInterface):
|
|
388
|
+
"""Represents outcome."""
|
|
389
|
+
|
|
390
|
+
def __init__(self, *, database: Database) -> None:
|
|
391
|
+
"""Set attributes."""
|
|
392
|
+
self.database = database
|
|
393
|
+
|
|
394
|
+
def __str__(self) -> str:
|
|
395
|
+
"""Get human-readable string."""
|
|
396
|
+
return f"Create {self.database.name} in {self.database.server_software_name}"
|
|
397
|
+
|
|
398
|
+
def __eq__(self, other: object) -> bool:
|
|
399
|
+
"""Get equality based on attributes."""
|
|
400
|
+
if not isinstance(other, DatabaseCreateItemCreateOutcome):
|
|
401
|
+
return False
|
|
402
|
+
|
|
403
|
+
return (
|
|
404
|
+
other.database.server_software_name == self.database.server_software_name
|
|
405
|
+
and other.database.name == self.database.name
|
|
406
|
+
)
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
class DatabaseDropItemDropOutcome(OutcomeInterface):
|
|
410
|
+
"""Represents outcome."""
|
|
411
|
+
|
|
412
|
+
def __init__(self, *, database: Database) -> None:
|
|
413
|
+
"""Set attributes."""
|
|
414
|
+
self.database = database
|
|
415
|
+
|
|
416
|
+
def __str__(self) -> str:
|
|
417
|
+
"""Get human-readable string."""
|
|
418
|
+
return f"Drop {self.database.name} in {self.database.server_software_name}"
|
|
419
|
+
|
|
420
|
+
def __eq__(self, other: object) -> bool:
|
|
421
|
+
"""Get equality based on attributes."""
|
|
422
|
+
if not isinstance(other, DatabaseDropItemDropOutcome):
|
|
423
|
+
return False
|
|
424
|
+
|
|
425
|
+
return (
|
|
426
|
+
other.database.server_software_name == self.database.server_software_name
|
|
427
|
+
and other.database.name == self.database.name
|
|
428
|
+
)
|
|
429
|
+
|
|
430
|
+
|
|
431
|
+
class DatabaseUserEnsureStateItemCreateOutcome(OutcomeInterface):
|
|
432
|
+
"""Represents outcome."""
|
|
433
|
+
|
|
434
|
+
def __init__(self, *, database_user: DatabaseUser) -> None:
|
|
435
|
+
"""Set attributes."""
|
|
436
|
+
self.database_user = database_user
|
|
437
|
+
|
|
438
|
+
def __str__(self) -> str:
|
|
439
|
+
"""Get human-readable string."""
|
|
440
|
+
return f"Create {self.database_user.name} in {self.database_user.server_software_name}"
|
|
441
|
+
|
|
442
|
+
def __eq__(self, other: object) -> bool:
|
|
443
|
+
"""Get equality based on attributes."""
|
|
444
|
+
if not isinstance(other, DatabaseUserEnsureStateItemCreateOutcome):
|
|
445
|
+
return False
|
|
446
|
+
|
|
447
|
+
return (
|
|
448
|
+
other.database_user.server_software_name
|
|
449
|
+
== self.database_user.server_software_name
|
|
450
|
+
and other.database_user.name == self.database_user.name
|
|
451
|
+
and other.database_user.password == self.database_user.password
|
|
452
|
+
and other.database_user.host == self.database_user.host
|
|
453
|
+
)
|
|
454
|
+
|
|
455
|
+
|
|
456
|
+
class DatabaseUserEnsureStateItemEditPasswordOutcome(OutcomeInterface):
|
|
457
|
+
"""Represents outcome."""
|
|
458
|
+
|
|
459
|
+
def __init__(self, *, database_user: DatabaseUser) -> None:
|
|
460
|
+
"""Set attributes."""
|
|
461
|
+
self.database_user = database_user
|
|
462
|
+
|
|
463
|
+
def __str__(self) -> str:
|
|
464
|
+
"""Get human-readable string."""
|
|
465
|
+
return f"Edit password of {self.database_user.name} in {self.database_user.server_software_name}"
|
|
466
|
+
|
|
467
|
+
def __eq__(self, other: object) -> bool:
|
|
468
|
+
"""Get equality based on attributes."""
|
|
469
|
+
if not isinstance(other, DatabaseUserEnsureStateItemEditPasswordOutcome):
|
|
470
|
+
return False
|
|
471
|
+
|
|
472
|
+
print(
|
|
473
|
+
other.database_user.server_software_name,
|
|
474
|
+
other.database_user.name,
|
|
475
|
+
other.database_user.password,
|
|
476
|
+
other.database_user.host,
|
|
477
|
+
)
|
|
478
|
+
print(
|
|
479
|
+
self.database_user.server_software_name,
|
|
480
|
+
self.database_user.name,
|
|
481
|
+
self.database_user.password,
|
|
482
|
+
self.database_user.host,
|
|
483
|
+
)
|
|
484
|
+
|
|
485
|
+
return (
|
|
486
|
+
other.database_user.server_software_name
|
|
487
|
+
== self.database_user.server_software_name
|
|
488
|
+
and other.database_user.name == self.database_user.name
|
|
489
|
+
and other.database_user.password == self.database_user.password
|
|
490
|
+
and other.database_user.host == self.database_user.host
|
|
491
|
+
)
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
class DatabaseUserDropItemDropOutcome(OutcomeInterface):
|
|
495
|
+
"""Represents outcome."""
|
|
496
|
+
|
|
497
|
+
def __init__(self, *, database_user: DatabaseUser) -> None:
|
|
498
|
+
"""Set attributes."""
|
|
499
|
+
self.database_user = database_user
|
|
500
|
+
|
|
501
|
+
def __str__(self) -> str:
|
|
502
|
+
"""Get human-readable string."""
|
|
503
|
+
return f"Drop {self.database_user.name} in {self.database_user.server_software_name}"
|
|
504
|
+
|
|
505
|
+
def __eq__(self, other: object) -> bool:
|
|
506
|
+
"""Get equality based on attributes."""
|
|
507
|
+
if not isinstance(other, DatabaseUserDropItemDropOutcome):
|
|
508
|
+
return False
|
|
509
|
+
|
|
510
|
+
return (
|
|
511
|
+
other.database_user.server_software_name
|
|
512
|
+
== self.database_user.server_software_name
|
|
513
|
+
and other.database_user.name == self.database_user.name
|
|
514
|
+
and other.database_user.host == self.database_user.host
|
|
515
|
+
)
|
|
516
|
+
|
|
517
|
+
|
|
518
|
+
class DatabaseUserGrantGrantItemGrantOutcome(OutcomeInterface):
|
|
519
|
+
"""Represents outcome."""
|
|
520
|
+
|
|
521
|
+
def __init__(self, *, database_user_grant: DatabaseUserGrant) -> None:
|
|
522
|
+
"""Set attributes."""
|
|
523
|
+
self.database_user_grant = database_user_grant
|
|
524
|
+
|
|
525
|
+
def __str__(self) -> str:
|
|
526
|
+
"""Get human-readable string."""
|
|
527
|
+
return f"Grant {self.database_user_grant.privilege_names} to {self.database_user_grant.table_name} in {self.database_user_grant.database_name} in {self.database_user_grant.database_user.server_software_name}"
|
|
528
|
+
|
|
529
|
+
def __eq__(self, other: object) -> bool:
|
|
530
|
+
"""Get equality based on attributes."""
|
|
531
|
+
if not isinstance(other, DatabaseUserGrantGrantItemGrantOutcome):
|
|
532
|
+
return False
|
|
533
|
+
|
|
534
|
+
return (
|
|
535
|
+
other.database_user_grant.database_user.server_software_name
|
|
536
|
+
== self.database_user_grant.database_user.server_software_name
|
|
537
|
+
and other.database_user_grant.database_user.name
|
|
538
|
+
== self.database_user_grant.database_user.name
|
|
539
|
+
and other.database_user_grant.database_user.host
|
|
540
|
+
== self.database_user_grant.database_user.host
|
|
541
|
+
and other.database_user_grant.privilege_names
|
|
542
|
+
== self.database_user_grant.privilege_names
|
|
543
|
+
and other.database_user_grant.table_name
|
|
544
|
+
== self.database_user_grant.table_name
|
|
545
|
+
)
|
|
546
|
+
|
|
547
|
+
|
|
548
|
+
class DatabaseUserGrantRevokeItemRevokeOutcome(OutcomeInterface):
|
|
549
|
+
"""Represents outcome."""
|
|
550
|
+
|
|
551
|
+
def __init__(self, *, database_user_grant: DatabaseUserGrant) -> None:
|
|
552
|
+
"""Set attributes."""
|
|
553
|
+
self.database_user_grant = database_user_grant
|
|
554
|
+
|
|
555
|
+
def __str__(self) -> str:
|
|
556
|
+
"""Get human-readable string."""
|
|
557
|
+
return f"Revoke {self.database_user_grant.privilege_names} to {self.database_user_grant.table_name} in {self.database_user_grant.database_name} in {self.database_user_grant.database_user.server_software_name}"
|
|
558
|
+
|
|
559
|
+
def __eq__(self, other: object) -> bool:
|
|
560
|
+
"""Get equality based on attributes."""
|
|
561
|
+
if not isinstance(other, DatabaseUserGrantRevokeItemRevokeOutcome):
|
|
562
|
+
return False
|
|
563
|
+
|
|
564
|
+
return (
|
|
565
|
+
other.database_user_grant.database_user.server_software_name
|
|
566
|
+
== self.database_user_grant.database_user.server_software_name
|
|
567
|
+
and other.database_user_grant.database_user.name
|
|
568
|
+
== self.database_user_grant.database_user.name
|
|
569
|
+
and other.database_user_grant.database_user.host
|
|
570
|
+
== self.database_user_grant.database_user.host
|
|
571
|
+
and other.database_user_grant.privilege_names
|
|
572
|
+
== self.database_user_grant.privilege_names
|
|
573
|
+
and other.database_user_grant.table_name
|
|
574
|
+
== self.database_user_grant.table_name
|
|
575
|
+
)
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: python3-cyberfusion-queue-support
|
|
3
|
-
Version: 2.
|
|
3
|
+
Version: 2.2.1
|
|
4
4
|
Summary: Library to queue actions.
|
|
5
5
|
Author-email: Cyberfusion <support@cyberfusion.io>
|
|
6
6
|
Project-URL: Source, https://github.com/CyberfusionIO/python3-cyberfusion-queue-support
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
Requires-Dist: python3-cyberfusion-systemd-support~=2.1
|
|
9
|
+
Requires-Dist: python3-cyberfusion-database-support~=3.0
|
|
9
10
|
Requires-Dist: alembic==1.8.1
|
|
10
11
|
Requires-Dist: SQLAlchemy==1.4.46
|
|
12
|
+
Requires-Dist: pydantic[dotenv]==1.10.4
|
|
11
13
|
|
|
12
14
|
# python3-cyberfusion-queue-support
|
|
13
15
|
|
|
@@ -48,6 +50,10 @@ Run the following command to install the package from PyPI:
|
|
|
48
50
|
|
|
49
51
|
pip3 install python3-cyberfusion-queue-support
|
|
50
52
|
|
|
53
|
+
Then, run database migrations:
|
|
54
|
+
|
|
55
|
+
bin/queue-support-migrate
|
|
56
|
+
|
|
51
57
|
## Debian
|
|
52
58
|
|
|
53
59
|
Run the following commands to build a Debian package:
|
|
@@ -5,6 +5,7 @@ src/cyberfusion/QueueSupport/__init__.py
|
|
|
5
5
|
src/cyberfusion/QueueSupport/database.py
|
|
6
6
|
src/cyberfusion/QueueSupport/interfaces.py
|
|
7
7
|
src/cyberfusion/QueueSupport/outcomes.py
|
|
8
|
+
src/cyberfusion/QueueSupport/settings.py
|
|
8
9
|
src/cyberfusion/QueueSupport/utilities.py
|
|
9
10
|
src/cyberfusion/QueueSupport/exceptions/__init__.py
|
|
10
11
|
src/cyberfusion/QueueSupport/items/__init__.py
|
|
@@ -12,6 +13,12 @@ src/cyberfusion/QueueSupport/items/chmod.py
|
|
|
12
13
|
src/cyberfusion/QueueSupport/items/chown.py
|
|
13
14
|
src/cyberfusion/QueueSupport/items/command.py
|
|
14
15
|
src/cyberfusion/QueueSupport/items/copy.py
|
|
16
|
+
src/cyberfusion/QueueSupport/items/database_create.py
|
|
17
|
+
src/cyberfusion/QueueSupport/items/database_drop.py
|
|
18
|
+
src/cyberfusion/QueueSupport/items/database_user_drop.py
|
|
19
|
+
src/cyberfusion/QueueSupport/items/database_user_ensure_state.py
|
|
20
|
+
src/cyberfusion/QueueSupport/items/database_user_grant_grant.py
|
|
21
|
+
src/cyberfusion/QueueSupport/items/database_user_grant_revoke.py
|
|
15
22
|
src/cyberfusion/QueueSupport/items/mkdir.py
|
|
16
23
|
src/cyberfusion/QueueSupport/items/move.py
|
|
17
24
|
src/cyberfusion/QueueSupport/items/rmtree.py
|
|
@@ -24,8 +31,13 @@ src/cyberfusion/QueueSupport/items/systemd_unit_restart.py
|
|
|
24
31
|
src/cyberfusion/QueueSupport/items/systemd_unit_start.py
|
|
25
32
|
src/cyberfusion/QueueSupport/items/systemd_unit_stop.py
|
|
26
33
|
src/cyberfusion/QueueSupport/items/unlink.py
|
|
34
|
+
src/cyberfusion/QueueSupport/migrations/__init__.py
|
|
35
|
+
src/cyberfusion/QueueSupport/migrations/env.py
|
|
36
|
+
src/cyberfusion/QueueSupport/migrations/versions/571e55ab5ed5_initial_migration.py
|
|
37
|
+
src/cyberfusion/QueueSupport/migrations/versions/__init__.py
|
|
27
38
|
src/python3_cyberfusion_queue_support.egg-info/PKG-INFO
|
|
28
39
|
src/python3_cyberfusion_queue_support.egg-info/SOURCES.txt
|
|
29
40
|
src/python3_cyberfusion_queue_support.egg-info/dependency_links.txt
|
|
41
|
+
src/python3_cyberfusion_queue_support.egg-info/entry_points.txt
|
|
30
42
|
src/python3_cyberfusion_queue_support.egg-info/requires.txt
|
|
31
43
|
src/python3_cyberfusion_queue_support.egg-info/top_level.txt
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|