#######################################################################################
#######################################################################################
#NIDD_VER: MNL17A_1708_010_00
# MNL: MNL17A_1708_010
# Migration from MNL17A_1708_009 to MNL17A_1708_010
# 13.12.2017 Sebastian Kulikowski
#######################################################################################
#######################################################################################

#######################################################################################
# general version check

for_objects "MRBTS/MNL"
    begin
        if not ( get_version $current_dist_name ) == "MNL17A_1708_009"
            abort_file
    end

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

for_objects "MRBTS/MNL/MNLENT"
	begin
        define "mnlentDn" $current_dist_name
        define "pmcadmDn" mnlentDn JOIN "/PMCADM-1"

        if ( objects_count pmcadmDn ) == 0
            begin
                add_object pmcadmDn
                set_operation pmcadmDn "create"

                add_param pmcadmDn "reportingIntervalPm" "60min"
                add_param pmcadmDn "sdlMaxUploadFileNumber" 1

                #sdlPrimaryDestIp is mandatory required but there is no default value defined - how should we define it? below value is just to avoid PDL validation error and does not make sense
                add_param pmcadmDn "sdlPrimaryDestIp" "10.105.24.50"
            end
    end

for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/GNSSI"
    begin
        define "gnssiDn" $current_dist_name
        define "clockDn" "MRBTS-" JOIN $current_MRBTS JOIN "/MNL-" JOIN $current_MNL JOIN "/MNLENT-" JOIN $current_MNLENT JOIN "/SYNC-" JOIN $current_SYNC JOIN "/CLOCK-" JOIN $current_CLOCK
        if ( param_exist clockDn "sModDN" )
            begin
                define "sModDN" get_param clockDn "sModDN"
                if ( param_exist sModDN "prodCodePlanned" )
                    begin
                        define "prodCodePlanned" get_param sModDN "prodCodePlanned"

                        # means that SMOD-prodCodePlanned is not FSIH
                        if ( prodCodePlanned ) != "472567A"
                            begin
                                del_object gnssiDn
                            end
                    end
            end
    end

for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/TOP"
    begin
        define "topDn" $current_dist_name

        if not ( param_exist topDn "topDomainNumber" )
            begin
                define "syncDn" "MRBTS-" JOIN $current_MRBTS JOIN "/MNL-" JOIN $current_MNL JOIN "/MNLENT-" JOIN $current_MNLENT JOIN "/SYNC-" JOIN $current_SYNC

                if ( param_exist syncDn "btsSyncMode" )
                    begin
                        define "btsSyncMode" get_param syncDn "btsSyncMode"

                        if ( btsSyncMode ) == "PhaseSync"
                            begin
                                define "toppDn" topDn JOIN "/TOPP-1"

                                if ( objects_count toppDn ) == 1
                                    begin
                                        if ( param_exist toppDn "topComMode" )
                                            begin
                                                define "topComMode" get_param toppDn "topComMode"

                                                if ( topComMode ) == "IP Unicast"
                                                    begin
                                                        add_param topDn "topDomainNumber" 0
                                                    end

                                                else if ( topComMode ) == "Ethernet Multicast"
                                                    begin
                                                        add_param topDn "topDomainNumber" 24
                                                    end
                                            end
                                    end
                            end

                        else if ( btsSyncMode ) == "FreqSync"
                            begin
                                define "topfDn" topDn JOIN "/TOPF-1"

                                if ( objects_count topfDn ) == 1
                                    begin
                                        if ( param_exist topfDn "ieeeTelecomProfile" )
                                            begin
                                                define "ieeeTelecomProfile" get_param topfDn "ieeeTelecomProfile"

                                                if ( ieeeTelecomProfile ) == "IEEE1588"
                                                    add_param topDn "topDomainNumber" 0
                                                else
                                                    add_param topDn "topDomainNumber" 4
                                            end
                                    end
                            end
                    end
            end
    end

for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/TOP/TOPP"
    begin
        define "toppDn" $current_dist_name

        if ( param_exist toppDn "topComMode" ) && ( param_exist toppDn "topEthMulticastAddress" )
            begin
                define "topComMode" get_param toppDn "topComMode"
                define "topEthMulticastAddress" get_param toppDn "topEthMulticastAddress"

                if ( topComMode ) == "IP Unicast"
                    begin
                        # IP Unicast excludes configuring topEthMulticastAddress
                        # DEM does not check it and BM handles such configuration incorrectly

                        del_param toppDn "topEthMulticastAddress"
                    end
            end
    end

# remove CELLMAPPING if it was not possible to create it properly - for instance when RMOD was not 'Online' in SBTS16

for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELC/CHANNELGROUP/CHANNEL"
    begin
        define "channelDn" $current_dist_name
        define "lcelcDn" "MRBTS-" JOIN $current_MRBTS JOIN "/MNL-" JOIN $current_MNL JOIN "/MNLENT-" JOIN $current_MNLENT JOIN "/CELLMAPPING-" JOIN $current_CELLMAPPING JOIN "/LCELC-" JOIN $current_LCELC
        define "channelGroupDn" lcelcDn JOIN "/CHANNELGROUP"

        if not ( param_exist channelDn "antlDN" )
            begin
                del_object channelDn

                for_objects channelGroupDn
                    del_object $current_dist_name

                if not ( objects_count lcelcDn ) == 0
                    del_object lcelcDn
            end
    end

