[Users] Delete & Detach Logical Network

Hi, I'm able to delete the logical network but this logical network after deletion shows as unmanaged network in "Setup Host Networks" against the hostnic. I tried with this code to detach the logical network. *Code 1:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action); *Returns*: code : 409 reason: Conflict detail: Network Interface is not attached to Logical Network. *Code 2:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1.1345"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action); *Returns*: code : 409 reason: Conflict detail: Cannot edit Network while Host is Active, change the Host to Maintenance mode and try again. -- Thanks & Regards Tejesh

----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "Moti Asayag" <masayag@redhat.com>, "users@oVirt.org" <users@ovirt.org> Sent: Monday, March 10, 2014 1:22:08 PM Subject: Delete & Detach Logical Network
Hi,
I'm able to delete the logical network but this logical network after deletion shows as unmanaged network in "Setup Host Networks" against the hostnic.
I tried with this code to detach the logical network.
*Code 1:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action);
*Returns*: code : 409 reason: Conflict detail: Network Interface is not attached to Logical Network.
I can guess by the error message that the logical network 'rhevhost' is vlan, so the proper interface should be the vlan device.
*Code 2:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1.1345"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action);
*Returns*: code : 409 reason: Conflict detail: Cannot edit Network while Host is Active, change the Host to Maintenance mode and try again.
This is the 3.0 api which required the host to be in maintenance for network operations on the host. You could use setup networks instead which is the recommended api and doesn't require the host to be in maintenance. you can modify the example from [1] and set null for the network name you wish to detach from the specific interface. Try by replacing only lines 28-41 with: HostNIC nic = nicsByNames.get("eth1.1345"); nic.setNetwork(null); [1] https://motiasayag.wordpress.com/2014/02/24/invoke-setup-networks-from-the-j...
-- Thanks & Regards Tejesh

Hi Moti, "rhevhost" is the Host name & logical network is sent as variable nw_name, in the code 1. On Mon, Mar 10, 2014 at 6:54 PM, Moti Asayag <masayag@redhat.com> wrote:
----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "Moti Asayag" <masayag@redhat.com>, "users@oVirt.org" < users@ovirt.org> Sent: Monday, March 10, 2014 1:22:08 PM Subject: Delete & Detach Logical Network
Hi,
I'm able to delete the logical network but this logical network after deletion shows as unmanaged network in "Setup Host Networks" against the hostnic.
I tried with this code to detach the logical network.
*Code 1:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action);
*Returns*: code : 409 reason: Conflict detail: Network Interface is not attached to Logical Network.
I can guess by the error message that the logical network 'rhevhost' is vlan, so the proper interface should be the vlan device.
*Code 2:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1.1345"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action);
*Returns*: code : 409 reason: Conflict detail: Cannot edit Network while Host is Active, change the Host to Maintenance mode and try again.
This is the 3.0 api which required the host to be in maintenance for network operations on the host. You could use setup networks instead which is the recommended api and doesn't require the host to be in maintenance.
you can modify the example from [1] and set null for the network name you wish to detach from the specific interface.
Try by replacing only lines 28-41 with: HostNIC nic = nicsByNames.get("eth1.1345"); nic.setNetwork(null);
[1] https://motiasayag.wordpress.com/2014/02/24/invoke-setup-networks-from-the-j...
-- Thanks & Regards Tejesh
-- Thanks & Regards Tejesh

I tried below code, but still it is not detaching the network HostNICs nicsApi = api.getHosts().get("venus-vdsb").getHostNics(); List<HostNIC> nics = nicsApi.list(); HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("bond1.1231"); //logical network network name is "testLNw" nic.setNetwork(null); *Result of executing this line*: nicsApi.setupnetworks(createSetupNetworksParams(nics)); *Result:* code : 400 reason: Bad Request 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. Can you post the complete code? On Mon, Mar 10, 2014 at 6:54 PM, Moti Asayag <masayag@redhat.com> wrote:
----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "Moti Asayag" <masayag@redhat.com>, "users@oVirt.org" < users@ovirt.org> Sent: Monday, March 10, 2014 1:22:08 PM Subject: Delete & Detach Logical Network
Hi,
I'm able to delete the logical network but this logical network after deletion shows as unmanaged network in "Setup Host Networks" against the hostnic.
I tried with this code to detach the logical network.
*Code 1:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action);
*Returns*: code : 409 reason: Conflict detail: Network Interface is not attached to Logical Network.
I can guess by the error message that the logical network 'rhevhost' is vlan, so the proper interface should be the vlan device.
*Code 2:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1.1345"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action);
*Returns*: code : 409 reason: Conflict detail: Cannot edit Network while Host is Active, change the Host to Maintenance mode and try again.
This is the 3.0 api which required the host to be in maintenance for network operations on the host. You could use setup networks instead which is the recommended api and doesn't require the host to be in maintenance.
you can modify the example from [1] and set null for the network name you wish to detach from the specific interface.
Try by replacing only lines 28-41 with: HostNIC nic = nicsByNames.get("eth1.1345"); nic.setNetwork(null);
[1] https://motiasayag.wordpress.com/2014/02/24/invoke-setup-networks-from-the-j...
-- Thanks & Regards Tejesh
-- Thanks & Regards Tejesh

------=_Part_1906964_1663425406.1394535150113 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit ----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "Moti Asayag" <masayag@redhat.com> Cc: "users@oVirt.org" <users@ovirt.org> Sent: Tuesday, March 11, 2014 3:18:37 AM Subject: Re: Delete & Detach Logical Network
I tried below code, but still it is not detaching the network
HostNICs nicsApi = api.getHosts().get("venus-vdsb").getHostNics(); List<HostNIC> nics = nicsApi.list(); HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("bond1.1231"); //logical network network name is "testLNw" nic.setNetwork(null);
*Result of executing this line*: nicsApi.setupnetworks(createSetupNetworksParams(nics));
*Result:* code : 400 reason: Bad Request 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.
Can you post the complete code?
See example attached. You'll have to adjust the parameters to fit yours (hostName and modified nic).
On Mon, Mar 10, 2014 at 6:54 PM, Moti Asayag <masayag@redhat.com> wrote:
----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "Moti Asayag" <masayag@redhat.com>, "users@oVirt.org" < users@ovirt.org> Sent: Monday, March 10, 2014 1:22:08 PM Subject: Delete & Detach Logical Network
Hi,
I'm able to delete the logical network but this logical network after deletion shows as unmanaged network in "Setup Host Networks" against the hostnic.
I tried with this code to detach the logical network.
*Code 1:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action);
*Returns*: code : 409 reason: Conflict detail: Network Interface is not attached to Logical Network.
I can guess by the error message that the logical network 'rhevhost' is vlan, so the proper interface should be the vlan device.
*Code 2:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1.1345"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action);
*Returns*: code : 409 reason: Conflict detail: Cannot edit Network while Host is Active, change the Host to Maintenance mode and try again.
This is the 3.0 api which required the host to be in maintenance for network operations on the host. You could use setup networks instead which is the recommended api and doesn't require the host to be in maintenance.
you can modify the example from [1] and set null for the network name you wish to detach from the specific interface.
Try by replacing only lines 28-41 with: HostNIC nic = nicsByNames.get("eth1.1345"); nic.setNetwork(null);
[1] https://motiasayag.wordpress.com/2014/02/24/invoke-setup-networks-from-the-j...
-- Thanks & Regards Tejesh
-- Thanks & Regards Tejesh
------=_Part_1906964_1663425406.1394535150113 Content-Type: text/x-java; name=SetupNetworksDetachNetworkExample.java Content-Disposition: attachment; filename=SetupNetworksDetachNetworkExample.java Content-Transfer-Encoding: base64 cGFja2FnZSBvcmcub3ZpcnQudGVzdDsKCmltcG9ydCBqYXZhLnV0aWwuQ29sbGVjdGlvbnM7Cmlt cG9ydCBqYXZhLnV0aWwuSGFzaE1hcDsKaW1wb3J0IGphdmEudXRpbC5MaXN0OwppbXBvcnQgamF2 YS51dGlsLk1hcDsKCmltcG9ydCBvcmcub3ZpcnQuZW5naW5lLnNkay5BcGk7CmltcG9ydCBvcmcu b3ZpcnQuZW5naW5lLnNkay5kZWNvcmF0b3JzLkhvc3Q7CmltcG9ydCBvcmcub3ZpcnQuZW5naW5l LnNkay5kZWNvcmF0b3JzLkhvc3ROSUM7CmltcG9ydCBvcmcub3ZpcnQuZW5naW5lLnNkay5kZWNv cmF0b3JzLkhvc3ROSUNzOwppbXBvcnQgb3JnLm92aXJ0LmVuZ2luZS5zZGsuZW50aXRpZXMuQWN0 aW9uOwppbXBvcnQgb3JnLm92aXJ0LmVuZ2luZS5zZGsuZW50aXRpZXMuQmFzZVJlc291cmNlOwpp bXBvcnQgb3JnLm92aXJ0LmVuZ2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GljIHN0YXRpYyBB Y3Rpb24gY3JlYXRlU2V0dXBOZXR3b3Jrc1BhcmFtcyhMaXN0PEhvc3ROSUM+IG5pY3MpIHsKICAg ICAgICBBY3Rpb24gYWN0aW9uID0gbmV3IEFjdGlvbigpOwogICAgICAgIEhvc3ROaWNzIG5pY3NQ YXJhbXMgPSBuZXcgSG9zdE5pY3MoKTsKICAgICAgICBuaWNzUGFyYW1zLmdldEhvc3ROaWNzKCku YWRkQWxsKG5pY3MpOwogICAgICAgIGFjdGlvbi5zZXRIb3N0TmljcyhuaWNzUGFyYW1zKTsKICAg ICAgICBhY3Rpb24uc2V0Q2hlY2tDb25uZWN0aXZpdHkodHJ1ZSk7CiAgICAgICAgcmV0dXJuIGFj dGlvbjsKICAgIH0KCiAgICBwdWJsaWMgc3RhdGljIDxFIGV4dGVuZHMgQmFzZVJlc291cmNlPiBN YXA8U3RyaW5nLCBFPiBlbnRpdGllc0J5TmFtZShMaXN0PEU+IGVudGl0eUxpc3QpIHsKICAgICAg ICBpZiAoZW50aXR5TGlzdCAhPSBudWxsKSB7CiAgICAgICAgICAgIE1hcDxTdHJpbmcsIEU+IG1h cCA9IG5ldyBIYXNoTWFwPFN0cmluZywgRT4oKTsKICAgICAgICAgICAgZm9yIChFIGUgOiBlbnRp dHlMaXN0KSB7CiAgICAgICAgICAgICAgICBtYXAucHV0KGUuZ2V0TmFtZSgpLCBlKTsKICAgICAg ICAgICAgfQogICAgICAgICAgICByZXR1cm4gbWFwOwogICAgICAgIH0gZWxzZSB7CiAgICAgICAg ICAgIHJldHVybiBDb2xsZWN0aW9ucy5lbXB0eU1hcCgpOwogICAgICAgIH0KICAgIH0KfQoK ------=_Part_1906964_1663425406.1394535150113--

Managed to delete network which is attached to Bond with below code: HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("bond1.1231"); nic.delete(); But not able to delete the same when attached to ethernet: HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1.1187"); nic.delete(); i want to unmap the logical network which is mapped to eth1. *Result*: code : 400 reason: Bad Request detail: Invalid Bonding definition On Mon, Mar 10, 2014 at 6:54 PM, Moti Asayag <masayag@redhat.com> wrote:
----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "Moti Asayag" <masayag@redhat.com>, "users@oVirt.org" < users@ovirt.org> Sent: Monday, March 10, 2014 1:22:08 PM Subject: Delete & Detach Logical Network
Hi,
I'm able to delete the logical network but this logical network after deletion shows as unmanaged network in "Setup Host Networks" against the hostnic.
I tried with this code to detach the logical network.
*Code 1:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action);
*Returns*: code : 409 reason: Conflict detail: Network Interface is not attached to Logical Network.
I can guess by the error message that the logical network 'rhevhost' is vlan, so the proper interface should be the vlan device.
*Code 2:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1.1345"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action);
*Returns*: code : 409 reason: Conflict detail: Cannot edit Network while Host is Active, change the Host to Maintenance mode and try again.
This is the 3.0 api which required the host to be in maintenance for network operations on the host. You could use setup networks instead which is the recommended api and doesn't require the host to be in maintenance.
you can modify the example from [1] and set null for the network name you wish to detach from the specific interface.
Try by replacing only lines 28-41 with: HostNIC nic = nicsByNames.get("eth1.1345"); nic.setNetwork(null);
[1] https://motiasayag.wordpress.com/2014/02/24/invoke-setup-networks-from-the-j...
-- Thanks & Regards Tejesh
-- Thanks & Regards Tejesh

