Commit f6afa0c7 authored by Shayan Hajipour's avatar Shayan Hajipour
Browse files

service creation and deletion with webui added to jinja mode

parent 8f65918f
Loading
Loading
Loading
Loading
+1 −4
Original line number Diff line number Diff line
@@ -227,11 +227,8 @@ def edit_config(
                chk_length(str_resource_name, resource, min_length=2, max_length=2)
                resource_key,resource_value = resource
                chk_string(str_resource_name + '.key', resource_key, allow_empty=False)

                str_config_messages = compose_config(                                                                          # get template for configuration
                    resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor, message_renderer='pyangbind')
                # str_config_messages = compose_config(                                                                          # get template for configuration
                #     resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor, message_renderer=netconf_handler.message_renderer)
                    resource_key, resource_value, delete=delete, vendor=netconf_handler.vendor, message_renderer=netconf_handler.message_renderer)
                for str_config_message in str_config_messages:                                                                 # configuration of the received templates 
                    if str_config_message is None: raise UnsupportedResourceKeyException(resource_key)
                    logger.debug('[{:s}] str_config_message[{:d}] = {:s}'.format(
+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ def compose_config( # template generation
            templates.append(JINJA_ENV.get_template('acl/acl-set/acl-entry/edit_config.xml'))
            templates.append(JINJA_ENV.get_template('acl/interfaces/ingress/edit_config.xml'))
        data : Dict[str, Any] = json.loads(resource_value)
        operation = 'delete' if delete else 'merge'
        operation = 'delete' if delete else ''

        return [
            '<config>{:s}</config>'.format(
+0 −13
Original line number Diff line number Diff line
@@ -30,19 +30,6 @@
                    </match>
                </vlan>
                {% endif %}
                {% if address_ip is defined %}
                <oc-ip:ipv4>
                    <oc-ip:addresses>
                        <oc-ip:address>
                            <oc-ip:ip>{{address_ip}}</oc-ip:ip>
                            <oc-ip:config>
                                <oc-ip:ip>{{address_ip}}</oc-ip:ip>
                                <oc-ip:prefix-length>{{address_prefix}}</oc-ip:prefix-length>
                            </oc-ip:config>
                        </oc-ip:address>
                    </oc-ip:addresses>
                </oc-ip:ipv4>
                {% endif %}
            </subinterface>
        </subinterfaces>
        {% endif %}
+34 −0
Original line number Diff line number Diff line
<network-instances xmlns="http://openconfig.net/yang/network-instance">
    <network-instance>
        <name>{{name}}</name>
        <config>
            <name>{{name}}</name>
            <type xmlns:oc-ni-types="http://openconfig.net/yang/network-instance-types">oc-ni-types:L3VRF</type>
        </config>
        <interfaces>
            <interface{% if operation is defined %} xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{{operation}}"{% endif %}>
                <id>{{id}}</id>
@@ -13,3 +17,33 @@
        </interfaces>
    </network-instance>
</network-instances>
<interfaces xmlns="http://openconfig.net/yang/interfaces">
    <interface>
        <name>{{interface}}</name>
        <config>
            <name>{{interface}}</name>
        </config>
        <subinterfaces>
            <subinterface>
                <index>{{subinterface}}</index>
                <config>
                    <index>{{subinterface}}</index>
                </config>
                <ipv4 xmlns="http://openconfig.net/yang/interfaces/ip">
                    <config>
                        <mtu>1500</mtu>
                    </config>
                    <addresses>
                        <address>
                            <ip>{{address_ip}}</ip>
                            <config>
                                <ip>{{address_ip}}</ip>
                                <prefix-length>{{address_prefix}}</prefix-length>
                            </config>
                        </address>
                    </addresses>
                </ipv4>
            </subinterface>
        </subinterfaces>
    </interface>
</interfaces>
+22 −0
Original line number Diff line number Diff line
@@ -9,15 +9,37 @@
                <config>
                    <identifier xmlns:oc-pol-types="http://openconfig.net/yang/policy-types">oc-pol-types:{{identifier}}</identifier>
                    <name>{{protocol_name}}</name>
                    <enabled>true</enabled>
                </config>
                {% if identifier=='BGP' %}
                <bgp>
                    <name>{{as}}</name>
                    <global>
                        <config>
                            <as>{{as}}</as>
                            <router-id>{{router_id}}</router-id>
                        </config>
                    </global>
                    {% if neighbors is defined %}
                    <neighbors>
                        {% for neighbor in neighbors %}
                        <neighbor>
                            <neighbor-address>{{neighbor['ip_address']}}</neighbor-address>
                            <afi-safis>
                                <afi-safi xmlns:oc-bgp-types="http://openconfig.net/yang/bgp-types">
                                    <afi-safi-name>oc-bgp-types:IPV4_UNICAST</afi-safi-name>
                                    <enabled>true</enabled>
                                </afi-safi>
                            </afi-safis>
                            <config>
                                <neighbor-address>{{neighbor['ip_address']}}</neighbor-address>
                                <enabled>true</enabled>
                                <peer-as>{{as}}</peer-as>
                            </config>
                        </neighbor>
                        {% endfor %}
                    </neighbors>
                    {% endif %}
                </bgp>
                {% endif %}
                {% endif %}
Loading