diff options
author | Alex Yang <yangyang1@zte.com.cn> | 2017-07-29 20:29:52 +0800 |
---|---|---|
committer | Alex Yang <yangyang1@zte.com.cn> | 2017-07-31 15:35:11 +0800 |
commit | b35baf61e48a1d2aff88e7c3e100aa996422d849 (patch) | |
tree | ded0fe80802a336d1729f607baadac9a90e3b5e5 /deploy/libvirt_utils.py | |
parent | e47fc2d62d07633c1883253d42f8e2cade35e868 (diff) |
Correct the mapping of nodes and roles in virtual deploy
JIRA: DAISY-56
Now the roles are assigned to nodes randomly, because the function
'add_hosts_interface' in tempest.py just uses zip to map the
host's name to the host.
libvirt_utils.py: get mac addresses from VM
environment.py: save the mac addresses
daisy_server.py: write a new deploy.yml which contains the mac addresses
and copy the file to daisy server
get_conf.py: get mac addresses from the new deploy.yml
tempest.py: assigned roles to nodes when the mac addresses matched
controller.xml: increase the RAM to make difference with computer nodes
deploy.sh: apply this change to bash script
Change-Id: Ia61b60d39d319c5d01e3505727fafc63a0585858
Signed-off-by: Alex Yang <yangyang1@zte.com.cn>
Diffstat (limited to 'deploy/libvirt_utils.py')
-rw-r--r-- | deploy/libvirt_utils.py | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/deploy/libvirt_utils.py b/deploy/libvirt_utils.py index 8c694c13..8e4523de 100644 --- a/deploy/libvirt_utils.py +++ b/deploy/libvirt_utils.py @@ -104,9 +104,10 @@ def create_vm(template, name=None, disks=None): if domain.create() < 0: err_exit('Failed to start VM %s' % template) domain.setAutostart(1) + conn.close() LI('VM %s is started' % domain.name()) - return + return domain def reboot_vm(vm_name, boot_devs=None): @@ -123,18 +124,13 @@ def reboot_vm(vm_name, boot_devs=None): vm.destroy() LI('Destroy VM %s' % vm_name) - # root = ET.fromstring(vm.XMLDesc()) - temp_file = path_join(WORKSPACE, 'tmp.xml') - commands.getoutput('virsh dumpxml %s > %s' % (vm_name, temp_file)) - tree = ET.parse(temp_file) - root = tree.getroot() + root = ET.fromstring(vm.XMLDesc()) LI('Modify the boot order %s' % boot_devs) modify_vm_boot_order(root, boot_devs) - tree.write(temp_file) LI('Re-define and start the VM %s' % vm_name) vm.undefine() - vm = conn.defineXML(commands.getoutput('cat %s' % temp_file)) + vm = conn.defineXML(ET.tostring(root)) vm.create() vm.setAutostart(1) else: @@ -222,3 +218,9 @@ def delete_virtual_network(network_xml): conn.close() if not result: LI('Network %s is not found' % name) + + +def get_vm_mac_addresses(domain): + root = ET.fromstring(domain.XMLDesc()) + macs = root.findall('./devices/interface/mac') + return [mac.attrib['address'] for mac in macs] |