
/*
 * 
 *   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 vlr
{
  namespace "urn:etsi:osm:yang:vlr";
  prefix "vlr";

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

  import mano-types {
    prefix "manotypes";
  }

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

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

  revision 2015-09-10 {
    description
      "Initial revision. This YANG file defines
       the Virtual Link Record (VLR)";
    reference
      "Derived from earlier versions of base YANG files";
  }

  augment "/osm-project:project" {
    container vlr-catalog {
      leaf schema-version {
        description "Schema version for the VLR. If unspecified, it assumes v3.0";
        type string;
        default "v3.0";
      }

      config false;

      list vlr {
        key "id";
        unique "name";

        leaf id {
          description "Identifier for the VLR.";
          type yang:uuid;
        }

        leaf name {
          description "VLR name.";
          type string;
        }

        leaf nsr-id-ref {
          description
            "NS instance identifier. 
             This is a leafref /osm-project:project/nsr:ns-instance-config/nsr:nsr/nsr:id";
          type yang:uuid;
        }

        leaf vld-ref {
          description
            "Reference to VLD
           /osm-project:project/nsr:ns-instance-config/nsr:nsr[nsr:id=../nsr-id-ref]
           /nsd/vld:vld/vld:id";
          type string;
        }

        leaf res-id {
          description "Identifier for resmgr id mapping";
          type yang:uuid;
        }

        leaf short-name {
          description "Short name to appear as label in the UI";
          type string;
        }

        leaf vendor {
          description "Provider of the VLR.";
          type string;
        }

        leaf description {
          description "Description of the VLR.";
          type string;
        }

        leaf version {
          description "Version of the VLR";
          type string;
        }

        leaf type {
          type manotypes:virtual-link-type;
        }

        leaf root-bandwidth {
          description
            "For ELAN this is the aggregate bandwidth.";
          type uint64;
        }

        leaf leaf-bandwidth {
          description
            "For ELAN this is the bandwidth of branches.";
          type uint64;
        }

        leaf create-time {
          description
            "Creation timestamp of this Virtual Link.
          The timestamp is expressed as seconds 
          since unix epoch - 1970-01-01T00:00:00Z";

          type uint32;
        }

        leaf uptime {
          description
            "Active period of this Virtual Link.
          Uptime is expressed in seconds";

          type uint32;
        }

        leaf network-id {
          description
            "Identifier for the allocated network resource.";
          type string;
        }

        leaf vim-network-name {
          description
            "Name of network in VIM account. This is used to indicate
            pre-provisioned network name in cloud account.";
          type string;
        }

        // replicate for pnfd container here

        uses manotypes:provider-network;
        uses manotypes:ip-profile-info;
      
        leaf status {
          description
            "Status of the virtual link record.";
          type enumeration {
            enum LINK_UP;
            enum DEGRADED;
            enum LINK_DOWN;
          }
        }
        leaf operational-status {
          description
            "The operational status of the Virtual Link
            init                 : The VL is in init stat.
            vl-alloc-pending     : The VL alloc is pending in VIM
            running              : The VL is up  and running in VM
            vl-terminate-pending : The VL is being terminated in VIM.
            terminated           : The VL is terminated in the VM.
            failed               : The VL instantiation failed in VIM.
          ";

          type enumeration {
            enum init;
            enum vl-alloc-pending;
            enum running;
            enum vl-terminate-pending;
            enum terminated;
            enum failed;
          }
        }
      }
    }
  }
}

