
/*
 *
 *   Copyright 2016-2017 RIFT.IO Inc
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 *
 *
 */

module mano-types
{
  namespace "urn:etsi:osm:yang:mano-types";
  prefix "manotypes";

  import ietf-inet-types {
    prefix "inet";
  }

  import osm-project {
    prefix "osm-project";
  }

  revision 2017-02-08 {
    description
      "Update model to support projects.";
  }

  revision 2015-04-23 {
    description
      "Initial revision. This YANG file defines
       the reusable base types for VNF Management
       and Orchestration (MANO).";
    reference
      "Derived from earlier versions of base YANG files";
  }

  typedef meta-data-type {
    type enumeration {
      enum STRING;
    }
  }

  typedef package-type {
      description "Type of descriptor being on-boarded";
      type enumeration {
        enum NSD;
        enum VNFD;
      }
    }

  typedef parameter-data-type {
    type enumeration {
      enum STRING;
      enum INTEGER;
      enum BOOLEAN;
    }
  }

  grouping primitive-parameter-value {
    list parameter {
      description
          "List of parameters to the configuration primitive.";
      key "name";
      leaf name {
        description
            "Name of the parameter.";
        type string;
      }

      leaf data-type {
        description
            "Data type associated with the value.";
        type manotypes:parameter-data-type;
      }

      leaf value {
        description
            "Value associated with the name.";
        type string;
      }
    }
  }

  grouping primitive-parameter {
    leaf name {
      description
          "Name of the parameter.";
      type string;
    }

    leaf data-type {
      description
          "Data type associated with the name.";
      type manotypes:parameter-data-type;
    }

    leaf mandatory {
      description "Is this field mandatory";
      type boolean;
      default false;
    }

    leaf default-value {
      description "The default value for this field";
      type string;
    }

    leaf parameter-pool {
      description "NSD parameter pool name to use for this parameter";
      type string;
    }

    leaf read-only {
      description
        "The value should be dimmed by the UI.
        Only applies to parameters with default values.";
      type boolean;
      default false;
    }

    leaf hidden {
      description
        "The value should be hidden by the UI.
        Only applies to parameters with default values.";
      type boolean;
      default false;
    }
  }

  grouping ui-primitive-group {
    list parameter-group {
      description
            "Grouping of parameters which are logically grouped in UI";
      key "name";

      leaf name {
        description
            "Name of the parameter group";
        type string;
      }

      list parameter {
        description
            "List of parameters for the service primitive.";
        key "name";
        uses manotypes:primitive-parameter;
      }

      leaf mandatory {
        description "Is this parameter group mandatory";
        type boolean;
        default true;
      }
    }
  }

  grouping event-config {
    leaf seq {
      description
          "Sequence number for the configuration primitive.";
      type uint64;
    }

    leaf name {
      description
          "Name of the configuration primitive.";
      type string;
      mandatory true;
    }

    leaf user-defined-script {
      description
          "A user defined script.";
      type string;
    }

    list parameter {
      key "name";
      leaf name {
        type string;
      }

      leaf value {
        description "Value of the configuration primitive.";
        type string;
      }
    }
  }

 grouping image-properties {
    leaf image {
      description
            "Image name for the software image.
             If the image name is found within the VNF package it will
             be uploaded to all VIM accounts during onboarding process.
             Otherwise, the image must be added to the VIM account with
             the same name as entered here.
            ";
      type string;
    }

    leaf image-checksum {
      description
            "Image md5sum for the software image.
            The md5sum, if provided, along with the image name uniquely
            identifies an image uploaded to the CAL.
            ";
      type string;
    }
  }


  grouping vca-relations {
    list relation {
      description "List of relations between elements in this descriptor.";
      key "name";

      leaf name {
        description
          "Name of the relation.";

        type string;
      }

      list entities {
        description
          "List of two elements to be related.
           Elements to be related are identified by a pair (id, endpoint).
           The relation will relate (id1, endpoint1) to (id2, endpoint2).";
        key "id";

        leaf id {
          description
            "A string, reference to the element id in the descriptor.
             It could be a vnfd-id or a vdu-id in a VNFD,
             or a nsd-id or member-vnf-index in a NSD.";
          type string;
        }

        leaf endpoint {
          description
            "Endpoint name defining the relation.";
          type string;
        }
      }
    }
  }

  grouping vca-metrics {
    description
        "Information about the VNF or VDU metrics";
    list metrics {
      description "List of VCA related metrics";
      key "name";
      leaf name {
        description
          "Name of the metric, as defined in the Juju charm.";
        type string;
      }
      leaf execution-environment-ref {
        description
          "Leaf reference to the particular execution environment getting that metric";
        type leafref {
          path "../../execution-environment-list/id";
        }
      }
      leaf execution-environment-metric {
        description
          "Metric in the execution environment referenced by execution-environment-ref";
        type string;
      }
    }
  } // END - grouping vca-metrics

