module openflowplugin-extension-general {
    yang-version 1;

    namespace "urn:opendaylight:openflowplugin:extension:general";
    prefix "openflowplugin-extension-general";

    import yang-ext {prefix ext; revision-date "2013-07-09";}
    import flow-node-inventory {prefix fni; revision-date 2013-08-19; }
    import opendaylight-inventory {prefix inv;revision-date "2013-08-19";}
    import sal-flow {prefix sal-flow;revision-date "2013-08-19";}
    import sal-group {prefix sal-group;revision-date "2013-09-18";}
    import packet-processing {prefix sal-packet;revision-date "2013-07-09";}
    import opendaylight-flow-statistics {prefix odl-flow-stats;revision-date "2013-08-19";}
    import opendaylight-group-statistics {prefix odl-group-stats;revision-date "2013-11-11";}
    import opendaylight-direct-statistics {prefix odl-direct-stats;revision-date "2016-05-11";}


    description
        "Everything for a vendor who want to implement openflow extensions.";

    revision "2014-07-14" {
        description "Initial revision";
    }

    identity extension-key {
        description "Base identity for all extension keys.";
    }

    grouping general-extension-grouping {
        leaf extension-key {
            type identityref {
                base extension-key;
            }
        }
        container extension {
            description "A vendor has to augment this container.";
        }
    }

    grouping general-extension-list-grouping {
        list extension-list {
            key extension-key;
            uses general-extension-grouping;
        }
    }




    // MATCH augmentations
    // RPCS
    augment "/sal-flow:add-flow/sal-flow:input/sal-flow:match" {
        ext:augment-identifier "general-aug-match-rpc-add-flow";
        uses general-extension-list-grouping;
    }
    augment "/sal-flow:remove-flow/sal-flow:input/sal-flow:match" {
        ext:augment-identifier "general-aug-match-rpc-remove-flow";
        uses general-extension-list-grouping;
    }
    augment "/sal-flow:update-flow/sal-flow:input/sal-flow:original-flow/sal-flow:match" {
        ext:augment-identifier "general-aug-match-rpc-update-flow-original";
        uses general-extension-list-grouping;
    }
    augment "/sal-flow:update-flow/sal-flow:input/sal-flow:updated-flow/sal-flow:match" {
        ext:augment-identifier "general-aug-match-rpc-update-flow-updated";
        uses general-extension-list-grouping;
    }

    // DATA
    augment "/inv:nodes/inv:node/fni:table/fni:flow/fni:match" {
        ext:augment-identifier "general-aug-match-nodes-node-table-flow";
        uses general-extension-list-grouping;
    }
    augment "/sal-packet:packet-in-message/sal-packet:match" {
        ext:augment-identifier "general-aug-match-packet-in-message";
        uses general-extension-list-grouping;
    }

    // NOTIFICATIONS
    augment "/sal-flow:switch-flow-removed/sal-flow:match" {
        ext:augment-identifier "general-aug-match-notif-switch-flow-removed";
        uses general-extension-list-grouping;
    }
    augment "/sal-packet:packet-received/sal-packet:match" {
        ext:augment-identifier "general-aug-match-notif-packet-in";
        uses general-extension-list-grouping;
    }
    augment "/odl-flow-stats:flows-statistics-update/odl-flow-stats:flow-and-statistics-map-list/odl-flow-stats:match" {
        ext:augment-identifier "general-aug-match-notif-update-flow-stats";
        uses general-extension-list-grouping;
    }

    augment "/odl-direct-stats:get-flow-statistics/odl-direct-stats:output/odl-direct-stats:flow-and-statistics-map-list/odl-direct-stats:match" {
        ext:augment-identifier "general-aug-match-rpc-output-flow-stats";
        uses general-extension-list-grouping;
    }

    // VENDOR EXAMPLE -- testing purposes -> remove later!
    augment "/inv:nodes/inv:node/fni:table/fni:flow/fni:match/extension-list/extension" {
        ext:augment-identifier "vendor-xxx1";
        uses vendor-xxx-grouping;
    }
    augment "/sal-flow:add-flow/sal-flow:input/sal-flow:match/extension-list/extension" {
        ext:augment-identifier "vendor-xxx2";
        uses vendor-xxx-grouping;
    }
    grouping vendor-xxx-grouping {
        leaf dos-ekis {
            type string;
        }
    }
    // -----^^^^-----


