Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ssh by domain #723

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions linodecli/plugins/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ def call(args, context): # pylint: disable=too-many-branches
action="store_true",
help="If given, uses the Linode's SLAAC address for SSH.",
)
parser.add_argument(
"-d",
action="store_true",
help="If given, uses the Lindoe's domain name for SSH",
)

parsed, args = parser.parse_known_args(args)

Expand Down Expand Up @@ -147,4 +152,9 @@ def parse_target_address(
if ip.startswith("192.168"):
continue

if getattr(
parsed, "d"
):
ip = ip.replace(".", "-") + ".ip.linodeusercontent.com"

return ip
8 changes: 7 additions & 1 deletion tests/unit/test_plugin_ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,17 @@ def test_parse_target_address():
"ipv6": "c001:d00d::1337/128",
}

test_namespace = argparse.Namespace(**{"6": False})
test_namespace = argparse.Namespace(**{"6": False, "d": False})

address = plugin.parse_target_address(test_namespace, test_target)
assert address == "123.123.123.123"

# Hack to work around invalid key
setattr(test_namespace, "d", True)

address = plugin.parse_target_address(test_namespace, test_target)
assert address == "123-123-123-123.ip.linodeusercontent.com"

# Hack to work around invalid key
setattr(test_namespace, "6", True)

Expand Down
Loading