Skip to content

Commit 10f8d88

Browse files
authored
Merge pull request #131 from UW-Macrostrat/storage-admin
Starting point for storage administration command
2 parents 119a566 + d1a6e98 commit 10f8d88

File tree

8 files changed

+175
-2
lines changed

8 files changed

+175
-2
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "submodules/postgis-tile-utils"]
55
path = submodules/postgis-tile-utils
66
url = https://github.com/UW-Macrostrat/postgis-tile-utils
7+
[submodule "submodules/storage-admin"]
8+
path = submodules/storage-admin
9+
url = https://github.com/UW-Macrostrat/radosgw_admin_client

cli/macrostrat/cli/subsystems/storage.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Storage system management
33
"""
44

5+
import re
56
from os import environ
67
from subprocess import run
78
from typing import List, Optional
@@ -12,6 +13,7 @@
1213
from macrostrat.core import app as app_
1314
from macrostrat.utils import get_logger
1415

16+
from ...core.exc import MacrostratError
1517
from ..kubernetes import _kubectl, get_secret
1618

1719
settings = app_.settings
@@ -21,6 +23,39 @@
2123

2224
app = Typer(no_args_is_help=True)
2325

26+
if admin := settings.get("storage.admin", None):
27+
host = settings.get("storage.endpoint", None)
28+
29+
if getattr(admin, "type") == "ceph-object-storage":
30+
access_key = getattr(admin, "access_key")
31+
secret_key = getattr(admin, "secret_key")
32+
33+
# Set up the radosgw-admin command
34+
35+
@app.command("admin", add_help_option=False)
36+
def storage_admin(args: List[str] = Argument(None)):
37+
"""
38+
Run the Ceph Object Storage admin command.
39+
"""
40+
import sys
41+
from os import environ
42+
43+
from htpheno.radosgw_admin_client.cli import UserError, main
44+
45+
environ["RADOSGW_ACCESS_KEY"] = access_key
46+
environ["RADOSGW_SECRET_KEY"] = secret_key
47+
environ["RADOSGW_HOST"] = re.sub("^https?://", "", host)
48+
49+
if args is None:
50+
args = ["--help"]
51+
52+
sys.argv = ["radosgw-admin", *args]
53+
try:
54+
main()
55+
except UserError as e:
56+
# raise MacrostratError(e)
57+
print("[red bold]Error:[/] [red]" + str(e))
58+
2459

2560
def _s3_users():
2661
res = _kubectl(

cli/poetry.lock

Lines changed: 61 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ ipython = "^8.5.0"
2828
"macrostrat.integrations" = { path = "../integrations", develop = true }
2929
"macrostrat.map-integration" = { path = "../map-integration", develop = true }
3030
"criticalmaas.ta1-geopackage" = "^0.2.0"
31-
"mapboard.topology-manager" = { path = "../submodules/topology-manager", develop = true }
31+
"mapboard.topology-manager" = { path = "../submodules/topology-manager", develop = true }
32+
"htpheno.radosgw-admin-client" = { path = "../submodules/storage-admin", develop = true }
3233
numpy = "^1.23.4"
3334
psycopg2-binary = "^2.9.4"
3435
pyproj = "^3.4.0"

core/macrostrat/core/config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ def all_environments(self):
4949
next(keys)
5050
return [k for k in keys]
5151

52+
def get(self, key, default=None):
53+
if not "." in key:
54+
return getattr(self, key, default)
55+
56+
keys = key.split(".")
57+
for k in keys:
58+
if k not in self:
59+
return default
60+
self = getattr(self, k)
61+
return self
62+
5263

5364
settings = MacrostratConfig()
5465

local-root/docker-compose.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ services:
121121
- minio_data:/data
122122
command: server --address 0.0.0.0:9000 --console-address 0.0.0.0:9001 /data
123123
web:
124+
profiles: ["web"]
124125
image: hub.opensciencegrid.org/macrostrat/macrostrat-web:main
125126
build: ${MACROSTRAT_WEB_SRC:-""}
126127
environment:

poetry.lock

Lines changed: 61 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

submodules/storage-admin

Submodule storage-admin added at f6e281f

0 commit comments

Comments
 (0)