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

Bug 1511369

Summary: REST: add external network provider by name
Product: [oVirt] ovirt-engine Reporter: Nelly Credi <ncredi>
Component: RestAPIAssignee: Dominik Holler <dholler>
Status: CLOSED CURRENTRELEASE QA Contact: Mor <mkalfon>
Severity: medium Docs Contact:
Priority: medium    
Version: 4.2.0CC: bugs, danken, juan.hernandez, lsvaty, myakove, omachace
Target Milestone: ovirt-4.2.1Keywords: Automation
Target Release: ---Flags: rule-engine: ovirt-4.2+
ykaul: blocker-
lsvaty: testing_ack+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: upstream 4.2.1 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-02-12 11:47:24 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:

Description Nelly Credi 2017-11-09 09:05:59 UTC
Description of problem:
External network provider is not added while adding cluster

Version-Release number of selected component (if applicable):
External network provider is not added while adding cluster

How reproducible:
100%

Steps to Reproduce:
1. add cluster via rest
<cluster>
  <name>mycluster</name>
  <cpu>
    <type>Intel Penryn Family</type>
  </cpu>
  <data_center id="123"/>
  <external_network_providers>
    <external_provider name="ovirt-provider-ovn"/>
  </external_network_providers>
</cluster>
2.
3.

Actual results:
rest returns 200


    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <cluster href="/ovirt-engine/api/clusters/76e90824-5ccb-4e46-bae2-e6d099e00fc9" id="76e90824-5ccb-4e46-bae2-e6d099e00fc9">
        <actions>
            <link href="/ovirt-engine/api/clusters/76e90824-5ccb-4e46-bae2-e6d099e00fc9/resetemulatedmachine" rel="resetemulatedmachine"/>
        </actions>
        <name>mycluster</name>
        <link href="/ovirt-engine/api/clusters/76e90824-5ccb-4e46-bae2-e6d099e00fc9/glustervolumes" rel="glustervolumes"/>
        <link href="/ovirt-engine/api/clusters/76e90824-5ccb-4e46-bae2-e6d099e00fc9/enabledfeatures" rel="enabledfeatures"/>
        <link href="/ovirt-engine/api/clusters/76e90824-5ccb-4e46-bae2-e6d099e00fc9/externalnetworkproviders" rel="externalnetworkproviders"/>
        <link href="/ovirt-engine/api/clusters/76e90824-5ccb-4e46-bae2-e6d099e00fc9/networkfilters" rel="networkfilters"/>
        <link href="/ovirt-engine/api/clusters/76e90824-5ccb-4e46-bae2-e6d099e00fc9/networks" rel="networks"/>
        <link href="/ovirt-engine/api/clusters/76e90824-5ccb-4e46-bae2-e6d099e00fc9/permissions" rel="permissions"/>
        <link href="/ovirt-engine/api/clusters/76e90824-5ccb-4e46-bae2-e6d099e00fc9/cpuprofiles" rel="cpuprofiles"/>
        <link href="/ovirt-engine/api/clusters/76e90824-5ccb-4e46-bae2-e6d099e00fc9/affinitygroups" rel="affinitygroups"/>
        <link href="/ovirt-engine/api/clusters/76e90824-5ccb-4e46-bae2-e6d099e00fc9/glusterhooks" rel="glusterhooks"/>
        <ballooning_enabled>false</ballooning_enabled>
        <cpu>
            <architecture>x86_64</architecture>
            <type>Intel Penryn Family</type>
        </cpu>
        <custom_scheduling_policy_properties>
            <property>
                <name>HighUtilization</name>
                <value>80</value>
            </property>
            <property>
                <name>CpuOverCommitDurationMinutes</name>
                <value>2</value>
            </property>
        </custom_scheduling_policy_properties>
        <error_handling>
            <on_error>migrate</on_error>
        </error_handling>
        <fencing_policy>
            <enabled>true</enabled>
            <skip_if_connectivity_broken>
                <enabled>false</enabled>
                <threshold>50</threshold>
            </skip_if_connectivity_broken>
            <skip_if_gluster_bricks_up>false</skip_if_gluster_bricks_up>
            <skip_if_gluster_quorum_not_met>false</skip_if_gluster_quorum_not_met>
            <skip_if_sd_active>
                <enabled>false</enabled>
            </skip_if_sd_active>
        </fencing_policy>
        <firewall_type>firewalld</firewall_type>
        <gluster_service>false</gluster_service>
        <ha_reservation>false</ha_reservation>
        <ksm>
            <enabled>false</enabled>
            <merge_across_nodes>true</merge_across_nodes>
        </ksm>
        <maintenance_reason_required>false</maintenance_reason_required>
        <memory_policy>
            <over_commit>
                <percent>100</percent>
            </over_commit>
            <transparent_hugepages>
                <enabled>false</enabled>
            </transparent_hugepages>
        </memory_policy>
        <migration>
            <auto_converge>inherit</auto_converge>
            <bandwidth>
                <assignment_method>auto</assignment_method>
            </bandwidth>
            <compressed>inherit</compressed>
        </migration>
        <optional_reason>false</optional_reason>
        <required_rng_sources>
            <required_rng_source>urandom</required_rng_source>
        </required_rng_sources>
        <switch_type>legacy</switch_type>
        <threads_as_cores>false</threads_as_cores>
        <trusted_service>false</trusted_service>
        <tunnel_migration>false</tunnel_migration>
        <version>
            <major>4</major>
            <minor>2</minor>
        </version>
        <virt_service>true</virt_service>
        <data_center href="/ovirt-engine/api/datacenters/7bf6dc7b-3580-427e-8a9a-07a46f2b9002" id="7bf6dc7b-3580-427e-8a9a-07a46f2b9002"/>
        <mac_pool href="/ovirt-engine/api/macpools/58ca604b-017d-0374-0220-00000000014e" id="58ca604b-017d-0374-0220-00000000014e"/>
        <management_network href="/ovirt-engine/api/clusters/76e90824-5ccb-4e46-bae2-e6d099e00fc9/networks/9144960c-f538-4018-b085-d7f521202bd1" id="9144960c-f538-4018-b085-d7f521202bd1"/>
        <scheduling_policy href="/ovirt-engine/api/schedulingpolicies/b4ed2332-a7ac-4d5f-9596-99a439cb2812" id="b4ed2332-a7ac-4d5f-9596-99a439cb2812"/>
    </cluster>
     
