def _create_port(self, network_id, port_state, fmt, custom_req_body=None, expected_res_status=202):
     LOG.debug("Creating port for network %s", network_id)
     content_type = "application/%s" % fmt
     port_req = testlib.new_port_request(self.tenant_id, network_id, port_state, fmt, custom_req_body)
     port_res = port_req.get_response(self.api)
     self.assertEqual(port_res.status_int, expected_res_status)
     if expected_res_status in (200, 202):
         port_data = self._deserialize_port_response(content_type, port_res)
         return port_data["port"]["id"]