VOL-1452 Changes to make runnable with old openolt code

Updates to mostly make the openolt adapter talk to the core.
Still have to implement adding logical devices

Change-Id: I3140af196eb38d8beb225a864b1fc42fe5242329
diff --git a/python/protos/events.proto b/python/protos/events.proto
new file mode 100644
index 0000000..725bb8c
--- /dev/null
+++ b/python/protos/events.proto
@@ -0,0 +1,195 @@
+syntax = "proto3";
+
+option go_package = "github.com/opencord/voltha/protos/go/voltha";
+
+package voltha;
+
+import "meta.proto";
+import "google/api/annotations.proto";
+
+message ConfigEventType {
+    enum ConfigEventType {
+        add = 0; // A new config has been added
+        remove = 1; // A config has been removed
+        update = 2; // A config has been updated
+    }
+}
+
+message ConfigEvent {
+    ConfigEventType.ConfigEventType type = 1;
+
+    string hash = 2; // hash for this change, can be used for quick lookup
+    string data = 3; // the actual new data, in json format
+}
+
+message KpiEventType {
+    enum KpiEventType {
+        slice = 0; // slice: a set of path/metric data for same time-stamp
+        ts = 1; // time-series: array of data for same metric
+    }
+}
+
+/*
+ * Struct to convey a dictionary of metric metadata.
+ */
+message MetricMetaData {
+    string title = 1;   // Metric group or individual metric name
+    double ts = 2;      // UTC time-stamp of data (seconds since epoch) of
+                        // when the metric or metric group was collected.
+                        // If this is a 15-min historical group, it is the
+                        // time of the collection and reporting, not the
+                        // start or end of the 15-min group interval.
+
+    string logical_device_id = 3; // The logical device ID of the VOLTHA
+                                  // (equivalent to the DPID that ONOS has
+                                  // for the VOLTHA device without the
+                                  //  'of:' prefix
+    string serial_no = 4;         // The OLT, ONU, ... device serial number
+    string device_id = 5;         // The OLT, ONU, ... physical device ID
+
+    map<string, string> context = 6; // Name value pairs that provide additional
+                                     // context information on the metrics being
+                                     // reported.
+}
+
+/*
+ * Struct to convey a dictionary of metric->value pairs. Typically used in
+ * pure shared-timestamp or shared-timestamp + shared object prefix situations.
+ */
+message MetricValuePairs {
+
+    // Metric / value pairs.
+    map<string, float> metrics = 1;
+
+}
+
+/*
+ * Struct to group metadata for a metric (or group of metrics) with the key-value
+ * pairs of collected metrics
+ */
+message MetricInformation {
+    MetricMetaData metadata = 1;
+    map<string, float> metrics = 2;
+}
+
+/*
+ * Legacy KPI Event structured.  In mid-August, the KPI event format was updated
+ *                               to a more easily parsable format. See VOL-1140
+ *                               for more information.
+ */
+message KpiEvent {
+
+    KpiEventType.KpiEventType type = 1;
+
+    // Fields used when for slice:
+
+    float ts = 2; // UTC time-stamp of data in slice mode (seconds since epoc)
+
+    map<string, MetricValuePairs> prefixes = 3;
+
+}
+
+message KpiEvent2 {
+    // Type of KPI Event
+    KpiEventType.KpiEventType type = 1;
+
+    // Fields used when for slice:
+    double ts = 2;  // UTC time-stamp of data in slice mode (seconds since epoch)
+                    // of the time this entire KpiEvent was published to the kafka bus
+
+    repeated MetricInformation slice_data = 3;
+}
+
+/*
+ * Identify to the area of the system impacted by the alarm
+ */
+message AlarmEventType {
+    enum AlarmEventType {
+        COMMUNICATION = 0;
+        ENVIRONMENT = 1;
+        EQUIPMENT = 2;
+        SERVICE = 3;
+        PROCESSING = 4;
+        SECURITY = 5;
+    }
+}
+
+/*
+ * Identify to the functional category originating the alarm
+ */
+message AlarmEventCategory {
+    enum AlarmEventCategory {
+        PON = 0;
+        OLT = 1;
+        ONT = 2;
+        ONU = 3;
+        NNI = 4;
+    }
+}
+
+/*
+ * Active state of the alarm
+ */
+message AlarmEventState {
+    enum AlarmEventState {
+        RAISED = 0;
+        CLEARED = 1;
+    }
+}
+
+/*
+ * Identify the overall impact of the alarm on the system
+ */
+message AlarmEventSeverity {
+    enum AlarmEventSeverity {
+        INDETERMINATE = 0;
+        WARNING = 1;
+        MINOR = 2;
+        MAJOR = 3;
+        CRITICAL = 4;
+    }
+}
+
+/*
+ *
+ */
+message AlarmEvent {
+    // Unique ID for this alarm.  e.g. voltha.some_olt.1234
+    string id = 1;
+
+    // Refers to the area of the system impacted by the alarm
+    AlarmEventType.AlarmEventType type = 2;
+
+    // Refers to functional category of the alarm
+    AlarmEventCategory.AlarmEventCategory category = 3;
+
+    // Current active state of the alarm
+    AlarmEventState.AlarmEventState state = 4;
+
+    // Overall impact of the alarm on the system
+    AlarmEventSeverity.AlarmEventSeverity severity = 5;
+
+    // Timestamp at which the alarm was first raised
+    float raised_ts = 6;
+
+    // Timestamp at which the alarm was reported
+    float reported_ts = 7;
+
+    // Timestamp at which the alarm has changed since it was raised
+    float changed_ts = 8;
+
+    // Identifier of the originating resource of the alarm
+    string resource_id = 9;
+
+    // Textual explanation of the alarm
+    string description = 10;
+
+    // Key/Value storage for extra information that may give context to the alarm
+    map<string, string> context = 11;
+
+    // logical device id
+    string logical_device_id = 12;
+
+    // alarm_type  name indicates clearly the name of the alarm
+    string alarm_type_name = 13;
+}
diff --git a/python/protos/openolt.proto b/python/protos/openolt.proto
index f6c1da1..ddc8f74 100644
--- a/python/protos/openolt.proto
+++ b/python/protos/openolt.proto
@@ -13,14 +13,8 @@
 // limitations under the License.
 
 syntax = "proto3";