BUT in the UI cluster edit shows that it is not set
and in REST:
https://ENGINE/ovirt-engine/api/clusters/123/externalnetworkproviders gives an empty value
<external_providers/>

Expected results:
external network provider should be set

Additional info:

Comment 1 Juan Hernández 2017-11-09 11:17:20 UTC
Currently adding the network provider when adding a cluster requires using the `id` attribute, as described here:

  http://ovirt.github.io/ovirt-engine-api-model/4.2/#services/clusters/methods/add

So your request should be like this:

  <cluster>
    <name>mycluster</name>
    <cpu>
      <type>Intel Penryn Family</type>
    </cpu>
    <data_center id="123"/>
    <external_network_providers>
      <external_provider id="123"/>
    </external_network_providers>
  </cluster>

(Replace `123` with the identifier of the network provider.)

As there is a way to do it, I am lowering the priority. Please check that it works correctly.

Specifying the network provider by name isn't currently implemented. Would be nice to do it. In that case you request would be like this:

  <cluster>
    <name>mycluster</name>
    <cpu>
      <type>Intel Penryn Family</type>
    </cpu>
    <data_center id="123"/>
    <external_network_providers>
      <external_provider>
        <name>ovirt-provider-ovn</name>
      </external_provider>
    </external_network_providers>
  </cluster>

Dan, I'd suggest to keep this bug open if you plan to implement add by name.

Comment 2 Juan Hernández 2017-11-09 11:18:10 UTC
Also, please remove the blocker+ flag if adding by id works correctly.

Comment 3 Dan Kenigsberg 2017-11-12 08:40:18 UTC
Nelly told me in person that this is required for Ansible, where the cluster id is not readily available.

Comment 4 Nelly Credi 2017-11-13 07:44:56 UTC
I actually found a W/A for it.
But it means that Ansible doesnt work as expected, 
so if it not going to be fixed soon, maybe the ansible module should at least indicate that it is not working (when using name, ansible seems to work - no failure, but it actually doesnt set the value)

Comment 5 Dominik Holler 2017-11-14 12:33:45 UTC
I just want to highlight that ansible works like documented in https://github.com/ansible/ansible/blob/devel/lib/ansible/modules/cloud/ovirt/ovirt_cluster.py#L272 , but the ovirt ansible role does not yet support external_network_providers, as documented in https://github.com/oVirt/ovirt-ansible/tree/master/roles/ovirt-clusters . I will extend the ovirt ansible role to support external_network_providers.
Nevertheless, it might be nice to have the possibility to add an external network provider by name.

Comment 6 Nelly Credi 2017-11-14 12:52:15 UTC
Thanks Dominik,
Im lowering the priority as it seems that we shouldnt use this functionality yet, as 4.2 is supporting ansible 2.4 atm and this was added to ansible master.

We will update the cluster in the tests, to be able to test the feature
Still, I would like to see the possibility added to rest

Comment 7 Mor 2018-01-09 12:05:45 UTC
Verified on:
RHV 4.2.1-0.2.el7

The API doc is on https://<SERVER_FQDN>/ovirt-engine/apidoc/#/services/clusters/methods/add is misleading. 

The following request body works:

<cluster>
  <name>mycluster</name>
  <cpu>
    <type>Intel Penryn Family</type>
  </cpu>
  <data_center id="<DC_ID>"/>
   <external_network_providers>
     <external_provider>
       <name>ovirt-provider-ovn</name>
     </external_provider>
    </external_network_providers>
</cluster>

Comment 8 Sandro Bonazzola 2018-02-12 11:47:24 UTC
This bugzilla is included in oVirt 4.2.1 release, published on Feb 12th 2018.

Since the problem described in this bug report should be
resolved in oVirt 4.2.1 release, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.