for_objects "MNL/CMD/ADDEECERTREQ/ADDEECERTRES"
    begin
        del_object $current_dist_name
    end

for_objects "MRBTS/MNL/CMD/ADDTACERTREQ/ADDTACERTRES"
    begin
        del_object $current_dist_name
    end

for_objects "MRBTS/MNL/CMD/ADDEECERTREQ"
    begin
        del_object $current_dist_name
    end

for_objects "MRBTS/MNL/CMD/ADDTACERTREQ"
    begin
        del_object $current_dist_name
    end

for_objects "MRBTS/MNL/CMD/CMPINITREQ/CMPINITRES"
    begin
        del_object $current_dist_name
    end

for_objects "MRBTS/MNL/CMD/CMPINITREQ"
    begin
        del_object $current_dist_name
    end

for_objects "MRBTS/MNL/CMD/CMPKEYUPDATEREQ/CMPKEYUPDATERES"
    begin
        del_object $current_dist_name
    end

for_objects "MRBTS/MNL/CMD/CMPKEYUPDATEREQ"
    begin
        del_object $current_dist_name
    end

for_objects "MRBTS/MNL/CMD/CRLUPDATEREQ/CRLUPDATERES"
    begin
        del_object $current_dist_name
    end

for_objects "MRBTS/MNL/CMD/CRLUPDATEREQ"
    begin
        del_object $current_dist_name
    end

for_objects "MRBTS/MNL/CMD/DELTACERTREQ/DELTACERTRES"
    begin
        del_object $current_dist_name
    end

for_objects "MRBTS/MNL/CMD/DELTACERTREQ"
    begin
        del_object $current_dist_name
    end

for_objects "MRBTS/MNL/CMD/RESTOREVENDORCERTREQ/RESTOREVENDORCERTRES"
    begin
        del_object $current_dist_name
    end

for_objects "MRBTS/MNL/CMD/RESTOREVENDORCERTREQ"
    begin
        del_object $current_dist_name
    end

for_objects  "MRBTS/MNL/CMD/SETCMPSECRETREQ/CMPSECRET"
    begin
        del_object $current_dist_name
    end

for_objects  "MRBTS/MNL/CMD/SETCMPSECRETREQ/SETCMPSECRETRES"
    begin
        del_object $current_dist_name
    end

for_objects  "MRBTS/MNL/CMD/SETCMPSECRETREQ"
    begin
        del_object $current_dist_name
    end

#######################################################################################
#######################################################################################
# Set proper versions and adaptations to MNL sub-tree

for_objects "MRBTS/MNL"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/AMGR"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/AMGR/LUAC"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/AMGR/LUAC/LUAC_R"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/CERTH"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/CERTH/CMP"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/CERTH/CRLH"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/CERTH/CRLH/CRLDPCONFIG"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/MNLENT"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/MNLENT/BBADM"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/MNLENT/CAPADM"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/MNLENT/CAPADM/CAPLIM"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/MNLENT/CERTHENT"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/MNLENT/CERTHENT/CACERT_R"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/MNLENT/CERTHENT/CMP_R"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/MNLENT/CERTHENT/CRLH_R"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/MNLENT/CERTHENT/CRLINFO_R"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/MNLENT/CERTHENT/NECERT_R"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/MNLENT/DNS"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/MNLENT/FEATCADM"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end

for_objects "MRBTS/MNL/MNLENT/FEATCADM/FEATGADM"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end

for_objects "MRBTS/MNL/MNLENT/FEATCADM/FEATLADM"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end

for_objects "MRBTS/MNL/MNLENT/MPLANENW"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/PMCADM"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/PMMNL"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/SECADM"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/SECADM/SECADM_R"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
	
for_objects "MRBTS/MNL/MNLENT/SYNC"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/CLOCK_FDD"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	

for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/GNSSE"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	

for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/NTP"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/PDH"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/SYNCE"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/TOP"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/TOP/TOPF"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	

for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/TOP/TOPP"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/SYNC/TIME"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	

for_objects "MRBTS/MNL/MNLENT/TAC"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end		
	
for_objects "MRBTS/MNL/MNLENT/TAC/LTAC"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/TRBLCADM"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/CELLMAPPING"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELC"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELC/CHANNELGROUP"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELC/CHANNELGROUP/CHANNEL"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELW"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELW/CHANNELGROUP"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELW/CHANNELGROUP/CHANNEL"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	

for_objects "MRBTS/MNL/MNLENT/FMCADM"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELL"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELL/CHANNELGROUP"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELL/CHANNELGROUP/CHANNEL"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	

for_objects "MRBTS/MNL/NOTES"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	

for_objects "MRBTS/MNL/NOTES/NOTE"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end	
	
for_objects "MRBTS/MNL/MNL_R"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end

for_objects "MRBTS/MNL/CMD"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end

for_objects "MRBTS/MNL/MNLENT/TRBLCADM/TRBLCADM_R"
	begin
		set_version $current_dist_name "MNL17A_1708_010"
		set_adaptation $current_dist_name "com.nokia.srbts.mnl"
	end
