Fix instance volume mount script creation

Now the volume mount script would be created with correct newlines.
Also, this change contain some additional debugging information, so
the process of creating and mounting the volume logged to the
instance /var/log/messages through syslog. Also, this commit contain
the the workaround for the AuthenticationException because the
Cirros image starts ssh servece just before the cloud-init and in
some cases we need to wait when the instance_initial_scenario canges
the password for the cirros user.

Change-Id: Icb981c90a5ed8beb75fa119158161bf5ea3e5900
Closes-Bug: #1588808
Signed-off-by: Maksim Malchuk <mmalchuk@mirantis.com>
This commit is contained in:
Maksim Malchuk 2016-06-06 19:00:04 +03:00
parent b4ba7a3af1
commit d28b6868f5
2 changed files with 14 additions and 1 deletions

View File

@ -4,7 +4,7 @@ echo "Creating test file"
touch /home/test_file
echo "Creating volume mount script on instance"
echo "#!/bin/sh\nsudo /usr/sbin/mkfs.ext4 /dev/vdb\nsudo mount /dev/vdb /mnt" | tee /home/mount_volume.sh
echo -e '#!/bin/sh\nsudo /usr/sbin/mkfs.ext4 /dev/vdb | logger -t mount_volume.sh\nsudo mount -t ext4 /dev/vdb /mnt | logger -t mount_volume.sh\nmount | grep /mnt | logger -t mount_volume.sh' | tee /home/mount_volume.sh
chmod 777 /home/mount_volume.sh
echo -e "test\ntest" | passwd cirros

View File

@ -16,6 +16,7 @@ import time
from ConfigParser import ConfigParser
from cStringIO import StringIO
import paramiko
from pkg_resources import parse_version
from proboscis.asserts import assert_true, assert_false, assert_equal
from proboscis import SkipTest
@ -657,7 +658,17 @@ class VmBackedWithCephMigrationBasic(TestBasic):
wait(lambda: tcp_ping(floating_ip.ip, 22), timeout=120)
def ssh_ready(remote, ip, creds):
try:
os.execute_through_host(remote, ip, '/bin/true', creds)
return True
except paramiko.AuthenticationException:
logger.info("Authentication failed. Trying again in a minute.")
time.sleep(60)
return False
with self.fuel_web.get_ssh_for_node("slave-01") as remote:
wait(lambda: ssh_ready(remote, floating_ip.ip, creds), timeout=300)
md5before = os.get_md5sum(
"/home/test_file", remote, floating_ip.ip, creds)
@ -745,6 +756,8 @@ class VmBackedWithCephMigrationBasic(TestBasic):
logger.info("Create filesystem and mount volume")
with self.fuel_web.get_ssh_for_node("slave-01") as remote:
wait(lambda: ssh_ready(remote, floating_ip.ip, creds), timeout=300)
os.execute_through_host(
remote,
floating_ip.ip, 'sudo sh /home/mount_volume.sh', creds)