'Test preserve pre-existing port
Tests that a pre-existing port provided on server boot is not deleted
if the server is deleted.
Nova should unbind the port from the instance on delete if the port was
not created by Nova as part of the boot request.
We should also be able to boot another server with the same port.'

@decorators.idempotent_id('759462e1-8535-46b0-ab3a-33aa45c55aaa')
@decorators.attr(type='slow')
@test.services('compute', 'network')
def test_preserve_preexisting_port(self):

    self._setup_network_and_servers(boot_with_port=True)
    (_, server) = self.floating_ip_tuple
    self.assertEqual(1, len(self.ports), ('There    should    only    be    one    port    created    for    server    %s.' % server['id']))
    port_id = self.ports[0]['port']
    self.assertIsNotNone(port_id, 'Server    should    have    been    created    from    a    pre-existing    port.')
    port_list = self.os_admin.ports_client.list_ports(device_id=server['id'], network_id=self.network['id'])['ports']
    self.assertEqual(1, len(port_list), ('There    should    only    be    one    port    created    for    server    %s.' % server['id']))
    self.assertEqual(port_id, port_list[0]['id'])
    self.servers_client.delete_server(server['id'])
    waiters.wait_for_server_termination(self.servers_client, server['id'])
    port = self.ports_client.show_port(port_id)['port']
    self.assertEqual(self.network['id'], port['network_id'])
    self.assertEqual('', port['device_id'])
    self.assertEqual('', port['device_owner'])
    server = self._create_server(self.network, port['id'])
    port_list = self.os_admin.ports_client.list_ports(device_id=server['id'], network_id=self.network['id'])['ports']
    self.assertEqual(1, len(port_list), ('There    should    only    be    one    port    created    for    server    %s.' % server['id']))
    self.assertEqual(port['id'], port_list[0]['id'])
