ionos-cloud / dim

DNS and IP Management
MIT License
48 stars 30 forks source link

[L3D] list ips <> status free behaviour with layer3domains is suboptimal #137

Open miesi opened 3 years ago

miesi commented 3 years ago

Example: The following layer3domains are defined:

$ ndcli list layer3domains
type name                     properties comment
vrf  default                  rd:64512:1 
vrf  internal                 rd:64512:2 
vrf  mlan                     rd:64512:3 
vrf  coms-shared-hosting    rd:6742:1  
vrf  coms-dedicated-hosting rd:6742:2

The following containers are defined

10.3.0.0/18 (Container) comment:reserved for MIP-customers (max. 32 possible; 1 data, 1 voice per customer)
  10.3.0.0/24 (Available)
  10.3.1.0/24 (Subnet) pool:ASIMMO
  10.3.2.0/24 (Subnet) pool:AWUG
  10.3.3.0/24 (Subnet) pool:BCI
  10.3.4.0/24 (Subnet) pool:HAEREO
  10.3.5.0/24 (Subnet) pool:MS-AUTOMATION
  10.3.6.0/24 (Available)
  10.3.7.0/24 (Subnet) pool:CRANIMAX
  10.3.8.0/23 (Available)
  10.3.10.0/24 (Subnet) pool:GISBO
  10.3.11.0/24 (Available)
  10.3.12.0/24 (Subnet) pool:de-fuh-bar-mip-mgruisbourne-u-afelk-182
  10.3.13.0/24 (Available)
  10.3.14.0/24 (Subnet) pool:ULB
  10.3.15.0/24 (Available)
  10.3.16.0/24 (Subnet) pool:ASSPARIO
  10.3.17.0/24 (Available)
  10.3.18.0/24 (Subnet) pool:IT-TEST
  10.3.19.0/24 (Available)
  10.3.20.0/24 (Subnet) pool:sahgev
  10.3.21.0/24 (Available)
  10.3.22.0/23 (Available)
  10.3.24.0/21 (Available)
  10.3.32.0/20 (Available)
  10.3.48.0/23 (Available)
  10.3.50.0/24 (Available)
  10.3.51.0/24 (Subnet) pool:HYDRAFORCE
  10.3.52.0/22 (Available)
  10.3.56.0/21 (Available)

$ ndcli list containers layer3domain internal 10.3.0.0/18
WARNING - 10.3.0.0/18 rounded to 10.0.0.0/8 because no ipblock exists at 10.3.0.0/18 with status Container
10.0.0.0/8 (Container) reverse_dns_profile:internal
  10.0.0.0/8 (Available)

$ ndcli list containers layer3domain mlan 10.3.0.0/18
WARNING - 10.3.0.0/18 rounded to 10.0.0.0/8 because no ipblock exists at 10.3.0.0/18 with status Container
10.0.0.0/8 (Container) reverse_dns_profile:mlan
  10.70.1.128/26 (Subnet) pool:fuhmlan

$ ndcli list containers layer3domain coms-shared-hosting
10.0.0.0/8 (Container) reverse_dns_profile:coms-shared-hosting
  10.255.0.0/24 (Subnet) pool:coms-sh-test

$ ndcli list containers layer3domain coms-dedicated-hosting 
10.0.0.0/8 (Container) reverse_dns_profile:coms-dedicated-hosting
  10.70.1.0/24 (Subnet) pool:fuhtest

The current implementation of {{list ips <> status free}} reports this

$ ndcli list ips  10.3.1.0/24  status free 
INFO - Result for list ips 10.3.1.0/24
ip       status    ptr_target comment layer3domain
10.3.1.0 Available                    internal
10.3.1.0 Available                    mlan
10.3.1.0 Available                    coms-dedicated-hosting
10.3.1.0 Available                    coms-shared-hosting
10.3.1.1 Available                    default
10.3.1.1 Available                    internal
10.3.1.1 Available                    mlan
10.3.1.1 Available                    coms-dedicated-hosting
10.3.1.1 Available                    coms-shared-hosting
10.3.1.2 Available                    default

this is unhandy.

3 different states of "free"

So {{list ips <> status usable}}

$ ndcli list ips  10.3.1.0/24  status usable 
INFO - Result for list ips 10.3.1.0/24
ip       status    ptr_target comment layer3domain
10.3.1.1 usable                       default
10.3.1.2 usable                       default

A pool column would be helpful.

Srudush commented 2 years ago

It is possible to define the layer3domain when looking for free IPs.

INFO - Result for list ips 10.23.24.0/24
ip         status    ptr_target comment layer3domain
10.23.24.0 Available                    default
10.23.24.0 Available                    one
10.23.24.0 Available                    two
10.23.24.1 Available                    default
10.23.24.1 Available                    one
10.23.24.1 Available                    two
10.23.24.2 Available                    default
10.23.24.2 Available                    one
10.23.24.2 Available                    two

vs

# /tmp/venv/bin/ndcli list ips 10.23.24.0/24 layer3domain default
INFO - Result for list ips 10.23.24.0/24
ip         status    ptr_target comment
10.23.24.0 Available            
10.23.24.1 Available            
10.23.24.2 Available

Seeing how list containers was changed in #125 to also list all containers on request, I would say that this is the correct behaviour.

Srudush commented 2 years ago

With #159 being implemented and committed, this probably changes how the output is actually working. Per default you should now only see the IPs in your default layer3domain. If you haven't set any, then the output is still correct and shows everything.

But when setting the default layer3domain we should still be able to view the content of all layer3domains, therefore we should add the all keyword here too in the same way we did in #125. That way I can still view all IPs in all layer3domains, even though I have a default layer3domain set in the config.