This commit consists of:
1) Yang annotations to the protobuf definitions.  These annotations, when
   added to the relevant proto files in Voltha,  allow us to convert
   the voltha proto schemas into Yang schemas without the need to change the
   model definitions.
2) Update to the Yang parser to handle the above annotations
3) Some initial work on the netconf GET RPCs (work in progress)
4) Cleanup

Change-Id: I5e4f4217850f0beb1c41aca1b2530a41e4f8a809
diff --git a/netconf/nc_rpc/base/get.py b/netconf/nc_rpc/base/get.py
index 05542dc..7334dba 100644
--- a/netconf/nc_rpc/base/get.py
+++ b/netconf/nc_rpc/base/get.py
@@ -20,40 +20,63 @@
 import netconf.nc_common.error as ncerror
 from netconf.constants import Constants as C
 from netconf.utils import filter_tag_match
+from twisted.internet.defer import inlineCallbacks, returnValue
+import dicttoxml
+from simplejson import dumps, load
 
 log = structlog.get_logger()
 
+
 class Get(Rpc):
+    def __init__(self, rpc_request, rpc_method, voltha_method_ref, grpc_client,
+                 session):
+        super(Get, self).__init__(rpc_request, rpc_method, voltha_method_ref,
+                                        grpc_client, session)
+        self._validate_parameters()
 
-	def __init__(self, rpc_request, rpc_method, grpc_client, session):
-		super(Get, self).__init__(rpc_request, rpc_method, grpc_client,
-								  session)
-		self._validate_parameters()
+    @inlineCallbacks
+    def execute(self):
+        log.info('get-request', session=self.session.session_id,
+                 method=self.rpc_method)
+        if self.rpc_response.is_error:
+            returnValue(self.rpc_response)
 
-	def execute(self):
-		log.info('get-request', session=self.session.session_id)
-		if self.rpc_response.is_error:
-			return self.rpc_response
+        # TODO: for debugging only, assume we are doing a voltha-getinstance
+        self.voltha_method_ref='VolthaLocalService-GetVolthaInstance'
+        # Invoke voltha via the grpc client
+        res_dict = yield self.grpc_client.invoke_voltha_api(self.voltha_method_ref)
 
-	def _validate_parameters(self):
-		log.info('validate-parameters',
-				 session=self.session.session_id,
-				 request=self.rpc_request,
-				 method=self.rpc_method
-				 )
-		self.params = self.rpc_method.getchildren()
-		if len(self.params) > 1:
-			self.rpc_response.is_error = True
-			self.rpc_response.node = ncerror.BadMsg(self.rpc_request)
-			return
+        # convert dict to xml
+        xml = dicttoxml.dicttoxml(res_dict, attr_type=False)
+        log.info('voltha-info', res=res_dict, xml=xml)
 
-		if self.params and not filter_tag_match(self.params[0], C.NC_FILTER):
-			self.rpc_response.is_error = True
-			self.rpc_response.node = ncerror.UnknownElement(
-				self.rpc_request, self.params[0])
-			return
+        root_elem = self.get_root_element(xml)
+        root_elem.tag = 'data'
 
-		if not self.params:
-			self.params = [None]
+        log.info('rpc-method', etree.tounicode(self.rpc_method,
+                                               pretty_print=True))
 
+        self.rpc_method.append(root_elem)
+        self.rpc_response.node = self.rpc_method
+        self.rpc_response.is_error = False
+
+        returnValue(self.rpc_response)
+
+
+    def _validate_parameters(self):
+        log.info('validate-parameters', session=self.session.session_id)
+        self.params = self.rpc_method.getchildren()
+        if len(self.params) > 1:
+            self.rpc_response.is_error = True
+            self.rpc_response.node = ncerror.BadMsg(self.rpc_request)
+            return
+
+        if self.params and not filter_tag_match(self.params[0], C.NC_FILTER):
+            self.rpc_response.is_error = True
+            self.rpc_response.node = ncerror.UnknownElement(
+                self.rpc_request, self.params[0])
+            return
+
+        if not self.params:
+            self.params = [None]
 
diff --git a/netconf/nc_rpc/ext/get_voltha.py b/netconf/nc_rpc/ext/get_voltha.py
index 271a20e..a083401 100644
--- a/netconf/nc_rpc/ext/get_voltha.py
+++ b/netconf/nc_rpc/ext/get_voltha.py
@@ -44,10 +44,8 @@
         # Invoke voltha via the grpc client
         res_dict = yield self.grpc_client.invoke_voltha_api(self.voltha_method_ref)
 
-        # res_dict = yield self.grpc_client.get_voltha_instance()
-
         # convert dict to xml
-        xml = dicttoxml.dicttoxml(res_dict)
+        xml = dicttoxml.dicttoxml(res_dict, attr_type=False)
         log.info('voltha-info', res=res_dict, xml=xml)
 
         root_elem = self.get_root_element(xml)
diff --git a/netconf/nc_rpc/rpc.py b/netconf/nc_rpc/rpc.py
index fb35313..5b579c9 100644
--- a/netconf/nc_rpc/rpc.py
+++ b/netconf/nc_rpc/rpc.py
@@ -31,6 +31,7 @@
         self.voltha_method_ref = voltha_method_ref
         self.session = session
 
+
     def execute(self):
         """ run the command - returns a OperationResponse """
         pass
diff --git a/netconf/nc_rpc/rpc_factory.py b/netconf/nc_rpc/rpc_factory.py
index e409198..aa0ced1 100644
--- a/netconf/nc_rpc/rpc_factory.py
+++ b/netconf/nc_rpc/rpc_factory.py
@@ -80,36 +80,13 @@
 
         rpc_method = rpc_method[0]
 
-        if rpc_method.prefix is None:
-            log.error("rpc-method-has-no-prefix", msg_id=msg_id)
-            raise ncerror.BadMsg(rpc_node)
+        rpc_name = rpc_method.tag.replace(qmap('nc'), "")
 
-        try:
-            # extract the namespace, service and name
-            namespace = ''.join(
-                ['{', rpc_method.nsmap[rpc_method.prefix], '}'])
-            # rpc_name = rpc_method.tag.replace(qmap('nc'), "")
-            rpc = rpc_method.tag.replace(namespace, "").split('-')
-            rpc_service = rpc[0]
-            rpc_name = rpc[1]
-            log.info("rpc-request",
-                     namespace=namespace,
-                     service=rpc_service,
-                     name=rpc_name)
-        except Exception as e:
-            log.error("rpc-parsing-error", exception=repr(e))
-            raise ncerror.BadMsg(rpc_node)
-
-        class_handler = self.get_handler(namespace, rpc_service, rpc_name)
-        if class_handler is None:
-            # TODO: for now just assume anything in voltha namespace will be
-            #  handled by the same api
-            class_handler = self.get_handler(namespace, 'any', 'any')
-
-        voltha_method_ref = ''.join([rpc_service, '-', rpc_name])
+        log.info("rpc-request", rpc=rpc_name)
+        class_handler = self.rpc_class_handlers.get(rpc_name, None)
         if class_handler is not None:
-            return class_handler(rpc_node, rpc_method, voltha_method_ref,
-                                 grpc_channel, session)
+            return class_handler(rpc_node, rpc_method, None, grpc_channel,
+                                 session)
 
         log.error("rpc-not-implemented", rpc=rpc_name)