    // SetField augmentations
    // RPCS
    augment "/sal-flow:add-flow/sal-flow:input/sal-flow:instructions/sal-flow:instruction/sal-flow:instruction/sal-flow:write-actions-case/sal-flow:write-actions/sal-flow:action/sal-flow:action/sal-flow:set-field-case/sal-flow:set-field" {
        ext:augment-identifier "general-aug-match-rpc-add-flow-write-actions-set-field";
        uses general-extension-list-grouping;
    }

    augment "/sal-flow:add-flow/sal-flow:input/sal-flow:instructions/sal-flow:instruction/sal-flow:instruction/sal-flow:apply-actions-case/sal-flow:apply-actions/sal-flow:action/sal-flow:action/sal-flow:set-field-case/sal-flow:set-field" {
        ext:augment-identifier "general-aug-match-rpc-add-flow-apply-actions-set-field";
        uses general-extension-list-grouping;
    }

    augment "/sal-flow:remove-flow/sal-flow:input/sal-flow:instructions/sal-flow:instruction/sal-flow:instruction/sal-flow:write-actions-case/sal-flow:write-actions/sal-flow:action/sal-flow:action/sal-flow:set-field-case/sal-flow:set-field" {
        ext:augment-identifier "general-aug-match-rpc-remove-flow-write-actions-set-field";
        uses general-extension-list-grouping;
    }

    augment "/sal-flow:remove-flow/sal-flow:input/sal-flow:instructions/sal-flow:instruction/sal-flow:instruction/sal-flow:apply-actions-case/sal-flow:apply-actions/sal-flow:action/sal-flow:action/sal-flow:set-field-case/sal-flow:set-field" {
        ext:augment-identifier "general-aug-match-rpc-remove-flow-apply-actions-set-field";
        uses general-extension-list-grouping;
    }

    augment "/sal-flow:update-flow/sal-flow:input/sal-flow:original-flow/sal-flow:instructions/sal-flow:instruction/sal-flow:instruction/sal-flow:write-actions-case/sal-flow:write-actions/sal-flow:action/sal-flow:action/sal-flow:set-field-case/sal-flow:set-field" {
        ext:augment-identifier "general-aug-match-rpc-update-flow-original-write-actions-set-field";
        uses general-extension-list-grouping;
    }

    augment "/sal-flow:update-flow/sal-flow:input/sal-flow:original-flow/sal-flow:instructions/sal-flow:instruction/sal-flow:instruction/sal-flow:apply-actions-case/sal-flow:apply-actions/sal-flow:action/sal-flow:action/sal-flow:set-field-case/sal-flow:set-field" {
        ext:augment-identifier "general-aug-match-rpc-update-flow-original-apply-actions-set-field";
        uses general-extension-list-grouping;
    }

    augment "/sal-flow:update-flow/sal-flow:input/sal-flow:updated-flow/sal-flow:instructions/sal-flow:instruction/sal-flow:instruction/sal-flow:write-actions-case/sal-flow:write-actions/sal-flow:action/sal-flow:action/sal-flow:set-field-case/sal-flow:set-field" {
        ext:augment-identifier "general-aug-match-rpc-update-flow-updated-write-actions-set-field";
        uses general-extension-list-grouping;
    }

    augment "/sal-flow:update-flow/sal-flow:input/sal-flow:updated-flow/sal-flow:instructions/sal-flow:instruction/sal-flow:instruction/sal-flow:apply-actions-case/sal-flow:apply-actions/sal-flow:action/sal-flow:action/sal-flow:set-field-case/sal-flow:set-field" {
        ext:augment-identifier "general-aug-match-rpc-update-flow-updated-apply-actions-set-field";
        uses general-extension-list-grouping;
    }

    augment "/sal-group:add-group/sal-group:input/sal-group:buckets/sal-group:bucket/sal-group:action/sal-group:action/sal-group:set-field-case/sal-group:set-field" {
        ext:augment-identifier "general-aug-match-rpc-add-group-set-field";
        uses general-extension-list-grouping;
    }

