'verify we have no port to delete
if we fail to allocate the first net resource.
Mox to raise exception when creating the first port.
In this case, the code should not delete any ports.'

def test_allocate_for_instance_ex2(self):

    self.instance = fake_instance.fake_instance_obj(self.context, **self.instance)
    api = neutronapi.API()
    requested_networks = objects.NetworkRequestList(objects=[objects.NetworkRequest(network_id=net['id']) for net in (self.nets2[0], self.nets2[1])])
    neutronapi.get_client(mox.IgnoreArg()).AndReturn(self.moxed_client)
    self.moxed_client.list_networks(id=[uuids.my_netid1, uuids.my_netid2]).AndReturn({'networks': self.nets2})
    port_req_body = {'port': {'network_id': self.nets2[0]['id'], 'admin_state_up': True, 'device_id': self.instance.uuid, 'tenant_id': self.instance.project_id}}
    self.moxed_client.create_port(MyComparator(port_req_body)).AndRaise(Exception('fail    to    create    port'))
    self.mox.ReplayAll()
    self.assertRaises(NEUTRON_CLIENT_EXCEPTION, api.allocate_for_instance, self.context, self.instance, False, requested_networks=requested_networks)
