v2 validity checks

Bug #1015148 reported by Gary Kotton
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
Gary Kotton

Bug Description

The user is now able to configure ip adresses, macs, etc.
There should be validity checks for the input.

Below is an exmaple how the client created a subnet 1/1.

(quantumv2) create_subnet --tenant-id admin 24a0efdb-5f5a-4ee5-98a1-c23cc05618cc 1/1
Created a new subnet:
+------------+--------------------------------------+
| Field | Value |
+------------+--------------------------------------+
| cidr | 1/1 |
| gateway_ip | 0.0.0.1 |
| id | 9c59da47-bf61-4a5e-a854-588f61f3b553 |
| ip_version | 4 |
| network_id | 24a0efdb-5f5a-4ee5-98a1-c23cc05618cc |
+------------+--------------------------------------+

Gary Kotton (garyk)
tags: added: low-hanging-fruit
Changed in quantum:
status: New → Confirmed
Revision history for this message
Chinmay Kulkarni (chnm-kulkarni) wrote :

I'm guessing that this would involve a database lookup to confirm the tenant and the network id??

Revision history for this message
Chinmay Kulkarni (chnm-kulkarni) wrote :

and does the current python-quantumclient have support form v2.0??

Changed in quantum:
assignee: nobody → Abhinav Sonker (mail-abhinavsonker)
Revision history for this message
Abhinav Sonker (mail-abhinavsonker) wrote :

It needs a database lookups and its implementation is still not out, so we might have to wait till it is completely out

Revision history for this message
Harsh Prasad (prasad-tanay) wrote :

Can anyone suggest how to start developing a plugin using v2 apis? Cant find any documentation related other than v2Api Intro.

Revision history for this message
dan wendlandt (danwent) wrote : Re: [Bug 1015148] Re: v2 validity checks

On Thu, Jun 21, 2012 at 4:55 AM, Harsh Prasad <email address hidden>wrote:

> Can anyone suggest how to start developing a plugin using v2 apis? Cant
> find any documentation related other than v2Api Intro.
>

Hi Harsh,

You'll want to sub-class or otherwise utilize the capabilities in
quantum/db/db_plugin_base.py . This class will store all of the basic L2
network and IPAM data for you, and handle allocation logic. Anything
special that your plugin does beyond this (e.g., allocate a VLAN used to
implement a network, contact remote switches) is plugin specific, and would
be added by your sub-class. Make sense?

For F-2 we'll be updating the OVS plugin to work with v2 API, as its a very
simple example. I expect most other people to work on updating more complex
plugins during F-3, and they can use the OVS plugin as an example.

Dan

>
> --
> You received this bug notification because you are a member of Netstack
> Core Developers, which is subscribed to quantum.
> https://bugs.launchpad.net/bugs/1015148
>
> Title:
> v2 validity checks
>
> Status in OpenStack Quantum (virtual network service):
> Confirmed
>
> Bug description:
> The user is now able to configure ip adresses, macs, etc.
> There should be validity checks for the input.
>
> Below is an exmaple how the client created a subnet 1/1.
>
> (quantumv2) create_subnet --tenant-id admin
> 24a0efdb-5f5a-4ee5-98a1-c23cc05618cc 1/1
> Created a new subnet:
> +------------+--------------------------------------+
> | Field | Value |
> +------------+--------------------------------------+
> | cidr | 1/1 |
> | gateway_ip | 0.0.0.1 |
> | id | 9c59da47-bf61-4a5e-a854-588f61f3b553 |
> | ip_version | 4 |
> | network_id | 24a0efdb-5f5a-4ee5-98a1-c23cc05618cc |
> +------------+--------------------------------------+
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/quantum/+bug/1015148/+subscriptions
>

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dan Wendlandt
Nicira, Inc: www.nicira.com
twitter: danwendlandt
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Revision history for this message
Chinmay Kulkarni (chnm-kulkarni) wrote :

This is with regard to what harsh posted earlier. i had a look at the pdb_plugin_base_v2 file and the corressponding models_v2 file used to update your databases. i did not notice any uuid filed in your network model definition but your make_network_dictionary did contain a network_id field. Could you tell me how these id's are being assigned in v2??

