Hostname or IP Adress Data Type

A hostname_or_ip data type tests data for being an instance of python's built-in class str and if it represents a hostname/FQDN or an IPv4/IPv6 address.

Features/Limitations

Hostname Features:

  • Validate conformity to IETF RFC 1123
  • Validate string length
  • Validate label count
  • Validate against allowed and not allowed regex patterns (always full matching the string)
  • Supports Referencing Feature
  • Data type conversion is not supported

IP Address Features:

  • Validate IP specific attributes
  • Validate against allowed and not allowed IP address ranges
  • Validate against allowed and not allowed IP addresses
  • Supports Referencing Feature

Hostname or IP Adress Definition Syntax

Table

Key/Option Type Default Value Restrictions Description
type str 'hostname_or_ip'
description str Data type description
default_value Must match data type's type(s) Value used to set as default value
hostname dict Hostname data type definition part
  minimum int min: 1 Data's length must be greater or equal
  maximum int min: 1
>= 'minimum'
Data's length must be lower or equal
  replace_empty_to any An empty input value will be replaced by this data
  relax_length bool True Relax hostname length from 63 to 255 characters
  minimum_labels int min: 1 Minimum amount of labels within in hostname
  maximum_labels int min: 1
>= 'minimum_labels'
Maximum amount of labels within in hostname
  allowed_values list[str] Data must match one of these regex patterns
    - < str > str
  not_allowed_values list[str] Data mustn't match any of these regex patterns
    - < str > str
ip dict IP address data type definition part
allowed_ranges list[dict] min length: 1 Value must be within defined ranges
  - start str required
    end str required
not_allowed_ranges list[dict] Value mustn't be within defined ranges
  - start str required
    end str required
  allowed_values list Data must match one of these values
    - < value > any Must match data type's type(s)
  not_allowed_values list Data mustn't match all of these values
    - < value > any Must match data type's type(s)
  link_local bool IP must be link-local
  loopback bool IP must be loopback
  multicast bool IP must be multicast
  private bool IP must be private
  public bool IP must be public/global
template str must be definded in schema Merge options from this template
template_merge_options dict Define schema-global template merge instructions
    recursive bool True Merge data type definition options in template options recursively.
If false, data type defintion options overwrites template options.
    list_merge str append_rp Allowed values:
- append
- append_rp
- prepend
- prepend_rp
- replace
How lists within options data should be merged.
reference dict|str
  option 1 str Reference keys (implies unique global mode)
  option 2 dict
  key str required
  mode str Allowed values:
- unique
- producer
- consumer
  unique_scope str Allowed values:
- global
- namespace
  producer_scope str Allowed values:
- global
- namespace
  consumer_scope str Allowed values:
- global
- namespace
  allow_orphan_producer bool True
  credit int 1 (if mode consumer) min: 0
references list[dict|str]
  - dict|str
    option 1 str Reference keys (implies unique global mode)
    option 2 dict
    key str required
    mode str Allowed values:
- unique
- producer
- consumer
    unique_scope str Allowed values:
- global
- namespace
    producer_scope str Allowed values:
- global
- namespace
    consumer_scope str Allowed values:
- global
- namespace
    allow_orphan_producer bool True
    credit int 1 (if mode consumer) min: 0
doc_value_name str Set value name for documentation

YAML

type: hostname_or_ip
description: <str>
default_value: <default_value>

ip:
  convert_to: <str>
  allowed_ranges:
    - start: <str>
      end: <str>
  not_allowed_ranges:
   - start: <str>
     end: <str>
  allowed_values:
  - <any>
  not_allowed_values:
  - <any>
  link_local: <true|false
  loopback: <true|false
  multicast: <true|false
  private: <true|false
  public: <true|false
hostname:
  version: <int>
  maximum: <int>
  minimum: <int>
  replace_empty_to: <any>
  relax_length: <true|false>
  minimum_labels: <int>
  maximum_labels: <int>
  allowed_values:
  - <str>
  not_allowed_values:
  - <str>

template: <str>
template_merge_options:
  recursive: <true|false>
  list_merge: <append|append_rp|prepend|prepend_rp|replace>

reference: <reference_definition>
  # Multitype!!!
  <str>
  # or:
  key: <str>
  mode: <unique|producer|consumer>
  unique_scope: <global|namespace>
  producer_scope: <global|namespace>
  consumer_scope: <global|namespace>
  allow_orphan_producer: <true|false>
  credits: <int>
references:
  - <reference_definition>
    # Multitype!!!
    <str>
    # or
    key: <str>
    mode: <unique|producer|consumer>
    unique_scope: <global|namespace>
    producer_scope: <global|namespace>
    consumer_scope: <global|namespace>
    allow_orphan_producer: <true|false>
    credits: <int>

doc_value_name: <str>

Example

type: hostname_or_ip
description: "Example hostname_or_ip definition"
default_value: "my-host"

hostname:
    minimum: 3
    maximum: 16
    minimum_labels: 3
    maximum_labels: 7

    not_allowed_values:
    - nadap-.*
    relax_length: false

ip:
    version: 4
    multicast: False
    private: True

    not_allowed_values:
    - 10.10.99.1
    - 192.168.0.1

reference: ref_key