Open Discussion

Expand all | Collapse all

API question, licenseAvailabilityReport

  • 1.  API question, licenseAvailabilityReport

    Posted 04-13-2018 12:03
    I'm a little weak on my python-fu, so I was hoping someone could give me a hand with this one. I'm setting up some of the scripts to run in cron from the API class and am having an issue with licenseAvailabilityReport.py. I get to "Sorting and prepping for output" section and it begins to give me available licenses and dates, but then I get:

    root : INFO 2 licenses will be available 2018-11
    Traceback (most recent call last):
    File "licenseAvailabilityreport.py", line 646, in <module>
    figureOutExpirelist()
    File "licenseAvailabilityreport.py", line 610, in figureOutExpirelist
    prettyResultsprinted(expiringMonthslist.items())
    File "licenseAvailabilityreport.py", line 558, in prettyResultsprinted
    totalInUselicenses = getLicensedUsers() #Get the total number of licenses actually being used
    File "licenseAvailabilityreport.py", line 439, in getLicensedUsers
    return MasterLicense['seatsInUse']
    KeyError: 'seatsInUse'

    I believe the script is looking for a module named seatsInUse, but when I check the script I'm not finding except in this line...
    gspiers3@gingermint ~/scripts/crashplan_api_examples $ cat licenseAvailabilityreport.py | grep seatsInUse
    return MasterLicense['seatsInUse']

    gspiers3@gingermint ~/scripts/crashplan_api_examples $ python -V
    Python 2.7.12

    Has anyone come across this issue before?










    ------------------------------
    Gairy Spiers
    Systems/IT Architect Lead
    Atlanta GA
    ------------------------------


  • 2.  RE: API question, licenseAvailabilityReport

    Posted 04-18-2018 13:42
    Hi Gairy,

    Since your question has simmered for a few days, I reached out to Riley, who ran the API workshop you alluded to, to see if he could help answer your question. Here's what he said:
    "It looks like Gairy may be using a version of the library that's either too old or too young for the version of the licenseAvailability script he's running. What I would recommend would be to use the history option for the library script and make sure to grab the version that was committed most recently before the license script was committed."

    Please give that a try and let us know how it works out--if you still have issues let me know. And, if anyone else in the community has anything to share, feel free to chime in.

    Thanks so much for your patience--good luck with it!

    ------------------------------
    Lindsay Starke
    Community Manager
    Code42
    ------------------------------



  • 3.  RE: API question, licenseAvailabilityReport

    Posted 04-19-2018 06:52
    Hi Lindsey,

    Sorry I haven't replied yet, I got pulled onto another project. I create a case and Jonathan was able to help me. Hopefully this can help someone else.

    We have a lot of labs that we created individual orgs for. We normally purchase all licenses, then bill the labs for usage. We wanted a way to alert the labs when they were getting close to their quota, instead of waking up one day and being at the limit and having to wait a few days while we go through our purchasing process (government purchasing delays, not c42).

    Jonathan showed me that I can add "&incAll=true" to the end of an Org API call and get the fields I was looking for. Without that, it will not return any license usage. With this, I can get the fields pasted below, which have helped us to create a quick dashboard and link that we can put at the bottom of our emails to lab staff.

    computerCount 220
    shareDeviceCount 0
    backupDeviceCount 220
    backupComputerCount 222
    userCount 141
    licensedUserCount 123

    Thanks for the help, and thank you Lindsey for the follow up.

    ------------------------------
    Gairy Spiers
    Systems/IT Architect Lead
    Atlanta GA
    ------------------------------