diff --git a/riocli/deployment/__init__.py b/riocli/deployment/__init__.py index be06553d..1ada4f60 100644 --- a/riocli/deployment/__init__.py +++ b/riocli/deployment/__init__.py @@ -21,7 +21,6 @@ from riocli.deployment.inspect import inspect_deployment from riocli.deployment.list import list_deployments from riocli.deployment.logs import deployment_logs -from riocli.deployment.ssh import ssh_init, ssh_deployment from riocli.deployment.status import status from riocli.deployment.update import update_deployment from riocli.deployment.wait import wait_for_deployment @@ -46,7 +45,5 @@ def deployment(): deployment.add_command(deployment_logs) deployment.add_command(wait_for_deployment) deployment.add_command(status) -deployment.add_command(ssh_deployment) -deployment.add_command(ssh_init) deployment.add_command(execute_command) deployment.add_command(update_deployment) diff --git a/riocli/deployment/ssh.py b/riocli/deployment/ssh.py deleted file mode 100644 index b4e1907c..00000000 --- a/riocli/deployment/ssh.py +++ /dev/null @@ -1,65 +0,0 @@ -# Copyright 2021 Rapyuta Robotics -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -import functools - -import click - -from riocli.deployment.util import select_details, name_to_guid -from riocli.utils.execute import run_on_cloud -from riocli.utils.ssh_tunnel import establish_ssh_tunnel - - -@click.command('ssh', hidden=True) -@click.argument('deployment-name') -@name_to_guid -def ssh_deployment(deployment_name: str, deployment_guid: str) -> None: - # FIXME(ankit): The remote command always exits in error - comp_id, exec_id, pod_name = select_details(deployment_guid) - exec_remote_command = functools.partial(run_on_cloud, deployment_guid, comp_id, exec_id, pod_name) - establish_ssh_tunnel(exec_remote_command) - - -@click.command('ssh-init', hidden=True) -@click.argument('deployment-name') -@name_to_guid -def ssh_init(deployment_name: str, deployment_guid: str) -> None: - try: - _ssh_setup(deployment_guid) - click.secho('Deployment ready for SSH', fg='green') - except Exception as e: - click.secho(str(e), fg='red') - raise SystemExit(1) - - -def _ssh_setup(deployment_guid: str) -> None: - """ - Sets up Socat and SSH Authorized Keys File for SSH through Piping server - """ - comp_id, exec_id, pod_name = select_details(deployment_guid) - - cmd_apt_update = ['apt', 'update'] - cmd_apt_install = ['apt', 'install', 'socat', 'openssh-server', '-y'] - cmd_mkdir_ssh = ['mkdir', '-p', '/root/.ssh'] - cmd_touch_file = ['touch', '/root/.ssh/authorized_keys'] - cmd_start_ssh = ['service', 'ssh', 'start'] - # FIXME(ankit): Setup SSH Keys - commands = [cmd_apt_update, cmd_apt_install, cmd_mkdir_ssh, cmd_touch_file, cmd_start_ssh] - click.clear() - for cmd in commands: - click.secho('$ {}'.format(' '.join(cmd)), fg='yellow') - stdout, stderr = run_on_cloud(deployment_guid, comp_id, exec_id, pod_name, cmd) - if stderr: - click.secho(stderr, fg='red') - if stdout: - click.secho(stdout, fg='yellow') diff --git a/riocli/package/__init__.py b/riocli/package/__init__.py index 757b9c39..3ba2f409 100644 --- a/riocli/package/__init__.py +++ b/riocli/package/__init__.py @@ -14,7 +14,6 @@ import click from click_help_colors import HelpColorsGroup -from riocli.package.create import create_package from riocli.package.delete import delete_package from riocli.package.deployment import list_package_deployments from riocli.package.inspect import inspect_package @@ -34,7 +33,6 @@ def package() -> None: pass -package.add_command(create_package) package.add_command(delete_package) package.add_command(list_packages) package.add_command(inspect_package) diff --git a/riocli/package/create.py b/riocli/package/create.py deleted file mode 100644 index 07be2e50..00000000 --- a/riocli/package/create.py +++ /dev/null @@ -1,45 +0,0 @@ -# Copyright 2021 Rapyuta Robotics -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -import json - -import click -import yaml -from click_spinner import spinner - -from riocli.config import new_client - - -@click.command('create', hidden=True) -@click.option('--manifest', type=click.File(mode='r', lazy=True), - help='Path for the manifest file') -@click.option('--format', 'format_type', default='json', - type=click.Choice(['json', 'yaml'], case_sensitive=False)) -def create_package(manifest: click.File, format_type: str) -> None: - """ - Create a new package - """ - data = manifest.read() - if format_type == 'json': - package = json.loads(data) - else: - package = yaml.load(data) - - try: - client = new_client() - with spinner(): - client.create_package(package) - click.secho('Package created successfully!', fg='green') - except Exception as e: - click.secho(str(e), fg='red') - raise SystemExit(1)