updated docs

Change-Id: Iab1bd8f31d251c85a8a0c68ce880bfad9c5f9b98
diff --git a/api/bbsim/bbsim.proto b/api/bbsim/bbsim.proto
index adc5b31..c079968 100644
--- a/api/bbsim/bbsim.proto
+++ b/api/bbsim/bbsim.proto
@@ -160,30 +160,51 @@
 message Empty {}
 
 service BBSim {
+    // Get BBSim version
     rpc Version(Empty) returns (VersionNumber) {}
+    // Set BBSim log level
     rpc SetLogLevel(LogLevel) returns (LogLevel) {}
 
+    // Get current status of OLT
     rpc GetOlt(Empty) returns (Olt) {}
+    // Poweron OLT
     rpc PoweronOlt(Empty) returns (Response) {}
+    // Shutdown OLT
     rpc ShutdownOlt(Empty) returns (Response) {}
+    // Reboot OLT
     rpc RebootOlt(Empty) returns (Response) {}
 
+    // Get status of an ONU by serial number
     rpc GetONU(ONURequest) returns (ONU) {}
+    // Get status of all ONUs
     rpc GetONUs(Empty) returns (ONUs) {}
 
+    // Shutdown an ONU by serial number
     rpc ShutdownONU (ONURequest) returns (Response) {}
+    // Shutdown all ONUs in OLT
     rpc ShutdownAllONUs (Empty) returns (Response) {}
+    // Shutdown all ONUs under a PON by pon-port-ID
     rpc ShutdownONUsOnPON(PONRequest) returns (Response) {}
 
+    // Poweron an ONU by serial number 
     rpc PoweronONU (ONURequest) returns (Response) {}
+    // Poweron all ONUs in OLT
     rpc PoweronAllONUs (Empty) returns (Response) {}
+    // Poweron all ONUs under a PON by pon-port-ID
     rpc PoweronONUsOnPON(PONRequest) returns (Response) {}
 
+    // Restart EAPOL for ONU
     rpc RestartEapol (ONURequest) returns (Response) {}
+    // Resatrt DHCP for ONU
     rpc RestartDhcp (ONURequest) returns (Response) {}
+    // Send ONU alarm indication
     rpc SetOnuAlarmIndication (ONUAlarmRequest) returns (Response) {}
+    // Send OLT alarm indication for Interface type NNI or PON
     rpc SetOltAlarmIndication (OLTAlarmRequest) returns (Response) {}
-    rpc GetFlows(ONURequest) returns(Flows) {} 
+    // Get all flows or ONU specific flows
+    rpc GetFlows(ONURequest) returns(Flows) {}
+    // Chnage IGMP state 
     rpc ChangeIgmpState (IgmpRequest) returns (Response) {}
+    // Get Traffic scheduler information for ONU
     rpc GetOnuTrafficSchedulers (ONURequest) returns (ONUTrafficSchedulers) {}
 }
diff --git a/docs/source/index.rst b/docs/source/index.rst
index 6a6325e..8eec878 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -121,6 +121,10 @@
            Set this flag for publishing BBSim events on configured kafkaAddress
      -kafkaAddress string
            IP:Port for kafka, used only when bbsimEvents flag is set (default ":9092")
+     -ca string
+           Set the mode for controlled activation of PON ports and ONUs
+     -enableperf bool
+           Setting this flag will cause BBSim to not store data like traffic schedulers, flows of ONUs etc
 
 ``BBSim`` also looks for a configuration file in ``configs/bbsim.yaml`` from
 which it reads a number of default settings. The command line options listed
@@ -171,6 +175,29 @@
 
 .. literalinclude:: ../../examples/sadis-in-bbsim.json
 
+Controlled PON and ONU activation
+---------------------------------
+
+BBSim provides support for controlled PON and ONU activation. By default both PON ports and ONUs are automatically activated when OLT is enabled.
+This can be controlled using ``-ca`` option.
+
+``-ca`` can be set to one of below four modes:
+
+- default: PON ports and ONUs are automatic activated (default behavior).
+
+- only-onu: PON ports automatically enabled and ONUs dynamically activated
+            On Enable OLT, IntfIndications for all PON ports are sent but ONU discovery indications are not sent.
+            When PoweronONU request is received at BBSim API server then ONU discovery indication is sent for that ONU.
+- only-pon: PON ports dynamically enabled and ONUs automatically activated
+            On Enable OLT, neither IntfIndications for PON ports nor ONU discovery indications are sent.
+            When EnablePonIf request is received at OpenOLT server, then that PON port is enabled and
+            IntfIndication is sent for that PON and all ONUs under that ports are discovered automatically.
+- both: Both PON ports and ONUs are dynamically activated
+        On Enable OLT, neither IntfIndication for PON ports nor ONU discovery indications are sent.
+        When EnablePonIf request is received on OpenOLT server then IntfIndication is sent for that PON but no ONU discovery indication will be sent.
+        When PoweronONU request is received at BBSim API server then ONU discovery indication is sent for that ONU.
+
+
 Publishing BBSim Events on kafka
 --------------------------------
 