------=_Part_1908289_1895769.1394535474883 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit ----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "Moti Asayag" <masayag@redhat.com> Cc: "users@oVirt.org" <users@ovirt.org> Sent: Tuesday, March 11, 2014 8:53:15 AM Subject: Re: Delete & Detach Logical Network
Managed to delete network which is attached to Bond with below code:
HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("bond1.1231"); nic.delete();
But not able to delete the same when attached to ethernet:
HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1.1187"); nic.delete();
i want to unmap the logical network which is mapped to eth1.
For this specific case I'd suggest using the attached example.
*Result*: code : 400 reason: Bad Request detail: Invalid Bonding definition
On Mon, Mar 10, 2014 at 6:54 PM, Moti Asayag <masayag@redhat.com> wrote:
----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "Moti Asayag" <masayag@redhat.com>, "users@oVirt.org" < users@ovirt.org> Sent: Monday, March 10, 2014 1:22:08 PM Subject: Delete & Detach Logical Network
Hi,
I'm able to delete the logical network but this logical network after deletion shows as unmanaged network in "Setup Host Networks" against the hostnic.
I tried with this code to detach the logical network.
*Code 1:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action);
*Returns*: code : 409 reason: Conflict detail: Network Interface is not attached to Logical Network.
I can guess by the error message that the logical network 'rhevhost' is vlan, so the proper interface should be the vlan device.
*Code 2:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1.1345"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action);
*Returns*: code : 409 reason: Conflict detail: Cannot edit Network while Host is Active, change the Host to Maintenance mode and try again.
This is the 3.0 api which required the host to be in maintenance for network operations on the host. You could use setup networks instead which is the recommended api and doesn't require the host to be in maintenance.
you can modify the example from [1] and set null for the network name you wish to detach from the specific interface.
Try by replacing only lines 28-41 with: HostNIC nic = nicsByNames.get("eth1.1345"); nic.setNetwork(null);
[1] https://motiasayag.wordpress.com/2014/02/24/invoke-setup-networks-from-the-j...
-- Thanks & Regards Tejesh
-- Thanks & Regards Tejesh
------=_Part_1908289_1895769.1394535474883 Content-Type: text/x-java; name=SetupNetworksDetachNetworkExample.java Content-Disposition: attachment; filename=SetupNetworksDetachNetworkExample.java Content-Transfer-Encoding: base64 cGFja2FnZSBvcmcub3ZpcnQudGVzdDsKCmltcG9ydCBqYXZhLnV0aWwuQ29sbGVjdGlvbnM7Cmlt cG9ydCBqYXZhLnV0aWwuSGFzaE1hcDsKaW1wb3J0IGphdmEudXRpbC5MaXN0OwppbXBvcnQgamF2 YS51dGlsLk1hcDsKCmltcG9ydCBvcmcub3ZpcnQuZW5naW5lLnNkay5BcGk7CmltcG9ydCBvcmcu b3ZpcnQuZW5naW5lLnNkay5kZWNvcmF0b3JzLkhvc3Q7CmltcG9ydCBvcmcub3ZpcnQuZW5naW5l LnNkay5kZWNvcmF0b3JzLkhvc3ROSUM7CmltcG9ydCBvcmcub3ZpcnQuZW5naW5lLnNkay5kZWNv cmF0b3JzLkhvc3ROSUNzOwppbXBvcnQgb3JnLm92aXJ0LmVuZ2luZS5zZGsuZW50aXRpZXMuQWN0 aW9uOwppbXBvcnQgb3JnLm92aXJ0LmVuZ2luZS5zZGsuZW50aXRpZXMuQmFzZVJlc291cmNlOwpp bXBvcnQgb3JnLm92aXJ0LmVuZ2luZS5zZGsuZW50aXRpZXMuSG9zdE5pY3M7CgpwdWJsaWMgY2xh c3MgU2V0dXBOZXR3b3Jrc0RldGFjaE5ldHdvcmtFeGFtcGxlIHsKCiAgICBwdWJsaWMgc3RhdGlj IHZvaWQgbWFpbihTdHJpbmdbXSBhcmdzKSB0aHJvd3MgRXhjZXB0aW9uIHsKCiAgICAgICAgdHJ5 IChBcGkgYXBpID0gbmV3IEFwaSgiaHR0cDovL2xvY2FsaG9zdDo4MDgwL2FwaSIsCiAgICAgICAg ICAgICAgICAiYWRtaW5AaW50ZXJuYWwiLAogICAgICAgICAgICAgICAgIjEiLAogICAgICAgICAg ICAgICAgbnVsbCwgbnVsbCwgbnVsbCwgbnVsbCwgbnVsbCwgbnVsbCwgdHJ1ZSkpIHsKCiAgICAg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0cmluZywgRT4gZW50aXRpZXNCeU5hbWUoTGlzdDxF PiBlbnRpdHlMaXN0KSB7CiAgICAgICAgaWYgKGVudGl0eUxpc3QgIT0gbnVsbCkgewogICAgICAg ICAgICBNYXA8U3RyaW5nLCBFPiBtYXAgPSBuZXcgSGFzaE1hcDxTdHJpbmcsIEU+KCk7CiAgICAg ICAgICAgIGZvciAoRSBlIDogZW50aXR5TGlzdCkgewogICAgICAgICAgICAgICAgbWFwLnB1dChl LmdldE5hbWUoKSwgZSk7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgcmV0dXJuIG1hcDsKICAg ICAgICB9IGVsc2UgewogICAgICAgICAgICByZXR1cm4gQ29sbGVjdGlvbnMuZW1wdHlNYXAoKTsK ICAgICAgICB9CiAgICB9Cn0KCg== ------=_Part_1908289_1895769.1394535474883--

