initial checkin of xos-core, cord-device, and cord-subscriber YANG models
diff --git a/.gitignore b/.gitignore
index 5148e52..f85f310 100644
--- a/.gitignore
+++ b/.gitignore
@@ -35,3 +35,9 @@
 
 # Optional REPL history
 .node_repl_history
+
+*~
+
+# ignore generated *.js files inside lib and dist
+lib/*
+dist/*
diff --git a/cord-device.yang b/cord-device.yang
new file mode 100644
index 0000000..6021966
--- /dev/null
+++ b/cord-device.yang
@@ -0,0 +1,48 @@
+module cord-device {
+  namespace "urn:cord:device";
+  prefix cord-dev;
+  yang-version 1.1;
+
+  organization
+   "Open Networking Lab (CORD) / Corenova Technologies";
+
+  contact
+    "Larry Peterson <llp@onlab.us>
+     Peter K. Lee <peter@corenova.com>";
+  
+  import ietf-yang-types { prefix yang; }
+  
+  revision 2016-07-14 {
+    description "Initial revision.";
+  }
+
+  typedef bandwidth {
+    type unit32;
+    range 1000000..max; // should be at least 1 Mbps?
+    units 'bps';
+  }
+  
+  grouping device {
+    leaf mac { type yang:mac-address; mandatory true; }
+    leaf identity { type string; }
+
+    leaf subscriber {
+      type instance-identifier;
+      config false;
+    }
+    
+    container features {
+      // how are the uplink/downlink speeds defined here related to 'subscriber'?
+      leaf uplink-speed {
+        type bandwidth;
+        default 1000000000;      
+      }
+      leaf downlink-speed {
+        type bandwidth;
+        default 1000000000;      
+      }
+      action update;
+    }
+    action save;
+  }
+}
diff --git a/cord-subscriber.yang b/cord-subscriber.yang
new file mode 100644
index 0000000..72185f8
--- /dev/null
+++ b/cord-subscriber.yang
@@ -0,0 +1,192 @@
+module cord-subscriber {
+  namespace "urn:cord:subscriber";
+  prefix cord-sub;
+  yang-version 1.1;
+
+  organization
+   "Open Networking Lab (CORD) / Corenova Technologies";
+
+  contact
+    "Larry Peterson <llp@onlab.us>
+     Peter K. Lee <peter@corenova.com>";
+  
+  import xos-core        { prefix xos; }
+  import cord-device     { prefix dev; }
+  import ietf-yang-types { prefix yang; }
+  import yang-node-link  { prefix node; }
+
+  revision 2016-07-14 {
+    description "Initial revision.";
+  }
+  
+  identity cord-subscriber { base xos:subscriber; }
+
+  grouping subscriber {
+    uses xos:subscriber {
+      refine kind { default cord-subscriber; }
+    }
+    leaf status {
+      type enumeration {
+        enum "enabled" {
+          description "Enabled";
+          value 1;
+        }
+        enum "suspended" {
+          description "Suspended";
+        }
+        enum "delinquent" {
+          description "Delinquent";
+        }
+        enum "violation" {
+          description "Copyright Violation";
+        }
+      }
+      default enabled;
+    }
+    leaf demo { type boolean; default false; }
+    leaf uplink-speed {
+      type dev:bandwidth;
+      default 1000000000;      
+    }
+    leaf downlink-speed {
+      type dev:bandwidth;
+      default 1000000000;      
+    }
+
+    container services {
+      description
+        "Contains various services available to the subscriber";
+      
+      container cdn {
+        leaf enabled { type boolean; default false; }
+      }
+      container firewall {
+        leaf enabled { type boolean; default false; }
+        leaf-list rules {
+          // should qualify further
+          type string;
+        }
+      }
+      container url-filter {
+        leaf enabled { type boolean; default false; }
+        leaf level {
+          type enumeration {
+            enum "PG";
+            // other types of level...
+          }
+        }
+        leaf-list rules {
+          // should qualify further
+          type string;
+        }
+      }
+      container uverse {
+        leaf enabled { type boolean; default false; }
+      }
+    }
+
+    list devices {
+      uses dev:device;
+      key 'mac';
+
+      action create {
+        input {
+          leaf mac {
+            type yang:mac-address;
+            mandatory true;
+          }
+          // other acceptable attributes that can be used during create
+        }
+      }
+      action update {
+        input {
+          leaf mac {
+            type yang:mac-address;
+            //must "../.[mac = current()]";
+            mandatory true;
+          }
+          // other acceptable attributes for updating
+        }
+      }
+      action delete {
+        input {
+          leaf mac {
+            type yang:mac-address;
+            //must "../.[mac = current()]";
+            mandatory true;
+          }
+          // other acceptable attributes for updating
+        }
+      }
+    }
+    action save {
+      description "when invoked, saves the model to a safe place";
+    }
+  }
+
+  grouping subscriber-controller {
+    uses subscriber;
+
+    container features {
+      node:link cdn {
+        path "../../services/cdn/enabled";
+      }
+      node:link uplink-speed {
+        path "../../uplink-speed";
+      }
+      node:link downlink-speed {
+        path "../../downlink-speed";
+      }
+      node:link uverse {
+        path "../../services/uverse/enabled";
+      }
+      node:link status {
+        path "../../status";
+      }
+      action update {
+        description "when invoked, updates the features container (PUT)";
+      }
+    }
+    
+    container identity {
+      node:link account-num {
+        path "../../service-specific-id";
+      }
+      node:link name {
+        path "../../name";
+      }
+      action update {
+        description "when invoked, updates the identity container (PUT)";
+      }
+    }
+
+    container related {
+      // placeholder where other services can augment for their info
+    }
+
+    action create;
+    action delete;
+  }
+
+  // primary configuration tree for this module
+  list subscriber {
+    uses subscriber-controller;
+    key 'id';
+
+    description
+      "Authorative list of all subscriber instances";
+
+    leaf humanReadableName {
+      config false;
+      type string {
+        pattern '^cordSubscriber-\w+$';
+      }
+    }
+  }
+
+  // here we augment the /api/tenant/cord API configuration tree in 'xos' module
+  augment "/xos:api/xos:tenant/xos:cord" {
+    node:link subscriber { path "/subscriber"; }
+  }
+  
+}
diff --git a/old/xos-core-service.yang b/old/xos-core-service.yang
new file mode 100644
index 0000000..3923221
--- /dev/null
+++ b/old/xos-core-service.yang
@@ -0,0 +1,120 @@
+module xos-core-service {
+  namespace "urn:xos:core:service";
+  prefix xos-cs;
+
+  import complex-types { prefix ct; }
+
+  revision 2015-10-01 {
+    description "Initial revision.";
+  }
+
+  grouping service-attribute {
+    leaf name { type string { length 128; } }
+    leaf value { type string { length 1024; } }
+    leaf service {
+      type instance-identifier { ct:instance-type Service; require-instance true; }
+    }
+  }
+
+  grouping service-role {
+    leaf role {
+      type enumeration {
+        enum "admin";
+        //enum "Admin";
+      }
+    }
+  }
+
+  grouping common-model-attr {
+    leaf kind {
+      type string { length 30; }
+      default "generic";
+    }
+    leaf name { type string { length 255; } }
+  }
+
+  ct:complex-type ServiceElement {
+    ct:abstract true;
+    leaf enabled { type boolean; default true; }
+  }
+  
+  ct:complex-type Service {
+    ct:extends ServiceElement;
+    
+    leaf description {
+      type string { length 255; }
+      description "Description of Service";
+    }
+    leaf published { type boolean; default true; }
+
+    uses common-model-attr {
+      refine kind {
+        description "Kind of Service";
+      }
+      refine name {
+        description "Service Name";
+      }
+    }
+  }
+
+  ct:complex-type User {
+    ct:extends ServiceElement;
+    // TBD - should go to a separate xos-core-user module or such
+  }
+  
+  ct:complex-type ServicePrivilege {
+    key "user-service-role";
+    
+    leaf user {
+      type instance-identifier { ct:instance-type User; require-instance true; }
+    }
+    leaf service {
+      type instance-identifier { ct:instance-type Service; }
+    }
+    uses service-role;
+  }
+
+  ct:complex-type TenantRoot {
+    ct:extends ServiceElement;
+    
+    description
+      "A tenantRoot is one of the things that can sit at the root of a chain
+        of tenancy. This object represents a node.";
+    uses common-model-attr;
+  }
+
+  ct:complex-type ContainerImage {
+    // TBD
+  }
+  
+  ct:complex-type Tenancy {
+    ct:extends ServiceElement;
+    
+    description
+      "A Tenancy describes relationship between a subscriber and a provider";
+    
+    uses common-model-attr;
+
+    leaf provider { type instance-identifer { ct:instance-type Service; } }
+    leaf subscriber {
+      type instance-identifier {
+        ct:instance-type ServiceElement;
+      }
+    }
+
+    // adding stuff from TenantWithContainer here...
+    leaf creator { type instance-identifier { ct:instance-type User; } }
+    leaf image { type instance-identifier { ct:instance-type ContainerImage; } }
+  }
+
+  ct:complex-type Subscriber {
+    ct:extends TenantRoot;
+    refine kind { default "Subscriber"; }
+  }
+
+  ct:complex-type Provider {
+    ct:extends TenantRoot;
+    refine kind { default "Provider"; }
+  }
+  
+}
diff --git a/xos-core.yang b/xos-core.yang
new file mode 100644
index 0000000..842a537
--- /dev/null
+++ b/xos-core.yang
@@ -0,0 +1,93 @@
+module xos-core {
+  namespace "urn:xos:core:service";
+  prefix xos;
+  yang-version 1.1;
+
+  organization
+   "Open Networking Lab (XOS) / Corenova Technologies";
+
+  contact
+    "Larry Peterson <llp@onlab.us>
+     Peter K. Lee <peter@corenova.com>";
+  
+  import ietf-yang-types { prefix yang; }
+
+  revision 2016-07-14 {
+    description "Initial revision.";
+  }
+  
+  identity kind;
+  identity generic    { base kind; }
+  identity subscriber { base kind; }
+
+  typedef unique-identifier {
+    description "defines valid formats for external reference id";
+    type union {
+      type yang:uuid;
+      type inet:uri;
+      type uint32 { range 1..max; }
+    }
+  }
+
+  grouping tenant-root {
+
+    description
+      "A Tenant Root is one of the things that can sit at the root of a chain
+       of tenancy. This object represents a node.";
+
+    leaf id {
+      type unique-identifier;
+      config false;
+      mandatory true;
+    }
+    leaf kind {
+      type identityref {
+        base kind;
+      }
+      default generic;
+    }
+    leaf name {
+      type string {
+        length 0..255;
+      }
+      description "Specify name of the TenantRoot";
+    }
+
+    leaf service-specific-attribute { type string; }
+    leaf service-specific-id {
+      type unique-identifier;
+      mandatory true;
+    }
+
+    list subscribed-tenants {
+      config false;
+      // not exactly clear how this is populated
+    }
+    
+  }
+  
+  grouping subscriber {
+    uses tenant-root {
+      refine kind { default subscriber; }
+    }
+    // seems we should have interesting attributes specific to subscriber?
+    
+  }
+
+  // main configuration tree for XOS
+
+  container api {
+    container service {
+      // placeholder endpoint for services
+    }
+    container tenant {
+      container cord {
+        // placeholder endpoint for augment
+      }
+      container onos {
+        // placeholder endpoint for augment
+      }
+    }
+  }
+  
+}