def _test_get_vif_ports(self, is_xen=False):
    pname = 'tap99'
    ofport = '6'
    vif_id = uuidutils.generate_uuid()
    mac = 'ca:fe:de:ad:be:ef'
    utils.execute(['ovs-vsctl', self.TO, 'list-ports', self.BR_NAME], root_helper=self.root_helper).AndReturn(('%s\n' % pname))
    if is_xen:
        external_ids = ('{xs-vif-uuid="%s", attached-mac="%s"}' % (vif_id, mac))
    else:
        external_ids = ('{iface-id="%s", attached-mac="%s"}' % (vif_id, mac))
    utils.execute(['ovs-vsctl', self.TO, 'get', 'Interface', pname, 'external_ids'], root_helper=self.root_helper).AndReturn(external_ids)
    utils.execute(['ovs-vsctl', self.TO, 'get', 'Interface', pname, 'ofport'], root_helper=self.root_helper).AndReturn(ofport)
    if is_xen:
        utils.execute(['xe', 'vif-param-get', 'param-name=other-config', 'param-key=nicira-iface-id', ('uuid=' + vif_id)], root_helper=self.root_helper).AndReturn(vif_id)
    self.mox.ReplayAll()
    ports = self.br.get_vif_ports()
    self.assertEqual(1, len(ports))
    self.assertEqual(ports[0].port_name, pname)
    self.assertEqual(ports[0].ofport, ofport)
    self.assertEqual(ports[0].vif_id, vif_id)
    self.assertEqual(ports[0].vif_mac, mac)
    self.assertEqual(ports[0].switch.br_name, self.BR_NAME)
    self.mox.VerifyAll()
def _test_get_vif_ports(self, is_xen=False):
    pname = 'tap99'
    ofport = '6'
    vif_id = uuidutils.generate_uuid()
    mac = 'ca:fe:de:ad:be:ef'
    utils.execute(['ovs-vsctl', self.TO, 'list-ports', self.BR_NAME], root_helper=self.root_helper).AndReturn(('%s\n' % pname))
    if is_xen:
        external_ids = ('{xs-vif-uuid="%s", attached-mac="%s"}' % (vif_id, mac))
    else:
        external_ids = ('{iface-id="%s", attached-mac="%s"}' % (vif_id, mac))
    utils.execute(['ovs-vsctl', self.TO, 'get', 'Interface', pname, 'external_ids'], root_helper=self.root_helper).AndReturn(external_ids)
    utils.execute(['ovs-vsctl', self.TO, 'get', 'Interface', pname, 'ofport'], root_helper=self.root_helper).AndReturn(ofport)
    if is_xen:
        utils.execute(['xe', 'vif-param-get', 'param-name=other-config', 'param-key=nicira-iface-id', ('uuid=' + vif_id)], root_helper=self.root_helper).AndReturn(vif_id)
    self.mox.ReplayAll()
    ports = self.br.get_vif_ports()
    self.assertEqual(1, len(ports))
    self.assertEqual(ports[0].port_name, pname)
    self.assertEqual(ports[0].ofport, ofport)
    self.assertEqual(ports[0].vif_id, vif_id)
    self.assertEqual(ports[0].vif_mac, mac)
    self.assertEqual(ports[0].switch.br_name, self.BR_NAME)
    self.mox.VerifyAll()