Skip to content

Commit

Permalink
fixed mx hotspare count
Browse files Browse the repository at this point in the history
  • Loading branch information
phlamprecht committed Aug 29, 2024
1 parent 21d0010 commit c0ea18b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
19 changes: 18 additions & 1 deletion compare_license.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
""" in this script are the classes for Meraki API communication
and for creation of csv files with compare functions"""

# Get Network Appliance Warm Spare for mx

import meraki
import csv
import glob
Expand Down Expand Up @@ -35,12 +37,27 @@ def get_coterm_licenses(self):
)
print(coterm_licenses)

def _get_count_devices(self, devices):
def get_count_devices(self, devices):
"""create list with all models of producttype"""
list_models = []
skipped_counter = 0
for device in devices:
if device["productType"] == "appliance":
hotspare = self.dashboard.appliance.getNetworkApplianceWarmSpare(
device["networkId"]
)
if device["serial"] == hotspare["spareSerial"]:
print(
device["serial"]
+ "is hot spare "
+ hotspare["spareSerial"]
+ " - skipping"
)
skipped_counter += 1
continue
list_models.append(device["model"])
dict_count_model = {i: list_models.count(i) for i in list_models}
print("Hot Spare MX skipped: " + str(skipped_counter))
return dict_count_model


Expand Down
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
to pull current list of active devices via Meraki API and compares it to
the latest information"""

import datetime as dt
from decouple import config
from compare_license import _Meraki, _Csv
from o365 import _Mail
from decouple import config
import datetime as dt


def main_coterm():
Expand All @@ -24,7 +24,7 @@ def main():
dashboard = _Meraki()
# capture licensed devices for all producttypes in list_producttype
diff_all.update(
**dashboard._get_count_devices(dashboard.get_devices(list_producttype))
**dashboard.get_count_devices(dashboard.get_devices(list_producttype))
)
# create new _csv object
delta_csv = _Csv()
Expand Down

0 comments on commit c0ea18b

Please sign in to comment.