Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codegen for netconf merge #70

Open
jgroom33 opened this issue Apr 28, 2022 · 0 comments
Open

Codegen for netconf merge #70

jgroom33 opened this issue Apr 28, 2022 · 0 comments

Comments

@jgroom33
Copy link

It should be possible to generate the code for def _state_merged method

Two additional pieces of information are required in order to accomplish the codegen

  1. singular entity name
  2. key name

Proposal:

Add RESOURCE_KEY_NAMEand RESOURCE_SINGULAR to template:

---

NETWORK_OS: myos
RESOURCE: interfaces
RESOURCE_SINGULAR: interface
RESOURCE_KEY_NAME: name
COPYRIGHT: Copyright 2019 Red Hat
LICENSE: gpl-3.0.txt

This would allow the template to be:

    def _state_merged(self, want, have):
        """ The command generator when state is merged

        :rtype: A list
        :returns: the xml necessary to migrate the current configuration
                  to the desired configuration
        """
        {{ resource }}_xml = []
        for child in want:
            {{ resource }} = build_root_xml_node("{{ resource }}")
            {{ resource_singular }}= build_child_xml_node({{ resource }}, "{{ resource_singular }}")
            build_child_xml_node(
                {{ resource_singular }}, "{{ resource_key_name }}", child["{{ resource_key_name }}"]
            )

        return {{ resource }}_xml

Additional codegen could be implemented based on the schema of the resource.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant