# (c) cavaliba.com

#  IPAM

# --------------------------------------------
# ipam permissions
# --------------------------------------------


- classname: _permission
  keyname: p_ipam_access
  description: "IPAM access"
  is_builtin: True
  
- classname: _permission
  keyname: p_ipam_read
  description: "IPAM read"
  is_builtin: True

- classname: _permission
  keyname: p_ipam_write
  description: "IPAM write"
  is_builtin: True
  
- classname: _permission
  keyname: p_ipam_admin
  description: "IPAM admin"
  is_builtin: True


# ---------------------------------------
# IPAM enumerate
# ---------------------------------------

- classname: _enumerate
  keyname: ipam_vlan_family
  displayname: IPAM VLAN Family
  description: IPAM VLAN Family enumerate
  content: |
    - value: "N/A"
    - value: "Unknown"
    - value: "Other"


# ---------------------------------
# IPAM IP schema
# ---------------------------------

- classname: _schema
  keyname: ipam_ip
  displayname: IPAM IPs
  order: 212
  page: Asset Management

  _options:
      keyname_mode: hexip
      keyname_label: HexKey
      displayname_label: IP Value
      icon: fa-map-pin
      p_admin: p_ipam_admin
      p_create: p_ipam_write
      p_read: p_ipam_read
      p_update: p_ipam_write
      p_delete: p_ipam_write
      description: "<p>All IPs including discovered IPs from ipv4 fields in other schema.</p>"

  description:
      displayname: Description
      description: Description and additional informations
      dataformat: string

  collected:
      displayname: Collected
      dataformat: boolean
      default_value: false
      description: "True if collected automatically from other schema / objects"


# ---------------------------------
# subnet schema
# ---------------------------------

- classname: _schema
  keyname: ipam_subnet
  displayname: IPAM IPv4 Subnet
  order: 214
  page: Asset Management

  _options:
      icon: fa-map-marker
      keyname_mode: dataformat ipv4 subnet strict
      keyname_label: Subnet
      keyname_help: CIDR IPV4 aligned subnet (10.1.2.0/24)
      displayname_label: Name
      displayname_help: "Option nice name ; default to subnet value"
      p_admin: p_ipam_admin
      p_create: p_ipam_write
      p_read: p_ipam_read
      p_update: p_ipam_write
      p_delete: p_ipam_write

  description:
      displayname: Description
      dataformat: string

# ---------------------------------
# vlan schema
# ---------------------------------

- classname: _schema
  keyname: ipam_vlan
  displayname: IPAM VLANs
  order: 216
  page: Asset Management

  _options:
      icon: fa-street-view
      p_admin: p_ipam_admin
      p_create: p_ipam_write
      p_read: p_ipam_read
      p_update: p_ipam_write
      p_delete: p_ipam_write

  description:
      displayname: Description
      dataformat: string

  vlan_id:
      displayname: VLAN ID
      description: VLAN ID (integer)
      dataformat: int

  subnet:
      displayname: IP Subnet
      description: 0 or more IP subnets
      dataformat: schema
      dataformat_ext: ipam_subnet
      cardinal_max: 0


# ---------------------------------------- 
# dataview IPAM
# ---------------------------------------- 

- classname: _dataview
  keyname: ipam_vlan_default
  target_class: ipam_vlan
  displayname: Default
  description: Default DataView for IPAM VLANs
  content: |
    columns:
       - keyname
       - displayname
       - description
       - vlan_family
       - vlan_id
       - subnet

- classname: _dataview
  keyname: ipam_subnet
  target_class: ipam_subnet
  displayname: Default
  description: Default DataView for IPAM IP Subnets
  content: |
    columns:
       - keyname
       - description

- classname: _dataview
  keyname: ipam_ip_default
  target_class: ipam_ip
  displayname: Default
  description: Default DataView for IPAM IP 
  content: |
    columns:
       - IP:
           from: displayname
       - collected
       - description

# ---------------------------------------- 
# IPAM dashboard
# ---------------------------------------- 


- classname: _home
  keyname: ipam
  displayname: IPAM
  description: IP & VLAN Management
  icon: fa-map-marker
  url: /data/private/ipam/
  dashboard_section: Services
  sidebar_section: Services
  order: 106
  permission: p_ipam_access


# ---------------------------------------- 
# IPAM builtin data
# ---------------------------------------- 

- classname: ipam_subnet
  keyname: 0.0.0.0/0
  displayname: 0.0.0.0/0
  description: all

- classname: ipam_subnet
  keyname: 10.0.0.0/8
  displayname: 10.0.0.0/8
  description: RFC 1918 10.*

- classname: ipam_subnet
  keyname: 192.168.0.0/16
  displayname: 192.168.0.0/16
  description: RFC 1918 192.168.*

- classname: ipam_subnet
  keyname: 172.16.0.0/12
  displayname: 172.16.0.0/12
  description: RFC 1918 172.16.0.0/12 (-> 172.31.255.255)
