Hi, I found a way to update property in setup network as shown below
# Get the reference to the hosts service: hosts_service = connection.system_service().hosts_service() myhost = hosts_service.list(search='name=myhost')[0] myhost_service = hosts_service.host_service(myhost.id) mynet_attached_services = myhost_service.network_attachments_service() for mynet_attachment in mynet_attached_services.list(): if mynet_attachment.network.name == "mynet": print "Found : %s"%(mynet_attachment.network.name) mynet_attached_services.attachment_service(mynet_attachment.id).update( attachment=types.NetworkAttachment( properties=[types.Property("ovs","1")] ) ) else: print "Not Found : %s"%(mynet_attachment.network.name) Please find below ovs output. # ovs-vsctl show Bridge "vdsmbr_tJ9jxY5o" Port "em2" Interface "em2" Port "vdsmbr_tJ9jxY5o" Interface "vdsmbr_tJ9jxY5o" type: internal Port mynet Interface mynet type: internal ovs_version: "2.4.0" But ovirt is showing me "out-of-sync" message. *Can someone explain me why it shown as out-of-sync ?* *How ovirt determine sync on logical network ?* Thanks, ~Rohit On Mon, Dec 26, 2016 at 7:04 PM, TranceWorldLogic . < tranceworldlo...@gmail.com> wrote: > Hi, > > Thanks for providing script it is working fine. > > But it not complete, would you help me to complete step 2 ? > > https://www.ovirt.org/networking/ovs/ > Setup network > > 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. > > > And have one doubt. > > Why we have to set ovs property two time ? > > > Thanks, > ~Rohit > > > On Tue, Dec 20, 2016 at 7:44 PM, Juan Hernández <jhern...@redhat.com> > wrote: > >> On 12/20/2016 02:19 PM, TranceWorldLogic . wrote: >> > Hi, >> > >> > I am trying to setup OVS network using ovirt and found guide as shown >> below: >> > https://www.ovirt.org/networking/ovs/ >> > >> > Then, I tried to explore "vNic Profile" in sdk but not found any ovs >> > profile in types.py. >> > Can anyone help me how to setup ovs using python sdk ? >> > I am using ovirtsdk4 (4.0 version). >> > >> >> Should be something like this: >> >> ---8<--- >> #!/usr/bin/env python >> # -*- coding: utf-8 -*- >> >> # >> # Copyright (c) 2016 Red Hat, Inc. >> # >> # Licensed under the Apache License, Version 2.0 (the "License"); >> # you may not use this file except in compliance with the License. >> # You may obtain a copy of the License at >> # >> # http://www.apache.org/licenses/LICENSE-2.0 >> # >> # Unless required by applicable law or agreed to in writing, software >> # distributed under the License is distributed on an "AS IS" BASIS, >> # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. >> # See the License for the specific language governing permissions and >> # limitations under the License. >> # >> >> import logging >> >> import ovirtsdk4 as sdk >> import ovirtsdk4.types as types >> >> logging.basicConfig(level=logging.DEBUG, filename='example.log') >> >> # This example will connect to the server and create a logical network >> # that using Open vSwitch. Note that in order for this to work the >> # engine has to be configured to use Open vSwitch, as described here: >> # >> # https://www.ovirt.org/networking/ovs >> # >> # Specifcally you need to run the following commands in the machine >> # where the engine is running: >> # >> # engine-config -s CustomDeviceProperties="{type= >> interface;prop={ovs=.*}}" >> # engine-config -s >> 'UserDefinedNetworkCustomProperties=ovs=.*;ovs_aa_sid=.*' >> # systemctl restart ovirt-engine >> >> # Create the connection to the server: >> connection = sdk.Connection( >> url='https://engine41.example.com/ovirt-engine/api', >> username='admin@internal', >> password='redhat123', >> ca_file='ca.pem', >> debug=True, >> log=logging.getLogger(), >> ) >> >> # Get the reference to the root of the tree of services: >> system_service = connection.system_service() >> >> # Get the reference to the service that manages the logical networks: >> nets_service = system_service.networks_service() >> >> # Create a logical network, which will automatically create a virtual >> # NIC profile: >> net = nets_service.add( >> network=types.Network( >> name='myovsnetwork', >> data_center=types.DataCenter( >> name='mydc' >> ) >> ) >> ) >> >> # Retrieve the details of the virtual NIC profile that was created for >> # the network (assuming that there is only one): >> profile = connection.follow_link(net.vnic_profiles)[0] >> >> # Get the reference to the service that manages the virtual NIC profile: >> profiles_service = system_service.vnic_profiles_service() >> profile_service = profiles_service.profile_service(profile.id) >> >> # Update the custom properties of the virtual NIC profile in order to >> # enable Open vSwitch: >> profile_service.update( >> profile=types.VnicProfile( >> custom_properties=[ >> types.CustomProperty( >> name='ovs', >> value='true' >> ) >> ] >> ) >> ) >> >> # Close the connection to the server: >> connection.close() >> --->8--- >> >> Note that it isn't complete, and that I didn't test if the OVS network >> does work. But at least the creation of the network and the modification >> of the VNIC profile does work. >> >> I am suggesting to add this to the collection of examples of the SDK: >> >> Add example of how to create OVS network >> https://gerrit.ovirt.org/68825 >> >> You may want to review it. >> >> >
_______________________________________________ Users mailing list Users@ovirt.org http://lists.ovirt.org/mailman/listinfo/users