<div dir="ltr"><div><div><div><div><div>Hi,<br><br></div>I found a way to update property in setup network as shown below<br><br># Get the reference to the hosts service:<br>hosts_service = connection.system_service().hosts_service()<br>myhost = hosts_service.list(search=&#39;name=myhost&#39;)[0]<br><br>myhost_service = hosts_service.host_service(<a href="http://myhost.id">myhost.id</a>)<br>mynet_attached_services = myhost_service.network_attachments_service()<br><br>for mynet_attachment in mynet_attached_services.list():<br>    if <a href="http://mynet_attachment.network.name">mynet_attachment.network.name</a> == &quot;mynet&quot;:<br>        print &quot;Found : %s&quot;%(<a href="http://mynet_attachment.network.name">mynet_attachment.network.name</a>)<br>        mynet_attached_services.attachment_service(<a href="http://mynet_attachment.id">mynet_attachment.id</a>).update( attachment=types.NetworkAttachment( properties=[types.Property(&quot;ovs&quot;,&quot;1&quot;)] ) )<br>    else:<br>        print &quot;Not Found : %s&quot;%(<a href="http://mynet_attachment.network.name">mynet_attachment.network.name</a>)<br><br>Please find below ovs output. <br># ovs-vsctl show<br>    Bridge &quot;vdsmbr_tJ9jxY5o&quot;<br>        Port &quot;em2&quot;<br>            Interface &quot;em2&quot;<br>        Port &quot;vdsmbr_tJ9jxY5o&quot;<br>            Interface &quot;vdsmbr_tJ9jxY5o&quot;<br>                type: internal<br>        Port mynet<br>            Interface mynet<br>                type: internal<br>    ovs_version: &quot;2.4.0&quot;<br><br><br></div>But ovirt is showing me &quot;out-of-sync&quot; message. <br></div><b>Can someone explain me why it shown as out-of-sync ?<br></b></div><div><b>How ovirt determine sync on logical network ?</b><br></div><div><br></div><div><br></div>Thanks,<br></div>~Rohit<br><div><div><div><br><br></div></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Dec 26, 2016 at 7:04 PM, TranceWorldLogic . <span dir="ltr">&lt;<a href="mailto:tranceworldlogic@gmail.com" target="_blank">tranceworldlogic@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div>Hi,<br><br></div>Thanks for providing script it is working fine.<br><br></div>But it not complete, would you help me to complete step 2 ?<br><br><a href="https://www.ovirt.org/networking/ovs/" target="_blank">https://www.ovirt.org/<wbr>networking/ovs/</a><br><h3 id="m_-2054494525990005442gmail-setup-network">Setup network</h3>

<p>In the oVirt UI open the &#39;Setup Host Networks&#39; dialog. Proceed to 
editing a desired logical network&#39;s properties. Among them you will find
 &#39;ovs&#39;, set it to &#39;true&#39; or &#39;1&#39; to mark is as a OVS Network.</p><p><br></p><p>And have one doubt.<br></p><p>Why we have to set ovs property two time ?</p><p><br></p>Thanks,<br></div>~Rohit<br><div><div><br></div></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 20, 2016 at 7:44 PM, Juan Hernández <span dir="ltr">&lt;<a href="mailto:jhernand@redhat.com" target="_blank">jhernand@redhat.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 12/20/2016 02:19 PM, TranceWorldLogic . wrote:<br>