  grouping configuration-method {
    choice config-method {
      description
          "Defines the configuration method for the VNF or VDU.";
      case script {
        description
            "Use custom script for configuring the VNF or VDU.
             This script is executed in the context of
             Orchestrator (The same system and environment
             as the Launchpad).";
        container script {
          leaf script-type {
            description
                "Script type - currently supported - Scripts confirming to Rift CA plugin";
            type enumeration {
              enum rift;
            }
          }
        }
      }

      case juju {
        description
          "Configure the VNF or VDU through Juju.";
        container juju {
          leaf charm {
            description "Juju charm to use with the VNF or VDU.";
            type string;
          }
          leaf proxy {
            description "Is this a proxy charm?";
            type boolean;
            default true;
          }
          leaf cloud {
            description
              "Type of cloud where the charm will be deployed. It only
               applies to proxy charms (not native)";
            type enumeration {
              enum lxd;
              enum k8s;
            }
            default lxd;
          }
        }
      }

      case execution-environment-list {
        description
          "List of Execution Environments to configure or monitor VNF or VDU.";
        list execution-environment-list {
          key "id";
          leaf id {
            description "Execution environment identifier.";
            type string;
          }
          choice execution-environment-model {
            description "Execution environment model (juju, helm-chart)";
            case juju {
              description
                "Interact with the VNF or xDU through Juju.";
              container juju {
                leaf charm {
                  description "Juju charm to use with the VNF or VDU.";
                  type string;
                }
                leaf proxy {
                  description "Is this a proxy charm?";
                  type boolean;
                  default true;
                }
                leaf cloud {
                  description
                    "Type of cloud where the charm will be deployed. It only
                     applies to proxy charms (not native)";
                  type enumeration {
                    enum lxd;
                    enum k8s;
                  }
                  default lxd;
                }
              }
            }
            case helm-chart {
              description
                "Interact with the VNF or xDU through Helm.";
              leaf helm-chart {
                description
                  "Helm chart that models the execution environment, in any of the following ways:
                   - <helm-repo>/<helm-chart>
                   - <helm-chart folder name under helm-charts folder in the package>
                   - <helm-chart tgz file (w/ or w/o extension) under helm-charts folder in the package>
                   - <URL_where_to_fetch_chart>
                  ";
                type string;
              }
              leaf helm-version {
                description
                  "Helm version to use for this helm-chart, v3 by default";
                type enumeration {
                  enum v2;
                  enum v3;
                }
                default v3;
              }
            }
          }
          leaf metric-service {
            description
              "Service name in the execution environment. For helm charts, it will be
               the name of the kubernetes service used by the exporter to expose metrics
               to the OSM collector.
              ";
            type string;
          }
          leaf connection-point-ref {
            description
              "String representing a leaf reference to the particular external connection point
               This field should match /vnfd:vnfd-catalog/vnfd:vnfd/vnfd:id/vnfd:connection-point/vnfd:name
              ";
            type string;
            // type leafref {
            //   path "/vnfd:vnfd-catalog/vnfd:vnfd/vnfd:id/vnfd:connection-point/vnfd:name";
            // }
          }
        }
      }

    }
  }

  grouping vca-config-access {

    container config-access {

      description
        "Indicates the way to access to the xNF or xDU for VCA configuration.
         For the moment there is a single way (ssh-access).";

      container ssh-access {

        description
          "If the xNF requires ssh and this parameter is set, SSH keys
          will be injected so that VCA can configure the xNF or xDU via ssh.";

        leaf required  {
          description "whether ssh access is needed or not";
          type boolean;
          default false;
        }

        leaf default-user {
          description "Default user for ssh";
          type string;
        }
      }
    }
  } // END - grouping vca-config-access

  grouping vca-configuration {
    description
        "Common information in the descriptors for NS, VNF or VDU configuration.
         Note: If the NS contains multiple instances of the
         same VNF or VDU, each instance could have a different
         configuration.";

    uses manotypes:configuration-method;

    list config-primitive {
      description
        "List of config primitives supported by the
        configuration agent for this VNF or VDU.";
      key "name";

      leaf name {
        description
          "Name of the config primitive.";
        type string;
      }

      leaf execution-environment-ref {
        description
          "Leaf reference to the particular execution environment";
        type leafref {
          path "../../execution-environment-list/id";
        }
      }

      leaf execution-environment-primitive {
        description
          "Name of the primitive in the execution enviroment. If not explicit,
           the leaf 'name' will be used as the name of the primitive.";
        type string;
      }

      list parameter {
        description
          "List of parameters to the config primitive.";
        key "name";
        uses primitive-parameter;
      }

      leaf user-defined-script {
        description
          "A user defined script. If user defined script is defined,
           the script will be executed using bash";
        type string;
      }
    }

    list initial-config-primitive {
      description
        "Initial set of configuration primitives.";
      key "seq";
      leaf seq {
        description
          "Sequence number for the configuration primitive.";
        type uint64;
      }

      choice primitive-type {
        case primitive-definition {
          leaf name {
            description
              "Name of the configuration primitive in the execution environment.";
            type string;
          }

          leaf execution-environment-ref {
            description
              "Leaf reference to the particular execution environment";
            type leafref {
              path "../../execution-environment-list/id";
            }
          }

          uses primitive-parameter-value;

          leaf user-defined-script {
            description
              "A user defined script.";
            type string;
          }
        }
      }
    }

    list terminate-config-primitive {
      description
        "Terminate set of configuration primitives.";
      key "seq";
      leaf seq {
        description
          "Sequence number for the configuration primitive.";
        type uint64;
      }
      leaf name {
        description
          "Name of the configuration primitive in the execution environment.";
        type string;
      }

      leaf execution-environment-ref {
        description
          "Leaf reference to the particular execution environment";
        type leafref {
          path "../../execution-environment-list/id";
        }
      }

      uses primitive-parameter-value;

      leaf user-defined-script {
        description
          "A user defined script.";
        type string;
      }
    }
    uses manotypes:vca-metrics;

  } // END - grouping vca-configuration

  typedef virtual-link-type {
    description
        "Type of virtual link
         ELAN: A multipoint service connecting a set of elements
         ELINE: A point-to-point service connecting two elements
         L3: A service providing either Layer-3 visibility (IP) between
             VDUs/VNFs or explicit interconnection between two ELAN VLDs.";
         // ETREE: A multipoint service connecting one or
         //        more roots and a set of leaves, but
         //        preventing inter-leaf communication.";
    type enumeration {
      enum ELAN;
      enum ELINE;
      enum L3;
      // enum ETREE;
    }
  }

  grouping named-value {
    leaf name {
      type string;
    }

    leaf value {
      type string;
    }
  }

  typedef http-method {
    description
      "Type of HTTP operation";

    type enumeration {
      enum POST;
      enum PUT;
      enum GET;
      enum DELETE;
      enum OPTIONS;
      enum PATCH;
    }
  }

  typedef api-type {
    description
      "Type of API to fetch monitoring parameters";

    type enumeration {
      enum HTTP;
      enum NETCONF;
      enum SOAP;
    }
  }

  typedef json-query-method {
    description
      "The method to extract a value from a JSON response

       NAMEKEY - Use the name as the key for a non-nested value.
       JSONPATH - Use jsonpath-rw implementation to extract a value.
       OBJECTPATH - Use objectpath implementation to extract a value.";
      type enumeration {
        enum NAMEKEY;
        enum JSONPATH;
        enum OBJECTPATH;
      }
  }

