#######################################################################################
#######################################################################################
#NIDD_VER: SBTS18_NIDD_1711_009_00
# MNL: MNL18_1711_008
# Migration from MNL18_1711_007 to MNL18_1711_008
#######################################################################################

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

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

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

for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/GNSSE"
	begin
		if ( param_exist $current_dist_name "locationMode" )
			begin
			define "locMode" get_param $current_dist_name "locationMode"
			if ( locMode == "automatic" ) 
				begin
					del_param $current_dist_name "gnssAntennaAltitudeConf"
					del_param $current_dist_name "gnssAntennaLatitudeConf"
					del_param $current_dist_name "gnssAntennaLongitudeConf"
				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 "isChannelIncomplete" "false"

        if not ( param_exist channelDn "antlDN" )
            define "isChannelIncomplete" "true"

        if not ( param_exist channelDn "direction" )
            define "isChannelIncomplete" "true"

        if ( isChannelIncomplete ) == "true"
            begin
                del_object channelDn
            end
    end

for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELC/CHANNELGROUP"
    begin
        define "channelGroupDn" $current_dist_name
        define "channelsDn" channelGroupDn JOIN "/CHANNEL"

        if ( objects_count channelsDn ) == 0
            begin
                del_object channelGroupDn
            end
    end

for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELC"
    begin
        define "lcelcDn" $current_dist_name
        define "lcelcId_cellMapping" $current_LCELC
        define "channelGroupDn" lcelcDn JOIN "/CHANNELGROUP"

        if ( objects_count channelGroupDn ) == 0
            begin
                del_object lcelcDn

                for_objects "MRBTS/GNBTS/GNBCF/GNCEL"
                    begin
                        define "gncelDn" $current_dist_name

                        if ( param_exist gncelDn "lcelcId" )
                            begin
                                define "lcelcId" get_param gncelDn "lcelcId"

                                if ( lcelcId ) == lcelcId_cellMapping
                                    begin
                                        del_object gncelDn
                                    end
                            end
                    end
            end
    end

for_objects "MRBTS/MNL/MNLENT/FEATCADM"
    begin
        if not ( param_exist $current_dist_name "actHybridSynch" )
            add_param $current_dist_name "actHybridSynch" "false"
    end

define "btsSyncMode" ""
for_objects "MRBTS/MNL/MNLENT/SYNC"
    begin
        define "syncDn" $current_dist_name

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

for_objects "MRBTS/LNBTS/LNBTS_FDD"
    begin
        if ( btsSyncMode ) == "LoosePhaseAndTimeSync" || ( btsSyncMode ) == "PhaseSync"
            begin
                if not ( param_exist $current_dist_name "maxBtsTimeError" )
                    add_param $current_dist_name "maxBtsTimeError" "1000"
            end
    end

for_objects "MRBTS/GNBTS/GNBCF"
    begin
        define "GNBCF_DN" $current_dist_name

        if ( ( btsSyncMode == "LoosePhaseAndTimeSync" ) || ( btsSyncMode == "PhaseSync" ) )
            begin
                if not ( param_exist GNBCF_DN "maxBtsTimeError" )
                    add_param GNBCF_DN "maxBtsTimeError" "1900"
            end
    end

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

for_objects "MRBTS/MNL/CMD/ADDEECERTREQ/ADDEECERTRES"
    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/ADDTACERTREQ/ADDTACERTRES"
    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/CMPINITREQ/CMPINITRES"
    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/CMPKEYUPDATEREQ/CMPKEYUPDATERES"
    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/CRLUPDATEREQ/CRLUPDATERES"
    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/DELTACERTREQ/DELTACERTRES"
    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/RESTOREVENDORCERTREQ/RESTOREVENDORCERTRES"
    begin
		del_object $current_dist_name
    end	
for_objects "MRBTS/MNL/CMD/SETCMPSECRETREQ"
    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/RESTOREVENDORCERTREQ/RESTOREVENDORCERTRES"
    begin
		del_object $current_dist_name
    end	

for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/TOP"
	begin
		if ( objects_count $current_dist_name JOIN "/TOPF" ) > 0
			begin
				if not ( param_exist $current_dist_name "sPlaneDscp" ) add_param $current_dist_name "sPlaneDscp" 46
			end
		if ( param_exist $current_dist_name JOIN "/TOPP-1" "topComMode" )
			begin
				define "topComValue" get_param $current_dist_name JOIN "/TOPP-1" "topComMode"
				if ( "IP Unicast" == topComValue )
					begin
						if not ( param_exist $current_dist_name "sPlaneDscp" ) add_param $current_dist_name "sPlaneDscp" 46
					end
			end		
	end
	
