<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/">https://www.ovirt.org/networking/ovs/</a><br><h3 id="gmail-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="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 class="">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/<wbr>networking/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/<wbr>licenses/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=<wbr>logging.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/<wbr>networking/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>
'<wbr>UserDefinedNetworkCustomProper<wbr>ties=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_<wbr>service()<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.<wbr>vnic_profiles)[0]<br>
<br>
# Get the reference to the service that manages the virtual NIC profile:<br>
profiles_service = system_service.vnic_profiles_<wbr>service()<br>
profile_service = profiles_service.profile_<wbr>service(<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>