<div dir="ltr">Thanks Moti.<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Mar 11, 2014 at 4:27 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>><br>
> Cc: "users@oVirt.org" <<a href="mailto:users@ovirt.org">users@ovirt.org</a>><br>
> Sent: Tuesday, March 11, 2014 8:53:15 AM<br>
> Subject: Re: Delete & Detach Logical Network<br>
><br>
> Managed to delete network which is attached to Bond with below code:<br>
><br>
> HostNIC nic =<br>
> api.getHosts().get("rhevhost").getHostNics().get("bond1.1231");<br>
> nic.delete();<br>
><br>
><br>
> 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>
> i want to unmap the logical network which is mapped to eth1.<br>
><br>
<br>
For this specific case I'd suggest using the attached example.<br>
<br>
> *Result*:<br>
> code : 400<br>
> reason: Bad Request<br>
> detail: Invalid Bonding definition<br>
><br>
><br>
><br>
><br>
><br>
> On Mon, Mar 10, 2014 at 6:54 PM, Moti Asayag <<a href="mailto:masayag@redhat.com">masayag@redhat.com</a>> wrote:<br>
><br>
> ><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" <<br>
> > <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<br>
> > vlan,<br>
> > so the proper interface should be the vlan device.<br>
> ><br>
> ><br>
> > > *Code 2:*<br>
> > > HostNIC nic =<br>
> > 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<br>
> > 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]<br>
> > <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>
> ><br>
> > ><br>
> > > --<br>
> > > Thanks & Regards<br>
> > > Tejesh<br>
> > ><br>
> ><br>
><br>
><br>
<span class="HOEnZb"><font color="#888888">><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>