Skip to content

Commit

Permalink
refactor(hwil): removes ssh shell via paramiko (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
pallabpain authored Jul 1, 2024
1 parent 7c257f1 commit dc9d26d
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 418 deletions.
1 change: 0 additions & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ python-benedict = ">=0.33.2"
etcd3gw = ">=2.4.0"
graphviz = ">=0.20.3"
python-magic = ">=0.4.27"
paramiko = "3.4.0"

[requires]
python_version = "3"
182 changes: 12 additions & 170 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions riocli/hwil/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
# 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 os

import click
from click_help_colors import HelpColorsCommand

from riocli.config import new_hwil_client
from riocli.constants import Colors
from riocli.constants import Colors, Symbols
from riocli.hwil.util import name_to_id
from riocli.utils.ssh_shell import SSHShell


@click.command(
Expand All @@ -33,7 +33,13 @@ def ssh(device_name: str, device_id: str, spinner=None) -> None:
"""SSH into the hardware-in-the-loop device."""
try:
device = new_hwil_client().get_device(device_id)
SSHShell(device.static_ip, device.username, device.password).connect()

if not device.get('static_ip'):
click.secho(f'{Symbols.ERROR} Device does not have a static IP address', fg=Colors.RED)
raise SystemExit(1)

click.secho(f'{Symbols.INFO} Enter this password when prompted: {device.password}', fg=Colors.BRIGHT_CYAN)
os.system(f'ssh {device.username}@{device["static_ip"]}')
except Exception as e:
click.secho(str(e), fg=Colors.RED)
raise SystemExit(1)
Loading

0 comments on commit dc9d26d

Please sign in to comment.