[ovs-dev] [PATCH] Copy external_ids from Logical_Switch_Port to SB database

Russell Bryant russell at ovn.org
Wed May 31 18:48:41 UTC 2017


On Wed, May 31, 2017 at 12:18 PM, Daniel Alvarez <dalvarez at redhat.com> wrote:
> This patch makes ovn-northd copy all string-string pairs in
> external_ids column of the Logical_Switch_Port table in Northbound
> database to the equivalent column of the Port_Binding table in
> Southbound database.
>
> OpenStack Neutron will add some useful data to NB database that can be
> later read by networking-ovn-metadata-agent without the need of
> maintaining a connection to NB database. This data would include
> the CIDR's of a port or the project and device ID's which are needed
> when talking to Nova to request metadata.
> ---
>  ovn/northd/ovn-northd.c | 12 ++++++++----
>  ovn/ovn-nb.xml          | 11 ++++++++++-
>  2 files changed, 18 insertions(+), 5 deletions(-)
>
> diff --git a/ovn/northd/ovn-northd.c b/ovn/northd/ovn-northd.c
> index 5914988..d4c5f3a 100644
> --- a/ovn/northd/ovn-northd.c
> +++ b/ovn/northd/ovn-northd.c
> @@ -1814,10 +1814,14 @@ ovn_port_update_sbrec(const struct ovn_port *op,
>                                     op->nbsp->n_addresses);
>
>          struct smap ids = SMAP_INITIALIZER(&ids);
> -        const char *name = smap_get(&op->nbsp->external_ids,
> -                                    "neutron:port_name");
> -        if (name && name[0]) {
> -            smap_add(&ids, "name", name);
> +        struct smap_node *id;
> +        SMAP_FOR_EACH (id, &op->nbsp->external_ids) {
> +            if(!strcmp(id->key, "neutron:port_name")) {
> +                if(id->value[0])
> +                    smap_add(&ids, "name", id->value);
> +            }
> +            else
> +                smap_add(&ids, id->key, id->value);

An easier way to do this would be ...

struct smap ids;
smap_clone(&ids, &op->nbsp->external_ids);

>          }
>          sbrec_port_binding_set_external_ids(op->sb, &ids);
>      }

or even easier, if we're just blind copying everything:

sbrec_port_binding_set_external_ids(op->sb, &op->nbsp->external_ids);

There's a more general question of whether we want to copy everything,
or make sure we have an explicit understanding of external-ids we know
about.  Copying everything is really convenient, but it's also nice to
have a conversation about each use case in case there's something
better we can do that would benefit other projects as well.

In this case, based on our IRC conversation, there are 3 pieces of
information you'd like to have associated with a Port_Binding:

1) network prefix length for each IP address associated with the port

2) a "project ID" -- an openstack tenancy identifier

3) a "device ID" -- an ID for the openstack VM the port is associated with

#1 seems like something that could be more generally useful.  We
discussed this on IRC, but perhaps we should just update the addresses
column to optionally allow you specify a prefix length with an
address?

#2 and #3 seem OpenStack specific, and just leaving them as
external-ids that get copied over seems fine.  I'm also OK with a bulk
copy.  It may be nice to document the specific external-ids you plan
to use, just so people have a reference that explains what they are
when they go to debug an environment.

> diff --git a/ovn/ovn-nb.xml b/ovn/ovn-nb.xml
> index eb348fe..7bb322f 100644
> --- a/ovn/ovn-nb.xml
> +++ b/ovn/ovn-nb.xml
> @@ -848,7 +848,16 @@
>
>      <group title="Common Columns">
>        <column name="external_ids">
> -        See <em>External IDs</em> at the beginning of this document.
> +        <p>
> +          See <em>External IDs</em> at the beginning of this document.
> +        </p>
> +
> +        <p>
> +          The <code>ovn-northd</code> program copies all these pairs into the
> +          <ref column="external_ids"/> column of the
> +          <ref table="Port_Binding"/> table in <ref db="OVN_Southbound"/>
> +          database.
> +        </p>
>        </column>
>      </group>
>    </table>
> --
> 1.8.3.1
>
> _______________________________________________
> dev mailing list
> dev at openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev



-- 
Russell Bryant


More information about the dev mailing list