module openconfig-system-terminal {
  yang-version 1;
  namespace "http://openconfig.net/yang/system/terminal";
  prefix oc-sys-term;

  import openconfig-extensions {
    prefix oc-ext;
  }

  organization
    "OpenConfig working group";
  contact
    "OpenConfig working group
     www.openconfig.net";
  description
    "This module defines configuration and operational state data
     related to remote terminal services such as ssh and telnet.";

  revision 2018-11-21 {
    description
      "Add OpenConfig module metadata extensions.";
    reference
      "0.3.1";
  }
  revision 2017-09-18 {
    description
      "Updated to use OpenConfig types modules";
    reference
      "0.3.0";
  }
  revision 2017-07-06 {
    description
      "Move to oc-inet types, add IETF attribution, add RADIUS
       counters, changed password leaf names to indicate hashed";
    reference
      "0.2.0";
  }
  revision 2017-01-29 {
    description
      "Initial public release";
    reference
      "0.1.0";
  }

  oc-ext:openconfig-version "0.3.1";
  oc-ext:regexp-posix;
  oc-ext:catalog-organization "openconfig";
  oc-ext:origin "openconfig";

  grouping system-terminal-common-config {
    description
      "Common configuration data for terminal services";
    leaf timeout {
      type uint16;
      units "seconds";
      description
        "Set the idle timeout in seconds on terminal connections to
         the system for the protocol.";
    }
    leaf rate-limit {
      type uint16;
      units "conn/min";
      description
        "Set a limit on the number of connection attempts per
         minute to the system for the protocol.";
    }
    leaf session-limit {
      type uint16;
      description
        "Set a limit on the number of simultaneous active terminal
         sessions to the system for the protocol (e.g., ssh,
         telnet, ...) ";
    }
  }

  grouping system-terminal-common-state {
    description
      "Common operational state data for terminal services";
  }

  grouping system-terminal-common-top {
    description
      "Top-level grouping for common terminal service data";
    container terminal-servers {
      description
        "Top-level container for terminal services";
      container config {
        description
          "Configuration data for terminal services";
        uses system-terminal-common-config;
      }
      container state {
        config false;
        description
          "Operational state data ";
        uses system-terminal-common-config;
        uses system-terminal-common-state;
      }
    }
  }

  grouping system-ssh-server-config {
    description
      "Configuration data for system ssh configuration";
    leaf enable {
      type boolean;
      default "true";
      description
        "Enables the ssh server.  The ssh server is enabled by
         default.";
    }
    leaf protocol-version {
      type enumeration {
        enum "V2" {
          description
            "Use SSH v2 only";
        }
        enum "V1" {
          description
            "Use SSH v1 only";
        }
        enum "V1_V2" {
          description
            "Use either SSH v1 or v2";
        }
      }
      default "V2";
      description
        "Set the protocol version for SSH connections to the system";
    }
    uses system-terminal-common-config;
  }

  grouping system-ssh-server-state {
    description
      "Operational state data for ssh server";
  }

  grouping system-ssh-server-top {
    description
      "Top-level grouping for ssh server data";
    container ssh-server {
      description
        "Top-level container for ssh server";
      container config {
        description
          "Configuration data for the system ssh server";
        uses system-ssh-server-config;
      }
      container state {
        config false;
        description
          "Operational state data for the system ssh server";
        uses system-ssh-server-config;
        uses system-ssh-server-state;
      }
    }
  }

  grouping system-telnet-server-config {
    description
      "Configuration data for telnet server";
    leaf enable {
      type boolean;
      default "false";
      description
        "Enables the telnet server.  Telnet is disabled by
         default";
    }
    uses system-terminal-common-config;
  }

  grouping system-telnet-server-state {
    description
      "Operational state data for telnet server";
  }

  grouping system-telnet-server-top {
    description
      "Top-level grouping for telnet server ";
    container telnet-server {
      description
        "Top-level container for telnet terminal servers";
      container config {
        description
          "Configuration data for telnet";
        uses system-telnet-server-config;
      }
      container state {
        config false;
        description
          "Operational state data for telnet";
        uses system-telnet-server-config;
        uses system-telnet-server-state;
      }
    }
  }
}