extract_config

        High-level api: Extract config from a rpc-reply of get-config or get
        message.

        Parameters
        ----------

        reply : `RPCReply`
            An instance of RPCReply in ncclient package. It has to be a
            successful reply in order to extract config, since there is no
            config data in an errored reply.

        Returns
        -------

        Config
            An instance of Config, which represents a config state of the
            device.


        Code Example::

            >>> reply = device.nc.get_config(models='openconfig-interfaces')
            >>> assert(reply.ok)
            >>> config1 = device.nc.extract_config(reply)
            >>>
            >>> reply = device.nc.get(models='openconfig-interfaces')
            >>> assert(reply.ok)
            >>> config2 = device.nc.extract_config(reply)
            >>>
            >>> config1 == config2
            True
            >>>

def extract_config(self, reply, type='netconf'):
        '''extract_config

        High-level api: Extract config from a rpc-reply of get-config or get
        message.

        Parameters
        ----------

        reply : `RPCReply`
            An instance of RPCReply in ncclient package. It has to be a
            successful reply in order to extract config, since there is no
            config data in an errored reply.

        Returns
        -------

        Config
            An instance of Config, which represents a config state of the
            device.


        Code Example::

            >>> reply = device.nc.get_config(models='openconfig-interfaces')
            >>> assert(reply.ok)
            >>> config1 = device.nc.extract_config(reply)
            >>>
            >>> reply = device.nc.get(models='openconfig-interfaces')
            >>> assert(reply.ok)
            >>> config2 = device.nc.extract_config(reply)
            >>>
            >>> config1 == config2
            True
            >>>
        '''

        def remove_read_only(parent):
            for child in parent.getchildren():
                schema_node = self.get_schema_node(child)
                if schema_node.get('access') == 'read-only':
                    parent.remove(child)
                elif len(child) > 0:
                    remove_read_only(child)

        config = Config(self, reply)
        remove_read_only(config.ele)
        return config