#NEWLINE# @ skipIf ( ( sys . version_info < ( 2 , 7 ) ) , 'ElementTree version 1.3 required which comes with Python 2.7' ) #NEWLINE# def test_gen_xml_for_kvm_default_profile( self ) : #NEWLINE# #INDENT# diskp = virt . _disk_profile ( 'default' , 'kvm' ) #NEWLINE# nicp = virt . _nic_profile ( 'default' , 'kvm' ) #NEWLINE# xml_data = virt . _gen_xml ( 'hello' , 1 , 512 , diskp , nicp , 'kvm' ) #NEWLINE# root = ET . fromstring ( xml_data ) #NEWLINE# self . assertEqual ( root . attrib [ 'type' ] , 'kvm' ) #NEWLINE# self . assertEqual ( root . find ( 'vcpu' ) . text , '1' ) #NEWLINE# self . assertEqual ( root . find ( 'memory' ) . text , str ( ( 512 * 1024 ) ) ) #NEWLINE# self . assertEqual ( root . find ( 'memory' ) . attrib [ 'unit' ] , 'KiB' ) #NEWLINE# disks = root . findall ( './/disk' ) #NEWLINE# self . assertEqual ( len ( disks ) , 1 ) #NEWLINE# disk = disks [ 0 ] #NEWLINE# self . assertTrue ( disk . find ( 'source' ) . attrib [ 'file' ] . startswith ( '/' ) ) #NEWLINE# self . assertTrue ( ( 'hello/system' in disk . find ( 'source' ) . attrib [ 'file' ] ) ) #NEWLINE# self . assertEqual ( disk . find ( 'target' ) . attrib [ 'dev' ] , 'vda' ) #NEWLINE# self . assertEqual ( disk . find ( 'target' ) . attrib [ 'bus' ] , 'virtio' ) #NEWLINE# self . assertEqual ( disk . find ( 'driver' ) . attrib [ 'name' ] , 'qemu' ) #NEWLINE# self . assertEqual ( disk . find ( 'driver' ) . attrib [ 'type' ] , 'qcow2' ) #NEWLINE# interfaces = root . findall ( './/interface' ) #NEWLINE# self . assertEqual ( len ( interfaces ) , 1 ) #NEWLINE# iface = interfaces [ 0 ] #NEWLINE# self . assertEqual ( iface . attrib [ 'type' ] , 'bridge' ) #NEWLINE# self . assertEqual ( iface . find ( 'source' ) . attrib [ 'bridge' ] , 'br0' ) #NEWLINE# self . assertEqual ( iface . find ( 'model' ) . attrib [ 'type' ] , 'virtio' ) #NEWLINE# mac = iface . find ( 'mac' ) . attrib [ 'address' ] #NEWLINE# self . assertTrue ( re . match ( '^([0-9A-F]{2}[:-]){5}([0-9A-F]{2})$' , mac , re . I ) )