From patchwork Mon Dec 23 01:34:57 2019
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
X-Patchwork-Submitter: taoyunxiang
X-Patchwork-Id: 1214809
Return-Path:
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@bilbo.ozlabs.org
Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized)
smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136;
helo=silver.osuosl.org;
envelope-from=ovs-dev-bounces@openvswitch.org;
receiver=)
Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none)
header.from=cmss.chinamobile.com
Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256
bits)) (No client certificate requested)
by ozlabs.org (Postfix) with ESMTPS id 47h24J5jj4z9sPW
for ;
Mon, 23 Dec 2019 12:36:00 +1100 (AEDT)
Received: from localhost (localhost [127.0.0.1])
by silver.osuosl.org (Postfix) with ESMTP id 55B002046E;
Mon, 23 Dec 2019 01:35:59 +0000 (UTC)
X-Virus-Scanned: amavisd-new at osuosl.org
Received: from silver.osuosl.org ([127.0.0.1])
by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id tfITAsWxftNy; Mon, 23 Dec 2019 01:35:57 +0000 (UTC)
Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56])
by silver.osuosl.org (Postfix) with ESMTP id 4327120472;
Mon, 23 Dec 2019 01:35:57 +0000 (UTC)
Received: from lf-lists.osuosl.org (localhost [127.0.0.1])
by lists.linuxfoundation.org (Postfix) with ESMTP id 29523C18DC;
Mon, 23 Dec 2019 01:35:57 +0000 (UTC)
X-Original-To: ovs-dev@openvswitch.org
Delivered-To: ovs-dev@lists.linuxfoundation.org
Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])
by lists.linuxfoundation.org (Postfix) with ESMTP id EF4AEC18DC
for ; Mon, 23 Dec 2019 01:35:55 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
by whitealder.osuosl.org (Postfix) with ESMTP id DC903861B2
for ; Mon, 23 Dec 2019 01:35:55 +0000 (UTC)
X-Virus-Scanned: amavisd-new at osuosl.org
Received: from whitealder.osuosl.org ([127.0.0.1])
by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id VtHDHoVkhjIC for ;
Mon, 23 Dec 2019 01:35:55 +0000 (UTC)
X-Greylist: from auto-whitelisted by SQLgrey-1.7.6
Received: from cmccmta1.chinamobile.com (cmccmta1.chinamobile.com
[221.176.66.79])
by whitealder.osuosl.org (Postfix) with ESMTP id 8B4CB8619A
for ; Mon, 23 Dec 2019 01:35:54 +0000 (UTC)
Received: from spf.mail.chinamobile.com (unknown[172.16.121.7]) by
rmmx-syy-dmz-app01-12001 (RichMail) with SMTP id
2ee15e0019c18e8-272e8; Mon, 23 Dec 2019 09:34:58 +0800 (CST)
X-RM-TRANSID: 2ee15e0019c18e8-272e8
X-RM-TagInfo: emlType=0
X-RM-SPAM-FLAG: 00000000
Received: from Yun (unknown[112.25.154.148])
by rmsmtp-syy-appsvr04-12004 (RichMail) with SMTP id
2ee45e0019c1c30-7dd2e; Mon, 23 Dec 2019 09:34:58 +0800 (CST)
X-RM-TRANSID: 2ee45e0019c1c30-7dd2e
Date: Mon, 23 Dec 2019 09:34:57 +0800
From: "taoyunxiang@cmss.chinamobile.com"
To: ovs-dev
X-Priority: 3
X-GUID: 88A9804A-2A92-45C7-BB87-B11F982684BF
X-Has-Attach: no
X-Mailer: Foxmail 7.2.13.365[cn]
Mime-Version: 1.0
Message-ID: <2019122309345673147612@cmss.chinamobile.com>
X-Content-Filtered-By: Mailman/MimeDel 2.1.15
Subject: [ovs-dev] [PATCH v2 1/2] ovn-nbctl.c: Add "name" column of QoS table
X-BeenThere: ovs-dev@openvswitch.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Errors-To: ovs-dev-bounces@openvswitch.org
Sender: "dev"
Add "name" column of QoS table
Add "name" column of QoS table and make qos could be list
by command "ovn-nbctl list qos "name"".
Signed-off-by: Yunxiang Tao
taoyunxiang@cmss.chinamobile.com
diff --git a/ovn-nb.ovsschema b/ovn-nb.ovsschema
index 12999a466..02ae48e73 100644
--- a/ovn-nb.ovsschema
+++ b/ovn-nb.ovsschema
@@ -1,7 +1,7 @@
{
"name": "OVN_Northbound",
"version": "5.18.0",
- "cksum": "2806349485 24196",
+ "cksum": "80177565 24240",
"tables": {
"NB_Global": {
"columns": {
@@ -204,6 +204,7 @@
"isRoot": false},
"QoS": {
"columns": {
+ "name": {"type": "string"},
"priority": {"type": {"key": {"type": "integer",
"minInteger": 0,
"maxInteger": 32767}}},
diff --git a/ovn-nb.xml b/ovn-nb.xml
index 4a93d2f4a..61e77397e 100644
--- a/ovn-nb.xml
+++ b/ovn-nb.xml
@@ -1662,6 +1662,12 @@
+
The value of this field is similar to [
X-Patchwork-Id: 1214808
Return-Path:
X-Original-To: incoming@patchwork.ozlabs.org
Delivered-To: patchwork-incoming@bilbo.ozlabs.org
Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized)
smtp.mailfrom=openvswitch.org (client-ip=140.211.166.136;
helo=silver.osuosl.org;
envelope-from=ovs-dev-bounces@openvswitch.org;
receiver=)
Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none)
header.from=cmss.chinamobile.com
Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])
(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256
bits)) (No client certificate requested)
by ozlabs.org (Postfix) with ESMTPS id 47h2464wKLz9sPW
for ;
Mon, 23 Dec 2019 12:35:49 +1100 (AEDT)
Received: from localhost (localhost [127.0.0.1])
by silver.osuosl.org (Postfix) with ESMTP id 471FE2040B;
Mon, 23 Dec 2019 01:35:47 +0000 (UTC)
X-Virus-Scanned: amavisd-new at osuosl.org
Received: from silver.osuosl.org ([127.0.0.1])
by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id kmy-ATe0YkiP; Mon, 23 Dec 2019 01:35:44 +0000 (UTC)
Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56])
by silver.osuosl.org (Postfix) with ESMTP id 941752043A;
Mon, 23 Dec 2019 01:35:44 +0000 (UTC)
Received: from lf-lists.osuosl.org (localhost [127.0.0.1])
by lists.linuxfoundation.org (Postfix) with ESMTP id 76358C18DC;
Mon, 23 Dec 2019 01:35:44 +0000 (UTC)
X-Original-To: ovs-dev@openvswitch.org
Delivered-To: ovs-dev@lists.linuxfoundation.org
Received: from whitealder.osuosl.org (smtp1.osuosl.org [140.211.166.138])
by lists.linuxfoundation.org (Postfix) with ESMTP id C6DFAC0881
for ; Mon, 23 Dec 2019 01:35:41 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
by whitealder.osuosl.org (Postfix) with ESMTP id C380E86186
for ; Mon, 23 Dec 2019 01:35:41 +0000 (UTC)
X-Virus-Scanned: amavisd-new at osuosl.org
Received: from whitealder.osuosl.org ([127.0.0.1])
by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id uGSi8FsCbl58 for ;
Mon, 23 Dec 2019 01:35:40 +0000 (UTC)
X-Greylist: from auto-whitelisted by SQLgrey-1.7.6
Received: from cmccmta1.chinamobile.com (cmccmta1.chinamobile.com
[221.176.66.79])
by whitealder.osuosl.org (Postfix) with ESMTP id 1251286055
for ; Mon, 23 Dec 2019 01:35:38 +0000 (UTC)
Received: from spf.mail.chinamobile.com (unknown[172.16.121.13]) by
rmmx-syy-dmz-app02-12002 (RichMail) with SMTP id
2ee25e0019cbd0f-27bae; Mon, 23 Dec 2019 09:35:07 +0800 (CST)
X-RM-TRANSID: 2ee25e0019cbd0f-27bae
X-RM-TagInfo: emlType=0
X-RM-SPAM-FLAG: 00000000
Received: from Yun (unknown[112.25.154.148])
by rmsmtp-syy-appsvr07-12007 (RichMail) with SMTP id
2ee75e0019c9938-fd5b1; Mon, 23 Dec 2019 09:35:07 +0800 (CST)
X-RM-TRANSID: 2ee75e0019c9938-fd5b1
Date: Mon, 23 Dec 2019 09:35:05 +0800
From: "taoyunxiang@cmss.chinamobile.com"
To: ovs-dev
X-Priority: 3
X-GUID: 98DA1A09-F1A9-4107-BA63-CB1B5137052E
X-Has-Attach: no
X-Mailer: Foxmail 7.2.13.365[cn]
Mime-Version: 1.0
Message-ID: <2019122309350468224413@cmss.chinamobile.com>
X-Content-Filtered-By: Mailman/MimeDel 2.1.15
Subject: [ovs-dev] [PATCH v2 2/2] ovn-nbctl.c: Add a way to delete QoS by
its name or uuid
X-BeenThere: ovs-dev@openvswitch.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id:
List-Unsubscribe: ,
List-Archive:
List-Post:
List-Help:
List-Subscribe: ,
Errors-To: ovs-dev-bounces@openvswitch.org
Sender: "dev"
Add a way to delete QoS by its name or uuid
Currently, qos can only be deleted by indirect way which must designate
switch or more parameters. This patch change the original "qos-del" to
"ls-qos-del", and add a new "qos-del" command. By the new command, you
can delete qos by uuid or name of the qos. It is very import to support
a way to delete a table by direct way. For example, we can associate
the qos table in neutron and OVN by "name" of qos in OVN, so neutron
could find and easily delete the corresponding qos in OVN.
Signed-off-by: Yunxiang Tao
taoyunxiang@cmss.chinamobile.com
diff --git a/utilities/ovn-nbctl.c b/utilities/ovn-nbctl.c
index 93e37d169..f1d64208d 100644
--- a/utilities/ovn-nbctl.c
+++ b/utilities/ovn-nbctl.c
@@ -604,8 +604,9 @@ ACL commands:\n\
QoS commands:\n\
qos-add SWITCH DIRECTION PRIORITY MATCH [rate=RATE [burst=BURST]] [dscp=DSCP]\n\
add an QoS rule to SWITCH\n\
- qos-del SWITCH [DIRECTION [PRIORITY MATCH]]\n\
+ ls-qos-del SWITCH [DIRECTION [PRIORITY MATCH]]\n\
remove QoS rules from SWITCH\n\
+ qos-del QOS remove QoS rules by name or UUID\n\
qos-list SWITCH print QoS rules for SWITCH\n\
\n\
Meter commands:\n\
@@ -2490,7 +2491,7 @@ nbctl_qos_add(struct ctl_context *ctx)
}
static void
-nbctl_qos_del(struct ctl_context *ctx)
+nbctl_ls_qos_del(struct ctl_context *ctx)
{
const struct nbrec_logical_switch *ls;
char *error = ls_by_name_or_uuid(ctx, ctx->argv[1], true, &ls);
@@ -2564,6 +2565,96 @@ nbctl_qos_del(struct ctl_context *ctx)
}
}
+/* Remove qos*/
+static void
+remove_qos(const struct nbrec_logical_switch *ls, size_t idx)
+{
+
+ /* First remove 'qos' from the array of qos_rules. This is what will
+ * actually cause the qos to be deleted when the transaction is
+ * sent to the database server (due to garbage collection). */
+ struct nbrec_qos **new_qos_rules
+ = xmemdup(ls->qos_rules, sizeof *new_qos_rules * ls->n_qos_rules);
+ new_qos_rules[idx] = new_qos_rules[ls->n_qos_rules - 1];
+ nbrec_logical_switch_verify_qos_rules(ls);
+ nbrec_logical_switch_set_qos_rules(ls, new_qos_rules, \
+ ls->n_qos_rules - 1);
+ free(new_qos_rules);
+
+ /* Delete 'qos' from the IDL.This won't have a real effect on the
+ * database server (the IDL will suppress it in fact) but it means that it
+ * won't show up when we iterate with NBREC_LOGICAL_QOS_FOR_EACH later. */
+}
+
+static char * OVS_WARN_UNUSED_RESULT
+qos_by_name_or_uuid(struct ctl_context *ctx, const char *id, bool must_exist,
+ const struct nbrec_qos **qos_p)
+{
+ const struct nbrec_qos *qos = NULL;
+ *qos_p = NULL;
+
+ struct uuid qos_uuid;
+ bool is_uuid = uuid_from_string(&qos_uuid, id);
+ if (is_uuid) {
+ qos = nbrec_qos_get_for_uuid(ctx->idl, &qos_uuid);
+ }
+
+ if (!qos) {
+ const struct nbrec_qos *iter;
+
+ NBREC_QOS_FOR_EACH(iter, ctx->idl) {
+ if (strcmp(iter->name, id)) {
+ continue;
+ }
+ if (qos) {
+ return xasprintf("Multiple qos named '%s'. "
+ "Use a UUID.", id);
+ }
+ qos = iter;
+ }
+ }
+
+ if (!qos && must_exist) {
+ return xasprintf("%s: qos %s not found",
+ id, is_uuid ? "UUID" : "name");
+ }
+
+ *qos_p = qos;
+ return NULL;
+}
+
+static void
+nbctl_qos_del(struct ctl_context *ctx)
+{
+ bool must_exist = !shash_find(&ctx->options, "--if-exists");
+ const char *id = ctx->argv[1];
+ const struct nbrec_qos *qos = NULL;
+
+ char *error = qos_by_name_or_uuid(ctx, id, must_exist, &qos);
+ if (error) {
+ ctx->error = error;
+ return;
+ }
+ if (!qos) {
+ return;
+ }
+
+ /* Find the switch that contains 'qos_rules', then delete it. */
+ const struct nbrec_logical_switch *ls;
+ NBREC_LOGICAL_SWITCH_FOR_EACH (ls, ctx->idl) {
+ for (size_t i = 0; i < ls->n_qos_rules; i++) {
+ if (ls->qos_rules[i] == qos) {
+ remove_qos(ls, i);
+ return;
+ }
+ }
+ }
+
+ /* Can't happen because of the database schema. */
+ ctl_error(ctx, "qos %s is not part of any logical switch",
+ ctx->argv[1]);
+}
+
static int
meter_cmp(const void *meter1_, const void *meter2_)
{
@@ -5652,8 +5743,9 @@ static const struct ctl_command_syntax nbctl_commands[] = {
{ "qos-add", 5, 7,
"SWITCH DIRECTION PRIORITY MATCH [rate=RATE [burst=BURST]] [dscp=DSCP]",
NULL, nbctl_qos_add, NULL, "--may-exist", RW },
- { "qos-del", 1, 4, "SWITCH [DIRECTION [PRIORITY MATCH]]", NULL,
- nbctl_qos_del, NULL, "", RW },
+ { "qos-del", 1, 1, "QOS", NULL, nbctl_qos_del, NULL, "--if-exists", RW },
+ { "ls-qos-del", 1, 4, "SWITCH [DIRECTION [PRIORITY MATCH]]", NULL,
+ nbctl_ls_qos_del, NULL, "", RW },
{ "qos-list", 1, 1, "SWITCH", NULL, nbctl_qos_list, NULL, "", RO },
/* meter commands. */
]