<div dir="ltr"><div><div>I tried below code, but still it is not detaching the network<br><br> HostNICs nicsApi = api.getHosts().get("venus-vdsb").getHostNics();<br> List<HostNIC> nics = nicsApi.list();<br>
HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("bond1.1231"); //logical network network name is "testLNw"<br> nic.setNetwork(null);<br> <br><br><b>Result of executing this line</b>: nicsApi.setupnetworks(createSetupNetworksParams(nics)); <br>
<br></div><div><b>Result:</b><br>code : 400<br>reason: Bad Request<br>detail: Cannot setup Networks. The following VMs are actively using the Logical Network: greyvm, vmLogicalTest1, OmVM1. Please stop the VMs and try again., Cannot setup Networks. The following Bonds consist of less than two Network Interfaces: bond0., Cannot setup Networks. The following Network Interfaces were specified more than once: eth0, eth3, eth1, eth2.<br>
</div><div><br></div>Can you post the complete code?<br><br></div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 10, 2014 at 6:54 PM, Moti Asayag <span dir="ltr"><<a href="mailto:masayag@redhat.com" target="_blank">masayag@redhat.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
----- Original Message -----<br>
> From: "Tejesh M" <<a href="mailto:tejeshmk@gmail.com">tejeshmk@gmail.com</a>><br>
> To: "Moti Asayag" <<a href="mailto:masayag@redhat.com">masayag@redhat.com</a>>, "users@oVirt.org" <<a href="mailto:users@ovirt.org">users@ovirt.org</a>><br>
> Sent: Monday, March 10, 2014 1:22:08 PM<br>
> Subject: Delete & Detach Logical Network<br>
><br>
> Hi,<br>
><br>
> I'm able to delete the logical network but this logical network after<br>
> deletion shows as unmanaged network in "Setup Host Networks" against the<br>
> hostnic.<br>
><br>
> I tried with this code to detach the logical network.<br>
><br>
> *Code 1:*<br>
> HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1");<br>
> Action action = new Action();<br>
> action.setNetwork(api.getNetworks().get(nw_name));<br>
> action.setDetach(true);<br>
> action.setCheckConnectivity(false);<br>
> nic.detach(action);<br>
><br>
> *Returns*:<br>
> code : 409<br>
> reason: Conflict<br>
> detail: Network Interface is not attached to Logical Network.<br>
><br>
<br>
I can guess by the error message that the logical network 'rhevhost' is vlan,<br>
so the proper interface should be the vlan device.<br>
<br>
<br>
> *Code 2:*<br>
> HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1.1345");<br>
> Action action = new Action();<br>
> action.setNetwork(api.getNetworks().get(nw_name));<br>
> action.setDetach(true);<br>
> action.setCheckConnectivity(false);<br>
> nic.detach(action);<br>
><br>
> *Returns*:<br>
> code : 409<br>
> reason: Conflict<br>
> detail: Cannot edit Network while Host is Active, change the Host to<br>
> Maintenance mode and try again.<br>
><br>
<br>
This is the 3.0 api which required the host to be in maintenance for network<br>
operations on the host. You could use setup networks instead which is the<br>
recommended api and doesn't require the host to be in maintenance.<br>
<br>
you can modify the example from [1] and set null for the network name you<br>
wish to detach from the specific interface.<br>
<br>
Try by replacing only lines 28-41 with:<br>
HostNIC nic = nicsByNames.get("eth1.1345");<br>
nic.setNetwork(null);<br>
<br>
[1] <a href="https://motiasayag.wordpress.com/2014/02/24/invoke-setup-networks-from-the-java-sdk/" target="_blank">https://motiasayag.wordpress.com/2014/02/24/invoke-setup-networks-from-the-java-sdk/</a><br>
<span class="HOEnZb"><font color="#888888"><br>
><br>
> --<br>
> Thanks & Regards<br>
> Tejesh<br>
><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div>Thanks & Regards</div>
<div>Tejesh</div>
</div>