Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1647912

Summary: Using 'setupnetworks' restapi call to update an existing network attachment does not work
Product: [oVirt] ovirt-engine Reporter: Miguel Martin <mmartinv>
Component: RestAPIAssignee: Dominik Holler <dholler>
Status: CLOSED CURRENTRELEASE QA Contact: msheena
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.2.6CC: bugs
Target Milestone: ovirt-4.3.0Flags: rule-engine: ovirt-4.3+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ovirt-engine-4.3.0_rc Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
: 1647928 (view as bug list) Environment:
Last Closed: 2019-01-08 11:16:39 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Network RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 1647928    

Description Miguel Martin 2018-11-08 14:26:58 UTC
Description of problem:

According to [1] a network attachment within a host can be created, modified and removed using the corresponding tags:

Create or modify -> <modified_network_attachments> 
Remove: -> <removed_network_attachments>

However it doesn't work when modifying or removing an existing network attachment.

[1] http://ovirt.github.io/ovirt-engine-api-model/4.2/#services/host/methods/setup_networks

Version-Release number of selected component (if applicable):
4.2

How reproducible:
Always

Steps to Reproduce:
1. Create a network and bind it to an interface as described at [1]:
~~~
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<action>
  <modified_network_attachments>
    <network_attachment>
      <network>
        <name>mynetwork</name>
      </network>
      <host_nic>
        <name>eth0</name>
      </host_nic>
    </network_attachment>
  </modified_network_attachments>
</action>
~~~

2. Try to modify the network to bind it to another interface:
~~~
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<action>
  <modified_network_attachments>
    <network_attachment>
      <network>
        <name>mynetwork</name>
      </network>
      <host_nic>
        <name>eth1</name>
      </host_nic>
    </network_attachment>
  </modified_network_attachments>
</action>
~~~

3. Or try to remove the network attachment:
~~~
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<action>
  <removed_network_attachments>
    <network_attachment>
      <network>
        <name>mynetwork</name>
      </network>
      <host_nic>
        <name>eth0</name>
      </host_nic>
    </network_attachment>
  </removed_network_attachments>
</action>
~~~

Actual results:

The network attachment cannot be modified failing with:
~~~
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<fault>
    <detail>[Cannot setup Networks. Network mynetwork is already attached via attachment 11111111-1111-1111-111111111111. A new attachment cannot be used for the same network, please reuse the existing one.]</detail>
    <reason>Operation Failed</reason>
</fault>

~~~

The network attachment cannot be removed failing with:
~~~
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<fault>
    <detail>[Cannot setup Networks. Cannot remove following Network Attachments, because they do not exist: 	null.]</detail>
    <reason>Operation Failed</reason>
</fault>
~~~

Expected results:

The network attachment successfuly modified or removed.

Additional info:

It's only possible to modify or remove a network attachment if it is referenced by ID.
The below examples would work.

To modify the network attachment:
~~~
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<action>
  <modified_network_attachments>
    <network_attachment id="11111111-1111-1111-111111111111">
      <network>
        <name>mynetwork</name>
      </network>
      <host_nic>
        <name>eth1</name>
      </host_nic>
    </network_attachment>
  </modified_network_attachments>
</action>
~~~

To remove the network attachment:
~~~
<action>
  <modified_network_attachments>
    <network_attachment id="11111111-1111-1111-111111111111"/>
  </modified_network_attachments>
</action>
~~~

Comment 1 Ondra Machacek 2018-11-08 14:37:23 UTC
I think we should improve the documentation to explicitly say that it's supported only with ID and add examples how to do so.

Comment 2 Dominik Holler 2019-01-08 11:16:39 UTC
see bug 1647928