05-25-2020 12:51 PM - edited 05-25-2020 12:52 PM
Hi, I have the following problem:
I have a services (service A) that when is created populate his path in another service (Service B). Service B have multiple path of instances of service A.
I want to make an action that read all service path in Service B, and delete the corresponding services A.
Here is the problem, to get the service object in Python from the path string I use:
service_to_delete = ncs.maagic.get_node(t, service_path)
del service_to_delete
But this only delete the Python object service_to_delete, and not the CDB service, as is explained in the nso docs.
If I use:
del ncs.maagic.get_node(t, service_path)
I get an error on package reload:
*** ALARM package-load-failure: [SyntaxError: can't delete function call]
Is there a delete_node() function or a workaround to solve this?
Solved! Go to Solution.
02-03-2022 05:08 AM - edited 02-03-2022 05:09 AM
You have to delete the child(item) of the node so when you call the del statement you have to mention which item you want to delete. In this case we have to identify the instance to be deleted by its name, so it had to look something like this:
service_to_delete = ncs.maagic.get_node(t, service_path)
del service_to_delete[service_name]
t.apply
Hope it helps.
05-30-2020 11:13 PM
WIth the first option, are you applying the transaction in which you use 'del service_to_delete'?
06-01-2020 05:11 AM
02-03-2022 05:08 AM - edited 02-03-2022 05:09 AM
You have to delete the child(item) of the node so when you call the del statement you have to mention which item you want to delete. In this case we have to identify the instance to be deleted by its name, so it had to look something like this:
service_to_delete = ncs.maagic.get_node(t, service_path)
del service_to_delete[service_name]
t.apply
Hope it helps.
07-17-2024 10:48 PM
You can delete the instance using _ncs.maapi.delete()
service_to_delete = ncs.maagic.get_node(t, service_path)
_ncs.maapi.delete(m.msock, t.th, service_to_delete._path)
t.apply()
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide