Python – Auto Rename Cable Notes in Ekahau

Naming cable notes in Ekahau is quite a manual process. You have to enter your note description at the end of drawing the cable note on the map.

What I like to do on my projects is rename the cable notes in the following way: “IDF-1 to AP01”. We then re-use this description in our report to provide the information to both the customer and the installers.

Doing this process manually can take time when you have a lot of APs. This is why I had the idea of creating a script that would automatically do it for me.

BEFORE

Here is an example of what Ekahau would love like before the script is run:

You can see that the cable notes link the AP objects to map notes specifying the location of the MDF/IDF. You can also see that non of them are renamed properly.

THE PROCESS

In order to be able to rename the cable note description properly, we do the following:

  • Look at the first coordinates of the cable note and identify which AP object is closest to it.
  • Once we know which AP is closest, we go and retreive the name of that AP.
  • Look at the last coordinates of the cable note and identify which map not containing IDF or MDF is closest to it.
  • Once we know which map note is closest, we go and retrieve its name.
  • We modify the description of the cable note to include both the AP name and the MDF/IDF name.

AFTER

Here is what the project will look like after the script is run:

As you can see, the cable note description is now renamed with the relevant information, indicating where each APs will be connecting to.

THE CODE

import argparse
import time
import os
import zipfile
import json
import pathlib
import shutil
import numpy as np
 
 
def find_ap_name_from_coord(accessPoints, cable_note_point):
    """Return the name of the AP which is located closest to the first point of the cable note."""
    ap_locations = []
    for accessPoint in accessPoints['accessPoints']:
        ap_location = [accessPoint['location']['coord']['x'], accessPoint['location']['coord']['y']]
        ap_locations.append(ap_location)
    closest_ap_location = np.argmin(np.sum((np.array(ap_locations) - np.array(cable_note_point))**2, axis=1))
 
    for accessPoint in accessPoints['accessPoints']:
        if accessPoint['location']['coord']['x'] == ap_locations[closest_ap_location][0]:
            if accessPoint['location']['coord']['y'] == ap_locations[closest_ap_location][1]:
                return (accessPoint['name'])
 
 
def find_telco_room_name_from_coord(notes, pictureNotes, cable_note_point):
    """Return the name of the MDF/IDF room closest to the last point ot the cable note."""
    telco_room_locations = []
    for note in notes['notes']:
        if note['text'].find('IDF') != -1 or note['text'].find('MDF') != -1:
            for pictureNote in pictureNotes['pictureNotes']:
                if note['id'] == pictureNote['noteIds'][0]:
                    telco_room_locations.append([pictureNote['location']['coord']['x'], pictureNote['location']['coord']['y']])
    closest_telco_room_location = np.argmin(np.sum((np.array(telco_room_locations) - np.array(cable_note_point))**2, axis=1))
 
    for pictureNote in pictureNotes['pictureNotes']:
        if pictureNote['location']['coord']['x'] == telco_room_locations[closest_telco_room_location][0]:
            if pictureNote['location']['coord']['y'] == telco_room_locations[closest_telco_room_location][1]:
                for note in notes['notes']:
                    if note['id'] == pictureNote['noteIds'][0]:
                        return note['text']
 
 
def main():
    parser = argparse.ArgumentParser(
        description='This script rename cable notes with AP name and IDF/MDF names.')
    parser.add_argument('file', metavar='esx_file', help='Ekahau project file')
    args = parser.parse_args()
 
    current_filename = pathlib.PurePath(args.file).stem
    working_directory = os.getcwd()
 
    # Load & Unzip the Ekahau Project File
    with zipfile.ZipFile(args.file, 'r') as myzip:
        myzip.extractall(current_filename)
 
        # Load the accessPoints.json file into the accessPoints dictionary
        with myzip.open('accessPoints.json') as json_file:
            accessPoints = json.load(json_file)
 
        # Load the notes.json file into the notes dictionary
        with myzip.open('notes.json') as json_file:
            notes = json.load(json_file)
 
        # Load the cableNotes.json file into the cableNotes dictionary
        with myzip.open('cableNotes.json') as json_file:
            cableNotes = json.load(json_file)
 
        # Load the pictureNotes.json file into the pictureNotes dictionary
        with myzip.open('pictureNotes.json') as json_file:
            pictureNotes = json.load(json_file)
 
        # Loop through the AP and auto populate the tag values based on the AP properties
        for cableNote in cableNotes['cableNotes']:
            # Retreiving the coordinates of both ends of the cable notes
            if cableNote['points']:
                cable_note_first_point = [cableNote['points'][0]['x'], cableNote['points'][0]['y']]
                cable_note_last_point = [cableNote['points'][-1]['x'], cableNote['points'][-1]['y']]
 
            # Search for AP Name coresponding to AP coordinates
            ap_name = find_ap_name_from_coord(accessPoints, cable_note_last_point)
 
            # Search for the IDF/MDF room closer to the end of the cable note
            telco_room_name = find_telco_room_name_from_coord(notes, pictureNotes, cable_note_first_point)
 
            # Rename Cable Note with AP & MDF/IDF Informationa
            for note in notes['notes']:
                if cableNote['noteIds']:
                    if note['id'] == cableNote['noteIds'][0]:
                        new_name = f"From {telco_room_name} to {ap_name}"
                        note['text'] = new_name
                        print(f"Renamed Cable Note to: {new_name}")
 
    # Write the changes into the accessPoints.json File
    with open(working_directory + '/' + current_filename + '/notes.json', 'w') as file:
        json.dump(notes, file, indent=4)
 
    # Create a new version of the Ekahau Project
    new_filename = current_filename + '_modified'
    shutil.make_archive(new_filename, 'zip', current_filename)
    shutil.move(new_filename + '.zip', new_filename + '.esx')
 
    # Cleaning Up
    shutil.rmtree(current_filename)
 
 
if __name__ == "__main__":
    start_time = time.time()
    print('** RENAME CABLE NOTES..\n')
    main()
    run_time = time.time() - start_time
    print("\n** Time to run: %s sec" % round(run_time, 2))

Note: we might update it in the future. So make sure to also check the GitHub repository to see the latest version available: https://github.com/francoisverges/semfio-ekahau

USAGE

Simply create a copy of your project file (.esx file) and run the script against it:

A modified version of your project file will be created. When you open it, you should see the cable notes descriptions updated with the proper information.

Note: For this script to work, you need to do the following in your Ekahau project file before running it:

  1. Place and rename simulated APs on the map
  2. Place and rename map notes indicating the location of MDF/IDF rooms
  3. Draw cable notes from the MDF/IDF to each of the APs
  4. Leave at least 1 character in the cable note description box (we used ‘-‘ in our example). This makes sure that a note object is created in the project file for that cable note

LINKS & RESOURCES

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments