* [PATCH] devtool: Add IPv6 deploy targets targets
[not found] <600e41e7-645c-7806-9580-6db458004a25@debian.org>
@ 2020-05-27 9:51 ` breno.debian
2020-05-28 22:33 ` [OE-core] " Richard Purdie
2020-05-27 10:03 ` ✗ patchtest: failure for " Patchwork
1 sibling, 1 reply; 3+ messages in thread
From: breno.debian @ 2020-05-27 9:51 UTC (permalink / raw)
To: openembedded-core
From: Breno Leitao <leit@fb.com>
Unfortunately devtool is not able to deploy (and undeploy) into IPv6
hosts.
This patch simply adds a way to use IPv6 target address similarly to
ssh/scp, as foo@[xxxx:yyyy::zzzz]:/destdir.
In order to do it, I've created a function that parses the hostname,
user and destdir, and then create a target_ssh (for ssh like parameter
-- foo@xxx:yyyy::zzz) and target_scp for scp paramers as
-- foo@[xxxx:yyyy::zzz]:/destdir. The urlparsing is done by urlparse
module and ip version discovery is done by ipaddress module.
This is the tests I have been using to validate my patch
IPV4_FORMATS="
root@11.11.11.2:/tmp
root@11.11.11.2
11.11.11.2:/tmp
11.11.11.2
"
IPV6_FORMATS="
root@[2620:10d:c0bb:403:dac4:97ff:feda:3325]:/tmp
root@[2620:10d:c0bb:403:dac4:97ff:feda:3325]
[2620:10d:c0bb:403:dac4:97ff:feda:3325]:/tmp
[2620:10d:c0bb:403:dac4:97ff:feda:3325]
"
HOSTNAMES="
root@foo.bar:/tmp
root@foo.bar
foo.bar:/tmp
foo.bar
"
for I in $IPV6_FORMATS
do
devtool deploy-target -6 -s mypkg ${I}
devtool undeploy-target -6 -s mypkg ${I}
done
for I in $HOSTNAMES
do
devtool deploy-target -s mypkg ${I}
devtool undeploy-target -s mypkg ${I}
done
for I in $IPV4_FORMATS
do
devtool deploy-target -s mypkg ${I}
devtool undeploy-target -s mypkg ${I}
done
---
scripts/lib/devtool/deploy.py | 61 +++++++++++++++++++++++++++--------
1 file changed, 47 insertions(+), 14 deletions(-)
diff --git a/scripts/lib/devtool/deploy.py b/scripts/lib/devtool/deploy.py
index 6a997735fc..1580256e2a 100644
--- a/scripts/lib/devtool/deploy.py
+++ b/scripts/lib/devtool/deploy.py
@@ -11,6 +11,8 @@ import os
import shutil
import subprocess
import tempfile
+import urllib
+import ipaddress
import bb.utils
import argparse_oe
@@ -134,6 +136,18 @@ def _prepare_remote_script(deploy, verbose=False, dryrun=False, undeployall=Fals
return '\n'.join(lines)
+def parse_ip(args):
+ t = urllib.parse.urlparse("ssh://" + args.target)
+
+ try:
+ ip = ipaddress.ip_address(t.hostname)
+ version = ip.version
+ except ValueError:
+ # hostname instead of ip return version 0
+ version = None;
+
+ return t.username, t.hostname, t.path, version
+
def deploy(args, config, basepath, workspace):
"""Entry point for the devtool 'deploy' subcommand"""
@@ -143,14 +157,7 @@ def deploy(args, config, basepath, workspace):
check_workspace_recipe(workspace, args.recipename, checksrc=False)
- try:
- host, destdir = args.target.split(':')
- except ValueError:
- destdir = '/'
- else:
- args.target = host
- if not destdir.endswith('/'):
- destdir += '/'
+ user, host, destdir, ipversion = parse_ip(args)
tinfoil = setup_tinfoil(basepath=basepath)
try:
@@ -235,16 +242,30 @@ def deploy(args, config, basepath, workspace):
f.write('%d\n' % ftotalsize)
for fpath, fsize in filelist:
f.write('%s %d\n' % (fpath, fsize))
+
+ # Need to generate target as a scp format
+ if ipversion == 6:
+ target_scp = "[%s]:%s" % (host, os.path.dirname(tmpscript))
+ else:
+ target_scp = "%s:%s" % (host, os.path.dirname(tmpscript))
+ if user:
+ target_scp = "%s@%s" % (user, target_scp)
+
# Copy them to the target
- ret = subprocess.call("scp %s %s %s %s/* %s:%s" % (scp_sshexec, scp_port, extraoptions, tmpdir, args.target, os.path.dirname(tmpscript)), shell=True)
+ ret = subprocess.call("scp %s %s %s %s/* %s" % (scp_sshexec, scp_port, extraoptions, tmpdir, target_scp), shell=True)
if ret != 0:
raise DevtoolError('Failed to copy script to %s - rerun with -s to '
'get a complete error message' % args.target)
finally:
shutil.rmtree(tmpdir)
+ if user:
+ target_ssh = "%s@%s" % (user, host)
+ else:
+ target_ssh = host
+
# Now run the script
- ret = exec_fakeroot(rd, 'tar cf - . | %s %s %s %s \'sh %s %s %s %s\'' % (ssh_sshexec, ssh_port, extraoptions, args.target, tmpscript, args.recipename, destdir, tmpfilelist), cwd=recipe_outdir, shell=True)
+ ret = exec_fakeroot(rd, 'tar cf - . | %s %s %s %s \'sh %s %s %s %s\'' % (ssh_sshexec, ssh_port, extraoptions, target_ssh, tmpscript, args.recipename, destdir, tmpfilelist), cwd=recipe_outdir, shell=True)
if ret != 0:
raise DevtoolError('Deploy failed - rerun with -s to get a complete '
'error message')
@@ -268,6 +289,8 @@ def undeploy(args, config, basepath, workspace):
elif not args.recipename and not args.all:
raise argparse_oe.ArgumentUsageError('If you don\'t specify a recipe, you must specify -a/--all', 'undeploy-target')
+ user, host, destdir, ipversion = parse_ip(args)
+
extraoptions = ''
if args.no_host_check:
extraoptions += '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no'
@@ -285,8 +308,6 @@ def undeploy(args, config, basepath, workspace):
scp_port = "-P %s" % args.port
ssh_port = "-p %s" % args.port
- args.target = args.target.split(':')[0]
-
tmpdir = tempfile.mkdtemp(prefix='devtool')
try:
tmpscript = '/tmp/devtool_undeploy.sh'
@@ -294,16 +315,28 @@ def undeploy(args, config, basepath, workspace):
# Write out the script to a file
with open(os.path.join(tmpdir, os.path.basename(tmpscript)), 'w') as f:
f.write(shellscript)
+
+ # Format for scp
+ if ipversion == 6:
+ target_scp = "[%s]:%s" % (host, os.path.dirname(tmpscript))
+ else:
+ target_scp = "%s:%s" % (host, os.path.dirname(tmpscript))
+ if user:
+ target_scp = "%s@%s" % (user, target_scp)
+
# Copy it to the target
- ret = subprocess.call("scp %s %s %s %s/* %s:%s" % (scp_sshexec, scp_port, extraoptions, tmpdir, args.target, os.path.dirname(tmpscript)), shell=True)
+ ret = subprocess.call("scp %s %s %s %s/* %s" % (scp_sshexec, scp_port, extraoptions, tmpdir, target_scp), shell=True)
if ret != 0:
raise DevtoolError('Failed to copy script to %s - rerun with -s to '
'get a complete error message' % args.target)
finally:
shutil.rmtree(tmpdir)
+ target_ssh = host
+ if user:
+ target_ssh = "%s@%s" % (user, target_ssh)
# Now run the script
- ret = subprocess.call('%s %s %s %s \'sh %s %s\'' % (ssh_sshexec, ssh_port, extraoptions, args.target, tmpscript, args.recipename), shell=True)
+ ret = subprocess.call('%s %s %s %s \'sh %s %s\'' % (ssh_sshexec, ssh_port, extraoptions, target_ssh, tmpscript, args.recipename), shell=True)
if ret != 0:
raise DevtoolError('Undeploy failed - rerun with -s to get a complete '
'error message')
--
2.24.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* ✗ patchtest: failure for devtool: Add IPv6 deploy targets targets
[not found] <600e41e7-645c-7806-9580-6db458004a25@debian.org>
2020-05-27 9:51 ` [PATCH] devtool: Add IPv6 deploy targets targets breno.debian
@ 2020-05-27 10:03 ` Patchwork
1 sibling, 0 replies; 3+ messages in thread
From: Patchwork @ 2020-05-27 10:03 UTC (permalink / raw)
To: Breno Leitao; +Cc: openembedded-core
== Series Details ==
Series: devtool: Add IPv6 deploy targets targets
Revision: 1
URL : https://patchwork.openembedded.org/series/24338/
State : failure
== Summary ==
Thank you for submitting this patch series to OpenEmbedded Core. This is
an automated response. Several tests have been executed on the proposed
series by patchtest resulting in the following failures:
* Patch devtool: Add IPv6 deploy targets targets
Issue Patch is missing Signed-off-by [test_signed_off_by_presence]
Suggested fix Sign off the patch (either manually or with "git commit --amend -s")
If you believe any of these test results are incorrect, please reply to the
mailing list (openembedded-core@lists.openembedded.org) raising your concerns.
Otherwise we would appreciate you correcting the issues and submitting a new
version of the patchset if applicable. Please ensure you add/increment the
version number when sending the new version (i.e. [PATCH] -> [PATCH v2] ->
[PATCH v3] -> ...).
---
Guidelines: https://www.openembedded.org/wiki/Commit_Patch_Message_Guidelines
Test framework: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest
Test suite: http://git.yoctoproject.org/cgit/cgit.cgi/patchtest-oe
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [OE-core] [PATCH] devtool: Add IPv6 deploy targets targets
2020-05-27 9:51 ` [PATCH] devtool: Add IPv6 deploy targets targets breno.debian
@ 2020-05-28 22:33 ` Richard Purdie
0 siblings, 0 replies; 3+ messages in thread
From: Richard Purdie @ 2020-05-28 22:33 UTC (permalink / raw)
To: Breno Leitao, openembedded-core
On Wed, 2020-05-27 at 10:51 +0100, Breno Leitao wrote:
> From: Breno Leitao <leit@fb.com>
>
> Unfortunately devtool is not able to deploy (and undeploy) into IPv6
> hosts.
>
> This patch simply adds a way to use IPv6 target address similarly to
> ssh/scp, as foo@[xxxx:yyyy::zzzz]:/destdir.
>
> In order to do it, I've created a function that parses the hostname,
> user and destdir, and then create a target_ssh (for ssh like
> parameter
> -- foo@xxx:yyyy::zzz) and target_scp for scp paramers as
> -- foo@[xxxx:yyyy::zzz]:/destdir. The urlparsing is done by urlparse
> module and ip version discovery is done by ipaddress module.
>
> This is the tests I have been using to validate my patch
>
> IPV4_FORMATS="
> root@11.11.11.2:/tmp
> root@11.11.11.2
> 11.11.11.2:/tmp
> 11.11.11.2
> "
>
> IPV6_FORMATS="
> root@[2620:10d:c0bb:403:dac4:97ff:feda:3325]:/tmp
> root@[2620:10d:c0bb:403:dac4:97ff:feda:3325]
> [2620:10d:c0bb:403:dac4:97ff:feda:3325]:/tmp
> [2620:10d:c0bb:403:dac4:97ff:feda:3325]
> "
>
> HOSTNAMES="
> root@foo.bar:/tmp
> root@foo.bar
> foo.bar:/tmp
> foo.bar
> "
>
> for I in $IPV6_FORMATS
> do
> devtool deploy-target -6 -s mypkg ${I}
> devtool undeploy-target -6 -s mypkg ${I}
> done
>
> for I in $HOSTNAMES
> do
> devtool deploy-target -s mypkg ${I}
> devtool undeploy-target -s mypkg ${I}
> done
>
> for I in $IPV4_FORMATS
> do
> devtool deploy-target -s mypkg ${I}
> devtool undeploy-target -s mypkg ${I}
> done
>
I think this breaks our selftests:
https://autobuilder.yoctoproject.org/typhoon/#/builders/87/builds/976
(and others in that build)
to reproduce it should be a case of running:
oe-selftest -r devtool.DevtoolExtractTests.test_devtool_deploy_target
Cheers,
Richard
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-28 22:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <600e41e7-645c-7806-9580-6db458004a25@debian.org>
2020-05-27 9:51 ` [PATCH] devtool: Add IPv6 deploy targets targets breno.debian
2020-05-28 22:33 ` [OE-core] " Richard Purdie
2020-05-27 10:03 ` ✗ patchtest: failure for " Patchwork
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.