    augment "/sal-group:remove-group/sal-group:input/sal-group:buckets/sal-group:bucket/sal-group:action/sal-group:action/sal-group:set-field-case/sal-group:set-field" {
        ext:augment-identifier "general-aug-match-rpc-remove-group-set-field";
        uses general-extension-list-grouping;
    }

    augment "/sal-group:update-group/sal-group:input/sal-group:original-group/sal-group:buckets/sal-group:bucket/sal-group:action/sal-group:action/sal-group:set-field-case/sal-group:set-field" {
        ext:augment-identifier "general-aug-match-rpc-update-group-original-set-field";
        uses general-extension-list-grouping;
    }

    augment "/sal-group:update-group/sal-group:input/sal-group:updated-group/sal-group:buckets/sal-group:bucket/sal-group:action/sal-group:action/sal-group:set-field-case/sal-group:set-field" {
        ext:augment-identifier "general-aug-match-rpc-update-group-updated-set-field";
        uses general-extension-list-grouping;
    }

    augment "/sal-packet:transmit-packet/sal-packet:input/sal-packet:action/sal-packet:action/sal-packet:set-field-case/sal-packet:set-field" {
        ext:augment-identifier "general-aug-match-rpc-transmit-packet-set-field";
        uses general-extension-list-grouping;
    }

    // DATA
    augment "/inv:nodes/inv:node/fni:table/fni:flow/fni:instructions/fni:instruction/fni:instruction/fni:write-actions-case/fni:write-actions/fni:action/fni:action/fni:set-field-case/fni:set-field" {
        ext:augment-identifier "general-aug-match-nodes-node-table-flow-write-actions-set-field";
        uses general-extension-list-grouping;
    }

    augment "/inv:nodes/inv:node/fni:table/fni:flow/fni:instructions/fni:instruction/fni:instruction/fni:apply-actions-case/fni:apply-actions/fni:action/fni:action/fni:set-field-case/fni:set-field" {
        ext:augment-identifier "general-aug-match-nodes-node-table-flow-apply-actions-set-field";
        uses general-extension-list-grouping;
    }

    augment "/inv:nodes/inv:node/fni:group/fni:buckets/fni:bucket/fni:action/fni:action/fni:set-field-case/fni:set-field" {
        ext:augment-identifier "general-aug-match-nodes-node-group-buckets-bucket-actions-set-field";
        uses general-extension-list-grouping;
    }

    // NOTIFICATIONS
    augment "/odl-flow-stats:flows-statistics-update/odl-flow-stats:flow-and-statistics-map-list/odl-flow-stats:instructions/odl-flow-stats:instruction/odl-flow-stats:instruction/odl-flow-stats:write-actions-case/odl-flow-stats:write-actions/odl-flow-stats:action/odl-flow-stats:action/odl-flow-stats:set-field-case/odl-flow-stats:set-field" {
        ext:augment-identifier "general-aug-match-notif-flows-statistics-update-write-actions-set-field";
        uses general-extension-list-grouping;
    }

    augment "/odl-flow-stats:flows-statistics-update/odl-flow-stats:flow-and-statistics-map-list/odl-flow-stats:instructions/odl-flow-stats:instruction/odl-flow-stats:instruction/odl-flow-stats:apply-actions-case/odl-flow-stats:apply-actions/odl-flow-stats:action/odl-flow-stats:action/odl-flow-stats:set-field-case/odl-flow-stats:set-field" {
        ext:augment-identifier "general-aug-match-notif-flows-statistics-update-apply-actions-set-field";
        uses general-extension-list-grouping;
    }

    augment "/odl-group-stats:group-desc-stats-updated/odl-group-stats:group-desc-stats/odl-group-stats:buckets/odl-group-stats:bucket/odl-group-stats:action/odl-group-stats:action/odl-group-stats:set-field-case/odl-group-stats:set-field" {
        ext:augment-identifier "general-aug-match-notif-group-desc-stats-updated-set-field";
        uses general-extension-list-grouping;
    }
}