  typedef param-value-type {
    description
      "The type of the parameter value";
    type enumeration {
       enum INT;
       enum DECIMAL;
       enum STRING;
    }
  }

  typedef connection-point-type {
    description
        "Type of connection point
        VPORT: Virtual Port
        // VNIC_ADDR: Virtual NIC Address
        // PNIC_ADDR: Physical NIC Address
        // PPORT: Physical Port.";

    type enumeration {
      enum VPORT;
    }
  }

  typedef widget-type {
    description
        "Type of the widget, typically used by the UI.";
    type enumeration {
      enum COUNTER;
      enum GAUGE;
      enum TEXTBOX;
      enum SLIDER;
      enum HISTOGRAM;
      enum BAR;
    }
  }

  typedef cpu-feature-type {
    description
        "Enumeration for CPU features.

         AES: CPU supports advanced instruction set for
         AES (Advanced Encryption Standard).

         CAT: Cache Allocation Technology (CAT) allows
         an Operating System, Hypervisor, or similar
         system management agent to specify the amount
         of L3 cache (currently the last-level cache
         in most server and client platforms) space an
         application can fill (as a hint to hardware
         functionality, certain features such as power
         management may override CAT settings).

         CMT: Cache Monitoring Technology (CMT) allows
         an Operating System, Hypervisor, or similar
         system management agent to determine the
         usage of cache based on applications running
         on the platform. The implementation is
         directed at L3 cache monitoring (currently
         the last-level cache in most server and
         client platforms).

         DDIO: Intel Data Direct I/O (DDIO) enables
         Ethernet server NICs and controllers talk
         directly to the processor cache without a
         detour via system memory. This enumeration
         specifies if the VM requires a DDIO
         capable host.";

    type enumeration {
      enum PREFER_AES;
      enum REQUIRE_AES;
      enum PREFER_CAT;
      enum REQUIRE_CAT;
      enum PREFER_CMT;
      enum REQUIRE_CMT;
      enum PREFER_DDIO;
      enum REQUIRE_DDIO;
      enum REQUIRE_VME;
      enum PREFER_VME;
      enum REQUIRE_DE;
      enum PREFER_DE;
      enum REQUIRE_PSE;
      enum PREFER_PSE;
      enum REQUIRE_TSC;
      enum PREFER_TSC;
      enum REQUIRE_MSR;
      enum PREFER_MSR;
      enum REQUIRE_PAE;
      enum PREFER_PAE;
      enum REQUIRE_MCE;
      enum PREFER_MCE;
      enum REQUIRE_CX8;
      enum PREFER_CX8;
      enum REQUIRE_APIC;
      enum PREFER_APIC;
      enum REQUIRE_SEP;
      enum PREFER_SEP;
      enum REQUIRE_MTRR;
      enum PREFER_MTRR;
      enum REQUIRE_PGE;
      enum PREFER_PGE;
      enum REQUIRE_MCA;
      enum PREFER_MCA;
      enum REQUIRE_CMOV;
      enum PREFER_CMOV;
      enum REQUIRE_PAT;
      enum PREFER_PAT;
      enum REQUIRE_PSE36;
      enum PREFER_PSE36;
      enum REQUIRE_CLFLUSH;
      enum PREFER_CLFLUSH;
      enum REQUIRE_DTS;
      enum PREFER_DTS;
      enum REQUIRE_ACPI;
      enum PREFER_ACPI;
      enum REQUIRE_MMX;
      enum PREFER_MMX;
      enum REQUIRE_FXSR;
      enum PREFER_FXSR;
      enum REQUIRE_SSE;
      enum PREFER_SSE;
      enum REQUIRE_SSE2;
      enum PREFER_SSE2;
      enum REQUIRE_SS;
      enum PREFER_SS;
      enum REQUIRE_HT;
      enum PREFER_HT;
      enum REQUIRE_TM;
      enum PREFER_TM;
      enum REQUIRE_IA64;
      enum PREFER_IA64;
      enum REQUIRE_PBE;
      enum PREFER_PBE;
      enum REQUIRE_RDTSCP;
      enum PREFER_RDTSCP;
      enum REQUIRE_PNI;
      enum PREFER_PNI;
      enum REQUIRE_PCLMULQDQ;
      enum PREFER_PCLMULQDQ;
      enum REQUIRE_DTES64;
      enum PREFER_DTES64;
      enum REQUIRE_MONITOR;
      enum PREFER_MONITOR;
      enum REQUIRE_DS_CPL;
      enum PREFER_DS_CPL;
      enum REQUIRE_VMX;
      enum PREFER_VMX;
      enum REQUIRE_SMX;
      enum PREFER_SMX;
      enum REQUIRE_EST;
      enum PREFER_EST;
      enum REQUIRE_TM2;
      enum PREFER_TM2;
      enum REQUIRE_SSSE3;
      enum PREFER_SSSE3;
      enum REQUIRE_CID;
      enum PREFER_CID;
      enum REQUIRE_FMA;
      enum PREFER_FMA;
      enum REQUIRE_CX16;
      enum PREFER_CX16;
      enum REQUIRE_XTPR;
      enum PREFER_XTPR;
      enum REQUIRE_PDCM;
      enum PREFER_PDCM;
      enum REQUIRE_PCID;
      enum PREFER_PCID;
      enum REQUIRE_DCA;
      enum PREFER_DCA;
      enum REQUIRE_SSE4_1;
      enum PREFER_SSE4_1;
      enum REQUIRE_SSE4_2;
      enum PREFER_SSE4_2;
      enum REQUIRE_X2APIC;
      enum PREFER_X2APIC;
      enum REQUIRE_MOVBE;
      enum PREFER_MOVBE;
      enum REQUIRE_POPCNT;
      enum PREFER_POPCNT;
      enum REQUIRE_TSC_DEADLINE_TIMER;
      enum PREFER_TSC_DEADLINE_TIMER;
      enum REQUIRE_XSAVE;
      enum PREFER_XSAVE;
      enum REQUIRE_AVX;
      enum PREFER_AVX;
      enum REQUIRE_F16C;
      enum PREFER_F16C;
      enum REQUIRE_RDRAND;
      enum PREFER_RDRAND;
      enum REQUIRE_FSGSBASE;
      enum PREFER_FSGSBASE;
      enum REQUIRE_BMI1;
      enum PREFER_BMI1;
      enum REQUIRE_HLE;
      enum PREFER_HLE;
      enum REQUIRE_AVX2;
      enum PREFER_AVX2;
      enum REQUIRE_SMEP;
      enum PREFER_SMEP;
      enum REQUIRE_BMI2;
      enum PREFER_BMI2;
      enum REQUIRE_ERMS;
      enum PREFER_ERMS;
      enum REQUIRE_INVPCID;
      enum PREFER_INVPCID;
      enum REQUIRE_RTM;
      enum PREFER_RTM;
      enum REQUIRE_MPX;
      enum PREFER_MPX;
      enum REQUIRE_RDSEED;
      enum PREFER_RDSEED;
      enum REQUIRE_ADX;
      enum PREFER_ADX;
      enum REQUIRE_SMAP;
      enum PREFER_SMAP;
    }
  }

