Skip to content

Commit

Permalink
Merge pull request #1068 from plomakin/cf-522
Browse files Browse the repository at this point in the history
CF-522 Modify auto tests to run migration as non-root user.
  • Loading branch information
plomakin authored Jun 29, 2016
2 parents 0cf4ad1 + 06e13bf commit 7810e19
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions cloudferry_devlab/cloudferry_devlab/generate_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)

0 comments on commit 7810e19

Please sign in to comment.