&gt; Hi,<br>
&gt;<br>
&gt; I am trying to setup OVS network using ovirt and found guide as shown below:<br>
&gt; <a href="https://www.ovirt.org/networking/ovs/" rel="noreferrer" target="_blank">https://www.ovirt.org/networki<wbr>ng/ovs/</a><br>
&gt;<br>
&gt; Then, I tried to explore &quot;vNic Profile&quot; in sdk but not found any ovs<br>
&gt; profile in types.py.<br>
&gt; Can anyone help me how to setup ovs using python sdk ?<br>
&gt; I am using ovirtsdk4 (4.0 version).<br>
&gt;<br>
<br>
</span>Should be something like this:<br>
<br>
---8&lt;---<br>
#!/usr/bin/env python<br>
# -*- coding: utf-8 -*-<br>
<br>
#<br>
# Copyright (c) 2016 Red Hat, Inc.<br>
#<br>
# Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);<br>
# you may not use this file except in compliance with the License.<br>
# You may obtain a copy of the License at<br>
#<br>
#   <a href="http://www.apache.org/licenses/LICENSE-2.0" rel="noreferrer" target="_blank">http://www.apache.org/license<wbr>s/LICENSE-2.0</a><br>
#<br>
# Unless required by applicable law or agreed to in writing, software<br>
# distributed under the License is distributed on an &quot;AS IS&quot; BASIS,<br>
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.<br>
# See the License for the specific language governing permissions and<br>
# limitations under the License.<br>
#<br>
<br>
import logging<br>
<br>
import ovirtsdk4 as sdk<br>
import ovirtsdk4.types as types<br>
<br>
logging.basicConfig(level=logg<wbr>ing.DEBUG, filename=&#39;example.log&#39;)<br>
<br>
# This example will connect to the server and create a logical network<br>
# that using Open vSwitch. Note that in order for this to work the<br>
# engine has to be configured to use Open vSwitch, as described here:<br>
#<br>
#   <a href="https://www.ovirt.org/networking/ovs" rel="noreferrer" target="_blank">https://www.ovirt.org/network<wbr>ing/ovs</a><br>
#<br>
# Specifcally you need to run the following commands in the machine<br>
# where the engine is running:<br>
#<br>
#   engine-config -s CustomDeviceProperties=&quot;{type=<wbr>interface;prop={ovs=.*}}&quot;<br>
#   engine-config -s<br>
&#39;UserDefinedNetworkCustomPrope<wbr>rties=ovs=.*;ovs_aa_sid=.*&#39;<br>
#   systemctl restart ovirt-engine<br>
<br>
# Create the connection to the server:<br>
connection = sdk.Connection(<br>
    url=&#39;<a href="https://engine41.example.com/ovirt-engine/api" rel="noreferrer" target="_blank">https://engine41.example.<wbr>com/ovirt-engine/api</a>&#39;,<br>
    username=&#39;admin@internal&#39;,<br>
    password=&#39;redhat123&#39;,<br>
    ca_file=&#39;ca.pem&#39;,<br>
    debug=True,<br>
    log=logging.getLogger(),<br>
)<br>
<br>
# Get the reference to the root of the tree of services:<br>
system_service = connection.system_service()<br>
<br>
# Get the reference to the service that manages the logical networks:<br>
nets_service = system_service.networks_servic<wbr>e()<br>
<br>
# Create a logical network, which will automatically create a virtual<br>
# NIC profile:<br>
net = nets_service.add(<br>
    network=types.Network(<br>
        name=&#39;myovsnetwork&#39;,<br>
        data_center=types.DataCenter(<br>
            name=&#39;mydc&#39;<br>
        )<br>
    )<br>
)<br>
<br>
# Retrieve the details of the virtual NIC profile that was created for<br>
# the network (assuming that there is only one):<br>
profile = connection.follow_link(net.vni<wbr>c_profiles)[0]<br>
<br>
# Get the reference to the service that manages the virtual NIC profile:<br>
profiles_service = system_service.vnic_profiles_s<wbr>ervice()<br>
profile_service = profiles_service.profile_servi<wbr>ce(<a href="http://profile.id" rel="noreferrer" target="_blank">profile.id</a>)<br>
<br>
# Update the custom properties of the virtual NIC profile in order to<br>
# enable Open vSwitch:<br>
profile_service.update(<br>
    profile=types.VnicProfile(<br>
        custom_properties=[<br>
            types.CustomProperty(<br>
                name=&#39;ovs&#39;,<br>
                value=&#39;true&#39;<br>
            )<br>
        ]<br>
    )<br>
)<br>
<br>
# Close the connection to the server:<br>
connection.close()<br>
---&gt;8---<br>
<br>
Note that it isn&#39;t complete, and that I didn&#39;t test if the OVS network<br>
does work. But at least the creation of the network and the modification<br>
of the VNIC profile does work.<br>
<br>
I am suggesting to add this to the collection of examples of the SDK:<br>
<br>
  Add example of how to create OVS network<br>
  <a href="https://gerrit.ovirt.org/68825" rel="noreferrer" target="_blank">https://gerrit.ovirt.org/68825</a><br>
<br>
You may want to review it.<br>
<br>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>