  typedef nfvi-metric-type {
    description "Type of NFVI metric to be monitored";
    type enumeration {
      enum cpu_utilization;
      enum average_memory_utilization;
      enum disk_read_ops;
      enum disk_write_ops;
      enum disk_read_bytes;
      enum disk_write_bytes;
      enum packets_sent;
      enum packets_received;
      enum packets_in_dropped;
      enum packets_out_dropped;
    }
  }

  typedef scaling-trigger {
    type enumeration {
      enum pre-scale-in {
        value 1;
      }
      enum post-scale-in {
        value 2;
      }
      enum pre-scale-out {
        value 3;
      }
      enum post-scale-out {
        value 4;
      }
    }
  }

  typedef scaling-policy-type {
    type enumeration {
      enum manual {
        value 1;
      }
      enum automatic {
        value 2;
      }
    }
  }

  typedef scaling-criteria-operation {
    type enumeration {
      enum AND {
        value 1;
      }
      enum OR {
        value 2;
      }
    }
  }

  grouping vm-flavor {
    container vm-flavor {
      leaf vcpu-count {
        description
            "Number of VCPUs for the VM.";
        type uint16;
      }

      leaf memory-mb {
        description
            "Amount of memory in MB.";
        type uint64;
      }

      leaf storage-gb {
        description
            "Amount of disk space in GB.";
        type uint64;
      }
    }
  } //grouping vm-flavor

  grouping vm-flavor-name {
    leaf vm-flavor-name {
      description "flavor name to be used while creating vm using cloud account";
      type string;
    }
  }

  grouping vswitch-epa {
    container vswitch-epa {
      leaf ovs-acceleration {
        description
            "Specifies Open vSwitch acceleration mode.
             MANDATORY: OVS acceleration is required
             PREFERRED: OVS acceleration is preferred";
        type enumeration {
          enum MANDATORY;
          enum PREFERRED;
          enum DISABLED;
        }
      }

      leaf ovs-offload {
        description
            "Specifies Open vSwitch hardware offload mode.
             MANDATORY: OVS offload is required
             PREFERRED: OVS offload is preferred";
        type enumeration {
          enum MANDATORY;
          enum PREFERRED;
          enum DISABLED;
        }
      }
    }
  }

  grouping hypervisor-epa {
    container hypervisor-epa {
      leaf type {
        description
            "Specifies the type of hypervisor.
             KVM: KVM
             XEN: XEN";
        type enumeration {
          enum PREFER_KVM;
          enum REQUIRE_KVM;
        }
      }
      leaf version {
        type string;
      }
    }
  }

  grouping host-epa {
    container host-epa {
      description "Specifies the host level EPA attributes.";
      leaf cpu-model {
        description
            "Host CPU model. Examples include: SandyBridge,
             IvyBridge";
        type enumeration {
          enum PREFER_WESTMERE;
          enum REQUIRE_WESTMERE;
          enum PREFER_SANDYBRIDGE;
          enum REQUIRE_SANDYBRIDGE;
          enum PREFER_IVYBRIDGE;
          enum REQUIRE_IVYBRIDGE;
          enum PREFER_HASWELL;
          enum REQUIRE_HASWELL;
          enum PREFER_BROADWELL;
          enum REQUIRE_BROADWELL;
          enum PREFER_NEHALEM;
          enum REQUIRE_NEHALEM;
          enum PREFER_PENRYN;
          enum REQUIRE_PENRYN;
          enum PREFER_CONROE;
          enum REQUIRE_CONROE;
          enum PREFER_CORE2DUO;
          enum REQUIRE_CORE2DUO;
        }
      }

      leaf cpu-arch {
        description "Host CPU architecture.";
        type enumeration {
          enum PREFER_X86;
          enum REQUIRE_X86;
          enum PREFER_X86_64;
          enum REQUIRE_X86_64;
          enum PREFER_I686;
          enum REQUIRE_I686;
          enum PREFER_IA64;
          enum REQUIRE_IA64;
          enum PREFER_ARMV7;
          enum REQUIRE_ARMV7;
          enum PREFER_ARMV8;
          enum REQUIRE_ARMV8;
        }
      }

      leaf cpu-vendor {
        description "Host CPU Vendor.";
        type enumeration {
          enum PREFER_INTEL;
          enum REQUIRE_INTEL;
          enum PREFER_AMD;
          enum REQUIRE_AMD;
        }
      }

      leaf cpu-socket-count {
        description "Number of sockets on the host.";
        type uint64;
      }

      leaf cpu-core-count {
        description "Number of cores on the host.";
        type uint64;
      }

      leaf cpu-core-thread-count {
        description "Number of threads per cores on the host.";
        type uint64;
      }

      list cpu-feature {
        key "feature";
        description "List of CPU features.";
        leaf feature {
          description "CPU feature.";
          type cpu-feature-type;
        }
      }

      leaf om-cpu-model-string {
        description "OpenMANO CPU model string";
        type string;
      }

      list om-cpu-feature {
        key "feature";
        description "List of OpenMANO CPU features";
        leaf feature {
          description "CPU feature";
          type string;
        }
      }

    }
  }

