Skip to content

Instantly share code, notes, and snippets.

@aletelecom
Created July 19, 2022 01:01
Show Gist options
  • Save aletelecom/d47ef94dce51e358b062a51c2872b4d1 to your computer and use it in GitHub Desktop.
Save aletelecom/d47ef94dce51e358b062a51c2872b4d1 to your computer and use it in GitHub Desktop.
Creating olt class
class OLT:
""" Define a class OLT that have the following attributes:
- An "int" Board quantity (slot_qty) which represent the maximun slot count that the OLT has.
- An "int" Port quantity per slot (port_per_slot) which represent the maximun port count per slot that the OLT has.
- An "int" Maximun client quantity per pon port (max_client_qty) which represent the maximun client count per port per slot that the OLT has. """
def __init__(self, slot_qty=16, port_per_slot=16):
self.slot_qty = slot_qty
self.port_per_slot = port_per_slot
# Then we define a method that will create and populate each pon port of the OLT instance with a client quantity
def create_olt_and_populate(self, max_client_qty):
# We assign the model of the OLT at random, during the creation
models = ['Model_A', 'Model_B', 'Model_C', 'Model_D']
model = choice(models)
# We define a list as population, to add to it the information as tuples (slot, port, client_qty, model)
population = []
slot_port_tuples = [(slot, port) for slot, port in product(range(1,self.slot_qty+1), range(1,self.port_per_slot+1))]
for tupla in slot_port_tuples:
population.append(tupla + (randint(0,max_client_qty),model))
# Then we create and return a Pandas DataFrame, in which each row represents "a PON port" with its information
df = pd.DataFrame(population, columns=['slot', 'port', 'client_qty', 'model'])
return df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment