From 06e13bf06bc9e666b6700a52a1f09c56c62ea1be Mon Sep 17 00:00:00 2001 From: Petr Lomakin Date: Fri, 17 Jun 2016 02:26:33 -0700 Subject: [PATCH] CF-522 Modify auto tests to run migration as non-root user. Fixed username and password to get from configuration.ini --- .../cloudferry_devlab/generate_load.py | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cloudferry_devlab/cloudferry_devlab/generate_load.py b/cloudferry_devlab/cloudferry_devlab/generate_load.py index 42b69af5..e2976213 100644 --- a/cloudferry_devlab/cloudferry_devlab/generate_load.py +++ b/cloudferry_devlab/cloudferry_devlab/generate_load.py @@ -929,9 +929,12 @@ def break_vm(self, vm_id): """ inst_name = getattr(self.novaclient.servers.get(vm_id), 'OS-EXT-SRV-ATTR:instance_name') - cmd = 'virsh destroy {0} && virsh undefine {0}'.format(inst_name) - self.migration_utils.execute_command_on_vm( - self.get_vagrant_vm_ip(), cmd, username='root', password='') + for cmd in ['virsh destroy {0}'.format(inst_name), + 'virsh undefine {0}'.format(inst_name)]: + self.migration_utils.execute_command_on_vm( + self.get_vagrant_vm_ip(), cmd, + username=self.configuration_ini['src']['ssh_user'], + password=self.configuration_ini['src']['ssh_sudo_password']) def delete_image_on_dst(self): """ Method delete images with a 'delete_on_dst' flag on @@ -957,7 +960,9 @@ def break_images(self): image_id = self.get_image_id(image['name']) cmd = 'rm -rf /var/lib/glance/images/%s' % image_id self.migration_utils.execute_command_on_vm( - self.get_vagrant_vm_ip(), cmd, username='root', password='') + self.get_vagrant_vm_ip(), cmd, + username=self.configuration_ini['src']['ssh_user'], + password=self.configuration_ini['src']['ssh_sudo_password']) for image in images_to_delete: image_id = self.get_image_id(image['name']) self.glanceclient.images.delete(image_id) @@ -1134,6 +1139,5 @@ def run_restore_vms_state(self): self.emulate_vm_states() self.log.info('Breaking VMs') for vm in [self.get_vm_id(vm['name']) for vm in - self.src_vms_from_config - if vm.get('broken')]: + self.src_vms_from_config if vm.get('broken')]: self.break_vm(vm)