[2.x, API] Creating a subnet with fabric specified gets the default fabric anyway

Bug #1701256 reported by Данило Шеган
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
MAAS
Invalid
High
Mike Pontillo

Bug Description

In noticing a problem with how defaults are handled with Django 1.11 (see https://code.launchpad.net/~danilo/maas/+git/maas/+merge/326514), I've wanted to ensure API works correctly and added a test from http://paste.ubuntu.com/24981036/.

However, that fails even with master: it still picks up the default fabric and default vlan from it.

http://paste.ubuntu.com/24981040/

Tags: api
summary: - Creating a subnet with fabric specified gets the default fabric anyway
+ [2.x, API] Creating a subnet with fabric specified gets the default
+ fabric anyway
Changed in maas:
milestone: none → 2.3.0
Changed in maas:
milestone: 2.3.0 → 2.3.x
Changed in maas:
milestone: 2.3.x → 2.5.x
assignee: nobody → Mike Pontillo (mpontillo)
Revision history for this message
Adam Collard (adam-collard) wrote :

This bug has not seen any activity in the last 6 months, so it is being automatically closed.

If you are still experiencing this issue, please feel free to re-open.

MAAS Team

Changed in maas:
status: Triaged → Invalid
Revision history for this message
jjqq (jjqq) wrote :
Download full text (4.5 KiB)

Let me leave a memo for anyone who encounter this issue.

To create a subnet in A SPECIFIC fabric, you should use the `vlan=...` option instead of `fabric=...` option.

```
maas <USER> subnets create ...options... vlan=<VLAN_ID_OF_UNTAGGED_VLAN_OF_THE_FABRIC>
```

I have confirmed this in MAAS 2.5.1 ( 2.2.2 also should be fine, please see the reason followed).

Having checked source code(maasserver/forms/subnet.py), I found that the fabric=... is not used at all, the table which store the subnets information does not have any column named fabric or fabric_id, it just has vlan_id column.

```
    class Meta:
        model = Subnet
        fields = (
            'name',
            'description',
            'vlan',
            'cidr',
            'gateway_ip',
            'dns_servers',
            'rdns_mode',
            'active_discovery',
            'allow_dns',
            'allow_proxy',
            'managed',
            )

```

I manually added subnets from MAAS Subnets UI, then inspected the db (also source code):
```
maasdb=# select * from maasserver_subnet;
 id | created | updated | name | cidr | gateway_ip | dns_servers | vlan_id | rdns_mode | allow_proxy | description | active_discovery | managed | allow_dns
----+-------------------------------+-------------------------------+--------------------------+-------------------+----------------+-------------+---------+-----------+-------------+-------------+------------------+---------+-----------
  4 | 2022-01-19 00:05:12.577246+00 | 2022-01-19 00:05:12.577246+00 | subnet-100.79.223.64/26 | 100.79.223.64/26 | | {} | 5001 | 2 | t | | f | t | t
  5 | 2022-01-19 04:20:30.429739+00 | 2022-01-19 04:20:30.432391+00 | 100.79.223.128/26 | 100.79.223.128/26 | 100.79.223.190 | {} | 5001 | 2 | t | | f | t | t
  6 | 2022-01-20 13:40:17.55268+00 | 2022-01-20 13:40:17.55268+00 | subnet-100.79.222.128/26 | 100.79.222.128/26 | | {} | 5001 | 2 | t | | f | t | t
  8 | 2022-10-17 15:40:03.724161+00 | 2022-10-17 15:40:03.724161+00 | subnet-100.79.223.0/26 | 100.79.223.0/26 | | {} | 5001 | 2 | t | | f | t | t
  9 | 2022-10-21 07:34:00.3236+00 | 2022-10-21 07:34:00.3236+00 | subnet-100.95.3.128/25 | 100.95.3.128/25 | | {} | 5001 | 2 | t | | f | t | t
  7 | 2022-10-14 18:59:25.204786+00 | 2023-03-08 15:13:48.06542+00 | subnet-100.95.2.0/25 | 100.95.2.0/25 | | {} | 5002 | 2 | t | | f | t | t
 11 | 2023-03-08 15:48:23.449369+00 | 2023-03-08 15:56:12.629415+00 | subnet-100.95.4.0/24 | 100.95.4.0/24 | | {} | 5002 | 2 | t | | f | t | t
(7 rows)

```

See the vlan_id col...

Read more...

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.