Skip to content

Codegen for netconf merge #70

@jgroom33

Description

@jgroom33

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions