mm.pop() mm.push() # device type mm.insert("draft") mm.push() # draft getPhysicalInterface(api, mm, devicetype, draft=True) mm.pop() # draft getLogicalInterfaces(api, mm, devicetype, draft=True) mm.pop() # device type # Devices devices = api.getDevicesForType(devicetype["id"])["results"] for device in devices: mm.insert("Device: " + device["deviceId"]) mm.gotoParent() linkedtodevicetypes = False # Now delete any resources not associated with a device type for physicalInterfaceId in draftPhysicalInterfaces: api.deletePhysicalInterface(physicalInterfaceId) for eventTypeId in draftEventTypes: api.deleteEventType(eventTypeId) for logicalInterfaceId in draftLogicalInterfaces: api.deleteLogicalInterface(logicalInterfaceId) for schemaId in draftSchemaIds: api.deleteSchema(schemaId)
if "physicalInterfaceId" in result.keys(): physicalInterfaceId = result[ "physicalInterfaceId"] # get the physical interface id print("Physical interface id", physicalInterfaceId) result = api.removePhysicalInterfaceFromDeviceType(devicetype) # list event types on the physical interface result = api.getEvents(physicalInterfaceId) eventIds = [res["eventId"] for res in result] eventTypeIds = [res["eventTypeId"] for res in result] print(eventIds, eventTypeIds) for eventId in eventIds: result = api.deleteEvent( physicalInterfaceId, eventId) # remove event mapping from device type result = api.deletePhysicalInterface(physicalInterfaceId) print("Physical interface deleted") # delete event types and schemas count = 0 schemaIds = [] for eventTypeId in eventTypeIds: schemaId = api.getEventType(eventTypeId)["schemaId"] result = api.deleteEventType(eventTypeId) result = api.deleteSchema(schemaId) count += 2 schemaIds.append(schemaId) print("Event types and event type schemas deleted:", count, schemaIds)
result = api.getDeviceType(devicetype) if "physicalInterfaceId" in result.keys(): physicalInterfaceId = result["physicalInterfaceId"] # get the physical interface id print("Physical interface id", physicalInterfaceId) result = api.removePhysicalInterfaceFromDeviceType(devicetype) # list event types on the physical interface result = api.getEvents(physicalInterfaceId) eventIds = [res["eventId"] for res in result] eventTypeIds = [res["eventTypeId"] for res in result] print(eventIds, eventTypeIds) for eventId in eventIds: result = api.deleteEvent(physicalInterfaceId, eventId) # remove event mapping from device type result = api.deletePhysicalInterface(physicalInterfaceId) print("Physical interface deleted") # delete event types and schemas count = 0; schemaIds = [] for eventTypeId in eventTypeIds: schemaId = api.getEventType(eventTypeId)["schemaId"] result = api.deleteEventType(eventTypeId) result = api.deleteSchema(schemaId) count += 2; schemaIds.append(schemaId) print("Event types and event type schemas deleted:", count, schemaIds)