2024-08-27 19:55:06 +00:00
|
|
|
# = str(min_required_payment) Copyright © 2023 Vulcanize
|
2023-12-14 04:56:40 +00:00
|
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
|
# it under the terms of the GNU Affero General Public License as published by
|
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
|
|
|
|
|
2024-02-28 00:38:11 +00:00
|
|
|
import datetime
|
2023-12-14 04:56:40 +00:00
|
|
|
import hashlib
|
|
|
|
|
import json
|
|
|
|
|
import os
|
|
|
|
|
import random
|
|
|
|
|
import subprocess
|
|
|
|
|
import sys
|
|
|
|
|
import tempfile
|
|
|
|
|
import uuid
|
2024-10-21 07:02:06 +00:00
|
|
|
from enum import Enum
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
from typing import Any, TextIO
|
|
|
|
|
|
|
|
|
|
import yaml
|
2024-10-21 07:02:06 +00:00
|
|
|
|
2024-10-25 08:40:54 +00:00
|
|
|
from stack_orchestrator.deploy.webapp.registry_mutex import registry_mutex
|
|
|
|
|
|
2024-10-21 07:02:06 +00:00
|
|
|
|
|
|
|
|
class AuctionStatus(str, Enum):
|
|
|
|
|
COMMIT = "commit"
|
|
|
|
|
REVEAL = "reveal"
|
|
|
|
|
COMPLETED = "completed"
|
|
|
|
|
EXPIRED = "expired"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TOKEN_DENOM = "alnt"
|
|
|
|
|
AUCTION_KIND_PROVIDER = "provider"
|
|
|
|
|
|
2023-12-14 04:56:40 +00:00
|
|
|
|
|
|
|
|
class AttrDict(dict):
|
2026-01-22 06:10:36 +00:00
|
|
|
def __init__(self, *args: Any, **kwargs: Any) -> None:
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
super().__init__(*args, **kwargs)
|
2023-12-14 04:56:40 +00:00
|
|
|
self.__dict__ = self
|
|
|
|
|
|
2026-01-22 06:10:36 +00:00
|
|
|
def __getattribute__(self, attr: str) -> Any:
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
__dict__ = super().__getattribute__("__dict__")
|
2023-12-14 04:56:40 +00:00
|
|
|
if attr in __dict__:
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
v = super().__getattribute__(attr)
|
2023-12-14 04:56:40 +00:00
|
|
|
if isinstance(v, dict):
|
|
|
|
|
return AttrDict(v)
|
|
|
|
|
return v
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
return super().__getattribute__(attr)
|
2026-01-22 06:10:36 +00:00
|
|
|
|
|
|
|
|
def __getattr__(self, attr: str) -> Any:
|
|
|
|
|
# This method is called when attribute is not found
|
|
|
|
|
# Return None for missing attributes (matches original behavior)
|
|
|
|
|
return None
|
2023-12-14 04:56:40 +00:00
|
|
|
|
|
|
|
|
|
2024-02-28 00:38:11 +00:00
|
|
|
class TimedLogger:
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
def __init__(self, id: str = "", file: TextIO | None = None) -> None:
|
2024-02-28 00:38:11 +00:00
|
|
|
self.start = datetime.datetime.now()
|
|
|
|
|
self.last = self.start
|
|
|
|
|
self.id = id
|
|
|
|
|
self.file = file
|
|
|
|
|
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
def log(self, msg: str, show_step_time: bool = True, show_total_time: bool = False) -> None:
|
2024-02-28 00:38:11 +00:00
|
|
|
prefix = f"{datetime.datetime.utcnow()} - {self.id}"
|
|
|
|
|
if show_step_time:
|
|
|
|
|
prefix += f" - {datetime.datetime.now() - self.last} (step)"
|
|
|
|
|
if show_total_time:
|
|
|
|
|
prefix += f" - {datetime.datetime.now() - self.start} (total)"
|
|
|
|
|
print(f"{prefix}: {msg}", file=self.file)
|
|
|
|
|
if self.file:
|
|
|
|
|
self.file.flush()
|
|
|
|
|
self.last = datetime.datetime.now()
|
|
|
|
|
|
|
|
|
|
|
2024-10-21 07:02:06 +00:00
|
|
|
def load_known_requests(filename):
|
|
|
|
|
if filename and os.path.exists(filename):
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
return json.load(open(filename))
|
2024-10-21 07:02:06 +00:00
|
|
|
return {}
|
|
|
|
|
|
|
|
|
|
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
def logged_cmd(log_file: TextIO | None, *vargs: str) -> str:
|
2024-02-22 01:24:44 +00:00
|
|
|
result = None
|
2023-12-14 04:56:40 +00:00
|
|
|
try:
|
2024-02-22 01:24:44 +00:00
|
|
|
if log_file:
|
|
|
|
|
print(" ".join(vargs), file=log_file)
|
|
|
|
|
result = subprocess.run(vargs, capture_output=True)
|
2023-12-14 04:56:40 +00:00
|
|
|
result.check_returncode()
|
|
|
|
|
return result.stdout.decode()
|
|
|
|
|
except Exception as err:
|
2026-01-22 06:10:36 +00:00
|
|
|
if log_file:
|
|
|
|
|
if result:
|
|
|
|
|
print(result.stderr.decode(), file=log_file)
|
|
|
|
|
else:
|
|
|
|
|
print(str(err), file=log_file)
|
2023-12-14 04:56:40 +00:00
|
|
|
raise err
|
|
|
|
|
|
|
|
|
|
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
def match_owner(recordA: AttrDict | None, *records: AttrDict | None) -> str | None:
|
2026-01-22 06:10:36 +00:00
|
|
|
if not recordA or not recordA.owners:
|
|
|
|
|
return None
|
2023-12-22 00:05:40 +00:00
|
|
|
for owner in recordA.owners:
|
|
|
|
|
for otherRecord in records:
|
2026-01-22 06:10:36 +00:00
|
|
|
if otherRecord and otherRecord.owners and owner in otherRecord.owners:
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
result: str | None = owner
|
|
|
|
|
return result
|
2023-12-22 00:05:40 +00:00
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
def is_lrn(name_or_id: str):
|
|
|
|
|
if name_or_id:
|
|
|
|
|
return str(name_or_id).startswith("lrn://")
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def is_id(name_or_id: str):
|
|
|
|
|
return not is_lrn(name_or_id)
|
|
|
|
|
|
|
|
|
|
|
2023-12-14 04:56:40 +00:00
|
|
|
class LaconicRegistryClient:
|
2024-10-28 06:03:13 +00:00
|
|
|
def __init__(self, config_file, log_file=None, mutex_lock_file=None):
|
2023-12-14 04:56:40 +00:00
|
|
|
self.config_file = config_file
|
2024-02-21 23:48:52 +00:00
|
|
|
self.log_file = log_file
|
2023-12-14 04:56:40 +00:00
|
|
|
self.cache = AttrDict(
|
|
|
|
|
{
|
|
|
|
|
"name_or_id": {},
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
"accounts": {},
|
|
|
|
|
"txs": {},
|
2023-12-14 04:56:40 +00:00
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
2024-10-29 04:05:35 +00:00
|
|
|
self.mutex_lock_file = mutex_lock_file
|
|
|
|
|
self.mutex_lock_acquired = False
|
|
|
|
|
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
def whoami(self, refresh=False):
|
|
|
|
|
if not refresh and "whoami" in self.cache:
|
|
|
|
|
return self.cache["whoami"]
|
|
|
|
|
|
|
|
|
|
args = ["laconic", "-c", self.config_file, "registry", "account", "get"]
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
results = [AttrDict(r) for r in json.loads(logged_cmd(self.log_file, *args)) if r]
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
|
|
|
|
|
if len(results):
|
|
|
|
|
self.cache["whoami"] = results[0]
|
|
|
|
|
return results[0]
|
|
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def get_owner(self, record, require=False):
|
|
|
|
|
bond = self.get_bond(record.bondId, require)
|
|
|
|
|
if bond:
|
|
|
|
|
return bond.owner
|
|
|
|
|
|
|
|
|
|
return bond
|
|
|
|
|
|
|
|
|
|
def get_account(self, address, refresh=False, require=False):
|
|
|
|
|
if not refresh and address in self.cache["accounts"]:
|
|
|
|
|
return self.cache["accounts"][address]
|
|
|
|
|
|
|
|
|
|
args = [
|
|
|
|
|
"laconic",
|
|
|
|
|
"-c",
|
|
|
|
|
self.config_file,
|
|
|
|
|
"registry",
|
|
|
|
|
"account",
|
|
|
|
|
"get",
|
|
|
|
|
"--address",
|
|
|
|
|
address,
|
|
|
|
|
]
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
results = [AttrDict(r) for r in json.loads(logged_cmd(self.log_file, *args)) if r]
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
if len(results):
|
|
|
|
|
self.cache["accounts"][address] = results[0]
|
|
|
|
|
return results[0]
|
|
|
|
|
|
|
|
|
|
if require:
|
|
|
|
|
raise Exception("Cannot locate account:", address)
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def get_bond(self, id, require=False):
|
|
|
|
|
if id in self.cache.name_or_id:
|
|
|
|
|
return self.cache.name_or_id[id]
|
|
|
|
|
|
|
|
|
|
args = [
|
|
|
|
|
"laconic",
|
|
|
|
|
"-c",
|
|
|
|
|
self.config_file,
|
|
|
|
|
"registry",
|
|
|
|
|
"bond",
|
|
|
|
|
"get",
|
|
|
|
|
"--id",
|
|
|
|
|
id,
|
|
|
|
|
]
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
results = [AttrDict(r) for r in json.loads(logged_cmd(self.log_file, *args)) if r]
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
self._add_to_cache(results)
|
|
|
|
|
if len(results):
|
|
|
|
|
return results[0]
|
|
|
|
|
|
|
|
|
|
if require:
|
|
|
|
|
raise Exception("Cannot locate bond:", id)
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def list_bonds(self):
|
|
|
|
|
args = ["laconic", "-c", self.config_file, "registry", "bond", "list"]
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
results = [AttrDict(r) for r in json.loads(logged_cmd(self.log_file, *args)) if r]
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
self._add_to_cache(results)
|
|
|
|
|
return results
|
|
|
|
|
|
|
|
|
|
def list_records(self, criteria=None, all=False):
|
|
|
|
|
if criteria is None:
|
|
|
|
|
criteria = {}
|
2024-07-27 18:59:42 +00:00
|
|
|
args = ["laconic", "-c", self.config_file, "registry", "record", "list"]
|
2023-12-14 04:56:40 +00:00
|
|
|
|
|
|
|
|
if all:
|
|
|
|
|
args.append("--all")
|
|
|
|
|
|
|
|
|
|
if criteria:
|
|
|
|
|
for k, v in criteria.items():
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
args.append(f"--{k}")
|
2023-12-14 04:56:40 +00:00
|
|
|
args.append(str(v))
|
|
|
|
|
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
results = [AttrDict(r) for r in json.loads(logged_cmd(self.log_file, *args)) if r]
|
2023-12-14 04:56:40 +00:00
|
|
|
|
|
|
|
|
# Most recent records first
|
2026-01-22 06:10:36 +00:00
|
|
|
results.sort(key=lambda r: r.createTime or "")
|
2023-12-14 04:56:40 +00:00
|
|
|
results.reverse()
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
self._add_to_cache(results)
|
2023-12-14 04:56:40 +00:00
|
|
|
|
|
|
|
|
return results
|
|
|
|
|
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
def _add_to_cache(self, records: list[AttrDict]) -> None:
|
2023-12-14 04:56:40 +00:00
|
|
|
if not records:
|
|
|
|
|
return
|
|
|
|
|
|
|
|
|
|
for p in records:
|
2026-01-22 06:10:36 +00:00
|
|
|
if p.id:
|
|
|
|
|
self.cache["name_or_id"][p.id] = p
|
2023-12-14 04:56:40 +00:00
|
|
|
if p.names:
|
2024-07-27 18:59:42 +00:00
|
|
|
for lrn in p.names:
|
|
|
|
|
self.cache["name_or_id"][lrn] = p
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
if p.attributes and p.attributes.type:
|
2026-01-22 06:10:36 +00:00
|
|
|
attr_type = p.attributes.type
|
|
|
|
|
if attr_type not in self.cache:
|
|
|
|
|
self.cache[attr_type] = []
|
|
|
|
|
self.cache[attr_type].append(p)
|
2023-12-14 04:56:40 +00:00
|
|
|
|
|
|
|
|
def resolve(self, name):
|
|
|
|
|
if not name:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
if name in self.cache.name_or_id:
|
|
|
|
|
return self.cache.name_or_id[name]
|
|
|
|
|
|
2024-07-27 18:59:42 +00:00
|
|
|
args = ["laconic", "-c", self.config_file, "registry", "name", "resolve", name]
|
2023-12-14 04:56:40 +00:00
|
|
|
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
parsed = [AttrDict(r) for r in json.loads(logged_cmd(self.log_file, *args)) if r]
|
2023-12-14 04:56:40 +00:00
|
|
|
if parsed:
|
|
|
|
|
self._add_to_cache(parsed)
|
|
|
|
|
return parsed[0]
|
|
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
def get_record(self, name_or_id, require=False):
|
|
|
|
|
if not name_or_id:
|
|
|
|
|
if require:
|
|
|
|
|
raise Exception("Cannot locate record:", name_or_id)
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
if name_or_id in self.cache.name_or_id:
|
|
|
|
|
return self.cache.name_or_id[name_or_id]
|
|
|
|
|
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
if is_lrn(name_or_id):
|
2023-12-14 04:56:40 +00:00
|
|
|
return self.resolve(name_or_id)
|
|
|
|
|
|
|
|
|
|
args = [
|
|
|
|
|
"laconic",
|
|
|
|
|
"-c",
|
|
|
|
|
self.config_file,
|
2024-07-27 18:59:42 +00:00
|
|
|
"registry",
|
2023-12-14 04:56:40 +00:00
|
|
|
"record",
|
|
|
|
|
"get",
|
|
|
|
|
"--id",
|
|
|
|
|
name_or_id,
|
|
|
|
|
]
|
|
|
|
|
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
parsed = [AttrDict(r) for r in json.loads(logged_cmd(self.log_file, *args)) if r]
|
2023-12-14 04:56:40 +00:00
|
|
|
if len(parsed):
|
|
|
|
|
self._add_to_cache(parsed)
|
|
|
|
|
return parsed[0]
|
|
|
|
|
|
|
|
|
|
if require:
|
|
|
|
|
raise Exception("Cannot locate record:", name_or_id)
|
|
|
|
|
return None
|
|
|
|
|
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
def get_tx(self, txHash, require=False):
|
|
|
|
|
if txHash in self.cache["txs"]:
|
|
|
|
|
return self.cache["txs"][txHash]
|
2023-12-22 00:05:40 +00:00
|
|
|
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
args = [
|
|
|
|
|
"laconic",
|
|
|
|
|
"-c",
|
|
|
|
|
self.config_file,
|
|
|
|
|
"registry",
|
|
|
|
|
"tokens",
|
|
|
|
|
"gettx",
|
|
|
|
|
"--hash",
|
|
|
|
|
txHash,
|
|
|
|
|
]
|
2023-12-22 00:05:40 +00:00
|
|
|
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
parsed = None
|
|
|
|
|
try:
|
|
|
|
|
parsed = AttrDict(json.loads(logged_cmd(self.log_file, *args)))
|
|
|
|
|
except: # noqa: E722
|
|
|
|
|
pass
|
2023-12-14 04:56:40 +00:00
|
|
|
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
if parsed:
|
|
|
|
|
self.cache["txs"][txHash] = parsed
|
|
|
|
|
return parsed
|
2023-12-14 04:56:40 +00:00
|
|
|
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
if require:
|
|
|
|
|
raise Exception("Cannot locate tx:", hash)
|
|
|
|
|
|
2024-10-21 07:02:06 +00:00
|
|
|
def get_auction(self, auction_id, require=False):
|
|
|
|
|
args = [
|
|
|
|
|
"laconic",
|
|
|
|
|
"-c",
|
|
|
|
|
self.config_file,
|
|
|
|
|
"registry",
|
|
|
|
|
"auction",
|
|
|
|
|
"get",
|
|
|
|
|
"--id",
|
|
|
|
|
auction_id,
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
results = None
|
|
|
|
|
try:
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
results = [AttrDict(r) for r in json.loads(logged_cmd(self.log_file, *args)) if r]
|
2024-10-21 07:02:06 +00:00
|
|
|
except: # noqa: E722
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
if results and len(results):
|
|
|
|
|
return results[0]
|
|
|
|
|
|
|
|
|
|
if require:
|
|
|
|
|
raise Exception("Cannot locate auction:", auction_id)
|
|
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
def app_deployment_requests(self, criteria=None, all=True):
|
|
|
|
|
if criteria is None:
|
|
|
|
|
criteria = {}
|
|
|
|
|
criteria = criteria.copy()
|
|
|
|
|
criteria["type"] = "ApplicationDeploymentRequest"
|
|
|
|
|
return self.list_records(criteria, all)
|
|
|
|
|
|
|
|
|
|
def app_deployments(self, criteria=None, all=True):
|
|
|
|
|
if criteria is None:
|
|
|
|
|
criteria = {}
|
|
|
|
|
criteria = criteria.copy()
|
|
|
|
|
criteria["type"] = "ApplicationDeploymentRecord"
|
|
|
|
|
return self.list_records(criteria, all)
|
|
|
|
|
|
|
|
|
|
def app_deployment_removal_requests(self, criteria=None, all=True):
|
|
|
|
|
if criteria is None:
|
|
|
|
|
criteria = {}
|
|
|
|
|
criteria = criteria.copy()
|
|
|
|
|
criteria["type"] = "ApplicationDeploymentRemovalRequest"
|
|
|
|
|
return self.list_records(criteria, all)
|
|
|
|
|
|
|
|
|
|
def app_deployment_removals(self, criteria=None, all=True):
|
|
|
|
|
if criteria is None:
|
|
|
|
|
criteria = {}
|
|
|
|
|
criteria = criteria.copy()
|
|
|
|
|
criteria["type"] = "ApplicationDeploymentRemovalRecord"
|
|
|
|
|
return self.list_records(criteria, all)
|
|
|
|
|
|
2024-10-21 07:02:06 +00:00
|
|
|
def webapp_deployers(self, criteria=None, all=True):
|
|
|
|
|
if criteria is None:
|
|
|
|
|
criteria = {}
|
|
|
|
|
criteria = criteria.copy()
|
|
|
|
|
criteria["type"] = "WebappDeployer"
|
|
|
|
|
return self.list_records(criteria, all)
|
|
|
|
|
|
|
|
|
|
def app_deployment_auctions(self, criteria=None, all=True):
|
|
|
|
|
if criteria is None:
|
|
|
|
|
criteria = {}
|
|
|
|
|
criteria = criteria.copy()
|
|
|
|
|
criteria["type"] = "ApplicationDeploymentAuction"
|
|
|
|
|
return self.list_records(criteria, all)
|
|
|
|
|
|
2024-10-25 08:40:54 +00:00
|
|
|
@registry_mutex()
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
def publish(self, record, names=None):
|
|
|
|
|
if names is None:
|
|
|
|
|
names = []
|
2023-12-14 04:56:40 +00:00
|
|
|
tmpdir = tempfile.mkdtemp()
|
|
|
|
|
try:
|
|
|
|
|
record_fname = os.path.join(tmpdir, "record.yml")
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
record_file = open(record_fname, "w")
|
2023-12-14 04:56:40 +00:00
|
|
|
yaml.dump(record, record_file)
|
|
|
|
|
record_file.close()
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
print(open(record_fname).read(), file=self.log_file)
|
2023-12-14 04:56:40 +00:00
|
|
|
|
|
|
|
|
new_record_id = json.loads(
|
2024-07-27 18:59:42 +00:00
|
|
|
logged_cmd(
|
|
|
|
|
self.log_file,
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
"laconic",
|
|
|
|
|
"-c",
|
2024-07-27 18:59:42 +00:00
|
|
|
self.config_file,
|
|
|
|
|
"registry",
|
|
|
|
|
"record",
|
|
|
|
|
"publish",
|
|
|
|
|
"--filename",
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
record_fname,
|
|
|
|
|
)
|
2023-12-14 04:56:40 +00:00
|
|
|
)["id"]
|
|
|
|
|
for name in names:
|
2023-12-22 00:05:40 +00:00
|
|
|
self.set_name(name, new_record_id)
|
2023-12-14 04:56:40 +00:00
|
|
|
return new_record_id
|
|
|
|
|
finally:
|
2024-02-22 01:24:44 +00:00
|
|
|
logged_cmd(self.log_file, "rm", "-rf", tmpdir)
|
2023-12-14 04:56:40 +00:00
|
|
|
|
2024-10-25 08:40:54 +00:00
|
|
|
@registry_mutex()
|
2023-12-22 00:05:40 +00:00
|
|
|
def set_name(self, name, record_id):
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
logged_cmd(
|
|
|
|
|
self.log_file,
|
|
|
|
|
"laconic",
|
|
|
|
|
"-c",
|
|
|
|
|
self.config_file,
|
|
|
|
|
"registry",
|
|
|
|
|
"name",
|
|
|
|
|
"set",
|
|
|
|
|
name,
|
|
|
|
|
record_id,
|
|
|
|
|
)
|
2023-12-22 00:05:40 +00:00
|
|
|
|
2024-10-25 08:40:54 +00:00
|
|
|
@registry_mutex()
|
2023-12-22 00:05:40 +00:00
|
|
|
def delete_name(self, name):
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
logged_cmd(
|
|
|
|
|
self.log_file,
|
|
|
|
|
"laconic",
|
|
|
|
|
"-c",
|
|
|
|
|
self.config_file,
|
|
|
|
|
"registry",
|
|
|
|
|
"name",
|
|
|
|
|
"delete",
|
|
|
|
|
name,
|
|
|
|
|
)
|
2023-12-22 00:05:40 +00:00
|
|
|
|
2024-10-25 08:40:54 +00:00
|
|
|
@registry_mutex()
|
2024-08-27 19:55:06 +00:00
|
|
|
def send_tokens(self, address, amount, type="alnt"):
|
|
|
|
|
args = [
|
|
|
|
|
"laconic",
|
|
|
|
|
"-c",
|
|
|
|
|
self.config_file,
|
|
|
|
|
"registry",
|
|
|
|
|
"tokens",
|
|
|
|
|
"send",
|
|
|
|
|
"--address",
|
|
|
|
|
address,
|
|
|
|
|
"--quantity",
|
|
|
|
|
str(amount),
|
|
|
|
|
"--type",
|
|
|
|
|
type,
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
return AttrDict(json.loads(logged_cmd(self.log_file, *args)))
|
|
|
|
|
|
2024-10-25 08:40:54 +00:00
|
|
|
@registry_mutex()
|
|
|
|
|
def create_deployment_auction(self, auction):
|
|
|
|
|
args = [
|
|
|
|
|
"laconic",
|
|
|
|
|
"-c",
|
|
|
|
|
self.config_file,
|
|
|
|
|
"registry",
|
|
|
|
|
"auction",
|
|
|
|
|
"create",
|
|
|
|
|
"--kind",
|
|
|
|
|
auction["kind"],
|
|
|
|
|
"--commits-duration",
|
|
|
|
|
str(auction["commits_duration"]),
|
|
|
|
|
"--reveals-duration",
|
|
|
|
|
str(auction["reveals_duration"]),
|
|
|
|
|
"--denom",
|
|
|
|
|
auction["denom"],
|
|
|
|
|
"--commit-fee",
|
|
|
|
|
str(auction["commit_fee"]),
|
|
|
|
|
"--reveal-fee",
|
|
|
|
|
str(auction["reveal_fee"]),
|
|
|
|
|
"--max-price",
|
|
|
|
|
str(auction["max_price"]),
|
|
|
|
|
"--num-providers",
|
2026-01-22 01:58:31 +00:00
|
|
|
str(auction["num_providers"]),
|
2024-10-25 08:40:54 +00:00
|
|
|
]
|
2024-10-21 07:02:06 +00:00
|
|
|
|
|
|
|
|
return json.loads(logged_cmd(self.log_file, *args))["auctionId"]
|
|
|
|
|
|
2024-10-25 08:40:54 +00:00
|
|
|
@registry_mutex()
|
2024-10-21 07:02:06 +00:00
|
|
|
def commit_bid(self, auction_id, amount, type="alnt"):
|
|
|
|
|
args = [
|
|
|
|
|
"laconic",
|
|
|
|
|
"-c",
|
|
|
|
|
self.config_file,
|
|
|
|
|
"registry",
|
|
|
|
|
"auction",
|
|
|
|
|
"bid",
|
|
|
|
|
"commit",
|
|
|
|
|
auction_id,
|
|
|
|
|
str(amount),
|
|
|
|
|
type,
|
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
return json.loads(logged_cmd(self.log_file, *args))["reveal_file"]
|
|
|
|
|
|
2024-10-25 08:40:54 +00:00
|
|
|
@registry_mutex()
|
2024-10-21 07:02:06 +00:00
|
|
|
def reveal_bid(self, auction_id, reveal_file_path):
|
|
|
|
|
logged_cmd(
|
|
|
|
|
self.log_file,
|
|
|
|
|
"laconic",
|
|
|
|
|
"-c",
|
|
|
|
|
self.config_file,
|
|
|
|
|
"registry",
|
|
|
|
|
"auction",
|
|
|
|
|
"bid",
|
|
|
|
|
"reveal",
|
|
|
|
|
auction_id,
|
|
|
|
|
reveal_file_path,
|
|
|
|
|
)
|
|
|
|
|
|
2023-12-14 04:56:40 +00:00
|
|
|
|
|
|
|
|
def file_hash(filename):
|
|
|
|
|
return hashlib.sha1(open(filename).read().encode()).hexdigest()
|
|
|
|
|
|
|
|
|
|
|
2024-02-03 00:04:06 +00:00
|
|
|
def determine_base_container(clone_dir, app_type="webapp"):
|
|
|
|
|
if not app_type or not app_type.startswith("webapp"):
|
|
|
|
|
raise Exception(f"Unsupported app_type {app_type}")
|
|
|
|
|
|
|
|
|
|
base_container = "cerc/webapp-base"
|
|
|
|
|
if app_type == "webapp/next":
|
|
|
|
|
base_container = "cerc/nextjs-base"
|
|
|
|
|
elif app_type == "webapp":
|
|
|
|
|
pkg_json_path = os.path.join(clone_dir, "package.json")
|
|
|
|
|
if os.path.exists(pkg_json_path):
|
|
|
|
|
pkg_json = json.load(open(pkg_json_path))
|
|
|
|
|
if "next" in pkg_json.get("dependencies", {}):
|
|
|
|
|
base_container = "cerc/nextjs-base"
|
|
|
|
|
|
|
|
|
|
return base_container
|
|
|
|
|
|
|
|
|
|
|
2026-01-22 06:10:36 +00:00
|
|
|
def build_container_image(
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
app_record: AttrDict | None,
|
2026-01-22 06:10:36 +00:00
|
|
|
tag: str,
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
extra_build_args: list[str] | None = None,
|
|
|
|
|
logger: TimedLogger | None = None,
|
2026-01-22 06:10:36 +00:00
|
|
|
) -> None:
|
|
|
|
|
if app_record is None:
|
|
|
|
|
raise ValueError("app_record cannot be None")
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
if extra_build_args is None:
|
|
|
|
|
extra_build_args = []
|
2023-12-14 04:56:40 +00:00
|
|
|
tmpdir = tempfile.mkdtemp()
|
|
|
|
|
|
2026-01-22 01:58:31 +00:00
|
|
|
# TODO: determine if this code could be calling into the Python git
|
|
|
|
|
# library like setup-repositories
|
2026-01-22 06:10:36 +00:00
|
|
|
log_file = logger.file if logger else None
|
2023-12-14 04:56:40 +00:00
|
|
|
try:
|
|
|
|
|
record_id = app_record["id"]
|
|
|
|
|
ref = app_record.attributes.repository_ref
|
|
|
|
|
repo = random.choice(app_record.attributes.repository)
|
|
|
|
|
clone_dir = os.path.join(tmpdir, record_id)
|
|
|
|
|
|
2026-01-22 06:10:36 +00:00
|
|
|
if logger:
|
|
|
|
|
logger.log(f"Cloning repository {repo} to {clone_dir} ...")
|
2024-07-05 12:27:22 +00:00
|
|
|
# Set github credentials if present running a command like:
|
2026-01-22 01:58:31 +00:00
|
|
|
# git config --global url."https://${TOKEN}:@github.com/".insteadOf
|
|
|
|
|
# "https://github.com/"
|
2024-07-05 12:27:22 +00:00
|
|
|
github_token = os.environ.get("DEPLOYER_GITHUB_TOKEN")
|
|
|
|
|
if github_token:
|
2026-01-22 06:10:36 +00:00
|
|
|
if logger:
|
|
|
|
|
logger.log("Github token detected, setting it in the git environment")
|
2024-07-05 12:27:22 +00:00
|
|
|
git_config_args = [
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
"git",
|
|
|
|
|
"config",
|
|
|
|
|
"--global",
|
|
|
|
|
f"url.https://{github_token}:@github.com/.insteadOf",
|
|
|
|
|
"https://github.com/",
|
|
|
|
|
]
|
2026-01-22 06:10:36 +00:00
|
|
|
result = subprocess.run(git_config_args, stdout=log_file, stderr=log_file)
|
2024-07-05 12:27:22 +00:00
|
|
|
result.check_returncode()
|
2023-12-14 04:56:40 +00:00
|
|
|
if ref:
|
|
|
|
|
# TODO: Determing branch or hash, and use depth 1 if we can.
|
2023-12-22 00:05:40 +00:00
|
|
|
git_env = dict(os.environ.copy())
|
|
|
|
|
# Never prompt
|
|
|
|
|
git_env["GIT_TERMINAL_PROMPT"] = "0"
|
2024-02-21 20:12:52 +00:00
|
|
|
try:
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
subprocess.check_call(
|
|
|
|
|
["git", "clone", repo, clone_dir],
|
|
|
|
|
env=git_env,
|
2026-01-22 06:10:36 +00:00
|
|
|
stdout=log_file,
|
|
|
|
|
stderr=log_file,
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
)
|
2024-02-21 20:12:52 +00:00
|
|
|
except Exception as e:
|
2026-01-22 06:10:36 +00:00
|
|
|
if logger:
|
|
|
|
|
logger.log(f"git clone failed. Is the repository {repo} private?")
|
2024-02-21 20:12:52 +00:00
|
|
|
raise e
|
|
|
|
|
try:
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
subprocess.check_call(
|
|
|
|
|
["git", "checkout", ref],
|
|
|
|
|
cwd=clone_dir,
|
|
|
|
|
env=git_env,
|
2026-01-22 06:10:36 +00:00
|
|
|
stdout=log_file,
|
|
|
|
|
stderr=log_file,
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
)
|
2024-02-21 20:12:52 +00:00
|
|
|
except Exception as e:
|
2026-01-22 06:10:36 +00:00
|
|
|
if logger:
|
|
|
|
|
logger.log(f"git checkout failed. Does ref {ref} exist?")
|
2024-02-21 20:12:52 +00:00
|
|
|
raise e
|
2023-12-14 04:56:40 +00:00
|
|
|
else:
|
2026-01-22 01:58:31 +00:00
|
|
|
# TODO: why is this code different vs the branch above (run vs check_call,
|
|
|
|
|
# and no prompt disable)?
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
result = subprocess.run(
|
|
|
|
|
["git", "clone", "--depth", "1", repo, clone_dir],
|
2026-01-22 06:10:36 +00:00
|
|
|
stdout=log_file,
|
|
|
|
|
stderr=log_file,
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
)
|
2023-12-14 04:56:40 +00:00
|
|
|
result.check_returncode()
|
|
|
|
|
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
base_container = determine_base_container(clone_dir, app_record.attributes.app_type)
|
2024-02-03 00:04:06 +00:00
|
|
|
|
2026-01-22 06:10:36 +00:00
|
|
|
if logger:
|
|
|
|
|
logger.log("Building webapp ...")
|
2024-02-03 00:04:06 +00:00
|
|
|
build_command = [
|
2024-02-28 00:38:11 +00:00
|
|
|
sys.argv[0],
|
|
|
|
|
"--verbose",
|
|
|
|
|
"build-webapp",
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
"--source-repo",
|
|
|
|
|
clone_dir,
|
|
|
|
|
"--tag",
|
|
|
|
|
tag,
|
|
|
|
|
"--base-container",
|
|
|
|
|
base_container,
|
2024-02-03 00:04:06 +00:00
|
|
|
]
|
2023-12-14 04:56:40 +00:00
|
|
|
if extra_build_args:
|
|
|
|
|
build_command.append("--extra-build-args")
|
|
|
|
|
build_command.append(" ".join(extra_build_args))
|
|
|
|
|
|
2026-01-22 06:10:36 +00:00
|
|
|
result = subprocess.run(build_command, stdout=log_file, stderr=log_file)
|
2023-12-14 04:56:40 +00:00
|
|
|
result.check_returncode()
|
|
|
|
|
finally:
|
2026-01-22 06:10:36 +00:00
|
|
|
logged_cmd(log_file, "rm", "-rf", tmpdir)
|
2023-12-14 04:56:40 +00:00
|
|
|
|
|
|
|
|
|
2024-02-28 00:38:11 +00:00
|
|
|
def push_container_image(deployment_dir, logger):
|
|
|
|
|
logger.log("Pushing images ...")
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
result = subprocess.run(
|
|
|
|
|
[sys.argv[0], "deployment", "--dir", deployment_dir, "push-images"],
|
|
|
|
|
stdout=logger.file,
|
|
|
|
|
stderr=logger.file,
|
|
|
|
|
)
|
2023-12-14 04:56:40 +00:00
|
|
|
result.check_returncode()
|
2024-02-28 00:38:11 +00:00
|
|
|
logger.log("Finished pushing images.")
|
2023-12-14 04:56:40 +00:00
|
|
|
|
|
|
|
|
|
2024-08-14 20:14:40 +00:00
|
|
|
def deploy_to_k8s(deploy_record, deployment_dir, recreate, logger):
|
|
|
|
|
logger.log("Deploying to k8s ...")
|
|
|
|
|
|
|
|
|
|
if recreate:
|
|
|
|
|
commands_to_run = ["stop", "start"]
|
2023-12-14 04:56:40 +00:00
|
|
|
else:
|
2024-08-14 20:14:40 +00:00
|
|
|
if not deploy_record:
|
|
|
|
|
commands_to_run = ["start"]
|
|
|
|
|
else:
|
2026-03-08 02:33:20 +00:00
|
|
|
commands_to_run = ["update-envs"]
|
2024-08-14 20:14:40 +00:00
|
|
|
|
|
|
|
|
for command in commands_to_run:
|
|
|
|
|
logger.log(f"Running {command} command on deployment dir: {deployment_dir}")
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
result = subprocess.run(
|
|
|
|
|
[sys.argv[0], "deployment", "--dir", deployment_dir, command],
|
|
|
|
|
stdout=logger.file,
|
|
|
|
|
stderr=logger.file,
|
|
|
|
|
)
|
2024-08-14 20:14:40 +00:00
|
|
|
result.check_returncode()
|
|
|
|
|
logger.log(f"Finished {command} command on deployment dir: {deployment_dir}")
|
2023-12-14 04:56:40 +00:00
|
|
|
|
2024-02-28 00:38:11 +00:00
|
|
|
logger.log("Finished deploying to k8s.")
|
2023-12-14 04:56:40 +00:00
|
|
|
|
|
|
|
|
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
def publish_deployment(
|
|
|
|
|
laconic: LaconicRegistryClient,
|
|
|
|
|
app_record,
|
|
|
|
|
deploy_record,
|
|
|
|
|
deployment_lrn,
|
|
|
|
|
dns_record,
|
|
|
|
|
dns_lrn,
|
|
|
|
|
deployment_dir,
|
2025-02-04 13:26:31 +00:00
|
|
|
dns_value=None,
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
app_deployment_request=None,
|
2024-08-27 19:55:06 +00:00
|
|
|
webapp_deployer_record=None,
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
logger=None,
|
|
|
|
|
):
|
2023-12-14 04:56:40 +00:00
|
|
|
if not deploy_record:
|
|
|
|
|
deploy_ver = "0.0.1"
|
|
|
|
|
else:
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
deploy_ver = f"0.0.{int(deploy_record.attributes.version.split('.')[-1]) + 1}"
|
2023-12-14 04:56:40 +00:00
|
|
|
|
|
|
|
|
if not dns_record:
|
|
|
|
|
dns_ver = "0.0.1"
|
|
|
|
|
else:
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
dns_ver = f"0.0.{int(dns_record.attributes.version.split('.')[-1]) + 1}"
|
2023-12-14 04:56:40 +00:00
|
|
|
|
|
|
|
|
spec = yaml.full_load(open(os.path.join(deployment_dir, "spec.yml")))
|
|
|
|
|
fqdn = spec["network"]["http-proxy"][0]["host-name"]
|
|
|
|
|
|
|
|
|
|
uniq = uuid.uuid4()
|
|
|
|
|
|
|
|
|
|
new_dns_record = {
|
|
|
|
|
"record": {
|
|
|
|
|
"type": "DnsRecord",
|
|
|
|
|
"version": dns_ver,
|
|
|
|
|
"name": fqdn,
|
|
|
|
|
"resource_type": "A",
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
"meta": {"so": uniq.hex},
|
2023-12-14 04:56:40 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if app_deployment_request:
|
|
|
|
|
new_dns_record["record"]["request"] = app_deployment_request.id
|
2025-02-04 13:26:31 +00:00
|
|
|
if dns_value:
|
|
|
|
|
new_dns_record["record"]["value"] = dns_value
|
2023-12-14 04:56:40 +00:00
|
|
|
|
2024-02-28 00:38:11 +00:00
|
|
|
if logger:
|
|
|
|
|
logger.log("Publishing DnsRecord.")
|
2024-07-27 18:59:42 +00:00
|
|
|
dns_id = laconic.publish(new_dns_record, [dns_lrn])
|
2023-12-14 04:56:40 +00:00
|
|
|
|
|
|
|
|
new_deployment_record = {
|
|
|
|
|
"record": {
|
|
|
|
|
"type": "ApplicationDeploymentRecord",
|
|
|
|
|
"version": deploy_ver,
|
|
|
|
|
"url": f"https://{fqdn}",
|
|
|
|
|
"name": app_record.attributes.name,
|
|
|
|
|
"application": app_record.id,
|
|
|
|
|
"dns": dns_id,
|
|
|
|
|
"meta": {
|
|
|
|
|
"config": file_hash(os.path.join(deployment_dir, "config.env")),
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
"so": uniq.hex,
|
2023-12-14 04:56:40 +00:00
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-10-21 07:02:06 +00:00
|
|
|
|
2023-12-14 04:56:40 +00:00
|
|
|
if app_deployment_request:
|
|
|
|
|
new_deployment_record["record"]["request"] = app_deployment_request.id
|
2024-10-21 07:02:06 +00:00
|
|
|
|
|
|
|
|
# Set auction or payment id from request
|
|
|
|
|
if app_deployment_request.attributes.auction:
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
new_deployment_record["record"]["auction"] = app_deployment_request.attributes.auction
|
2024-10-21 07:02:06 +00:00
|
|
|
elif app_deployment_request.attributes.payment:
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
new_deployment_record["record"]["payment"] = app_deployment_request.attributes.payment
|
Require payment for app deployment requests. (#928)
Adds three new options for deployment/undeployment:
```
"--min-required-payment",
help="Requests must have a minimum payment to be processed",
"--payment-address",
help="The address to which payments should be made. Default is the current laconic account.",
"--all-requests",
help="Handle requests addressed to anyone (by default only requests to my payment address are examined).",
```
In this mode, requests should be designated for a particular address with the attribute `to` and include a `payment` attribute which is the tx hash for the payment.
The deployer will confirm the payment (to the right account, right amount, not used before, etc.) and then proceed with the deployment or undeployment.
Reviewed-on: https://git.vdb.to/cerc-io/stack-orchestrator/pulls/928
Reviewed-by: David Boreham <dboreham@noreply.git.vdb.to>
Co-authored-by: Thomas E Lackey <telackey@bozemanpass.com>
Co-committed-by: Thomas E Lackey <telackey@bozemanpass.com>
2024-08-21 14:39:20 +00:00
|
|
|
|
2024-08-27 19:55:06 +00:00
|
|
|
if webapp_deployer_record:
|
|
|
|
|
new_deployment_record["record"]["deployer"] = webapp_deployer_record.names[0]
|
2023-12-14 04:56:40 +00:00
|
|
|
|
2024-02-28 00:38:11 +00:00
|
|
|
if logger:
|
|
|
|
|
logger.log("Publishing ApplicationDeploymentRecord.")
|
2024-07-27 18:59:42 +00:00
|
|
|
deployment_id = laconic.publish(new_deployment_record, [deployment_lrn])
|
2023-12-14 04:56:40 +00:00
|
|
|
return {"dns": dns_id, "deployment": deployment_id}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def hostname_for_deployment_request(app_deployment_request, laconic):
|
|
|
|
|
dns_name = app_deployment_request.attributes.dns
|
|
|
|
|
if not dns_name:
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
app = laconic.get_record(app_deployment_request.attributes.application, require=True)
|
2023-12-14 04:56:40 +00:00
|
|
|
dns_name = generate_hostname_for_app(app)
|
2024-07-27 18:59:42 +00:00
|
|
|
elif dns_name.startswith("lrn://"):
|
2023-12-14 04:56:40 +00:00
|
|
|
record = laconic.get_record(dns_name, require=True)
|
|
|
|
|
dns_name = record.attributes.name
|
|
|
|
|
return dns_name
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def generate_hostname_for_app(app):
|
|
|
|
|
last_part = app.attributes.name.split("/")[-1]
|
|
|
|
|
m = hashlib.sha256()
|
|
|
|
|
m.update(app.attributes.name.encode())
|
|
|
|
|
m.update(b"|")
|
|
|
|
|
if isinstance(app.attributes.repository, list):
|
|
|
|
|
m.update(app.attributes.repository[0].encode())
|
|
|
|
|
else:
|
|
|
|
|
m.update(app.attributes.repository.encode())
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
return f"{last_part}-{m.hexdigest()[0:10]}"
|
2024-02-07 21:45:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def skip_by_tag(r, include_tags, exclude_tags):
|
|
|
|
|
for tag in exclude_tags:
|
2024-02-08 20:38:41 +00:00
|
|
|
if r.attributes.tags and tag in r.attributes.tags:
|
2024-02-07 21:45:16 +00:00
|
|
|
return True
|
|
|
|
|
|
2024-02-08 20:38:41 +00:00
|
|
|
if include_tags:
|
|
|
|
|
for tag in include_tags:
|
|
|
|
|
if r.attributes.tags and tag in r.attributes.tags:
|
|
|
|
|
return False
|
|
|
|
|
return True
|
2024-02-07 21:45:16 +00:00
|
|
|
|
|
|
|
|
return False
|
2024-10-21 07:02:06 +00:00
|
|
|
|
|
|
|
|
|
2026-01-22 01:58:31 +00:00
|
|
|
def confirm_payment(
|
2026-01-22 06:10:36 +00:00
|
|
|
laconic: LaconicRegistryClient,
|
|
|
|
|
record: AttrDict,
|
|
|
|
|
payment_address: str,
|
|
|
|
|
min_amount: int,
|
|
|
|
|
logger: TimedLogger,
|
|
|
|
|
) -> bool:
|
2024-10-21 07:02:06 +00:00
|
|
|
req_owner = laconic.get_owner(record)
|
|
|
|
|
if req_owner == payment_address:
|
|
|
|
|
# No need to confirm payment if the sender and recipient are the same account.
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
if not record.attributes.payment:
|
|
|
|
|
logger.log(f"{record.id}: no payment tx info")
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
tx = laconic.get_tx(record.attributes.payment)
|
|
|
|
|
if not tx:
|
|
|
|
|
logger.log(f"{record.id}: cannot locate payment tx")
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
if tx.code != 0:
|
|
|
|
|
logger.log(
|
2026-01-22 01:58:31 +00:00
|
|
|
f"{record.id}: payment tx {tx.hash} was not successful - "
|
|
|
|
|
f"code: {tx.code}, log: {tx.log}"
|
2024-10-21 07:02:06 +00:00
|
|
|
)
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
if tx.sender != req_owner:
|
|
|
|
|
logger.log(
|
2026-01-22 01:58:31 +00:00
|
|
|
f"{record.id}: payment sender {tx.sender} in tx {tx.hash} "
|
|
|
|
|
f"does not match deployment request owner {req_owner}"
|
2024-10-21 07:02:06 +00:00
|
|
|
)
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
if tx.recipient != payment_address:
|
|
|
|
|
logger.log(
|
2026-01-22 01:58:31 +00:00
|
|
|
f"{record.id}: payment recipient {tx.recipient} in tx {tx.hash} "
|
|
|
|
|
f"does not match {payment_address}"
|
2024-10-21 07:02:06 +00:00
|
|
|
)
|
|
|
|
|
return False
|
|
|
|
|
|
2026-01-22 06:10:36 +00:00
|
|
|
tx_amount = tx.amount or ""
|
|
|
|
|
pay_denom = "".join([i for i in tx_amount if not i.isdigit()])
|
2024-10-21 07:02:06 +00:00
|
|
|
if pay_denom != "alnt":
|
|
|
|
|
logger.log(
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
f"{record.id}: {pay_denom} in tx {tx.hash} is not an expected " "payment denomination"
|
2024-10-21 07:02:06 +00:00
|
|
|
)
|
|
|
|
|
return False
|
|
|
|
|
|
2026-01-22 06:10:36 +00:00
|
|
|
pay_amount = int("".join([i for i in tx_amount if i.isdigit()]) or "0")
|
2024-10-21 07:02:06 +00:00
|
|
|
if pay_amount < min_amount:
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
logger.log(f"{record.id}: payment amount {tx.amount} is less than minimum {min_amount}")
|
2024-10-21 07:02:06 +00:00
|
|
|
return False
|
|
|
|
|
|
2024-10-29 06:51:48 +00:00
|
|
|
# Check if the payment was already used on a deployment
|
2024-10-21 07:02:06 +00:00
|
|
|
used = laconic.app_deployments(
|
2024-10-29 06:51:48 +00:00
|
|
|
{"deployer": record.attributes.deployer, "payment": tx.hash}, all=True
|
2024-10-21 07:02:06 +00:00
|
|
|
)
|
|
|
|
|
if len(used):
|
2024-10-29 11:30:03 +00:00
|
|
|
# Fetch the app name from request record
|
|
|
|
|
used_request = laconic.get_record(used[0].attributes.request, require=True)
|
|
|
|
|
|
2024-10-29 06:51:48 +00:00
|
|
|
# Check that payment was used for deployment of same application
|
2026-01-22 06:10:36 +00:00
|
|
|
used_app = used_request.attributes.application if used_request else None
|
|
|
|
|
if record.attributes.application != used_app:
|
2026-01-22 01:58:31 +00:00
|
|
|
logger.log(
|
|
|
|
|
f"{record.id}: payment {tx.hash} already used on a different "
|
|
|
|
|
f"application deployment {used}"
|
|
|
|
|
)
|
2024-10-29 06:51:48 +00:00
|
|
|
return False
|
2024-10-21 07:02:06 +00:00
|
|
|
|
|
|
|
|
used = laconic.app_deployment_removals(
|
2024-10-29 06:51:48 +00:00
|
|
|
{"deployer": record.attributes.deployer, "payment": tx.hash}, all=True
|
2024-10-21 07:02:06 +00:00
|
|
|
)
|
|
|
|
|
if len(used):
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
logger.log(f"{record.id}: payment {tx.hash} already used on deployment removal {used}")
|
2024-10-21 07:02:06 +00:00
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
2026-01-22 01:58:31 +00:00
|
|
|
def confirm_auction(
|
2026-01-22 06:10:36 +00:00
|
|
|
laconic: LaconicRegistryClient,
|
|
|
|
|
record: AttrDict,
|
|
|
|
|
deployer_lrn: str,
|
|
|
|
|
payment_address: str,
|
|
|
|
|
logger: TimedLogger,
|
|
|
|
|
) -> bool:
|
2024-10-21 07:02:06 +00:00
|
|
|
auction_id = record.attributes.auction
|
|
|
|
|
auction = laconic.get_auction(auction_id)
|
|
|
|
|
|
|
|
|
|
# Fetch auction record for given auction
|
|
|
|
|
auction_records_by_id = laconic.app_deployment_auctions({"auction": auction_id})
|
|
|
|
|
if len(auction_records_by_id) == 0:
|
|
|
|
|
logger.log(f"{record.id}: unable to locate record for auction {auction_id}")
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# Cross check app against application in the auction record
|
|
|
|
|
requested_app = laconic.get_record(record.attributes.application, require=True)
|
fix: add pre-commit hooks and fix all lint/type/format errors
Process bug fix: no pre-commit existed for this repo's Python code.
Added pyproject.toml with unified dependencies (ruff, mypy, ansible-lint),
.pre-commit-config.yaml with repo-based hooks (ruff) and local uv-run
hooks (mypy, ansible-lint).
Fixed 249 ruff errors (B023, B904, B006, B007, UP008, UP031, C408),
~13 mypy type errors, 11 ansible-lint violations, and ruff-format
across all Python files including stack-orchestrator subtree.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-10 14:56:22 +00:00
|
|
|
auction_app = laconic.get_record(auction_records_by_id[0].attributes.application, require=True)
|
2026-01-22 06:10:36 +00:00
|
|
|
requested_app_id = requested_app.id if requested_app else None
|
|
|
|
|
auction_app_id = auction_app.id if auction_app else None
|
|
|
|
|
if requested_app_id != auction_app_id:
|
2024-10-21 07:02:06 +00:00
|
|
|
logger.log(
|
2026-01-22 01:58:31 +00:00
|
|
|
f"{record.id}: requested application {record.attributes.application} "
|
|
|
|
|
f"does not match application from auction record "
|
|
|
|
|
f"{auction_records_by_id[0].attributes.application}"
|
2024-10-21 07:02:06 +00:00
|
|
|
)
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
if not auction:
|
|
|
|
|
logger.log(f"{record.id}: unable to locate auction {auction_id}")
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
# Check if the deployer payment address is in auction winners list
|
|
|
|
|
if payment_address not in auction.winnerAddresses:
|
|
|
|
|
logger.log(f"{record.id}: deployer payment address not in auction winners.")
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
return True
|