Error while patching

I am using this command to patch and merge kubernetes resource. But getting error saying ’ Error from server (BadRequest): Invalid JSON Patch ’

 os.popen("oc patch bmh %s -n openshift-machine-api --type='merge' -p %s" % (node_name, node_file_path))

output of this bmh file is

$ oc get bmh -A
NAMESPACE NAME STATE CONSUMER ONLINE ERROR AGE
openshift-machine-api slabnode2173.sl699.dyn.nesc.nokia.net unmanaged sl699-gtllz-master-0 true 5d
openshift-machine-api slabnode2174.sl699.dyn.nesc.nokia.net unmanaged sl699-gtllz-master-1 true 5d
openshift-machine-api slabnode2175.sl699.dyn.nesc.nokia.net unmanaged sl699-gtllz-master-2 true 5d
openshift-machine-api slabnode2176.sl699.dyn.nesc.nokia.net unmanaged sl699-gtllz-worker-0-4lmkm true 5d
openshift-machine-api slabnode2177.sl699.dyn.nesc.nokia.net unmanaged sl699-gtllz-worker-0-fkjln true 5d

I am trying to create a secret using the node name from bmh and then patching it so that it will change the state of nodes.

try using subprocess.run() and use a list of command line parts not a string.

subprocess.run(['oc', 'patch', ...])

Do you get better results?

What does:

print("oc patch bmh %s -n openshift-machine-api --type='merge' -p %s" % (node_name, node_file_path)

say? Does it look correct?

If you type that at a command line prompt, does it work?