Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/1558023/?format=api
{ "id": 1558023, "url": "http://patchwork.ozlabs.org/api/patches/1558023/?format=api", "web_url": "http://patchwork.ozlabs.org/project/openvswitch/patch/20211122112256.2011194-7-amorenoz@redhat.com/", "project": { "id": 47, "url": "http://patchwork.ozlabs.org/api/projects/47/?format=api", "name": "Open vSwitch", "link_name": "openvswitch", "list_id": "ovs-dev.openvswitch.org", "list_email": "ovs-dev@openvswitch.org", "web_url": "http://openvswitch.org/", "scm_url": "git@github.com:openvswitch/ovs.git", "webscm_url": "https://github.com/openvswitch/ovs", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20211122112256.2011194-7-amorenoz@redhat.com>", "list_archive_url": null, "date": "2021-11-22T11:22:44", "name": "[ovs-dev,v1,06/18] python: add flow base class", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "9dc5e37700513b4ceda4a60f4add31c3044a70d6", "submitter": { "id": 77477, "url": "http://patchwork.ozlabs.org/api/people/77477/?format=api", "name": "Adrian Moreno", "email": "amorenoz@redhat.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/openvswitch/patch/20211122112256.2011194-7-amorenoz@redhat.com/mbox/", "series": [ { "id": 273222, "url": "http://patchwork.ozlabs.org/api/series/273222/?format=api", "web_url": "http://patchwork.ozlabs.org/project/openvswitch/list/?series=273222", "date": "2021-11-22T11:22:39", "name": "python: add flow parsing library", "version": 1, "mbox": "http://patchwork.ozlabs.org/series/273222/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/1558023/comments/", "check": "fail", "checks": "http://patchwork.ozlabs.org/api/patches/1558023/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<ovs-dev-bounces@openvswitch.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "dev@openvswitch.org" ], "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "ovs-dev@lists.linuxfoundation.org" ], "Authentication-Results": [ "bilbo.ozlabs.org;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=Cu3vjn2n;\n\tdkim-atps=neutral", "ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org\n (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org;\n envelope-from=ovs-dev-bounces@openvswitch.org; receiver=<UNKNOWN>)", "smtp1.osuosl.org (amavisd-new);\n dkim=pass (1024-bit key) header.d=redhat.com", "relay.mimecast.com;\n auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=amorenoz@redhat.com" ], "Received": [ "from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby bilbo.ozlabs.org (Postfix) with ESMTPS id 4HyPzy17q1z9sRR\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 22 Nov 2021 22:24:14 +1100 (AEDT)", "from localhost (localhost [127.0.0.1])\n\tby smtp2.osuosl.org (Postfix) with ESMTP id AE34940423;\n\tMon, 22 Nov 2021 11:24:11 +0000 (UTC)", "from smtp2.osuosl.org ([127.0.0.1])\n\tby localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n\twith ESMTP id gRAQIcbOirRB; Mon, 22 Nov 2021 11:24:10 +0000 (UTC)", "from lists.linuxfoundation.org (lf-lists.osuosl.org\n [IPv6:2605:bc80:3010:104::8cd3:938])\n\tby smtp2.osuosl.org (Postfix) with ESMTPS id 79114403F3;\n\tMon, 22 Nov 2021 11:24:09 +0000 (UTC)", "from lf-lists.osuosl.org (localhost [127.0.0.1])\n\tby lists.linuxfoundation.org (Postfix) with ESMTP id 2F1C2C0036;\n\tMon, 22 Nov 2021 11:24:09 +0000 (UTC)", "from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138])\n by lists.linuxfoundation.org (Postfix) with ESMTP id D0E1BC0012\n for <dev@openvswitch.org>; Mon, 22 Nov 2021 11:24:07 +0000 (UTC)", "from localhost (localhost [127.0.0.1])\n by smtp1.osuosl.org (Postfix) with ESMTP id 50EFC80F34\n for <dev@openvswitch.org>; Mon, 22 Nov 2021 11:23:35 +0000 (UTC)", "from smtp1.osuosl.org ([127.0.0.1])\n by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)\n with ESMTP id ImOSwcJcinP3 for <dev@openvswitch.org>;\n Mon, 22 Nov 2021 11:23:34 +0000 (UTC)", "from us-smtp-delivery-124.mimecast.com\n (us-smtp-delivery-124.mimecast.com [170.10.129.124])\n by smtp1.osuosl.org (Postfix) with ESMTPS id 99A9180F3C\n for <dev@openvswitch.org>; Mon, 22 Nov 2021 11:23:34 +0000 (UTC)", "from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com\n [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id\n us-mta-43-RTRAbeE2Mze1RBZkh7eerQ-1; Mon, 22 Nov 2021 06:23:29 -0500", "from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com\n [10.5.11.13])\n (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits))\n (No client certificate requested)\n by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C7071005E4C\n for <dev@openvswitch.org>; Mon, 22 Nov 2021 11:23:28 +0000 (UTC)", "from amorenoz.users.ipa.redhat.com (unknown [10.2.16.196])\n by smtp.corp.redhat.com (Postfix) with ESMTP id 7F81C60862;\n Mon, 22 Nov 2021 11:23:27 +0000 (UTC)" ], "X-Virus-Scanned": [ "amavisd-new at osuosl.org", "amavisd-new at osuosl.org" ], "X-Greylist": "domain auto-whitelisted by SQLgrey-1.8.0", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1637580213;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:content-type:content-type:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=jbNVNWPRH9BlM5PcA5P8/vXQ3bBMN7IuWg1EIb6tHx8=;\n b=Cu3vjn2ne36yiN/YWZ0Xodfuu/WRiDpn7shomOqwvwGm0b2DIzeceIVXNf9NXm1vbaY89k\n YYt3sgS/em/lnQ4hRPiyvyWn+rXaL6Ze20ZzzoGdXYh+zKPv9iw9p9VR+FbZOqjEZV4AqZ\n uFPhJn+Jay5jJK1IdlW9NNv0BfoyZsc=", "X-MC-Unique": "RTRAbeE2Mze1RBZkh7eerQ-1", "From": "Adrian Moreno <amorenoz@redhat.com>", "To": "dev@openvswitch.org", "Date": "Mon, 22 Nov 2021 12:22:44 +0100", "Message-Id": "<20211122112256.2011194-7-amorenoz@redhat.com>", "In-Reply-To": "<20211122112256.2011194-1-amorenoz@redhat.com>", "References": "<20211122112256.2011194-1-amorenoz@redhat.com>", "MIME-Version": "1.0", "X-Scanned-By": "MIMEDefang 2.79 on 10.5.11.13", "X-Mimecast-Spam-Score": "0", "X-Mimecast-Originator": "redhat.com", "Subject": "[ovs-dev] [PATCH v1 06/18] python: add flow base class", "X-BeenThere": "ovs-dev@openvswitch.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "<ovs-dev.openvswitch.org>", "List-Unsubscribe": "<https://mail.openvswitch.org/mailman/options/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=unsubscribe>", "List-Archive": "<http://mail.openvswitch.org/pipermail/ovs-dev/>", "List-Post": "<mailto:ovs-dev@openvswitch.org>", "List-Help": "<mailto:ovs-dev-request@openvswitch.org?subject=help>", "List-Subscribe": "<https://mail.openvswitch.org/mailman/listinfo/ovs-dev>,\n <mailto:ovs-dev-request@openvswitch.org?subject=subscribe>", "Content-Type": "text/plain; charset=\"us-ascii\"", "Content-Transfer-Encoding": "7bit", "Errors-To": "ovs-dev-bounces@openvswitch.org", "Sender": "\"dev\" <ovs-dev-bounces@openvswitch.org>" }, "content": "It simplifies the implementation of different types of flows by creating\nthe concept of Section (e.g: match, action) and automatic accessors for\nall the provided Sections\n\nSigned-off-by: Adrian Moreno <amorenoz@redhat.com>\n---\n python/automake.mk | 3 +-\n python/ovs/flows/flow.py | 94 ++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 96 insertions(+), 1 deletion(-)\n create mode 100644 python/ovs/flows/flow.py", "diff": "diff --git a/python/automake.mk b/python/automake.mk\nindex 9dfc62fce..136da26bd 100644\n--- a/python/automake.mk\n+++ b/python/automake.mk\n@@ -45,7 +45,8 @@ ovs_pyfiles = \\\n \tpython/ovs/flows/__init__.py \\\n \tpython/ovs/flows/decoders.py \\\n \tpython/ovs/flows/kv.py \\\n-\tpython/ovs/flows/list.py\n+\tpython/ovs/flows/list.py \\\n+\tpython/ovs/flows/flow.py\n \n # These python files are used at build time but not runtime,\n # so they are not installed.\ndiff --git a/python/ovs/flows/flow.py b/python/ovs/flows/flow.py\nnew file mode 100644\nindex 000000000..ad5846c0b\n--- /dev/null\n+++ b/python/ovs/flows/flow.py\n@@ -0,0 +1,94 @@\n+\"\"\" Defines the Flow class\n+\"\"\"\n+\n+\n+class Section(object):\n+ \"\"\"A section within a Flow\n+\n+ Attributes:\n+ name (str): name of the section\n+ pos (int): position within the overall flow string\n+ string (str): section string\n+ data (list[KeyValue]): parsed data of the section\n+ is_list (bool): whether the key-values shall be expressed as a list\n+ (e.g: it allows repeated keys)\n+ \"\"\"\n+\n+ def __init__(self, name, pos, string, data, is_list=False):\n+ self.name = name\n+ self.pos = pos\n+ self.string = string\n+ self.data = data\n+ self.is_list = is_list\n+\n+ def __str__(self):\n+ return \"{} (at {}): {}\".format(self.name, self.pos, self.string)\n+\n+ def __repr__(self):\n+ return \"%s('%s')\" % (self.__class__.__name__, self)\n+\n+ def dict(self):\n+ return {self.name: self.format_data()}\n+\n+ def format_data(self):\n+ if self.is_list:\n+ return [{item.key: item.value} for item in self.data]\n+ else:\n+ return {item.key: item.value for item in self.data}\n+\n+\n+class Flow(object):\n+ \"\"\"The Flow class is a base class for other types of concrete flows\n+ (such as OFproto Flows or DPIF Flows)\n+\n+ For each section provided, the object will have the following attributes\n+ {section} will return the sections data in a formatted way\n+ {section}_kv will return the sections data as a list of KeyValues\n+\n+ Args:\n+ sections (list[Section]): list of sections that comprise the flow\n+ orig (str): Original flow string\n+ id (Any): Identifier\n+ \"\"\"\n+\n+ def __init__(self, sections, orig=\"\", id=None):\n+ self._sections = sections\n+ self._orig = orig\n+ self._id = id\n+ for section in sections:\n+ setattr(\n+ self, section.name, self.section(section.name).format_data()\n+ )\n+ setattr(\n+ self,\n+ \"{}_kv\".format(section.name),\n+ self.section(section.name).data,\n+ )\n+\n+ def section(self, name):\n+ \"\"\"Return the section by name\"\"\"\n+ return next(\n+ (sect for sect in self._sections if sect.name == name), None\n+ )\n+\n+ @property\n+ def id(self):\n+ \"\"\"Return the Flow ID\"\"\"\n+ return self._id\n+\n+ @property\n+ def sections(self):\n+ \"\"\"Return the section by name\"\"\"\n+ return self._sections\n+\n+ @property\n+ def orig(self):\n+ return self._orig\n+\n+ def dict(self):\n+ \"\"\"Returns the Flow information in a dictionary\"\"\"\n+ flow_dict = {\"orig\": self.orig}\n+ for section in self.sections:\n+ flow_dict.update(section.dict())\n+\n+ return flow_dict\n", "prefixes": [ "ovs-dev", "v1", "06/18" ] }