Fix packet.net dynamic inventory projects limit. (#64889)

* Added parameters to list more than 10 projects per run

* Fix slug issue due to packet api change. Same as https://github.com/ansible/ansible/pull/63916
This commit is contained in:
Vitaly Shestovskiy 2020-02-15 16:55:40 +02:00 committed by GitHub
parent f978b6c789
commit 95d4908987
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -249,9 +249,14 @@ class PacketInventory(object):
def get_projects(self): def get_projects(self):
'''Makes a Packet API call to get the list of projects''' '''Makes a Packet API call to get the list of projects'''
params = {
'per_page': self.items_per_page
}
try: try:
manager = self.connect() manager = self.connect()
projects = manager.list_projects() projects = manager.list_projects(params=params)
return projects return projects
except Exception as e: except Exception as e:
traceback.print_exc() traceback.print_exc()
@ -351,7 +356,7 @@ class PacketInventory(object):
# Inventory: Group by OS # Inventory: Group by OS
if self.group_by_operating_system: if self.group_by_operating_system:
self.push(self.inventory, device.operating_system.slug, dest) self.push(self.inventory, device.operating_system['slug'], dest)
if self.nested_groups: if self.nested_groups:
self.push_group(self.inventory, 'operating_systems', device.operating_system.slug) self.push_group(self.inventory, 'operating_systems', device.operating_system.slug)
@ -400,7 +405,7 @@ class PacketInventory(object):
elif key == 'packet_facility': elif key == 'packet_facility':
device_vars[key] = value['code'] device_vars[key] = value['code']
elif key == 'packet_operating_system': elif key == 'packet_operating_system':
device_vars[key] = value.slug device_vars[key] = value['slug']
elif key == 'packet_plan': elif key == 'packet_plan':
device_vars[key] = value['slug'] device_vars[key] = value['slug']
elif key == 'packet_tags': elif key == 'packet_tags':