
/*
 * 
 *   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 rwsdnal
{
  namespace "http://riftio.com/ns/riftware-1.0/rwsdnal";
  prefix "rwsdnal";

  import rw-base {
    prefix rwbase;
  }

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

  import rw-yang-types {
    prefix "rwt";
  }

  import rw-log {
    prefix "rwlog";
  }

  import mano-types {
    prefix "manotypes";
  }

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

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


  revision 2014-12-30 {
    description
        "Initial revision.";
    reference
        "RIFT RWSDN cloud data";
  }

  typedef sdn-connection-status-enum {
    description "Connection status for the sdn account";
    type enumeration {
      enum unknown;
      enum validating;
      enum success;
      enum failure;
    }
  }

  grouping connection-status {
    container connection-status {
      config false;
      rwpb:msg-new SdnConnectionStatus;
      leaf status {
        type sdn-connection-status-enum;
      }
      leaf details {
        type string;
      }
    }
  }

  uses connection-status;

  typedef sdn-account-type {
    description "SDN account type";
    type enumeration {
      enum odl;
      enum mock;
      enum sdnsim;
      enum openstack;
    }
  }

  grouping sdn-provider-auth {
    leaf account-type {
      type sdn-account-type;
    }

    choice provider-specific-info {
      container odl {
        leaf username {
          type string {
            length "1..255";
          }
        }

        leaf password {
          type string {
            length "1..32";
          }
        }

        leaf url {
          type string {
            length "1..255";
          }
        }
        leaf plugin-name {
          type string;
          default "rwsdn_odl";
        }
      }
      container mock {
        leaf username {
          type string;
        }
        leaf plugin-name {
          type string;
          default "rwsdn_mock";
        }
      }

      container sdnsim {
        leaf username {
          type string;
        }
        leaf topology-source {
          type string;
        }
        leaf plugin-name {
          type string;
          default "rwsdn_sim";
        }
      }

      container openstack {
        leaf key {
          type string;
          mandatory true;
        }

        leaf secret {
          type string;
          mandatory true;
        }

        leaf auth_url {
          type string;
          mandatory true;
        }

        leaf tenant {
          type string;
          mandatory true;
        }

        leaf admin {
          type boolean;
          default false;
        }

        leaf user-domain {
          type string;
          default "Default";
          description "Domain of the OpenStack user";
        }

        leaf project-domain {
          type string;
          default "Default";
          description "Domain of the OpenStack project";
        }

        leaf region {
          type string;
          default "RegionOne";
        }

        leaf plugin-name {
          type string;
          default "rwsdn_openstack";
        }

        leaf cert-validate {
          type boolean;
          default false;
          description "Certificate validatation policy in case of SSL/TLS connection";
        }
      }

    }
  }

  container sdn-accounts {
    list sdn-account-list {
      rwpb:msg-new SDNAccount;
      key "name";

      leaf name {
        type string;
      }

      uses sdn-provider-auth;
      uses connection-status;
    }
  }

  container vnffgs {
    list vnffg-chain {
      key "name";
      rwpb:msg-new VNFFGChain;

      leaf name {
        type string;
      }

      list vnf-chain-path {
        key "order";
        leaf order {
          type uint32;
          description " Order of the VNF in VNFFG chain";
        }
        leaf service-function-type {
          type string;
        }
        leaf nsh-aware {
          type boolean;
        }
        leaf transport-type {
          type string;
        }
        list vnfr-ids {
          key "vnfr-id";
          leaf vnfr-id {
            type yang:uuid;
          }
          leaf vnfr-name {
            type string;
          }
          leaf mgmt-address {
            type inet:ip-address;
          }
          leaf mgmt-port {
              type inet:port-number;
          }
          list vdu-list {
            key "vm-id port-id";
            leaf port-id {
              rwpb:field-inline "true";
              rwpb:field-string-max 64;
              type string;
            }
            leaf vm-id {
              rwpb:field-inline "true";
              rwpb:field-string-max 64;
              type string;
            }
            leaf name {
              type string;
            }
            leaf address {
              type inet:ip-address;
            }
            leaf port {
              type inet:port-number;
            }
          }
          leaf sff-name {
            description "SFF name useful for non OVS based SFF";
            type string;
          } 
        }
      }
      list sff {
        rwpb:msg-new VNFFGSff;
        key "name"; 
        leaf name {
          type string;
        }
        leaf function-type {
          type string;
        }
        leaf mgmt-address {
          type inet:ip-address;
        }
        leaf mgmt-port {
          type inet:port-number;
        }
        list dp-endpoints {
          key "name";
          leaf name {
           type string;
          } 
          leaf address {
            type inet:ip-address;
          }
          leaf port {
            type inet:port-number;
          }
        }
        list vnfr-list {
          key "vnfr-name";
          leaf vnfr-name {
            type string;
          }
        }
      }
      leaf classifier-name {
        type string;
      }
    }
  }

  container vnffg-rendered-paths {
    rwpb:msg-new VNFFGRenderedPaths;
    list vnffg-rendered-path {
      key "name";
      rwpb:msg-new VNFFGRenderedPath;
      config false;
      leaf name {
        type string;
      }
      leaf path-id {
          description
              "Unique Identifier for the service path";
        type uint32;
      }
      list rendered-path-hop {
        key "hop-number";
        leaf hop-number {
          type uint8;
        }
        leaf service-index {
            description
                "Location within the service path";
          type uint8;
        }
        leaf vnfr-name {
          type string;
        }
        container service-function-forwarder {
          leaf name { 
            description
                "Service Function Forwarder name";
            type string;
          }
          leaf ip-address {
            description
                "Service Function Forwarder Data Plane IP address";
            type inet:ip-address;
          }  
          leaf port {
            description
                "Service Function Forwarder Data Plane port";
            type inet:port-number;
          }  
        }
      }
    }
  }


  container vnffg-classifiers {
    list vnffg-classifier {
      key "name";
      rwpb:msg-new VNFFGClassifier;

      leaf name {
        type string;
      }
      leaf rsp-name {
        type string;
      }
      leaf rsp-id {
        type yang:uuid;
      }
      leaf port-id {
        rwpb:field-inline "true";
        rwpb:field-string-max 64;
        type string;
      }
      leaf vm-id {
        rwpb:field-inline "true";
        rwpb:field-string-max 64;
        type string;
      }
      leaf sff-name {
        type string;
      }
      container vnffg-metadata {
        leaf ctx1 {
          type string;
        }
        leaf ctx2 {
          type string;
        }
        leaf ctx3 {
          type string;
        }
        leaf ctx4 {
          type string;
        }
      }
      list match-attributes {
        description
            "List of match attributes.";
        key "name";
        leaf name {
          description
              "Name for the Access list";
          type string;  
        }

        leaf ip-proto {
          description
              "IP Protocol.";
          type uint8;
        }

        leaf source-ip-address {
          description
              "Source IP address.";
          type inet:ip-prefix;
        }

        leaf destination-ip-address {
          description
              "Destination IP address.";
          type inet:ip-prefix;
        }

        leaf source-port {
          description
              "Source port number.";
          type inet:port-number;
        }

        leaf destination-port {
          description
              "Destination port number.";
          type inet:port-number;
        }
      } //match-attributes
    }
  }

}

/* vim: set ts=2:sw=2: */
