Пример #1
0
    def validate_dhcp_forwarding(self, source_fixture,
            dest_fixture, source_interface=None):
        '''
            Validate that dhcp discover packet from a VM/BMS 
            is seen on the destination VM/BMS
            Returns True in such a case, else False
        '''
        (session, pcap) = dest_fixture.start_tcpdump(filters='udp port 68 -v')
        source_fixture.run_dhclient(source_interface, timeout=20)
        time.sleep(5)
        dest_fixture.stop_tcpdump(session, pcap)
        if isinstance(source_fixture, HostEndpointFixture):
            source_mac = source_fixture.info['hwaddr']
            source_name = source_fixture.identifier
        elif isinstance(source_fixture, VMFixture):
            source_mac = source_fixture.get_vm_interface_name(source_interface)
            source_name = source_fixture.vm_name

        if isinstance(dest_fixture, HostEndpointFixture):
            dest_name = dest_fixture.identifier
        elif isinstance(dest_fixture, VMFixture):
            dest_name = dest_fixture.vm_name

        result = search_in_pcap(session, pcap, 'BOOTP/DHCP, Request from %s' % (
            source_mac))
        if result :
            message = 'DHCP discover/request from %s, MAC %s is seen '\
                'on %s' % (source_name, source_mac, dest_name)
        else:
            message = 'DHCP discover/request from %s, MAC %s is NOT '\
                'seen on %s' % (source_name, source_mac, dest_name)

        self.logger.info(message)
        delete_pcap(session, pcap)
        return (result, message)
Пример #2
0
    def validate_arp_forwarding(self, source_fixture,
            ip, dest_fixture, source_interface=None):
        '''
            Validate that arp packet from a VM/BMS destined to 'ip'
            is seen on the destination VM/BMS
            Returns True in such a case, else False
        '''
        (session, pcap) = dest_fixture.start_tcpdump(filters='arp -v')
        source_fixture.arping(ip, source_interface)
        time.sleep(5)
        dest_fixture.stop_tcpdump(session, pcap)
        if isinstance(source_fixture, HostEndpointFixture):
            source_ip = source_fixture.info['inet_addr']
        elif isinstance(source_fixture, VMFixture):
            source_ip = source_fixture.vm_ips[0]

        if isinstance(dest_fixture, HostEndpointFixture):
            dest_name = dest_fixture.identifier
        elif isinstance(dest_fixture, VMFixture):
            dest_name = dest_fixture.vm_name
        
        result = search_in_pcap(session, pcap, 'Request who-has %s tell %s' % (
            ip, source_ip))
        if result :
            message = 'ARP request from %s to %s is seen on %s' % (
                source_ip, ip, dest_name)
        else:
            message = 'ARP request from %s to %s is NOT seen on %s' % (
                source_ip, ip, dest_name)
                
        self.logger.info(message)
        delete_pcap(session, pcap)
        return (result, message)