load_model

        High-level api: Load schema information by compiling the model using
        pyang package.

        Parameters
        ----------

        model : `str`
            Model name.

        Returns
        -------

        Model
            An instance of Model.


        YAML Example::

            devices:
                asr22:
                    type: 'ASR'
                    tacacs:
                        login_prompt: "login:"
                        password_prompt: "Password:"
                        username: "admin"
                    passwords:
                        tacacs: admin
                        enable: admin
                        line: admin
                    connections:
                        a:
                            protocol: telnet
                            ip: "1.2.3.4"
                            port: 2004
                        vty:
                            protocol : telnet
                            ip : "2.3.4.5"
                        netconf:
                            class: yang.ncdiff.ModelDevice
                            ip : "2.3.4.5"
                            port: 830
                            username: admin
                            password: admin

        Code Example::

            >>> from pyats.topology import loader
            >>> testbed = loader.load('/users/yuekyang/projects/asr21.yaml')
            >>> device = testbed.devices['asr21']
            >>> device.connect(alias='nc', via='netconf')
            >>> device.nc.scan_models()
            >>>
            >>> m = device.nc.load_model('openconfig-system')
            >>> print(m)
            ...
            >>>

def load_model(self, model):
        '''load_model

        High-level api: Load schema information by compiling the model using
        pyang package.

        Parameters
        ----------

        model : `str`
            Model name.

        Returns
        -------

        Model
            An instance of Model.


        YAML Example::

            devices:
                asr22:
                    type: 'ASR'
                    tacacs:
                        login_prompt: "login:"
                        password_prompt: "Password:"
                        username: "admin"
                    passwords:
                        tacacs: admin
                        enable: admin
                        line: admin
                    connections:
                        a:
                            protocol: telnet
                            ip: "1.2.3.4"
                            port: 2004
                        vty:
                            protocol : telnet
                            ip : "2.3.4.5"
                        netconf:
                            class: yang.ncdiff.ModelDevice
                            ip : "2.3.4.5"
                            port: 830
                            username: admin
                            password: admin

        Code Example::

            >>> from pyats.topology import loader
            >>> testbed = loader.load('/users/yuekyang/projects/asr21.yaml')
            >>> device = testbed.devices['asr21']
            >>> device.connect(alias='nc', via='netconf')
            >>> device.nc.scan_models()
            >>>
            >>> m = device.nc.load_model('openconfig-system')
            >>> print(m)
            ...
            >>>
        '''

        if os.path.isfile(model):
            file_name, file_ext = os.path.splitext(model)
            if file_ext.lower() == '.xml':
                logger.debug('Read model file {}'.format(model))
                with open(model, 'r') as f:
                    xml = f.read()
                parser = etree.XMLParser(remove_blank_text=True)
                tree = etree.XML(xml, parser)
            else:
                raise ValueError("'{}' is not a file with extension 'xml'" \
                                 .format(model))
        elif model in self.models_loadable:
            if self.compiler is None:
                raise ValueError('please first call scan_models() to build ' \
                                 'up supported namespaces of a device')
            else:
                m = self.compiler.compile(model)
        else:
            raise ValueError("argument 'model' {} needs to be either a model " \
                             "name or a compiled model xml file".format(model))
        if m.name in self.models:
            self.nodes = {k: v for k, v in self.nodes.items()
                          if self.roots[k.split(' ')[0]] != m.name}
            logger.info('Model {} is reloaded'.format(m.name))
        else:
            logger.info('Model {} is loaded'.format(m.name))
        self.models[m.name] = m
        return m