  grouping guest-epa {
    description "EPA attributes for the guest";
    container guest-epa {
      leaf trusted-execution {
        description "This VM should be allocated from trusted pool";
        type boolean;
      }

      leaf mempage-size {
        description
            "Memory page allocation size. If a VM requires
             hugepages, it should choose LARGE or SIZE_2MB
             or SIZE_1GB. If the VM prefers hugepages it
             should choose PREFER_LARGE.
             LARGE        : Require hugepages (either 2MB or 1GB)
             SMALL        : Doesn't require hugepages
             SIZE_2MB     : Requires 2MB hugepages
             SIZE_1GB     : Requires 1GB hugepages
             PREFER_LARGE : Application prefers hugepages";
        type enumeration {
          enum LARGE;
          enum SMALL;
          enum SIZE_2MB;
          enum SIZE_1GB;
          enum PREFER_LARGE;
        }
      }

      choice cpu-policy {
        case cpu-pinning {
          leaf cpu-pinning-policy {
            description
                "CPU pinning policy describes association
                 between virtual CPUs in guest and the
                 physical CPUs in the host.
                 DEDICATED : Virtual CPUs are pinned to
                             physical CPUs
                 SHARED    : Multiple VMs may share the
                             same physical CPUs.
                 ANY       : Any policy is acceptable for the VM";
            type enumeration {
              enum DEDICATED;
              enum SHARED;
              enum ANY;
            }
            default "ANY";
          }
          leaf cpu-thread-pinning-policy {
              description
                "CPU thread pinning policy describes how to
                 place the guest CPUs when the host supports
                 hyper threads:
                 AVOID   : Avoids placing a guest on a host
                           with threads.
                 SEPARATE: Places vCPUs on separate cores,
                           and avoids placing two vCPUs on
                           two threads of same core.
                 ISOLATE : Places each vCPU on a different core,
                           and places no vCPUs from a different
                           guest on the same core.
                 PREFER  : Attempts to place vCPUs on threads
                           of the same core.";
            type enumeration {
              enum AVOID;
              enum SEPARATE;
              enum ISOLATE;
              enum PREFER;
            }
          }
        }

        case cpu-quota {
          container cpu-quota {
              description "CPU quota describes the CPU resource allocation policy.
                           Limit and Reserve values are defined in MHz";
              uses allocation-properties;
          }
        }
      }

      container mem-quota {
          description "Memory quota describes the memory resource allocation policy.
                       Limit and Reserve values are defined in MB";
          uses allocation-properties;
      }

      container disk-io-quota {
          description "Disk IO quota describes the disk IO operations resource allocation policy.
                       Limit and Reserve values are defined in IOPS";
          uses allocation-properties;
      }

      container vif-quota {
          description "Virtual interfaces quota describes the virtual interface bandwidth resource allocation policy.
                       Limit and Reserve values are defined in Mbps";
          uses allocation-properties;
      }

      list pcie-device {
        description
            "List of pcie passthrough devices.";
        key device-id;
        leaf device-id {
          description
              "Device identifier.";
          type string;
        }
        leaf count {
          description
              "Number of devices to attach to the VM.";
          type uint64;
        }
      }

      choice numa-policy {
        case numa-unaware {
          leaf numa-unaware {
            type empty;
          }
        }

        case numa-aware {
          container numa-node-policy {
            description
                "This policy defines NUMA topology of the
                 guest. Specifically identifies if the guest
                 should be run on a host with one NUMA
                 node or multiple NUMA nodes. As an example
                 a guest might need 8 VCPUs and 4 GB of
                 memory. However, it might need the VCPUs
                 and memory distributed across multiple
                 NUMA nodes. In this scenario, NUMA node
                 1 could run with 6 VCPUs and 3GB, and
                 NUMA node 2 could run with 2 VCPUs and
                 1GB.";

            leaf node-cnt {
              description
                  "The number of NUMA nodes to expose to the VM.";
              type uint16;
            }

            leaf mem-policy {
              description
                  "This policy specifies how the memory should
                   be allocated in a multi-node scenario.
                   STRICT    : The memory must be allocated
                               strictly from the memory attached
                               to the NUMA node.
                   PREFERRED : The memory should be allocated
                               preferentially from the memory
                               attached to the NUMA node";
              type enumeration {
                enum STRICT;
                enum PREFERRED;
              }
            }

           list node {
              key id;
              leaf id {
                description
                    "NUMA node identification. Typically
                     it's 0 or 1";
                type uint64;
              }

              list vcpu {
                key "id";
                description
                    "List of VCPUs to allocate on
                     this NUMA node.";
                leaf id {
                  type uint64;
                  description "List of VCPUs ids to allocate on
                               this NUMA node";
                }
              }

              leaf memory-mb {
                description
                    "Memory size expressed in MB
                     for this NUMA node.";
                type uint64;
              }

              choice om-numa-type {
                description
                    "OpenMANO Numa type selection";

                case cores {
                  leaf num-cores {
                    type uint8;
                  }
                }

                case paired-threads {
                  container paired-threads {
                    leaf num-paired-threads {
                      type uint8;
                    }

                    list paired-thread-ids {
                      description
                          "List of thread pairs to use in case of paired-thread NUMA";
                      max-elements 16;
                      key thread-a;

                      leaf thread-a {
                          type uint8;
                      }

                      leaf thread-b {
                          type uint8;
                      }
                    }
                  }
                }
                case threads {
                  leaf num-threads {
                    type uint8;
                  }
                }
              }
            }

          }
        }
      }
    }
  }

  grouping allocation-properties {
    leaf limit {
      description "Defines the maximum allocation. The value 0 indicates that usage is not limited.
                   This parameter ensures that the instance never uses more than the defined amount of resource.";
      type uint64;
    }

    leaf reserve {
      description "Defines the guaranteed minimum reservation.
                   If needed, the machine will definitely get allocated the reserved amount of resources.";
      type uint64;
    }

    leaf shares {
      description "Number of shares allocated.
                   Specifies the proportional weighted share for the domain.
                   If this element is omitted, the service defaults to the OS provided defaults";
      type uint64;
    }
  }

