Пример #1
0
        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)
Пример #2
0
    # list application interfaces for the device type
    schemaIds = []
    try:
        ids, result = api.getLogicalInterfacesOnDeviceType(devicetype)
        print("Application interfaces found:", ids)
        print("Schemas found:", schemaIds)
    except:
        ids = result = []

    # disassociate and delete the application interfaces from the device type
    count = 0
    for logicalInterfaceId in ids:
        result = api.removeLogicalInterfaceFromDeviceType(
            devicetype, logicalInterfaceId)
        result = api.deleteLogicalInterface(logicalInterfaceId)
        count += 1
    print("Application interfaces disassociated and deleted:", count, ids)

    # delete the application interface schemas
    count = 0
    for schemaId in schemaIds:
        result = deleteSchema(applicationInterfaceId)
        count += 1
    print("Application interface 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)
Пример #3
0
    api = ibmiotf.api.ApiClient(params)

    # find all the device types
    #devicetypes = [x["id"] for x in api.getDeviceTypes(draft=True)["results"]]
    devicetypes = ['dt0']
    print("Device types", devicetypes)

    # find all application interfaces
    appintids, result = api.getLogicalInterfaces(draft=True)
    if len(appintids) > 0:
        print("Application interface ids", appintids)

    # try and delete the application interfaces
    for appintid in appintids:
        try:
            result = api.deleteLogicalInterface(appintid)
        except Exception as exc:
            print(exc)
            #if it fails, remove the app interface from the device type
            for devicetype in devicetypes:
                succeeded = True
                try:
                    result = api.removeLogicalInterfaceFromDeviceType(
                        devicetype, appintid)
                except Exception as exc:
                    succeeded = False
                if succeeded:
                    print("app interface removed from device type", devicetype)
            try:
                result = api.deleteLogicalInterface(appintid)
            except Exception as exc: