def test_get_gbp_details(self):
        self._mock_external_dict([('supported', '192.168.0.2/24')])
        self.driver.apic_manager.ext_net_dict[
                'supported']['host_pool_cidr'] = '192.168.200.1/24'
        es = self.create_external_segment(name='supported',
            cidr='192.168.0.2/24',
            expected_res_status=201, shared=False)['external_segment']
        self.create_nat_pool(external_segment_id=es['id'],
                             ip_pool='20.20.20.0/24')
        l3p = self.create_l3_policy(name='myl3',
            external_segments={es['id']: ['']})['l3_policy']
        l2p = self.create_l2_policy(name='myl2',
                                    l3_policy_id=l3p['id'])['l2_policy']
        nsp = self.create_network_service_policy(
            network_service_params=[
                {"type": "ip_pool", "value": "nat_pool", "name": "test"}])[
            'network_service_policy']
        ptg = self.create_policy_target_group(
            name="ptg1", l2_policy_id=l2p['id'],
            network_service_policy_id=nsp['id'])['policy_target_group']
        pt1 = self.create_policy_target(
            policy_target_group_id=ptg['id'])['policy_target']
        self._bind_port_to_host(pt1['port_id'], 'h1')

        mapping = self.driver.get_gbp_details(context.get_admin_context(),
            device=pt1['port_id'] % 'tap%s', host='h1')
        self.assertEqual(pt1['port_id'], mapping['port_id'])
        self.assertEqual(ptg['id'], mapping['endpoint_group_name'])
        self.assertEqual('someid', mapping['vm-name'])
        self.assertTrue(mapping['enable_dhcp_optimization'])
        self.assertEqual(1, len(mapping['subnets']))
        self.assertEqual(ptg['subnets'][0], mapping['subnets'][0]['id'])
        self.assertEqual(1, len(mapping['floating_ip']))
        fip = mapping['floating_ip'][0]
        self.assertEqual(pt1['port_id'], fip['port_id'])
        self.assertEqual("NAT-epg-%s" % es['id'], fip['nat_epg_name'])
        self.assertEqual(es['tenant_id'], fip['nat_epg_tenant'])

        self.assertEqual(l3p['tenant_id'], mapping['vrf_tenant'])
        self.assertEqual(l3p['id'], mapping['vrf_name'])
        if 'proxy_ip_pool' in l3p:
            self.assertEqual([l3p['ip_pool'], l3p['proxy_ip_pool']],
                             mapping['vrf_subnets'])
        else:
            self.assertEqual([l3p['ip_pool']], mapping['vrf_subnets'])
        self.assertEqual(1, len(mapping['host_snat_ips']))
        self.assertEqual(es['name'],
            mapping['host_snat_ips'][0]['external_segment_name'])
        self.assertEqual("192.168.200.1",
            mapping['host_snat_ips'][0]['gateway_ip'])
        self.assertEqual("192.168.200.2",
            mapping['host_snat_ips'][0]['host_snat_ip'])
        self.assertEqual(24, mapping['host_snat_ips'][0]['prefixlen'])

        # Create event on a second host to verify that the SNAT
        # port gets created for this second host
        pt2 = self.create_policy_target(
            policy_target_group_id=ptg['id'])['policy_target']
        self._bind_port_to_host(pt2['port_id'], 'h1')

        mapping = self.driver.get_gbp_details(context.get_admin_context(),
            device='tap%s' % pt2['port_id'], host='h2')
        self.assertEqual(pt2['port_id'], mapping['port_id'])
        self.assertEqual(1, len(mapping['host_snat_ips']))
        self.assertEqual(es['name'],
            mapping['host_snat_ips'][0]['external_segment_name'])
        self.assertEqual("192.168.200.1",
            mapping['host_snat_ips'][0]['gateway_ip'])
        self.assertEqual("192.168.200.3",
            mapping['host_snat_ips'][0]['host_snat_ip'])
        self.assertEqual(24, mapping['host_snat_ips'][0]['prefixlen'])
dataset/ETHPy150Open openstack/group-based-policy/gbpservice/neutron/tests/unit/services/grouppolicy/test_apic_mapping.py/TestPolicyTarget.test_get_gbp_details/swapped operands of `%`