  grouping provider-network {
    container provider-network {
      description "Container for the provider network.";
      leaf physical-network {
        description
            "Name of the physical network on which the provider
             network is built.";
        type string;
      }

      leaf segmentation_id {
        description
            "ID of segregated virtual networks";
            type uint32;
      }
    }
  }

  grouping http-endpoints {
    list http-endpoint {
      description
          "List of http endpoints to be used by monitoring params";
      key path;

      leaf path {
        description "The HTTP path on the management server";
        type string;
      }

      leaf https {
        description "Pick HTTPS instead of HTTP , Default is false";
        type boolean;
        default "false";
      }

      leaf port {
        description "The HTTP port to connect to";
        type inet:port-number;
      }

      leaf username {
        description "The HTTP basic auth username";
        type string;
      }

      leaf password {
        description "The HTTP basic auth password";
        type string;
      }

      leaf polling-interval-secs {
        description "The HTTP polling interval in seconds";
        type uint8;
        default 2;
      }

      leaf method {
        description
          "Method that the URI should perform.
           Deafult action is GET.";

        type manotypes:http-method;
        default "GET";
      }

      list headers {
        description "Custom HTTP headers to put on HTTP request";
        key key;
        leaf key{
          description "HTTP header key";
          type string;
        }

        leaf value{
          description "HTTP header value";
          type string;
        }
      }
    }
  }

  grouping monitoring-param-aggregation {
    typedef aggregation-type {
      description
          "aggregation-type, indicates the way to aggregate monitoring-params
          (e.g. how to aggregate CPU utilisation of all VNFs belonging to the
          same VNF group identified by member-vnf-index; or how to aggregate
          memory utilisation of all VDUs belonging to the same VDU group
          identified by vdu id)";
      type enumeration {
        enum AVERAGE;
        enum MINIMUM;
        enum MAXIMUM;
        enum COUNT;
        enum SUM;
      }
    }

    leaf aggregation-type {
      type aggregation-type;
    }
  }

  grouping monitoring-param-ui-data {
      leaf description {
        type string;
      }

      leaf group-tag {
        description "A tag to group monitoring parameters";
        type string;
      }


      leaf widget-type {
        description "Defines the UI Display variant of measured counters.";
        type manotypes:widget-type;
        default "COUNTER";
      }

      leaf units {
        description "Measured Counter Units (e.g., Packets, Kbps, Mbps, etc.)";
        type string;
      }
  }

  grouping monitoring-param-value {
      leaf value-type {
        type param-value-type;
        default "INT";
      }

      container numeric-constraints {
        leaf min-value {
          description
              "Minimum value for the parameter";
          type uint64;
        }
        leaf max-value {
          description
              "Maximum value for the parameter";
          type uint64;
        }
      }

      container text-constraints {
        leaf min-length {
          description
              "Minimum string length for the parameter";
          type uint8;
        }
        leaf max-length {
          description
              "Maximum string length for the parameter";
          type uint8;
        }
      }

      leaf value-integer {
        description
            "Current value for an integer parameter";
        type int64;
      }

      leaf value-decimal {
        description
            "Current value for a decimal parameter";
        type decimal64 {
          fraction-digits 4;
        }
      }

      leaf value-string {
        description
            "Current value for a string parameter";
        type string;
      }
  }

  grouping control-param {
    list control-param {
      description
          "List of control parameters to manage and
           update the running configuration of the VNF";
      key id;

      leaf id {
        description "Identifier for control parameter";
        type string;
      }

      leaf name {
        description "Name of a control parameter";
        type string;
      }

      leaf description {
        description "A description of the control parameter";
        type string;
      }

      leaf group-tag {
        description "A tag to group control parameters";
        type string;
      }

      leaf min-value {
        description
            "Minimum value for the parameter";
        type uint64;
      }

      leaf max-value {
        description
            "Maximum value for the parameter";
        type uint64;
      }

      leaf current-value {
        description
            "Current value for the parameter";
        type uint64;
      }

      leaf step-value {
        description
            "Step value for the parameter";
        type uint64;
      }

      leaf units {
        type string;
      }

      leaf widget-type {
        type manotypes:widget-type;
      }

      leaf url {
        description
          "This is the URL where the operation should be performed.";

        type inet:uri;
      }

      leaf method {
        description
          "Method that the URI should perform.
           Default Action is POST";

        type manotypes:http-method;
        default "POST";
      }

      leaf payload {
        description
          "This is the operation payload or payload template as stringified
           JSON. This field provides the data  to be sent for this operation
           call";

        type string;
      }
    }
  }

  grouping action-param {
    list action-param {
      description
          "List of action parameters to
           control VNF";
      key id;
      leaf id {
        type string;
      }

      leaf name {
        type string;
      }

      leaf description {
        type string;
      }

      leaf group-tag {
        description "A tag to group monitoring parameter";
        type string;
      }

      leaf url {
        description
          "This is the URL where to perform the operation";
        type inet:uri;
      }

      leaf method {
        description
          "This is the method to be performed at the uri.
           POST by default for action";

        type manotypes:http-method;
        default "POST";
      }

      leaf payload {
        description
          "This is the operation payload or payload template to be sent in
           the data for this operation call";

        type string;
      }
    }
  }

  grouping input-parameter {
    description "List of input parameters that can be specified when instantiating a network service.";

    list input-parameter {
      description
          "List of input parameters";

      key xpath;


      leaf xpath {
        description
          "An xpath that specfies which element in a descriptor is to be
          modified.";
        type string;
      }

      leaf value {
        description
          "The value that the element specified by the xpath should take when a
          record is created.";
        type string;
      }
    }
  }

  grouping input-parameter-xpath {
    list input-parameter-xpath {
      description
          "List of xpaths to parameters inside the NSD
           the can be customized during the instantiation.";

      key "xpath";
      leaf xpath {
        description
            "An xpath that specifies the element in a descriptor.";
        type string;
      }

      leaf label {
        description "A descriptive string";
        type string;
      }

      leaf default-value {
        description "Default Value for the Input Parameter";
        type string;
      }
    }
  }

  grouping nfvi-metrics {
    container vcpu {
      leaf label {
        description
          "Label to show in UI";
        type string;
        default "VCPU";
      }

      leaf total {
        description
          "The total number of VCPUs available.";
        type uint64;
      }

      leaf utilization {
        description
          "The VCPU utilization (percentage).";
        type decimal64 {
          fraction-digits 2;
          range "0 .. 100";
        }
      }
    }

    container memory {
      leaf label {
        description
          "Label to show in UI";
        type string;
        default "MEMORY";
      }

      leaf used {
        description
          "The amount of memory (bytes) currently in use.";
        type uint64;
      }

      leaf total {
        description
          "The amount of memory (bytes) available.";
        type uint64;
      }

      leaf utilization {
        description
          "The memory utilization (percentage).";
        type decimal64 {
          fraction-digits 2;
          range "0 .. 100";
        }
      }
    }

    container storage {
      leaf label {
        description
          "Label to show in UI";
        type string;
        default "STORAGE";
      }

      leaf used {
        description
          "The amount of storage (bytes) currently in use.";
        type uint64;
      }

      leaf total {
        description
          "The amount of storage (bytes) available.";
        type uint64;
      }

      leaf utilization {
        description
          "The storage utilization (percentage).";
        type decimal64 {
          fraction-digits 2;
          range "0 .. 100";
        }
      }
    }

    container external-ports {
      leaf label {
        description
          "Label to show in UI";
        type string;
        default "EXTERNAL PORTS";
      }

      leaf total {
        description
          "The total number of external ports.";
        type uint64;
      }
    }

    container internal-ports {
      leaf label {
        description
          "Label to show in UI";
        type string;
        default "INTERNAL PORTS";
      }

      leaf total {
        description
          "The total number of internal ports.";
        type uint64;
      }
    }

    container network {
      leaf label {
        description
          "Label to show in UI";
        type string;
        default "NETWORK TRAFFIC";
      }

      container incoming {
        leaf label {
          description
            "Label to show in UI";
          type string;
          default "INCOMING NETWORK TRAFFIC";
        }

        leaf bytes {
          description
            "The cumulative number of incoming bytes.";
          type uint64;
        }

        leaf packets {
          description
            "The cumulative number of incoming packets.";
          type uint64;
        }

        leaf byte-rate {
          description
            "The current incoming byte-rate (bytes per second).";
          type decimal64 {
            fraction-digits 2;
          }
        }

        leaf packet-rate {
          description
            "The current incoming packet (packets per second).";
          type decimal64 {
            fraction-digits 2;
          }
        }
      }

      container outgoing {
        leaf label {
          description
            "Label to show in UI";
          type string;
          default "OUTGOING NETWORK TRAFFIC";
        }

        leaf bytes {
          description
            "The cumulative number of outgoing bytes.";
          type uint64;
        }

        leaf packets {
          description
            "The cumulative number of outgoing packets.";
          type uint64;
        }

        leaf byte-rate {
          description
            "The current outgoing byte-rate (bytes per second).";
          type decimal64 {
            fraction-digits 2;
          }
        }

        leaf packet-rate {
          description
            "The current outgoing packet (packets per second).";
          type decimal64 {
            fraction-digits 2;
          }
        }
      }
    }
  }

  typedef alarm-severity-type {
    description "An indication of the importance or urgency of the alarm";
    type enumeration {
      enum LOW;
      enum MODERATE;
      enum CRITICAL;
    }
  }

  typedef alarm-metric-type {
    description "The type of metrics to register the alarm for";
    type enumeration {
      enum CPU_UTILIZATION;
      enum MEMORY_UTILIZATION;
      enum STORAGE_UTILIZATION;
    }
  }

  typedef alarm-statistic-type {
    description
        "Statistic type to use to determine threshold crossing
         for an alarm.";
    type enumeration {
      enum AVERAGE;
      enum MINIMUM;
      enum MAXIMUM;
      enum COUNT;
      enum SUM;
    }
  }

  typedef relational-operation-type {
    description
        "The relational operator used to define whether an alarm,
        scaling event, etc. should be triggered in certain scenarios,
        such as if the metric statistic goes above or below a specified
        value.";
    type enumeration {
      enum GE; // greater than or equal
      enum LE; // less than or equal
      enum GT; // greater than
      enum LT; // less than
      enum EQ; // equal
    }
  }

  grouping alarm-properties {
    leaf name {
      description "A human readable string to identify the alarm";
      type string;
    }

    leaf description {
      description "A description of this alarm";
      type string;
    }

    leaf vdur-id {
      description
          "The identifier of the VDUR that the alarm is associated with";
      type string;
    }

    container actions {
      list ok {
        key "url";
        leaf url {
          type string;
        }
      }

      list insufficient-data {
        key "url";
        leaf url {
          type string;
        }
      }

      list alarm {
        key "url";
        leaf url {
          type string;
        }
      }
    }

    leaf repeat {
      description
          "This flag indicates whether the alarm should be repeatedly emitted
          while the associated threshold has been crossed.";

      type boolean;
      default true;
    }

    leaf enabled {
      description
          "This flag indicates whether the alarm has been enabled or
          disabled.";

      type boolean;
      default true;
    }

    leaf severity {
      description "A measure of the importance or urgency of the alarm";
      type alarm-severity-type;
    }

    leaf statistic {
      description "The type of metric statistic that is tracked by this alarm";
      type alarm-statistic-type;
    }

    leaf operation {
      description
          "The relational operator used to define whether an alarm should be
           triggered in certain scenarios, such as if the metric statistic
           goes above or below a specified value.";
      type relational-operation-type;
    }

    leaf value {
      description
          "This value defines the threshold that, if crossed, will trigger
          the alarm.";
      type decimal64 {
        fraction-digits 4;
      }
    }

    leaf period {
      description
          "The period defines the length of time (seconds) that the metric
          data are collected over in oreder to evaluate the chosen
          statistic.";
      type uint32;
    }

    leaf evaluations {
      description
          "Defines the length of time (seconds) in which metric data are
           collected in order to evaluate the chosen statistic.";
      type uint32;
    }
  }

