From b03b0fa22cd397d8e42b166fb7ce2fdc5d694cc7 Mon Sep 17 00:00:00 2001 From: micafer Date: Fri, 7 Feb 2020 09:33:43 +0100 Subject: [PATCH 1/2] Maintain reverse SSH connection --- IM/REST.py | 8 ++++++-- test/unit/REST.py | 15 +++++++++++---- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/IM/REST.py b/IM/REST.py index 9bbaeeb42..40cbae419 100644 --- a/IM/REST.py +++ b/IM/REST.py @@ -626,6 +626,7 @@ def RESTGetVMProperty(infid=None, vmid=None, prop=None): command = ('curl --insecure -s -H "Authorization: type = InfrastructureManager; %s" ' '-H "Accept: text/plain" %s' % (imauth, url)) + ps_command = "ps aux | grep -v grep | grep 'ssh -N -R'" info = """ res="wait" while [ "$res" == "wait" ] @@ -633,11 +634,14 @@ def RESTGetVMProperty(infid=None, vmid=None, prop=None): res=`%s` if [ "$res" != "wait" ] then - eval "$res" + echo "$res" > /var/tmp/reverse_ssh.sh + chmod a+x /var/tmp/reverse_ssh.sh + echo "*/1 * * * * root %s || /var/tmp/reverse_ssh.sh" > /etc/cron.d/reverse_ssh + /var/tmp/reverse_ssh.sh else sleep 20 fi - done""" % command + done""" % (command, ps_command) logger.debug("Step 1 command: %s" % info) elif step == 2: sel_vm = None diff --git a/test/unit/REST.py b/test/unit/REST.py index 02af74e40..786f6a64c 100755 --- a/test/unit/REST.py +++ b/test/unit/REST.py @@ -893,6 +893,7 @@ def test_commands(self, bottle_request, check_auth_data, get_infrastructure, SSH res = RESTGetVMProperty("1", "1", "command") auth_str = "Authorization: type = InfrastructureManager; username = user; password = pass" url = "http://imserver.com/infrastructures/1/vms/1/command?step=2" + ps_command = "ps aux | grep -v grep | grep 'ssh -N -R'" expected_res = """ res="wait" while [ "$res" == "wait" ] @@ -900,11 +901,14 @@ def test_commands(self, bottle_request, check_auth_data, get_infrastructure, SSH res=`curl --insecure -s -H "%s" -H "Accept: text/plain" %s` if [ "$res" != "wait" ] then - eval "$res" + echo "$res" > /var/tmp/reverse_ssh.sh + chmod a+x /var/tmp/reverse_ssh.sh + echo "*/1 * * * * root %s || /var/tmp/reverse_ssh.sh" > /etc/cron.d/reverse_ssh + /var/tmp/reverse_ssh.sh else sleep 20 fi - done""" % (auth_str, url) + done""" % (auth_str, url, ps_command) self.assertEqual(res, expected_res) inf.auth = Authentication([{'type': 'InfrastructureManager', 'token': 'token'}]) @@ -918,11 +922,14 @@ def test_commands(self, bottle_request, check_auth_data, get_infrastructure, SSH res=`curl --insecure -s -H "%s" -H "Accept: text/plain" %s` if [ "$res" != "wait" ] then - eval "$res" + echo "$res" > /var/tmp/reverse_ssh.sh + chmod a+x /var/tmp/reverse_ssh.sh + echo "*/1 * * * * root %s || /var/tmp/reverse_ssh.sh" > /etc/cron.d/reverse_ssh + /var/tmp/reverse_ssh.sh else sleep 20 fi - done""" % (auth_str, url) + done""" % (auth_str, url, ps_command) self.assertEqual(res, expected_res) radl_master = parse_radl(""" From 403bdfefd3d38c15905fa9543571d6d07dadc4b7 Mon Sep 17 00:00:00 2001 From: micafer Date: Tue, 11 Feb 2020 09:59:34 +0100 Subject: [PATCH 2/2] Update changelog --- changelog | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/changelog b/changelog index 55289db97..73b62e2ed 100644 --- a/changelog +++ b/changelog @@ -569,3 +569,10 @@ IM 1.9.1: * Fix intermittent errors in SSH connections. * Fix ssh_connect_errors count must be reset when a ssh connection is ok. * Fix check_ctxt_process thread dies and contextalization never ends. + * Fix error not setting network_type in TOSCA network. + * Enable to mount nvme disks in EC2. + * Fix error merging TOSCA documents. + * Fix error getting VM errors in the cont msg in case of all VMs has failed. + * Fix Error creating OpenStack Network. + * Fix error updating VM info in OpenStack conn. +