Thanks Moti. On Tue, Mar 11, 2014 at 4:27 PM, Moti Asayag <masayag@redhat.com> wrote:
----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "Moti Asayag" <masayag@redhat.com> Cc: "users@oVirt.org" <users@ovirt.org> Sent: Tuesday, March 11, 2014 8:53:15 AM Subject: Re: Delete & Detach Logical Network
Managed to delete network which is attached to Bond with below code:
HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("bond1.1231"); nic.delete();
But not able to delete the same when attached to ethernet:
HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1.1187"); nic.delete();
i want to unmap the logical network which is mapped to eth1.
For this specific case I'd suggest using the attached example.
*Result*: code : 400 reason: Bad Request detail: Invalid Bonding definition
On Mon, Mar 10, 2014 at 6:54 PM, Moti Asayag <masayag@redhat.com> wrote:
----- Original Message -----
From: "Tejesh M" <tejeshmk@gmail.com> To: "Moti Asayag" <masayag@redhat.com>, "users@oVirt.org" < users@ovirt.org> Sent: Monday, March 10, 2014 1:22:08 PM Subject: Delete & Detach Logical Network
Hi,
I'm able to delete the logical network but this logical network after deletion shows as unmanaged network in "Setup Host Networks" against
hostnic.
I tried with this code to detach the logical network.
*Code 1:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action);
*Returns*: code : 409 reason: Conflict detail: Network Interface is not attached to Logical Network.
I can guess by the error message that the logical network 'rhevhost' is vlan, so the proper interface should be the vlan device.
*Code 2:* HostNIC nic = api.getHosts().get("rhevhost").getHostNics().get("eth1.1345"); Action action = new Action(); action.setNetwork(api.getNetworks().get(nw_name)); action.setDetach(true); action.setCheckConnectivity(false); nic.detach(action);
*Returns*: code : 409 reason: Conflict detail: Cannot edit Network while Host is Active, change the Host to Maintenance mode and try again.
This is the 3.0 api which required the host to be in maintenance for network operations on the host. You could use setup networks instead which is
the the
recommended api and doesn't require the host to be in maintenance.
you can modify the example from [1] and set null for the network name you wish to detach from the specific interface.
Try by replacing only lines 28-41 with: HostNIC nic = nicsByNames.get("eth1.1345"); nic.setNetwork(null);
[1]
https://motiasayag.wordpress.com/2014/02/24/invoke-setup-networks-from-the-j...
-- Thanks & Regards Tejesh
-- Thanks & Regards Tejesh
-- Thanks & Regards Tejesh
participants (2)
-
Moti Asayag
-
Tejesh M