for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/TOP/TOPF"
	begin
		if not ( param_exist $current_dist_name "announceRequestMode" ) add_param $current_dist_name "announceRequestMode" "ANNOUNCE_ALL"
		if not ( param_exist $current_dist_name "ieeeTelecomProfile" ) add_param $current_dist_name "ieeeTelecomProfile" "IEEE1588"
		if not ( param_exist $current_dist_name "syncMessageRate" ) add_param $current_dist_name "syncMessageRate" "RATE_16"
		
		if ( ( ( get_param $current_dist_name "announceRequestMode" ) == "ANNOUNCE_ALL" ) && ( ( get_param $current_dist_name "ieeeTelecomProfile" ) == "IEEE1588" ) )
			begin
				for_list $current_dist_name "topMasterList"
					begin
						if not ( param_exist $current_dist_name "topMasterList." JOIN $current_index JOIN ".priority_2" )
							add_param $current_dist_name "topMasterList." JOIN $current_index JOIN ".priority_2" 0
					end
			end
	end
	
for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/TOP/TOPP"
	begin
		if not ( param_exist $current_dist_name "topComMode" ) add_param $current_dist_name "topComMode" "IP Unicast"
			for_list $current_dist_name "topMasterList"
				begin
					if not ( param_exist  $current_dist_name "topMasterList." JOIN $current_index JOIN ".phaseErrorComp" ) add_param $current_dist_name "topMasterList." JOIN $current_index JOIN ".phaseErrorComp" 0
				end	
	end

for_objects "MRBTS/MNL/MNLENT/DNS"
	begin
		if ( param_exist $current_dist_name "serverIpAddressSecondary" )
			begin
				if ( get_param $current_dist_name "serverIpAddressSecondary" ) == "0.0.0.0" || ( get_param $current_dist_name "serverIpAddressSecondary" ) == "255.255.255.255"
					del_param $current_dist_name "serverIpAddressSecondary"
			end
	end	
#######################################################################################
#######################################################################################
# Set proper versions and adaptations to MNL sub-tree

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

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

for_objects "MRBTS/MNL/AMGR/LUAC"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

for_objects "MRBTS/MNL/AMGR/LUAC/LUAC_R"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

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

for_objects "MRBTS/MNL/CERTH/CMP"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

for_objects "MRBTS/MNL/CERTH/CRLH"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

for_objects "MRBTS/MNL/CERTH/CRLH/CRLDPCONFIG"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

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

for_objects "MRBTS/MNL/MNLENT/BBADM"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

for_objects "MRBTS/MNL/MNLENT/CAPADM"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

for_objects "MRBTS/MNL/MNLENT/CAPADM/CAPLIM"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

for_objects "MRBTS/MNL/MNLENT/CERTHENT"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

for_objects "MRBTS/MNL/MNLENT/CERTHENT/CACERT_R"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

for_objects "MRBTS/MNL/MNLENT/CERTHENT/CMP_R"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

for_objects "MRBTS/MNL/MNLENT/CERTHENT/CRLH_R"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

for_objects "MRBTS/MNL/MNLENT/CERTHENT/CRLINFO_R"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

for_objects "MRBTS/MNL/MNLENT/CERTHENT/NECERT_R"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

for_objects "MRBTS/MNL/MNLENT/DNS"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

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

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

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

for_objects "MRBTS/MNL/MNLENT/MPLANENW"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

for_objects "MRBTS/MNL/MNLENT/PMCADM"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

for_objects "MRBTS/MNL/MNLENT/PMMNL"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

for_objects "MRBTS/MNL/MNLENT/SECADM"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

for_objects "MRBTS/MNL/MNLENT/SECADM/SECADM_R"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end

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

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

for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/GNSSI"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        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 "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

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

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

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

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

for_objects "MRBTS/MNL/MNLENT/SYNC/CLOCK/TOP"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        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 "MNL18_1711_008"
        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 "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

for_objects "MRBTS/MNL/MNLENT/SYNC/TIME"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

for_objects "MRBTS/MNL/MNLENT/TAC"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end		

for_objects "MRBTS/MNL/MNLENT/TAC/LTAC"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

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

for_objects "MRBTS/MNL/MNLENT/CELLMAPPING"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELC"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELC/CHANNELGROUP"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        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 "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELW"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELW/CHANNELGROUP"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        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 "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

for_objects "MRBTS/MNL/MNLENT/FMCADM"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELL"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

for_objects "MRBTS/MNL/MNLENT/CELLMAPPING/LCELL/CHANNELGROUP"
    begin
        set_version $current_dist_name "MNL18_1711_008"
        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 "MNL18_1711_008"
        set_adaptation $current_dist_name "com.nokia.srbts.mnl"
    end	

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

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

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

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

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