#######################################################################################
#######################################################################################
#NIDD_VER: TNL17A_1708_008_00
# TNL: TNL17A_1708_008
# delta from TNL17A_1708_007 to TNL17A_1708_008
# 13.12.2017 Sebastian Kulikowski
#######################################################################################

#######################################################################################
#######################################################################################
# Check if ruleset should be executed

for_objects "MRBTS/TNLSVC"
    begin
        if not ( get_version $current_dist_name ) == "TNL17A_1708_007"
            abort_file
    end

#######################################################################################
# update

# Workaround. Relationships not defined in NIDD due to freeze but implemented in PDL rules
# TNLSVC/TNL/IPNO/IPIF/IPADDRESSV4 localIpAddr
# 3.) If the IPIF instance under which the IPADDRESSV4 object is located has the parameter interfaceDN defined, it is mandatory to define the localIpPrefixLength.
# TNLSVC/TNL/IPNO/IPIF/IPADDRESSV4 localIpPrefixLength
# If the IPIF instance under which the IPADDRESSV4 object is located has not the parameter interfaceDN defined, the parameter localIpPrefixLength must not be defined.
# TNLSVC/TNL/IPNO/IPIF/IPADDRESSV6 localIpAddr
# 3.) If the IPIF instance under which the IPADDRESSV6 object is located has the parameter interfaceDN defined, it is mandatory to define the localIpPrefixLength.
# TNLSVC/TNL/IPNO/IPIF/IPADDRESSV6 localIpPrefixLength
# If the IPIF instance under which the IPADDRESSV6 object is located has not the parameter interfaceDN defined, the parameter localIpPrefixLength must not be defined.

for_objects "MRBTS/TNLSVC/TNL/IPNO/IPIF"
    begin
        define "ipifDn" $current_dist_name

        for_objects ipifDn JOIN "/IPADDRESSV4"
            begin
                define "ipaddressv4Dn" $current_dist_name

                if ( param_exist ipifDn "interfaceDN" )
                    begin
                        # TODO - confirm default value since it was removed
                        if not ( param_exist ipaddressv4Dn "localIpPrefixLength" ) add_param ipaddressv4Dn "localIpPrefixLength" "0"
                    end
                else
                    begin
                        if ( param_exist ipaddressv4Dn "localIpPrefixLength" ) del_param ipaddressv4Dn "localIpPrefixLength"
                    end
            end

        for_objects ipifDn JOIN "/IPADDRESSV6"
            begin
                define "ipaddressv6Dn" $current_dist_name

                if ( param_exist ipifDn "interfaceDN" )
                    begin
                        # TODO - confirm default value since it was removed
                        if not ( param_exist ipaddressv6Dn "localIpPrefixLength" ) add_param ipaddressv6Dn "localIpPrefixLength" "0"
                    end
                else
                    begin
                        if ( param_exist ipaddressv6Dn "localIpPrefixLength" ) del_param ipaddressv6Dn "localIpPrefixLength"
                    end
            end
    end

define "smodIsFsmfa" "false"

for_objects "MRBTS/EQM/APEQM/CABINET/SMOD"
    begin
        define "smodDn" $current_dist_name
        if ( param_exist smodDn "prodCodePlanned" )
            begin
                define "prodCodePlanned" get_param smodDn "prodCodePlanned"
                if ( prodCodePlanned ) == "473585A"
                    begin
                        define "smodIsFsmfa" "true"
                    end
            end
    end

if ( smodIsFsmfa ) == "true"
    begin
        for_objects "TNLSVC/TNL/IPAPP/IPSECC"
            del_object $current_dist_name

        for_objects "TNLSVC/TNL/IPAPP/IPSECC/EMBYPASSREQ"
            del_object $current_dist_name

        for_objects "TNLSVC/TNL/IPAPP/IPSECC/EMBYPASSREQ/EMBYPASSRES"
            del_object $current_dist_name

        for_objects "TNLSVC/TNL/IPAPP/IPSECC/IKEP"
            del_object $current_dist_name

        for_objects "TNLSVC/TNL/IPAPP/IPSECC/IKEPROTGRP"
            del_object $current_dist_name

        for_objects "TNLSVC/TNL/IPAPP/IPSECC/IKEPROTGRP/IKEPSWITCHREQ"
            del_object $current_dist_name

        for_objects "TNLSVC/TNL/IPAPP/IPSECC/IKEPROTGRP/IKEPSWITCHREQ/IKEPSWITCHRES"
            del_object $current_dist_name

        for_objects "TNLSVC/TNL/IPAPP/IPSECC/IPSECP"
            del_object $current_dist_name

        for_objects "TNLSVC/TNL/IPAPP/IPSECC/SECPOL"
            del_object $current_dist_name
    end

#######################################################################################
### !! workaround for PR293325 removal - sir range was corrected and is now as in SBTS16.10: from 100 to 10000000 step 100

for_objects "MRBTS/TNLSVC/TNL/IPNO/QOS/FSTSCH"
    begin
        if ( param_exist $current_dist_name "userLabel" )
            begin
                define "userLabel" get_param $current_dist_name "userLabel"
                define "sirString" replace userLabel "(.*(sir=).*)" "$2" flags "g"
                define "sirValue" replace userLabel "\D+" "" flags "g"

                if ( sirString ) == "sir="
                    begin
                        add_param $current_dist_name "sir" sirValue
                        del_param $current_dist_name "userLabel"
                    end
            end
    end

for_objects "TNLSVC/TNL/IPNO/IPRT"
    begin
        define "iprtDn" $current_dist_name

        for_list iprtDn "staticRoutes"
            begin
                if not ( param_exist iprtDn "staticRoutes." JOIN $current_index JOIN ".gateway" )
                    begin
                        del_object iprtDn
                    end
            end
    end

for_objects "MRBTS/TNLSVC/TNL/IPNO/IPIF"
    begin
        # might be defined as empty: <p name="interfacePtr"/> in SBTS16.10 SCF and migrated also as empty
        del_param $current_dist_name "interfacePtr"
    end

for_objects "MRBTS/TNLSVC/TNL/ETHSVC/L2SWI/BRGPRT"
    begin
        if ( param_exist $current_dist_name "ethlkId" )
            del_param $current_dist_name "ethlkId"
    end

#######################################################################################
# update version
	
for_objects "VLANID2QMAP"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end

for_objects "TWAMPREFLECT"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end

for_objects "TNL"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end

for_objects "TNLSVC"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
	
for_objects "ETHSVC"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end

for_objects "ETHIF"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "VLANIF"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "ETHLK"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "L2SWI"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "BRGPRT"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "IBRGPRT"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "DSCPTOQMAP"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "PCP2QMAP"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "FRLI"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "IPAPP"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "BFD"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "BFDGRP"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "IPSECC"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
	
for_objects "IKEP"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "IKEPROTGRP"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "IKEPSWITCHREQ"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "IPSECP"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "SECPOL"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "TWAMP"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "IPNO"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "IPIF"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "IPADDRESSV4"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "IPADDRESSV6"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "IPRT"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "IPRTV6"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "MCAPP"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "QOS"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "DSCP2PCPMAP"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "DSCP2QMAP"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "FLOWCL"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "FSTSCH"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "RTPOL"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "P3LP"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "P3ML"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "DSCP2MC2MAP"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "DSCP2MC4MAP"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "P3SL"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "PMTNL"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "PPTT"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
		
for_objects "TRIGGER"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end

for_objects "FPMUX"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end

for_objects "MRBTS/TNLSVC/TNL/PMTNL"
	begin
		set_version $current_dist_name "TNL17A_1708_008"
	end
