<div dir="ltr">Managed to delete network which is attached to Bond with below code:<br><br>HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("bond1.1231");<br><div dir="ltr">nic.delete();<br>
<br><br></div><div>But not able to delete the same when attached to ethernet:<br><br>HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1.1187");<br>nic.delete();<br><br></div><div>i want to unmap the logical network which is mapped to eth1.<br>
</div><div><div dir="ltr"><br></div><div><b>Result</b>:<br>code : 400<br>reason: Bad Request<br>detail: Invalid Bonding definition<br></div><br></div><br><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>