Skip to content

Commit

Permalink
Merge pull request #984 from grycap/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
micafer authored Feb 12, 2020
2 parents 1ac551f + 403bdfe commit 79bac8b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
8 changes: 6 additions & 2 deletions IM/REST.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,18 +626,22 @@ 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" ]
do
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
Expand Down
7 changes: 7 additions & 0 deletions changelog
Original file line number Diff line number Diff line change
Expand Up @@ -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.

15 changes: 11 additions & 4 deletions test/unit/REST.py
Original file line number Diff line number Diff line change
Expand Up @@ -893,18 +893,22 @@ 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" ]
do
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'}])
Expand All @@ -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("""
Expand Down

0 comments on commit 79bac8b

Please sign in to comment.