diff --git a/docs/swagger/bbsim/bbsim.swagger.json b/docs/swagger/bbsim/bbsim.swagger.json
index 951d187..d4130f1 100644
--- a/docs/swagger/bbsim/bbsim.swagger.json
+++ b/docs/swagger/bbsim/bbsim.swagger.json
@@ -13,6 +13,7 @@
   "paths": {
     "/v1/olt": {
       "get": {
+        "summary": "Get current status of OLT",
         "operationId": "GetOlt",
         "responses": {
           "200": {
@@ -20,6 +21,12 @@
             "schema": {
               "$ref": "#/definitions/bbsimOlt"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "tags": [
@@ -29,6 +36,7 @@
     },
     "/v1/olt/flows": {
       "get": {
+        "summary": "Get all flows or ONU specific flows",
         "operationId": "GetFlows2",
         "responses": {
           "200": {
@@ -36,6 +44,12 @@
             "schema": {
               "$ref": "#/definitions/bbsimFlows"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -53,6 +67,7 @@
     },
     "/v1/olt/onus": {
       "get": {
+        "summary": "Get status of all ONUs",
         "operationId": "GetONUs",
         "responses": {
           "200": {
@@ -60,6 +75,54 @@
             "schema": {
               "$ref": "#/definitions/bbsimONUs"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
+          }
+        },
+        "tags": [
+          "BBSim"
+        ]
+      },
+      "delete": {
+        "summary": "Shutdown all ONUs in OLT",
+        "operationId": "ShutdownAllONUs",
+        "responses": {
+          "200": {
+            "description": "A successful response.",
+            "schema": {
+              "$ref": "#/definitions/bbsimResponse"
+            }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
+          }
+        },
+        "tags": [
+          "BBSim"
+        ]
+      },
+      "post": {
+        "summary": "Poweron all ONUs in OLT",
+        "operationId": "PoweronAllONUs",
+        "responses": {
+          "200": {
+            "description": "A successful response.",
+            "schema": {
+              "$ref": "#/definitions/bbsimResponse"
+            }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "tags": [
@@ -69,6 +132,7 @@
     },
     "/v1/olt/onus/{SerialNumber}": {
       "get": {
+        "summary": "Get status of an ONU by serial number",
         "operationId": "GetONU",
         "responses": {
           "200": {
@@ -76,6 +140,12 @@
             "schema": {
               "$ref": "#/definitions/bbsimONU"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -91,6 +161,7 @@
         ]
       },
       "delete": {
+        "summary": "Shutdown an ONU by serial number",
         "operationId": "ShutdownONU",
         "responses": {
           "200": {
@@ -98,6 +169,12 @@
             "schema": {
               "$ref": "#/definitions/bbsimResponse"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -113,6 +190,7 @@
         ]
       },
       "post": {
+        "summary": "Poweron an ONU by serial number",
         "operationId": "PoweronONU",
         "responses": {
           "200": {
@@ -120,6 +198,12 @@
             "schema": {
               "$ref": "#/definitions/bbsimResponse"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -137,6 +221,7 @@
     },
     "/v1/olt/onus/{SerialNumber}/alarms/{AlarmType}/{Status}": {
       "post": {
+        "summary": "Send ONU alarm indication",
         "operationId": "SetOnuAlarmIndication",
         "responses": {
           "200": {
@@ -144,6 +229,12 @@
             "schema": {
               "$ref": "#/definitions/bbsimResponse"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -173,6 +264,7 @@
     },
     "/v1/olt/onus/{SerialNumber}/flows": {
       "get": {
+        "summary": "Get all flows or ONU specific flows",
         "operationId": "GetFlows",
         "responses": {
           "200": {
@@ -180,6 +272,12 @@
             "schema": {
               "$ref": "#/definitions/bbsimFlows"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -197,6 +295,7 @@
     },
     "/v1/olt/onus/{SerialNumber}/trafficschedulers": {
       "get": {
+        "summary": "Get Traffic scheduler information for ONU",
         "operationId": "GetOnuTrafficSchedulers",
         "responses": {
           "200": {
@@ -204,6 +303,12 @@
             "schema": {
               "$ref": "#/definitions/bbsimONUTrafficSchedulers"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -219,8 +324,71 @@
         ]
       }
     },
+    "/v1/olt/port/{PonPortId}/onus": {
+      "delete": {
+        "summary": "Shutdown all ONUs under a PON by pon-port-ID",
+        "operationId": "ShutdownONUsOnPON",
+        "responses": {
+          "200": {
+            "description": "A successful response.",
+            "schema": {
+              "$ref": "#/definitions/bbsimResponse"
+            }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
+          }
+        },
+        "parameters": [
+          {
+            "name": "PonPortId",
+            "in": "path",
+            "required": true,
+            "type": "integer",
+            "format": "int64"
+          }
+        ],
+        "tags": [
+          "BBSim"
+        ]
+      },
+      "post": {
+        "summary": "Poweron all ONUs under a PON by pon-port-ID",
+        "operationId": "PoweronONUsOnPON",
+        "responses": {
+          "200": {
+            "description": "A successful response.",
+            "schema": {
+              "$ref": "#/definitions/bbsimResponse"
+            }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
+          }
+        },
+        "parameters": [
+          {
+            "name": "PonPortId",
+            "in": "path",
+            "required": true,
+            "type": "integer",
+            "format": "int64"
+          }
+        ],
+        "tags": [
+          "BBSim"
+        ]
+      }
+    },
     "/v1/olt/ports/{InterfaceType}/{InterfaceID}/alarms/los/{Status}": {
       "post": {
+        "summary": "Send OLT alarm indication for Interface type NNI or PON",
         "operationId": "SetOltAlarmIndication",
         "responses": {
           "200": {
@@ -228,6 +396,12 @@
             "schema": {
               "$ref": "#/definitions/bbsimResponse"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -258,6 +432,7 @@
     },
     "/v1/olt/status": {
       "get": {
+        "summary": "Get current status of OLT",
         "operationId": "GetOlt2",
         "responses": {
           "200": {
@@ -265,6 +440,12 @@
             "schema": {
               "$ref": "#/definitions/bbsimOlt"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "tags": [
@@ -274,6 +455,7 @@
     },
     "/v1/version": {
       "get": {
+        "summary": "Get BBSim version",
         "operationId": "Version",
         "responses": {
           "200": {
@@ -281,6 +463,12 @@
             "schema": {
               "$ref": "#/definitions/bbsimVersionNumber"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "tags": [
@@ -654,6 +842,39 @@
         }
       }
     },
+    "protobufAny": {
+      "type": "object",
+      "properties": {
+        "type_url": {
+          "type": "string"
+        },
+        "value": {
+          "type": "string",
+          "format": "byte"
+        }
+      }
+    },
+    "runtimeError": {
+      "type": "object",
+      "properties": {
+        "error": {
+          "type": "string"
+        },
+        "code": {
+          "type": "integer",
+          "format": "int32"
+        },
+        "message": {
+          "type": "string"
+        },
+        "details": {
+          "type": "array",
+          "items": {
+            "$ref": "#/definitions/protobufAny"
+          }
+        }
+      }
+    },
     "tech_profileAdditionalBW": {
       "type": "string",
       "enum": [
diff --git a/docs/swagger/legacy/bbsim.swagger.json b/docs/swagger/legacy/bbsim.swagger.json
index 2873efd..b558518 100644
--- a/docs/swagger/legacy/bbsim.swagger.json
+++ b/docs/swagger/legacy/bbsim.swagger.json
@@ -34,6 +34,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "tags": [
@@ -58,6 +64,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -144,6 +156,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -230,6 +248,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -314,6 +338,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -346,6 +376,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -380,6 +416,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -464,6 +506,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -550,6 +598,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -597,6 +651,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -681,6 +741,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -765,6 +831,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -798,6 +870,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -882,6 +960,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -968,6 +1052,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -1008,6 +1098,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -1053,6 +1149,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -1118,6 +1220,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "tags": [
@@ -1142,6 +1250,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -1186,6 +1300,12 @@
               "type": "string",
               "format": "string"
             }
+          },
+          "default": {
+            "description": "An unexpected error response",
+            "schema": {
+              "$ref": "#/definitions/runtimeError"
+            }
           }
         },
         "parameters": [
@@ -1539,6 +1659,42 @@
         }
       }
     },
+    "protobufAny": {
+      "type": "object",
+      "properties": {
+        "type_url": {
+          "type": "string",
+          "description": "A URL/resource name that uniquely identifies the type of the serialized\nprotocol buffer message. This string must contain at least\none \"/\" character. The last segment of the URL's path must represent\nthe fully qualified name of the type (as in\n`path/google.protobuf.Duration`). The name should be in a canonical form\n(e.g., leading \".\" is not accepted).\n\nIn practice, teams usually precompile into the binary all types that they\nexpect it to use in the context of Any. However, for URLs which use the\nscheme `http`, `https`, or no scheme, one can optionally set up a type\nserver that maps type URLs to message definitions as follows:\n\n* If no scheme is provided, `https` is assumed.\n* An HTTP GET on the URL must yield a [google.protobuf.Type][]\n  value in binary format, or produce an error.\n* Applications are allowed to cache lookup results based on the\n  URL, or have them precompiled into a binary to avoid any\n  lookup. Therefore, binary compatibility needs to be preserved\n  on changes to types. (Use versioned type names to manage\n  breaking changes.)\n\nNote: this functionality is not currently available in the official\nprotobuf release, and it is not used for type URLs beginning with\ntype.googleapis.com.\n\nSchemes other than `http`, `https` (or the empty scheme) might be\nused with implementation specific semantics."
+        },
+        "value": {
+          "type": "string",
+          "format": "byte",
+          "description": "Must be a valid serialized protocol buffer of the above specified type."
+        }
+      },
+      "description": "`Any` contains an arbitrary serialized protocol buffer message along with a\nURL that describes the type of the serialized message.\n\nProtobuf library provides support to pack/unpack Any values in the form\nof utility functions or additional generated methods of the Any type.\n\nExample 1: Pack and unpack a message in C++.\n\n    Foo foo = ...;\n    Any any;\n    any.PackFrom(foo);\n    ...\n    if (any.UnpackTo(\u0026foo)) {\n      ...\n    }\n\nExample 2: Pack and unpack a message in Java.\n\n    Foo foo = ...;\n    Any any = Any.pack(foo);\n    ...\n    if (any.is(Foo.class)) {\n      foo = any.unpack(Foo.class);\n    }\n\n Example 3: Pack and unpack a message in Python.\n\n    foo = Foo(...)\n    any = Any()\n    any.Pack(foo)\n    ...\n    if any.Is(Foo.DESCRIPTOR):\n      any.Unpack(foo)\n      ...\n\n Example 4: Pack and unpack a message in Go\n\n     foo := \u0026pb.Foo{...}\n     any, err := ptypes.MarshalAny(foo)\n     ...\n     foo := \u0026pb.Foo{}\n     if err := ptypes.UnmarshalAny(any, foo); err != nil {\n       ...\n     }\n\nThe pack methods provided by protobuf library will by default use\n'type.googleapis.com/full.type.name' as the type URL and the unpack\nmethods only use the fully qualified type name after the last '/'\nin the type URL, for example \"foo.bar.com/x/y.z\" will yield type\nname \"y.z\".\n\n\nJSON\n====\nThe JSON representation of an `Any` value uses the regular\nrepresentation of the deserialized, embedded message, with an\nadditional field `@type` which contains the type URL. Example:\n\n    package google.profile;\n    message Person {\n      string first_name = 1;\n      string last_name = 2;\n    }\n\n    {\n      \"@type\": \"type.googleapis.com/google.profile.Person\",\n      \"firstName\": \u003cstring\u003e,\n      \"lastName\": \u003cstring\u003e\n    }\n\nIf the embedded message type is well-known and has a custom JSON\nrepresentation, that representation will be embedded adding a field\n`value` which holds the custom JSON in addition to the `@type`\nfield. Example (for message [google.protobuf.Duration][]):\n\n    {\n      \"@type\": \"type.googleapis.com/google.protobuf.Duration\",\n      \"value\": \"1.212s\"\n    }"
+    },
+    "runtimeError": {
+      "type": "object",
+      "properties": {
+        "error": {
+          "type": "string"
+        },
+        "code": {
+          "type": "integer",
+          "format": "int32"
+        },
+        "message": {
+          "type": "string"
+        },
+        "details": {
+          "type": "array",
+          "items": {
+            "$ref": "#/definitions/protobufAny"
+          }
+        }
+      }
+    },
     "tech_profileAdditionalBW": {
       "type": "string",
       "enum": [