Python OPC-UA client: add_folder() gives BadNotSupported

Hello,

When I try to add a folder using the Python OPC-UA client from here I get the following error:

opcua.ua.uaerrors._auto.BadNotSupported: "The requested operation is not supported."(BadNotSupported)

The user has the role ReadWrite assigned.

I’m not sure if the code is wrong or I need to change something in Ignition?

Any guidance is much appricated!

Sample code:

from opcua import ua
from opcua import Client
import sys
sys.path.insert(0, "..")

if __name__ == "__main__":
    client = Client("opc.tcp://localhost:62541/")
    client.set_user("test")
    client.set_password("test")

    try:
        client.connect()

        test = client.get_node("ns=2;s=[Sample_Tags]")
        print("Info: ", test)

        test.add_folder("ns=2;s=[Sample_Tags]/Test", "Test")
    finally:
        client.disconnect()

Output:

Requested session timeout to be 3600000ms, got 120000ms instead
Info:  ns=2;s=[Sample_Tags]
Traceback (most recent call last):
  File "/home/simon/Projects/opcua-client/test copy.py", line 31, in <module>
    test.add_folder("ns=2;s=[Sample_Tags]/Test", "Test")
  File "/home/simon/Projects/opcua-client/venv/lib/python3.8/site-packages/opcua/common/node.py", line 658, in add_folder
    return opcua.common.manage_nodes.create_folder(self, nodeid, bname)
  File "/home/simon/Projects/opcua-client/venv/lib/python3.8/site-packages/opcua/common/manage_nodes.py", line 41, in create_folder
    return node.Node(parent.server, _create_object(parent.server, parent.nodeid, nodeid, qname, ua.ObjectIds.FolderType))
  File "/home/simon/Projects/opcua-client/venv/lib/python3.8/site-packages/opcua/common/manage_nodes.py", line 171, in _create_object
    results[0].StatusCode.check()
  File "/home/simon/Projects/opcua-client/venv/lib/python3.8/site-packages/opcua/ua/uatypes.py", line 218, in check
    raise UaStatusCodeError(self.value)
opcua.ua.uaerrors._auto.BadNotSupported: "The requested operation is not supported."(BadNotSupported)

Ignition’s OPC UA server doesn’t support the Node Management services. You can’t arbitrarily create Nodes in the server.

Ah, our intention was to do device management elsewhere and create the appropriate nodes in Ignition programmatically.

Are you saying that there is no way to do this? In other words we need to do this statically/manually from within Ignition?

Thanks.

Correct.

While you can’t do it via OPC UA, you might be able to use the WebDev module to expose REST endpoints that use the system.device scripting functions to configure devices.

If I look at system.device in the docs, it looks like there is no way to actually define the folder structure, tags etc. right? Just define a device that will receive data through a specific driver. Or am I missing something?

I basically need to define the whole folder structure, tag definitions from outside Ignition. The “devices” are actually pseudo devices that I will write data to from outside Ignition.

I need to define something similar using code:

image

In that case you probably don’t want system.device, but rather you want system.tag.configure, and you’d just be creating folders full of memory tags.

These would be Ignition tags you create, so in order to see them the “Exposed Tags” feature of the OPC UA server must be enabled.

https://docs.inductiveautomation.com/display/DOC81/system.tag.configure

Ok, so I’m basically defining Python functions (using system.*) for creating folders and tags using the WebDev module. I can call these functions from outside Ignition using REST API.