  typedef cloud-account-type {
    description "VIM account type";
    type enumeration {
      enum aws;
      enum cloudsim;
      enum cloudsim_proxy;
      enum mock;
      enum openmano;
      enum openstack;
      enum vsphere;
      enum openvim;
    }
  }

  grouping host-aggregate {
    list host-aggregate {
      description "Name of the Host Aggregate";
      key "metadata-key";

      leaf metadata-key {
        description
            "Name of the additional information attached to the host-aggregate";
        type string;
      }
      leaf metadata-value {
        description
            "Value of the corresponding metadata-key";
        type string;
      }
    }
  }

  grouping placement-group-input {
    leaf cloud-type {
      type manotypes:cloud-account-type;
    }
    choice cloud-provider {
      case openstack {
        container availability-zone {
          description "Name of the Availability Zone";
          leaf name {
            type string;
          }
        }
        container server-group {
          description "Name of the Affinity/Anti-Affinity Server Group";
          leaf name {
            type string;
          }
        }
        uses host-aggregate;
      }
      case aws {
        leaf aws-construct {
          type empty;
        }
      }
      case openmano {
        leaf openmano-construct {
          type empty;
        }
      }
      case vsphere {
        leaf vsphere-construct {
          type empty;
        }
      }
      case mock {
        leaf mock-construct {
          type empty;
        }
      }
      case cloudsim {
        leaf cloudsim-construct {
          type empty;
        }
      }
    }
  }

  grouping cloud-config {
    list key-pair {
      key "name";
      description "Used to configure the list of public keys to be injected as part
          of ns instantiation";

      leaf name {
        description "Name of this key pair";
        type string;
      }

      leaf key {
        description "Key associated with this key pair";
        type string;
      }
    }

    list user {
      key "name";
      description "List of users to be added through cloud-config";

      leaf name {
        description "Name of the user ";
        type string;
      }

      leaf user-info {
        description "The user name's real name";
        type string;
      }

      list key-pair {
        key "name";
        description "Used to configure the list of public keys to be injected as part
            of ns instantiation";

        leaf name {
          description "Name of this key pair";
          type string;
        }

        leaf key {
          description "Key associated with this key pair";
          type string;
        }
      }
    }
  }

  grouping placement-group-info {
    description "";

    leaf name {
      description
          "Place group construct to define the compute resource placement strategy
           in cloud environment";
      type string;
    }

    leaf requirement {
      description "This is free text space used to describe the intent/rationale
                   behind this placement group. This is for human consumption only";
      type string;
    }

    leaf strategy {
      description
          "Strategy associated with this placement group
             Following values are possible
               - COLOCATION: Colocation strategy imply intent to share the physical
                             infrastructure (hypervisor/network) among all members
                             of this group.
               - ISOLATION: Isolation strategy imply intent to not share the physical
                            infrastructure (hypervisor/network) among the members
                            of this group.
             ";
      type enumeration {
        enum COLOCATION;
        enum ISOLATION;
      }
      default "COLOCATION";
    }
  }

  grouping ip-profile-info {
    description "Grouping for IP-Profile";
    container ip-profile-params {

      leaf ip-version {
        type inet:ip-version;
        default ipv4;
      }

      leaf subnet-address {
        description "Subnet IP prefix associated with IP Profile";
        type inet:ip-prefix;
      }

      leaf gateway-address {
        description "IP Address of the default gateway associated with IP Profile";
        type inet:ip-address;
      }

      leaf security-group {
        description "Name of the security group";
        type string;
      }

      list dns-server {
        key "address";
        leaf address {
          description "List of DNS Servers associated with IP Profile";
          type inet:ip-address;
        }
      }

      container dhcp-params {
        leaf enabled {
          description "This flag indicates if DHCP is enabled or not";
          type boolean;
          default true;
        }

        leaf start-address {
          description "Start IP address of the IP-Address range associated with DHCP domain";
          type inet:ip-address;
        }

        leaf count {
          description "Size of the DHCP pool associated with DHCP domain";
          type uint32;
        }
      }

      leaf subnet-prefix-pool {
        description "VIM Specific reference to pre-created subnet prefix";
        type string;
      }
    }
  }

  grouping ip-profile-list {
    list ip-profiles {
      description
          "List of IP Profiles.
             IP Profile describes the IP characteristics for the Virtual-Link";

      key "name";

      leaf name {
        description "Name of the IP-Profile";
        type string;
      }

      leaf description {
        description "Description for IP profile";
        type string;
      }

      uses ip-profile-info;
    }
  }

  grouping config-file {
    description "Grouping for files needed to be mounted into an additional drive";
    list config-file {
      description
          "List of configuration files to be written on an additional drive";
      key "source";
      leaf source {
        description "Name of the configuration file";
        type string;
      }
      leaf dest {
        description "Full path of the destination in the guest";
        type string;
      }
    }
  }

  grouping supplemental-boot-data {
    description "Grouping for custom vim data";
    container supplemental-boot-data {
//    uses manotypes:config-file;
      leaf boot-data-drive {
        description "Some VIMs implement additional drives to host config-files or meta-data";
        type boolean;
        default false;
      }
    }
  }

  grouping volume-info {
    description "Grouping for Volume-info";

    leaf description {
      description "Description for Volume";
      type string;
    }

    leaf size {
      description "Size of disk in GB";
      type uint64;
    }

    choice volume-source {
      description
            "Defines the source of the volume. Possible options are
             1. Ephemeral -- Empty disk
             2. Image     -- Refer to image to be used for volume
             3. Volume    -- Reference of pre-existing volume to be used
            ";

      case ephemeral {
        leaf ephemeral {
          type empty;
        }
      }

      case image {
        uses image-properties;
      }
    }

    leaf device-bus {
      description "Type of disk-bus on which this disk is exposed to guest";
      type enumeration {
        enum ide;
        enum usb;
        enum virtio;
        enum scsi;
      }
    }

    leaf device-type {
      description "The type of device as exposed to guest";
      type enumeration {
          enum disk;
          enum cdrom;
          enum floppy;
          enum lun;
      }
    }
  }

  grouping rpc-project-name {
    leaf project-name {
      default "default";
      description
        "Project to which this belongs";
      type leafref {
        path "/osm-project:project/osm-project:name";
      }
    }
  }
}
