Add deploy setup command
This commit is contained in:
parent
43d9861508
commit
dcfd7e3d45
@ -13,6 +13,7 @@
|
|||||||
# 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.stack_state import State
|
from app.stack_state import State
|
||||||
|
|
||||||
@ -24,6 +25,27 @@ 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
|
||||||
|
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
chain_id = "laconic_81337-1"
|
||||||
|
mounts = [
|
||||||
|
VolumeMapping("./path", "~/.laconicd")
|
||||||
|
]
|
||||||
|
output, status = run_container_command(ctx, "laconicd", f"laconicd init {node_moniker} --chain-id {chain_id}", mounts)
|
||||||
|
|
||||||
|
|
||||||
def init(command_context):
|
def init(command_context):
|
||||||
print(init_help_text)
|
print(init_help_text)
|
||||||
@ -34,3 +56,7 @@ def init(command_context):
|
|||||||
def get_state(command_context):
|
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):
|
||||||
|
pass
|
||||||
|
@ -29,6 +29,7 @@ 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.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
|
||||||
|
|
||||||
|
|
||||||
class DeployCommandContext(object):
|
class DeployCommandContext(object):
|
||||||
@ -420,3 +421,4 @@ def _orchestrate_cluster_config(ctx, cluster_config, docker, container_exec_env)
|
|||||||
|
|
||||||
command.add_command(deployment_init)
|
command.add_command(deployment_init)
|
||||||
command.add_command(deployment_create)
|
command.add_command(deployment_create)
|
||||||
|
command.add_command(deployment_setup)
|
||||||
|
@ -126,15 +126,3 @@ def logs(ctx, extra_args):
|
|||||||
@click.pass_context
|
@click.pass_context
|
||||||
def status(ctx):
|
def status(ctx):
|
||||||
print(f"Context: {ctx.parent.obj}")
|
print(f"Context: {ctx.parent.obj}")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#from importlib import resources, util
|
|
||||||
# TODO: figure out how to do this dynamically
|
|
||||||
#stack = "mainnet-laconic"
|
|
||||||
#module_name = "commands"
|
|
||||||
#spec = util.spec_from_file_location(module_name, "./app/data/stacks/" + stack + "/deploy/commands.py")
|
|
||||||
#imported_stack = util.module_from_spec(spec)
|
|
||||||
#spec.loader.exec_module(imported_stack)
|
|
||||||
#command.add_command(imported_stack.init)
|
|
||||||
#command.add_command(imported_stack.create)
|
|
||||||
|
@ -99,6 +99,18 @@ def call_stack_deploy_init(stack):
|
|||||||
return imported_stack.init(None)
|
return imported_stack.init(None)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: fold this with function above
|
||||||
|
def call_stack_deploy_setup(stack):
|
||||||
|
# Link with the python file in the stack
|
||||||
|
# Call a function in it
|
||||||
|
# If no function found, return None
|
||||||
|
python_file_path = get_stack_file_path(stack).parent.joinpath("deploy", "commands.py")
|
||||||
|
spec = util.spec_from_file_location("commands", python_file_path)
|
||||||
|
imported_stack = util.module_from_spec(spec)
|
||||||
|
spec.loader.exec_module(imported_stack)
|
||||||
|
return imported_stack.setup(None)
|
||||||
|
|
||||||
|
|
||||||
@click.command()
|
@click.command()
|
||||||
@click.option("--output", required=True, help="Write yaml spec file here")
|
@click.option("--output", required=True, help="Write yaml spec file here")
|
||||||
@click.pass_context
|
@click.pass_context
|
||||||
@ -158,3 +170,15 @@ def create(ctx, spec_file, deployment_dir):
|
|||||||
source_config_dir = data_dir.joinpath("config", pod)
|
source_config_dir = data_dir.joinpath("config", pod)
|
||||||
if os.path.exists(source_config_dir):
|
if os.path.exists(source_config_dir):
|
||||||
copytree(source_config_dir, os.path.join(deployment_dir, "config", pod))
|
copytree(source_config_dir, os.path.join(deployment_dir, "config", pod))
|
||||||
|
|
||||||
|
|
||||||
|
@click.command()
|
||||||
|
@click.option("--node-moniker", help="Help goes here")
|
||||||
|
@click.option("--key-name", 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("--create-network", is_flag=True, default=False, help="Help goes here")
|
||||||
|
@click.pass_context
|
||||||
|
def setup(ctx, node_moniker, key_name, initialize_network, join_network, create_network):
|
||||||
|
stack = global_options(ctx).stack
|
||||||
|
call_stack_deploy_setup(stack)
|
||||||
|
Loading…
Reference in New Issue
Block a user