
/*
 * 
 *   Copyright 2016 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:ietf:params:xml:ns:yang:nfvo:mano-types";
  prefix "manotypes";

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

  import rw-pb-ext {
    prefix "rwpb";
  }

  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 parameter-data-type {
    type enumeration {
      enum STRING;
      enum INTEGER;
      enum BOOLEAN;
    }
  }

  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 paramter";
      type string;
    }

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

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


  grouping vnf-configuration {
    container vnf-configuration {
      ////rwpb:msg-new VnfConfiguration;
      description
          "Information regarding the VNF configuration
           is captured here. ";

      choice config-method {
        description
            "Defines the configuration method for the VNF.";
        case netconf {
          description
              "Use NETCONF for configuring the VNF.";
          container netconf {
            leaf target {
              description
                  "Netconf configuration target";
              type enumeration {
                enum running;
                enum candidate;
              }
            }

            leaf protocol {
              description
                  "Protocol to use for netconf (e.g. ssh)";
              type enumeration {
                enum None;
                enum ssh;
              }
            }

            leaf port {
              description
                  "Port for the netconf server.";
              type inet:port-number;
            }
          }
        }

        case rest {
          description
              "Use REST for configuring the VNF.";
          container rest {
            leaf port {
              description
                  "Port for the REST server.";
              type inet:port-number;
            }
          }
        }

        case script {
          description
              "Use custom script for configuring the VNF.
               This script is executed in the context of
               Orchestrator.";
          container script {
            leaf script-type {
              description
                  "Script type - currently supported : bash, expect";
              type enumeration {
                enum bash;
                enum expect;
              }
            }
          }
        }

        case juju {
          description
            "Configure the VNF through Juju.";
          container juju {
            leaf charm {
              description "Juju charm to use with the VNF.";
              type string;
            }
          }
        }
      }

      container config-access {
        leaf mgmt-ip-address {
          description
              "IP address to be used to configure this VNF,
               optional if it is possible to resolve dynamically.";
          type inet:ip-address;
        }

        leaf username {
          description
              "username for configuration.";
          type string;
        }

        leaf password {
          description
              "Password for configuration access authentication.";
          type string;
        }
      }

      container config-attributes {
        description
            "Miscelaneous input parameters to be considered
             while processing the NSD to apply configuration";

        leaf config-priority {
          description
              "Configuration priority - order of confgiration
               to be applied to each VNF in this NS,
               low number gets precedence over high number";
          type uint64;
        }

        leaf config-delay {
          description
              "Wait (seconds) before applying the configuration to VNF";
          type uint64;
        }
      }

      list config-primitive {
        ////rwpb:msg-new ConfigPrimitive;
        description
            "List of configuration primitives supported by the
            configuration agent for this VNF.";
        key "name";

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

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

      list initial-config-primitive {
        ////rwpb:msg-new InitialConfigPrimitive;
        description
            "Initial 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.";
          type string;
        }

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

          leaf value {
            type string;
          }
        }
      }

      leaf config-template {
        description
            "Configuration template for each VNF";
        type string;
      }
    }
  } // END - grouping vnf-configuration

  typedef virtual-link-type {
    description
        "Type of virtual link
         ELAN: A multipoint service connecting a set of VNFs
         // ELINE: For a simple point to point connection
         //        between a VNF and the existing network.
         // ETREE: A multipoint service connecting one or
         //        more roots and a set of leaves, but
         //        preventing inter-leaf communication.";
    type enumeration {
      enum ELAN;
      // enum ETREE;
      // enum ELINE;
    }
  }

  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 params";

    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 implemenation to extract a value.
       OBJECTPATH - Use objectpath implemenation 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: Phsical Port.";

    type enumeration {
      enum VPORT;
    }
  }

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

  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;
    }
  }

  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 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;
      }

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


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

      leaf-list om-cpu-feature {
        description "Openmano CPU features";
        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 chose 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 perfers hugepages";
        type enumeration {
          enum LARGE;
          enum SMALL;
          enum SIZE_2MB;
          enum SIZE_1GB;
          enum PREFER_LARGE;
        }
      }

      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;
        }
      }

      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-unware {
          leaf numa-unware {
            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 may want 8 vcpus and 4 GB of
                 memory. But may want the vcpus and memory
                 distributed across multiple numa nodes.
                 The NUMA node 1 may run with 6 vcpus and
                 3GB, and NUMA node 2 may 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
                               perferentially 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;
              }

              leaf-list vcpu {
                description
                    "List of vcpus to allocate on
                     this numa node.";
                type uint64;
              }

              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 provider-network {
    container provider-network {
      description "Container for the provider network.";
      leaf physical-network {
        description
            "Name of the phsyical network on which the provider
             network is built.";
        type string;
      }

      leaf overlay-type {
        description
            "Type of the overlay network.";
        type enumeration {
          enum LOCAL;
          enum FLAT;
          enum VLAN;
          enum VXLAN;
          enum GRE;
        }
      }
      leaf segmentation_id {
        description
            "Segmentation ID";
            type uint32;
      }
    }
  }
  grouping config-primitive {
    list config-primitive {
      description
          "Network service level configuration primitives.";

      key "name";

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

      list parameter {
        description
            "List of parameters to the configuration primitive.";

        key "name";
        uses manotypes:primitive-parameter;
      }

      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 to the configuration primitive.";
          key "name";
          uses manotypes:primitive-parameter;
        }

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

      list vnf-primitive-group {
        description
            "List of configuration primitives grouped by VNF.";

        key "member-vnf-index-ref";
        leaf member-vnf-index-ref {
          description
              "Reference to member-vnf within constituent-vnfds";
          type uint64;
        }

        leaf vnfd-id-ref {
          description
              "A reference to a vnfd. This is a
               leafref to path:
                   ../../../../nsd:constituent-vnfd
                   + [nsd:id = current()/../nsd:id-ref]
                   + /nsd:vnfd-id-ref
               NOTE: An issue with confd is preventing the
               use of xpath. Seems to be an issue with leafref
               to leafref, whose target is in a different module.
               Once that is resovled this will switched to use
               leafref";

          type string;
        }

        leaf vnfd-name {
          description
              "Name of the VNFD";
          type string;
        }

        list primitive {
          key "index";

          leaf index {
            description "Index of this primitive";
            type uint32;
          }

          leaf name {
            description "Name of the primitive in the VNF primitive ";
            type string;
          }
        }
      }

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

  grouping monitoring-param {
    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
          "This is the method to be performed at the uri.
           GET by default for action";

        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;
        }
      }
    }

    list monitoring-param {
      description
          "List of monitoring parameters at the NS level";
      key id;
      leaf id {
        type string;
      }

      leaf name {
        type string;
      }

      leaf http-endpoint-ref {
        type leafref {
          path "../../http-endpoint/path";
        }
      }

      leaf json-query-method {
        type manotypes:json-query-method;
        default "NAMEKEY";
      }

      container json-query-params {
        leaf json-path {
          description
            "The jsonpath to use to extract value from JSON structure";
          type string;
        }
        leaf object-path {
          description
            "The objectpath to use to extract value from JSON structure";
          type string;
        }
      }

      leaf description {
        type string;
      }

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

      leaf value-type {
        type manotypes:param-value-type;
        default "INT";
      }

      container numeric-constraints {
        leaf min-value {
          description
              "Minimum value for the parameter";
          type uint64;
        }
        leaf max-value {
          description
              "Maxium 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;
      }

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

      leaf units {
        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 {
        type string;
      }

      leaf name {
        type string;
      }

      leaf description {
        type string;
      }

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

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

      leaf max-value {
        description
            "Maxium 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 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 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 simple 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 input-parameter {
      description
          "List of input parameters";

      key xpath;


      leaf xpath {
        description
          "A 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 " A default value for this 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 ugency 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
        "The type of statistic to used to measure a metric to determine
        threshold crossing for an alarm.";
    type enumeration {
      enum AVERAGE;
      enum MINIMUM;
      enum MAXIMUM;
      enum COUNT;
      enum SUM;
    }
  }

  typedef alarm-operation-type {
    description
        "The relational operator used to define whether an alarm should be
        triggered when, say, 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 {
    leaf alarm-id {
      description
          "This field is reserved for the identifier assigned by the cloud
          provider";

      type string;
    }

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

    leaf description {
      description "A string containing 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 important or urgency of the alarm";
      type manotypes:alarm-severity-type;
    }

    leaf metric {
      description "The metric to be tracked by this alarm.";
      type manotypes:alarm-metric-type;
    }

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

    leaf operation {
      description
          "The relational operator that defines whether the alarm should be
          triggered when the metric statistic is, say, above or below the
          specified threshold value.";
      type manotypes:alarm-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
          "This is the number of samples of the metric statistic used to
          evaluate threshold crossing. Each sample or evaluation is equal to
          the metric statistic obtained for a given period. This can be used
          to mitigate spikes in the metric that may skew the statistic of
          interest.";
      type uint32;
    }
  }

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

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

      leaf metadata-key {
        type string;
      }
      leaf metadata-value {
        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 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";
    }
  }
}