Revision history for this message
Chinmay Kulkarni (chnm-kulkarni) wrote :

i meant uuid field..

Revision history for this message
dan wendlandt (danwent) wrote :

Look at the base class QuantumBaseV2 in db/models_v2.py

its the 'id' field.

Revision history for this message
Harsh Prasad (prasad-tanay) wrote :

That was great help Dan. db_plugin_base_v2.py explains everything. Thanks!

Revision history for this message
Harsh Prasad (prasad-tanay) wrote :

And QuantumBasev2 is in model_base.py.

Revision history for this message
dan wendlandt (danwent) wrote :

ah, yes, correct :)

On Mon, Jun 25, 2012 at 5:23 AM, Harsh Prasad <email address hidden>wrote:

> And QuantumBasev2 is in model_base.py.
>
> --
> You received this bug notification because you are a member of Netstack
> Core Developers, which is subscribed to quantum.
> https://bugs.launchpad.net/bugs/1015148
>
> Title:
> v2 validity checks
>
> Status in OpenStack Quantum (virtual network service):
> Confirmed
>
> Bug description:
> The user is now able to configure ip adresses, macs, etc.
> There should be validity checks for the input.
>
> Below is an exmaple how the client created a subnet 1/1.
>
> (quantumv2) create_subnet --tenant-id admin
> 24a0efdb-5f5a-4ee5-98a1-c23cc05618cc 1/1
> Created a new subnet:
> +------------+--------------------------------------+
> | Field | Value |
> +------------+--------------------------------------+
> | cidr | 1/1 |
> | gateway_ip | 0.0.0.1 |
> | id | 9c59da47-bf61-4a5e-a854-588f61f3b553 |
> | ip_version | 4 |
> | network_id | 24a0efdb-5f5a-4ee5-98a1-c23cc05618cc |
> +------------+--------------------------------------+
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/quantum/+bug/1015148/+subscriptions
>

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~
Dan Wendlandt
Nicira, Inc: www.nicira.com
twitter: danwendlandt
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Changed in quantum:
milestone: none → folsom-3
importance: Undecided → Medium
Revision history for this message
Chinmay Kulkarni (chnm-kulkarni) wrote :

hey,

i'm guessing that this would need the followwing snippet of code
try:
            net_check = self._get_by_id(context, models_v2.Network, id,
                                      joins=('subnets',), verbose=verbose)
        except exc.NoResultFound:
            raise q_exc.NetworkNotFound(net_id=id)

before the database entry takes place in order to verify network existance??

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to quantum (master)

Fix proposed to branch: master
Review: https://review.openstack.org/9894

Changed in quantum:
assignee: Abhinav Sonker (mail-abhinavsonker) → Gary Kotton (garyk)
status: Confirmed → In Progress
Revision history for this message
Gary Kotton (garyk) wrote :

Sorry to have jumped in an done this. Please feel free to build on the validity checks. I managed to create a situation where the database was corrupted due to invalid data.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to quantum (master)

Reviewed: https://review.openstack.org/9894
Committed: http://github.com/openstack/quantum/commit/4605dff64fb2fac764e58baf397f2e6811216ec4
Submitter: Jenkins
Branch: master

commit 4605dff64fb2fac764e58baf397f2e6811216ec4
Author: Gary Kotton <email address hidden>
Date: Tue Jul 17 04:52:20 2012 -0400

    Add validity checks to Quantum v2 resources

    Fixes bug 1015148

    The code enable defining validity checks for input variables. This
    is done via callback functions per type. The following types are supported:
        - type:values - checks that data is valid according to a list of values
        - type:mac_address - checks that data is a valid mac address
        - type:ip_address - checks that data is a valid ip address
        - type:subnet - checks that data is a valid cidr
        - type:regex - checks that data matches a regular expression (for
          example checking UUID validity)

    Change-Id: Iaa694cbfe3c518a5cd3951271853fe986106e7f5

Changed in quantum:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in quantum:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in quantum:
milestone: folsom-3 → 2012.2
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.