<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='name=myhost')[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> == "mynet":<br> print "Found : %s"%(<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("ovs","1")] ) )<br> else:<br> print "Not Found : %s"%(<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 "vdsmbr_tJ9jxY5o"<br> Port "em2"<br> Interface "em2"<br> Port "vdsmbr_tJ9jxY5o"<br> Interface "vdsmbr_tJ9jxY5o"<br> type: internal<br> Port mynet<br> Interface mynet<br> type: internal<br> ovs_version: "2.4.0"<br><br><br></div>But ovirt is showing me "out-of-sync" 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"><<a href="mailto:tranceworldlogic@gmail.com" target="_blank">tranceworldlogic@gmail.com</a>></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 'Setup Host Networks' dialog. Proceed to
editing a desired logical network's properties. Among them you will find
'ovs', set it to 'true' or '1' 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"><<a href="mailto:jhernand@redhat.com" target="_blank">jhernand@redhat.com</a>></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>
> Hi,<br>
><br>
> I am trying to setup OVS network using ovirt and found guide as shown below:<br>
> <a href="https://www.ovirt.org/networking/ovs/" rel="noreferrer" target="_blank">https://www.ovirt.org/networki<wbr>ng/ovs/</a><br>
><br>
> Then, I tried to explore "vNic Profile" in sdk but not found any ovs<br>
> profile in types.py.<br>
> Can anyone help me how to setup ovs using python sdk ?<br>
> I am using ovirtsdk4 (4.0 version).<br>
><br>
<br>
</span>Should be something like this:<br>
<br>
---8<---<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 "License");<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 "AS IS" 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='example.log')<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="{type=<wbr>interface;prop={ovs=.*}}"<br>
# engine-config -s<br>
'UserDefinedNetworkCustomPrope<wbr>rties=ovs=.*;ovs_aa_sid=.*'<br>
# systemctl restart ovirt-engine<br>
<br>
# Create the connection to the server:<br>
connection = sdk.Connection(<br>
url='<a href="https://engine41.example.com/ovirt-engine/api" rel="noreferrer" target="_blank">https://engine41.example.<wbr>com/ovirt-engine/api</a>',<br>
username='admin@internal',<br>
password='redhat123',<br>
ca_file='ca.pem',<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='myovsnetwork',<br>
data_center=types.DataCenter(<br>
name='mydc'<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='ovs',<br>
value='true'<br>
)<br>
]<br>
)<br>
)<br>
<br>
# Close the connection to the server:<br>
connection.close()<br>
--->8---<br>
<br>
Note that it isn't complete, and that I didn'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>