-option go_package = "github.com/opencord/voltha-go/protos/voltha";
-
-package voltha;
-
+package openolt;
 import "google/api/annotations.proto";
-import "openflow_13.proto";
-
-
 
 service Openolt {
 
@@ -136,6 +130,20 @@
         };
     }
 
+    rpc CreateTconts(Tconts) returns (Empty) {
+        option (google.api.http) = {
+            post: "/v1/CreateTconts"
+            body: "*"
+        };
+    }
+
+    rpc RemoveTconts(Tconts) returns (Empty) {
+        option (google.api.http) = {
+            post: "/v1/RemoveTconts"
+            body: "*"
+        };
+    }
+
     rpc EnableIndication(Empty) returns (stream Indication) {}
 }
 
@@ -209,6 +217,8 @@
     fixed32 intf_id = 1;
     fixed32 gemport_id = 2;
     fixed32 flow_id = 3;
+    fixed32 port_no = 6;
+    fixed64 cookie = 7;
     bytes pkt = 4;
 }
 
@@ -225,7 +235,6 @@
     fixed32 onu_id = 2;
     SerialNumber serial_number = 3;
     fixed32 pir = 4;   // peak information rate assigned to onu
-    fixed32 alloc_id = 5;
 }
 
 message OmciMsg {
@@ -237,6 +246,7 @@
 message OnuPacket {
     fixed32 intf_id = 1;
     fixed32 onu_id = 2;
+    fixed32 port_no = 4;
     bytes pkt = 3;
 }
 
@@ -250,6 +260,8 @@
     string model = 2;
     string hardware_version = 3;
     string firmware_version = 4;
+    string device_id = 16;
+    string device_serial_number = 17;
 
     // Total number of pon intf ports on the device
     fixed32 pon_ports = 12;
@@ -335,6 +347,7 @@
 message Flow {
     sfixed32 access_intf_id = 1;
     sfixed32 onu_id = 2;
+    sfixed32 uni_id = 11;
     fixed32 flow_id = 3;
     string flow_type = 4;	// upstream, downstream, broadcast, multicast
     sfixed32 alloc_id = 10;
@@ -343,6 +356,8 @@
     Classifier classifier = 7;
     Action action = 8;
     sfixed32 priority = 9;
+    fixed64 cookie = 12; // must be provided for any flow with trap_to_host action. Returned in PacketIndication
+    fixed32 port_no = 13; // must be provided for any flow with trap_to_host action. Returned in PacketIndication
 }
 
 message SerialNumber {
@@ -449,5 +464,93 @@
     fixed32 onu_id = 2;
 }
 
+enum Direction {
+    UPSTREAM = 0;
+    DOWNSTREAM = 1;
+    BIDIRECTIONAL = 2;
+}
+
+enum SchedulingPolicy {
+    WRR = 0;
+    StrictPriority = 1;
+    Hybrid = 2;
+}
+
+enum AdditionalBW {
+    AdditionalBW_None = 0;
+    AdditionalBW_NA = 1;
+    AdditionalBW_BestEffort = 2;
+    AdditionalBW_Auto = 3;
+}
+
+enum DiscardPolicy {
+    TailDrop = 0;
+    WTailDrop = 1;
+    Red = 2;
+    WRed = 3;
+}
+
+enum InferredAdditionBWIndication {
+    InferredAdditionBWIndication_None = 0;
+    InferredAdditionBWIndication_Assured = 1;
+    InferredAdditionBWIndication_BestEffort = 2;
+}
+
+message Scheduler {
+    Direction direction = 1;
+    AdditionalBW additional_bw = 2; // Valid on for “direction == Upstream”.
+    fixed32 priority = 3;
+    fixed32 weight = 4;
+    SchedulingPolicy sched_policy = 5;
+}
+
+message TrafficShapingInfo {
+    fixed32 cir = 1;
+    fixed32 cbs = 2;
+    fixed32 pir = 3;
+    fixed32 pbs = 4;
+    fixed32 gir = 5; // only if “direction == Upstream ”
+    InferredAdditionBWIndication add_bw_ind = 6; // only if “direction == Upstream”
+}
+
+message Tcont {
+    Direction direction = 1;
+    fixed32 alloc_id = 2; // valid only if “direction == Upstream ”
+    Scheduler scheduler = 3;
+    TrafficShapingInfo traffic_shaping_info = 4;
+}
+
+message Tconts {
+    fixed32 intf_id = 1;
+    fixed32 onu_id = 2;
+    fixed32 uni_id = 4;
+    fixed32 port_no = 5;
+    repeated Tcont tconts = 3;
+}
+
+message TailDropDiscardConfig {
+    fixed32 queue_size = 1;
+}
+
+message RedDiscardConfig {
+    fixed32 min_threshold = 1;
+    fixed32 max_threshold = 2;
+    fixed32 max_probability = 3;
+}
+
+message WRedDiscardConfig {
+    RedDiscardConfig green = 1;
+    RedDiscardConfig yellow = 2;
+    RedDiscardConfig red = 3;
+}
+
+message DiscardConfig {
+    DiscardPolicy discard_policy = 1;
+    oneof discard_config {
+        TailDropDiscardConfig tail_drop_discard_config = 2;
+        RedDiscardConfig red_discard_config = 3;
+        WRedDiscardConfig wred_discard_config = 4;
+    }
+}
 
 message Empty {}