ansible-collections / community.yang

Ansible Community Collection to support Yang in network devices.
GNU General Public License v3.0
10 stars 14 forks source link

Getting all with fetch fails on dependant models #23

Open cidrblock opened 4 years ago

cidrblock commented 4 years ago

I think this may be an issue with the quotes when regexing the import statements.

def get_schema_and_dependants(self, schema_id, result):
        try:
            found, data_model = self.get_one_schema(schema_id, result)
        except ValueError as exc:
            raise ValueError(exc)

        if found:
            result["fetched"][schema_id] = data_model
            importre = re.compile(r"import (.+) {")
            all_found = importre.findall(data_model)
            all_found = [re.sub("['\"]", "", imp) for imp in all_found]
            return all_found

^^^ fixed the issue

example of issue

 - community.yang.fetch:
      name: ietf-yang-types

  - community.yang.fetch:
      name: openconfig-network-instance
Fetched 'arista-mpls-augments' yang model
"openconfig-network-instance"
fatal: [eos101]: FAILED! => {
    "changed": false,
    "msg": "Fail to fetch '\"openconfig-network-instance\"' yang model"
}
rohitthakur2590 commented 4 years ago

@cidrblock Looks like this works fine for supported yang models after the latest changes.