How to attach new nic in vm using command line?

Hello,
I am looking for a assistance on how I can attach/detach network card from VM using bash script or any other script using terminal/cli ? My objective is I will send the command remotely based on some activity like if any abnormal traffic outrounded from any VM then i will switch the vm into a different nic/lan.

Any quick help would be highly appreciated. I am using OpenNebula version 6.4.0.1.

Thanks
Shaf

You can use the onevm nic-attach command. An example can be found here.

Thanks for quick response