forked from cerc-io/stack-orchestrator
Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8684f64eb6 | ||
|
|
525d7ee49b |
@@ -75,6 +75,8 @@ services:
|
|||||||
uni-watcher-server:
|
uni-watcher-server:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
|
ipld-eth-server:
|
||||||
|
condition: service_healthy
|
||||||
uniswap-watcher-db:
|
uniswap-watcher-db:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
uni-watcher-job-runner:
|
uni-watcher-job-runner:
|
||||||
|
|||||||
@@ -23,8 +23,8 @@
|
|||||||
|
|
||||||
[upstream]
|
[upstream]
|
||||||
[upstream.ethServer]
|
[upstream.ethServer]
|
||||||
gqlApiEndpoint = "http://ipld-eth-server.example.com:8083/graphql"
|
gqlApiEndpoint = "http://ipld-eth-server:8082/graphql"
|
||||||
rpcProviderEndpoint = "http://ipld-eth-server.example.com:8082"
|
rpcProviderEndpoint = "http://ipld-eth-server:8081"
|
||||||
|
|
||||||
[upstream.cache]
|
[upstream.cache]
|
||||||
name = "requests"
|
name = "requests"
|
||||||
|
|||||||
@@ -63,8 +63,8 @@
|
|||||||
|
|
||||||
[upstream]
|
[upstream]
|
||||||
[upstream.ethServer]
|
[upstream.ethServer]
|
||||||
gqlApiEndpoint = "http://ipld-eth-server.example.com:8083/graphql"
|
gqlApiEndpoint = "http://ipld-eth-server:8082/graphql"
|
||||||
rpcProviderEndpoint = "http://ipld-eth-server.example.com:8082"
|
rpcProviderEndpoint = "http://ipld-eth-server:8081"
|
||||||
|
|
||||||
[upstream.cache]
|
[upstream.cache]
|
||||||
name = "requests"
|
name = "requests"
|
||||||
|
|||||||
@@ -22,8 +22,8 @@
|
|||||||
|
|
||||||
[upstream]
|
[upstream]
|
||||||
[upstream.ethServer]
|
[upstream.ethServer]
|
||||||
gqlApiEndpoint = "http://ipld-eth-server.example.com:8083/graphql"
|
gqlApiEndpoint = "http://ipld-eth-server:8082/graphql"
|
||||||
rpcProviderEndpoint = "http://ipld-eth-server.example.com:8082"
|
rpcProviderEndpoint = "http://ipld-eth-server:8081"
|
||||||
|
|
||||||
[upstream.cache]
|
[upstream.cache]
|
||||||
name = "requests"
|
name = "requests"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
ARG TAG_SUFFIX="-modern"
|
ARG TAG_SUFFIX="-modern"
|
||||||
FROM sigp/lighthouse:v4.3.0${TAG_SUFFIX}
|
FROM sigp/lighthouse:v4.1.0${TAG_SUFFIX}
|
||||||
|
|
||||||
RUN apt-get update; apt-get install bash netcat curl less jq -y;
|
RUN apt-get update; apt-get install bash netcat curl less jq -y;
|
||||||
|
|
||||||
|
|||||||
@@ -13,10 +13,9 @@
|
|||||||
# You should have received a copy of the GNU Affero General Public License
|
# 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/>.
|
# along with this program. If not, see <http:#www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from dataclasses import dataclass
|
||||||
from app.util import get_yaml
|
from app.util import get_yaml
|
||||||
from app.deploy_types import DeployCommandContext, DeploymentContext
|
|
||||||
from app.stack_state import State
|
from app.stack_state import State
|
||||||
from app.deploy_util import VolumeMapping, run_container_command
|
|
||||||
|
|
||||||
default_spec_file_content = """config:
|
default_spec_file_content = """config:
|
||||||
node_moniker: my-node-name
|
node_moniker: my-node-name
|
||||||
@@ -26,26 +25,38 @@ default_spec_file_content = """config:
|
|||||||
init_help_text = """Add helpful text here on setting config variables.
|
init_help_text = """Add helpful text here on setting config variables.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
@dataclass
|
||||||
|
class VolumeMapping:
|
||||||
|
host_path: str
|
||||||
|
container_path: str
|
||||||
|
|
||||||
def setup(command_context: DeployCommandContext):
|
|
||||||
|
# In order to make this, we need the ability to run the stack
|
||||||
|
# In theory we can make this same way as we would run deploy up
|
||||||
|
def run_container_command(ctx, ontainer, command, mounts):
|
||||||
|
deploy_context = ctx.obj
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def setup(ctx):
|
||||||
node_moniker = "dbdb-node"
|
node_moniker = "dbdb-node"
|
||||||
chain_id = "laconic_81337-1"
|
chain_id = "laconic_81337-1"
|
||||||
mounts = [
|
mounts = [
|
||||||
VolumeMapping("./path", "~/.laconicd")
|
VolumeMapping("./path", "~/.laconicd")
|
||||||
]
|
]
|
||||||
output, status = run_container_command(command_context.cluster_context, "laconicd", f"laconicd init {node_moniker} --chain-id {chain_id}", mounts)
|
output, status = run_container_command(ctx, "laconicd", f"laconicd init {node_moniker} --chain-id {chain_id}", mounts)
|
||||||
|
|
||||||
|
|
||||||
def init(command_context: DeployCommandContext):
|
def init(command_context):
|
||||||
print(init_help_text)
|
print(init_help_text)
|
||||||
yaml = get_yaml()
|
yaml = get_yaml()
|
||||||
return yaml.load(default_spec_file_content)
|
return yaml.load(default_spec_file_content)
|
||||||
|
|
||||||
|
|
||||||
def get_state(command_context: DeployCommandContext):
|
def get_state(command_context):
|
||||||
print("Here we get state")
|
print("Here we get state")
|
||||||
return State.CONFIGURED
|
return State.CONFIGURED
|
||||||
|
|
||||||
|
|
||||||
def change_state(command_context: DeployCommandContext):
|
def change_state(command_context):
|
||||||
pass
|
pass
|
||||||
|
|||||||
@@ -1,54 +0,0 @@
|
|||||||
# Copyright © 2022, 2023 Cerc
|
|
||||||
|
|
||||||
# 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/>.
|
|
||||||
|
|
||||||
from app.util import get_yaml
|
|
||||||
from app.deploy_types import DeployCommandContext, DeploymentContext
|
|
||||||
from app.stack_state import State
|
|
||||||
from app.deploy_util import VolumeMapping, run_container_command
|
|
||||||
import os
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
default_spec_file_content = """config:
|
|
||||||
config_variable: test-value
|
|
||||||
"""
|
|
||||||
|
|
||||||
init_help_text = """Add helpful text here on setting config variables.
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Output a known string to a know file in the bind mounted directory ./container-output-dir
|
|
||||||
# for test purposes -- test checks that the file was written.
|
|
||||||
def setup(command_context: DeployCommandContext, extra_args):
|
|
||||||
host_directory = "./container-output-dir"
|
|
||||||
host_directory_absolute = Path(extra_args[0]).absolute().joinpath(host_directory)
|
|
||||||
host_directory_absolute.mkdir(parents=True, exist_ok=True)
|
|
||||||
mounts = [
|
|
||||||
VolumeMapping(host_directory_absolute, "/data")
|
|
||||||
]
|
|
||||||
output, status = run_container_command(command_context, "test", "echo output-data > /data/output-file && echo success", mounts)
|
|
||||||
|
|
||||||
|
|
||||||
def init(command_context: DeployCommandContext):
|
|
||||||
print(init_help_text)
|
|
||||||
yaml = get_yaml()
|
|
||||||
return yaml.load(default_spec_file_content)
|
|
||||||
|
|
||||||
|
|
||||||
def get_state(command_context: DeployCommandContext):
|
|
||||||
print("Here we get state")
|
|
||||||
return State.CONFIGURED
|
|
||||||
|
|
||||||
|
|
||||||
def change_state(command_context: DeployCommandContext):
|
|
||||||
pass
|
|
||||||
@@ -22,13 +22,13 @@ Instructions to deploy Uniswap v3 watcher stack (watcher + uniswap-v3-info front
|
|||||||
* Clone / pull required repositories:
|
* Clone / pull required repositories:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ laconic-so setup-repositories --include vulcanize/uniswap-watcher-ts,vulcanize/uniswap-v3-info --git-ssh --pull
|
$ laconic-so --stack uniswap-v3 setup-repositories
|
||||||
```
|
```
|
||||||
|
|
||||||
* Build watcher and info app container images:
|
* Build watcher and info app container images:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
$ laconic-so build-containers --include cerc/watcher-uniswap-v3,cerc/uniswap-v3-info
|
$ laconic-so --stack uniswap-v3 build-containers
|
||||||
```
|
```
|
||||||
|
|
||||||
This should create the required docker images in the local image registry.
|
This should create the required docker images in the local image registry.
|
||||||
|
|||||||
@@ -3,8 +3,14 @@ name: uniswap-v3
|
|||||||
repos:
|
repos:
|
||||||
- github.com/vulcanize/uniswap-watcher-ts
|
- github.com/vulcanize/uniswap-watcher-ts
|
||||||
- github.com/vulcanize/uniswap-v3-info
|
- github.com/vulcanize/uniswap-v3-info
|
||||||
|
- github.com/cerc-io/ipld-eth-db
|
||||||
|
- github.com/cerc-io/ipld-eth-server
|
||||||
containers:
|
containers:
|
||||||
- cerc/watcher-uniswap-v3
|
- cerc/watcher-uniswap-v3
|
||||||
- cerc/uniswap-v3-info
|
- cerc/uniswap-v3-info
|
||||||
|
- cerc/ipld-eth-db
|
||||||
|
- cerc/ipld-eth-server
|
||||||
pods:
|
pods:
|
||||||
- watcher-uniswap-v3
|
- watcher-uniswap-v3
|
||||||
|
- ipld-eth-db
|
||||||
|
- ipld-eth-server
|
||||||
|
|||||||
+18
-3
@@ -27,12 +27,17 @@ from python_on_whales import DockerClient, DockerException
|
|||||||
import click
|
import click
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from app.util import include_exclude_check, get_parsed_stack_config, global_options2
|
from app.util import include_exclude_check, get_parsed_stack_config, global_options2
|
||||||
from app.deploy_types import ClusterContext, DeployCommandContext
|
|
||||||
from app.deployment_create import create as deployment_create
|
from app.deployment_create import create as deployment_create
|
||||||
from app.deployment_create import init as deployment_init
|
from app.deployment_create import init as deployment_init
|
||||||
from app.deployment_create import setup as deployment_setup
|
from app.deployment_create import setup as deployment_setup
|
||||||
|
|
||||||
|
|
||||||
|
class DeployCommandContext(object):
|
||||||
|
def __init__(self, cluster_context, docker):
|
||||||
|
self.cluster_context = cluster_context
|
||||||
|
self.docker = docker
|
||||||
|
|
||||||
|
|
||||||
@click.group()
|
@click.group()
|
||||||
@click.option("--include", help="only start these components")
|
@click.option("--include", help="only start these components")
|
||||||
@click.option("--exclude", help="don\'t start these components")
|
@click.option("--exclude", help="don\'t start these components")
|
||||||
@@ -53,7 +58,7 @@ def create_deploy_context(global_context, stack, include, exclude, cluster, env_
|
|||||||
# See: https://gabrieldemarmiesse.github.io/python-on-whales/sub-commands/compose/
|
# See: https://gabrieldemarmiesse.github.io/python-on-whales/sub-commands/compose/
|
||||||
docker = DockerClient(compose_files=cluster_context.compose_files, compose_project_name=cluster_context.cluster,
|
docker = DockerClient(compose_files=cluster_context.compose_files, compose_project_name=cluster_context.cluster,
|
||||||
compose_env_file=cluster_context.env_file)
|
compose_env_file=cluster_context.env_file)
|
||||||
return DeployCommandContext(stack, cluster_context, docker)
|
return DeployCommandContext(cluster_context, docker)
|
||||||
|
|
||||||
|
|
||||||
def up_operation(ctx, services_list, stay_attached=False):
|
def up_operation(ctx, services_list, stay_attached=False):
|
||||||
@@ -308,7 +313,17 @@ def _make_cluster_context(ctx, stack, include, exclude, cluster, env_file):
|
|||||||
if ctx.verbose:
|
if ctx.verbose:
|
||||||
print(f"files: {compose_files}")
|
print(f"files: {compose_files}")
|
||||||
|
|
||||||
return ClusterContext(cluster, compose_files, pre_start_commands, post_start_commands, cluster_config, env_file)
|
return cluster_context(cluster, compose_files, pre_start_commands, post_start_commands, cluster_config, env_file)
|
||||||
|
|
||||||
|
|
||||||
|
class cluster_context:
|
||||||
|
def __init__(self, cluster, compose_files, pre_start_commands, post_start_commands, config, env_file) -> None:
|
||||||
|
self.cluster = cluster
|
||||||
|
self.compose_files = compose_files
|
||||||
|
self.pre_start_commands = pre_start_commands
|
||||||
|
self.post_start_commands = post_start_commands
|
||||||
|
self.config = config
|
||||||
|
self.env_file = env_file
|
||||||
|
|
||||||
|
|
||||||
def _convert_to_new_format(old_pod_array):
|
def _convert_to_new_format(old_pod_array):
|
||||||
|
|||||||
@@ -1,47 +0,0 @@
|
|||||||
# Copyright © 2023 Cerc
|
|
||||||
|
|
||||||
# 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/>.
|
|
||||||
|
|
||||||
from typing import List
|
|
||||||
from dataclasses import dataclass
|
|
||||||
from pathlib import Path
|
|
||||||
from python_on_whales import DockerClient
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class ClusterContext:
|
|
||||||
cluster: str
|
|
||||||
compose_files: List[str]
|
|
||||||
pre_start_commands: List[str]
|
|
||||||
post_start_commands: List[str]
|
|
||||||
config: str
|
|
||||||
env_file: str
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class DeployCommandContext:
|
|
||||||
stack: str
|
|
||||||
cluster_context: ClusterContext
|
|
||||||
docker: DockerClient
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class DeploymentContext:
|
|
||||||
deployment_dir: Path
|
|
||||||
command_context: DeployCommandContext
|
|
||||||
|
|
||||||
|
|
||||||
@dataclass
|
|
||||||
class VolumeMapping:
|
|
||||||
host_path: str
|
|
||||||
container_path: str
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
# Copyright © 2022, 2023 Cerc
|
|
||||||
|
|
||||||
# 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/>.
|
|
||||||
|
|
||||||
import os
|
|
||||||
from typing import List
|
|
||||||
from dataclasses import dataclass
|
|
||||||
from app.deploy_types import DeployCommandContext, VolumeMapping
|
|
||||||
from app.util import get_parsed_stack_config, get_yaml, get_compose_file_dir
|
|
||||||
|
|
||||||
|
|
||||||
def _container_image_from_service(stack:str, service: str):
|
|
||||||
# Parse the compose files looking for the image name of the specified service
|
|
||||||
image_name = None
|
|
||||||
parsed_stack = get_parsed_stack_config(stack)
|
|
||||||
pods = parsed_stack["pods"]
|
|
||||||
yaml = get_yaml()
|
|
||||||
for pod in pods:
|
|
||||||
pod_file_path = os.path.join(get_compose_file_dir(), f"docker-compose-{pod}.yml")
|
|
||||||
parsed_pod_file = yaml.load(open(pod_file_path, "r"))
|
|
||||||
if "services" in parsed_pod_file:
|
|
||||||
services = parsed_pod_file["services"]
|
|
||||||
if service in services:
|
|
||||||
service_definition = services[service]
|
|
||||||
if "image" in service_definition:
|
|
||||||
image_name = service_definition["image"]
|
|
||||||
return image_name
|
|
||||||
|
|
||||||
|
|
||||||
def _volumes_to_docker(mounts: List[VolumeMapping]):
|
|
||||||
# Example from doc: [("/", "/host"), ("/etc/hosts", "/etc/hosts", "rw")]
|
|
||||||
result = []
|
|
||||||
for mount in mounts:
|
|
||||||
docker_volume = (mount.host_path, mount.container_path)
|
|
||||||
result.append(docker_volume)
|
|
||||||
return result
|
|
||||||
|
|
||||||
|
|
||||||
def run_container_command(ctx: DeployCommandContext, service: str, command: str, mounts: List[VolumeMapping]):
|
|
||||||
docker = ctx.docker
|
|
||||||
container_image = _container_image_from_service(ctx.stack, service)
|
|
||||||
docker_volumes = _volumes_to_docker(mounts)
|
|
||||||
docker_output = docker.run(container_image, ["-c", command], entrypoint="bash", volumes=docker_volumes)
|
|
||||||
# There doesn't seem to be a way to get an exit code from docker.run()
|
|
||||||
return (docker_output, 0)
|
|
||||||
+26
-14
@@ -20,14 +20,26 @@ import os
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from shutil import copyfile, copytree
|
from shutil import copyfile, copytree
|
||||||
import sys
|
import sys
|
||||||
from app.util import get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options, get_yaml, get_compose_file_dir
|
from app.util import get_stack_file_path, get_parsed_deployment_spec, get_parsed_stack_config, global_options, get_yaml
|
||||||
from app.deploy_types import DeploymentContext, DeployCommandContext
|
|
||||||
|
@dataclass
|
||||||
|
class DeploymentContext:
|
||||||
|
stack: str
|
||||||
|
deployment_dir: Path
|
||||||
|
|
||||||
|
|
||||||
def _make_default_deployment_dir():
|
def _make_default_deployment_dir():
|
||||||
return "deployment-001"
|
return "deployment-001"
|
||||||
|
|
||||||
|
|
||||||
|
def _get_compose_file_dir():
|
||||||
|
# TODO: refactor to use common code with deploy command
|
||||||
|
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
||||||
|
data_dir = Path(__file__).absolute().parent.joinpath("data")
|
||||||
|
source_compose_dir = data_dir.joinpath("compose")
|
||||||
|
return source_compose_dir
|
||||||
|
|
||||||
|
|
||||||
def _get_named_volumes(stack):
|
def _get_named_volumes(stack):
|
||||||
# Parse the compose files looking for named volumes
|
# Parse the compose files looking for named volumes
|
||||||
named_volumes = []
|
named_volumes = []
|
||||||
@@ -35,7 +47,7 @@ def _get_named_volumes(stack):
|
|||||||
pods = parsed_stack["pods"]
|
pods = parsed_stack["pods"]
|
||||||
yaml = get_yaml()
|
yaml = get_yaml()
|
||||||
for pod in pods:
|
for pod in pods:
|
||||||
pod_file_path = os.path.join(get_compose_file_dir(), f"docker-compose-{pod}.yml")
|
pod_file_path = os.path.join(_get_compose_file_dir(), f"docker-compose-{pod}.yml")
|
||||||
parsed_pod_file = yaml.load(open(pod_file_path, "r"))
|
parsed_pod_file = yaml.load(open(pod_file_path, "r"))
|
||||||
if "volumes" in parsed_pod_file:
|
if "volumes" in parsed_pod_file:
|
||||||
volumes = parsed_pod_file["volumes"]
|
volumes = parsed_pod_file["volumes"]
|
||||||
@@ -82,27 +94,27 @@ def _fixup_pod_file(pod, spec, compose_dir):
|
|||||||
pod["volumes"][volume] = new_volume_spec
|
pod["volumes"][volume] = new_volume_spec
|
||||||
|
|
||||||
|
|
||||||
def call_stack_deploy_init(deploy_command_context):
|
def call_stack_deploy_init(stack):
|
||||||
# Link with the python file in the stack
|
# Link with the python file in the stack
|
||||||
# Call a function in it
|
# Call a function in it
|
||||||
# If no function found, return None
|
# If no function found, return None
|
||||||
python_file_path = get_stack_file_path(deploy_command_context.stack).parent.joinpath("deploy", "commands.py")
|
python_file_path = get_stack_file_path(stack).parent.joinpath("deploy", "commands.py")
|
||||||
spec = util.spec_from_file_location("commands", python_file_path)
|
spec = util.spec_from_file_location("commands", python_file_path)
|
||||||
imported_stack = util.module_from_spec(spec)
|
imported_stack = util.module_from_spec(spec)
|
||||||
spec.loader.exec_module(imported_stack)
|
spec.loader.exec_module(imported_stack)
|
||||||
return imported_stack.init(deploy_command_context)
|
return imported_stack.init(None)
|
||||||
|
|
||||||
|
|
||||||
# TODO: fold this with function above
|
# TODO: fold this with function above
|
||||||
def call_stack_deploy_setup(deploy_command_context, extra_args):
|
def call_stack_deploy_setup(stack):
|
||||||
# Link with the python file in the stack
|
# Link with the python file in the stack
|
||||||
# Call a function in it
|
# Call a function in it
|
||||||
# If no function found, return None
|
# If no function found, return None
|
||||||
python_file_path = get_stack_file_path(deploy_command_context.stack).parent.joinpath("deploy", "commands.py")
|
python_file_path = get_stack_file_path(stack).parent.joinpath("deploy", "commands.py")
|
||||||
spec = util.spec_from_file_location("commands", python_file_path)
|
spec = util.spec_from_file_location("commands", python_file_path)
|
||||||
imported_stack = util.module_from_spec(spec)
|
imported_stack = util.module_from_spec(spec)
|
||||||
spec.loader.exec_module(imported_stack)
|
spec.loader.exec_module(imported_stack)
|
||||||
return imported_stack.setup(deploy_command_context, extra_args)
|
return imported_stack.setup(None)
|
||||||
|
|
||||||
|
|
||||||
# TODO: fold this with function above
|
# TODO: fold this with function above
|
||||||
@@ -142,7 +154,7 @@ def init(ctx, output):
|
|||||||
yaml = get_yaml()
|
yaml = get_yaml()
|
||||||
stack = global_options(ctx).stack
|
stack = global_options(ctx).stack
|
||||||
verbose = global_options(ctx).verbose
|
verbose = global_options(ctx).verbose
|
||||||
default_spec_file_content = call_stack_deploy_init(ctx.obj)
|
default_spec_file_content = call_stack_deploy_init(stack)
|
||||||
spec_file_content = {"stack": stack}
|
spec_file_content = {"stack": stack}
|
||||||
if default_spec_file_content:
|
if default_spec_file_content:
|
||||||
spec_file_content.update(default_spec_file_content)
|
spec_file_content.update(default_spec_file_content)
|
||||||
@@ -205,7 +217,7 @@ def create(ctx, spec_file, deployment_dir):
|
|||||||
if not os.path.exists(destination_config_dir):
|
if not os.path.exists(destination_config_dir):
|
||||||
copytree(source_config_dir, destination_config_dir)
|
copytree(source_config_dir, destination_config_dir)
|
||||||
# Delegate to the stack's Python code
|
# Delegate to the stack's Python code
|
||||||
deployment_context = DeploymentContext(Path(deployment_dir), ctx.obj)
|
deployment_context = DeploymentContext(stack_name, Path(deployment_dir))
|
||||||
call_stack_deploy_create(deployment_context)
|
call_stack_deploy_create(deployment_context)
|
||||||
|
|
||||||
|
|
||||||
@@ -215,7 +227,7 @@ def create(ctx, spec_file, deployment_dir):
|
|||||||
@click.option("--initialize-network", is_flag=True, default=False, help="Help goes here")
|
@click.option("--initialize-network", is_flag=True, default=False, help="Help goes here")
|
||||||
@click.option("--join-network", is_flag=True, default=False, help="Help goes here")
|
@click.option("--join-network", is_flag=True, default=False, help="Help goes here")
|
||||||
@click.option("--create-network", is_flag=True, default=False, help="Help goes here")
|
@click.option("--create-network", is_flag=True, default=False, help="Help goes here")
|
||||||
@click.argument('extra_args', nargs=-1)
|
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
def setup(ctx, node_moniker, key_name, initialize_network, join_network, create_network, extra_args):
|
def setup(ctx, node_moniker, key_name, initialize_network, join_network, create_network):
|
||||||
call_stack_deploy_setup(ctx.obj, extra_args)
|
stack = global_options(ctx).stack
|
||||||
|
call_stack_deploy_setup(stack)
|
||||||
|
|||||||
@@ -56,14 +56,6 @@ def get_parsed_stack_config(stack):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def get_compose_file_dir():
|
|
||||||
# TODO: refactor to use common code with deploy command
|
|
||||||
# See: https://stackoverflow.com/questions/25389095/python-get-path-of-root-project-structure
|
|
||||||
data_dir = Path(__file__).absolute().parent.joinpath("data")
|
|
||||||
source_compose_dir = data_dir.joinpath("compose")
|
|
||||||
return source_compose_dir
|
|
||||||
|
|
||||||
|
|
||||||
def get_parsed_deployment_spec(spec_file):
|
def get_parsed_deployment_spec(spec_file):
|
||||||
spec_file_path = Path(spec_file)
|
spec_file_path = Path(spec_file)
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -23,26 +23,6 @@ mkdir -p $CERC_REPO_BASE_DIR
|
|||||||
# with and without volume removal
|
# with and without volume removal
|
||||||
$TEST_TARGET_SO --stack test setup-repositories
|
$TEST_TARGET_SO --stack test setup-repositories
|
||||||
$TEST_TARGET_SO --stack test build-containers
|
$TEST_TARGET_SO --stack test build-containers
|
||||||
# Test deploy command execution
|
|
||||||
$TEST_TARGET_SO --stack test deploy setup $CERC_REPO_BASE_DIR
|
|
||||||
# Check that we now have the expected output directory
|
|
||||||
if [ ! -d "$CERC_REPO_BASE_DIR/container-output-dir" ]; then
|
|
||||||
echo "deploy setup test: output directory not present"
|
|
||||||
echo "deploy setup test: FAILED"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
if [ ! -f "$CERC_REPO_BASE_DIR/container-output-dir/output-file" ]; then
|
|
||||||
echo "deploy setup test: output file not present"
|
|
||||||
echo "deploy setup test: FAILED"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
output_file_content=$(<$CERC_REPO_BASE_DIR/container-output-dir/output-file)
|
|
||||||
if [ ! "$output_file_content" == "output-data" ]; then
|
|
||||||
echo "deploy setup test: output file contents not correct"
|
|
||||||
echo "deploy setup test: FAILED"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# Check that we now have the expected output file
|
|
||||||
$TEST_TARGET_SO --stack test deploy up
|
$TEST_TARGET_SO --stack test deploy up
|
||||||
# Test deploy port command
|
# Test deploy port command
|
||||||
deploy_port_output=$( $TEST_TARGET_SO --stack test deploy port test 80 )
|
deploy_port_output=$( $TEST_TARGET_SO --stack test deploy port test 80 )
|
||||||
|
|||||||
Reference in New Issue
Block a user