Thanks again. I will check it out in more detail. I have looked at it, but some things wasn't that clear Most stuff in the SDK I have working, but I get stumped sometimes.
Regards, Don On Mon, Feb 25, 2019 at 11:21 PM Joey Ma <[email protected]> wrote: > Hi Don, > > So glad to see it worked. If you want to know more about how to use the > Python SDK, the official documentation > http://ovirt.github.io/ovirt-engine-sdk/ would introduce you the detailed > guidance. > > If you have any other questions, please feel free to post here. > > Regards, > Joey > > On Tue, Feb 26, 2019 at 12:50 PM Don Dupuis <[email protected]> wrote: > >> Joey >> >> That WORKED just great. I am still trying to understand the >> services/service stuff. I was trying something similar earlier, but I was >> using >> connection.system_service().vnic_profiles_service().vnic_profile_service(), >> I understand now from your code on what is going on and why was going down >> the wrong road. >> >> Thanks again for your help >> >> Don >> >> On Mon, Feb 25, 2019 at 10:24 PM Joey Ma <[email protected]> wrote: >> >>> >>> On Tue, Feb 26, 2019 at 1:00 AM Don Dupuis <[email protected]> wrote: >>> >>>> Joey >>>> I am still not quite getting it. I am trying the below code and where >>>> it is commented out, I have tried different things, but I am no table to >>>> update the name of the object that I have found. >>>> >>>> networks_service = connection.system_service().networks_service() >>>> network = networks_service.list( >>>> search='name=ovirtmgmt and datacenter=%s-local' % HOSTNAME) [0] >>>> print ("Network name is %s" % network.name) >>>> print ("Network id is %s" % network.id) >>>> vnics = connection.follow_link(network.vnic_profiles) >>>> #vnicsprofile_service = >>>> connection.system_service().vnic_profile_service() >>>> #vnicprofile_service = vnic_profiles_service.vnic_profile_service( >>>> vnics.id) >>>> >>> >>> Hi Don, >>> >>> The var `vnics` is actually a List, so the statement `vnics.id` would >>> produce errors. >>> >>> The following codes could successfully update the name of a vnicprofile, >>> probably meets your needs. >>> >>> ```python >>> vnics = connection.follow_link(network.vnic_profiles) >>> >>> # Iterate the var `vnics` would be better. >>> vnic_service = >>> connection.system_service().vnic_profiles_service().profile_service(vnics[0].id) >>> vnic_service.update( >>> types.VnicProfile( >>> name='the-new-name', >>> ) >>> ) >>> vnic = vnic_service.get() >>> print('new name', vnic.name) >>> ``` >>> >>> If the above codes could not work as expected, please let me know. >>> >>> Regards, >>> Joey >>> >>> for dev in vnics: >>>> print ("Dev name is %s" % dev.name) >>>> # vnicprofile_service.update(types.VnicProfile( >>>> # name='%s' % HOSTNAME, >>>> # ), >>>> # ) >>>> connection.close() >>>> >>>> ./update-vnic.py >>>> Network name is ovirtmgmt >>>> Network id is 740cae1f-c49f-4563-877a-5ce173e83be4 >>>> Dev name is ovirtmgmt >>>> >>>> Thanks >>>> Don >>>> >>>> On Mon, Feb 25, 2019 at 12:06 AM Joey Ma <[email protected]> wrote: >>>> >>>>> Hi Don, >>>>> >>>>> Please using `network.vnic_profiles` instead of `network.vnicprofiles` >>>>> as the parameter of `connection.follow_link`. >>>>> >>>>> Regards, >>>>> Joey >>>>> >>>>> >>>>> On Mon, Feb 25, 2019 at 9:22 AM Don Dupuis <[email protected]> wrote: >>>>> >>>>>> Hi >>>>>> >>>>>> I am trying to write some code to update the names of existing >>>>>> vnicprofiles in ovirt-4.2. The problem I am having is trying to follow >>>>>> the >>>>>> links to the vnicprofiles. Below is web info that I am trying to get: >>>>>> >>>>>> <network >>>>>> href="/ovirt-engine/api/networks/740cae1f-c49f-4563-877a-5ce173e83be4" >>>>>> id="740cae1f-c49f-4563-877a-5ce173e83be4"><name>ovirtmgmt</name><description>LOOKING</description><comment/><link >>>>>> href="/ovirt-engine/api/networks/740cae1f-c49f-4563-877a-5ce173e83be4/permissions" >>>>>> rel="permissions"/><link >>>>>> href="/ovirt-engine/api/networks/740cae1f-c49f-4563-877a-5ce173e83be4/vnicprofiles" >>>>>> rel="vnicprofiles"/><link >>>>>> href="/ovirt-engine/api/networks/740cae1f-c49f-4563-877a-5ce173e83be4/networklabels" >>>>>> rel="networklabels"/><mtu>0</mtu><stp>false</stp><usages><usage>vm</usage></usages><vlan >>>>>> id="4050"/><data_center >>>>>> href="/ovirt-engine/api/datacenters/1d00d32b-abdc-43cd-b990-257aaf01d514" >>>>>> id="1d00d32b-abdc-43cd-b990-257aaf01d514"/></network> >>>>>> >>>>>> Below is the code that I am trying to do the same thing and I want to >>>>>> follow the vnicprofiles link to get to the actual data that I want to >>>>>> change: >>>>>> #!/usr/bin/env python >>>>>> >>>>>> import logging >>>>>> import time >>>>>> import string >>>>>> import sys >>>>>> import os >>>>>> import MySQLdb >>>>>> >>>>>> import ovirtsdk4 as sdk >>>>>> import ovirtsdk4.types as types >>>>>> >>>>>> #logging.basicConfig(level=logging.DEBUG, filename='/tmp/addhost.log') >>>>>> >>>>>> ### Variables to be used ### >>>>>> #NUMANODE = 3 >>>>>> #MEM = 20 >>>>>> GB = 1024 * 1024 * 1024 >>>>>> #MEMORY = MEM * GB >>>>>> GB = 1024 * 1024 * 1024 >>>>>> URL = 'https://host/ovirt-engine/api' >>>>>> CAFILE = '/etc/pki/ovirt-engine/ca.pem' >>>>>> USERNAME = 'admin@internal' >>>>>> PASSWORD = 'password' >>>>>> HOSTNAME = 'rvs06' >>>>>> >>>>>> connection = sdk.Connection( >>>>>> url=URL, >>>>>> username=USERNAME, >>>>>> password=PASSWORD, >>>>>> # ca_file='ca.pem', >>>>>> debug='True', >>>>>> insecure='True', >>>>>> # log=logging.getLogger(), >>>>>> ) >>>>>> >>>>>> #dcs_service = connection.system_service().data_centers_service() >>>>>> #dc = dcs_service.list(search='cluster=%s-local' % HOSTNAME)[0] >>>>>> #network = dcs_service.service(dc.id).networks_service() >>>>>> networks_service = connection.system_service().networks_service() >>>>>> network = networks_service.list( >>>>>> search='name=ovirtmgmt and datacenter=%s-local' % HOSTNAME) [0] >>>>>> print ("Network name is %s" % network.name) >>>>>> print ("Network id is %s" % network.id) >>>>>> vnic = connection.follow_link(network.vnicprofiles) >>>>>> >>>>>> connection.close() >>>>>> >>>>>> Below is the output of my code: >>>>>> >>>>>> ./update-vnic.py >>>>>> Network name is ovirtmgmt >>>>>> Network id is 740cae1f-c49f-4563-877a-5ce173e83be4 >>>>>> Traceback (most recent call last): >>>>>> File "./update-vnic.py", line 46, in <module> >>>>>> vnic = connection.follow_link(network.vnicprofiles) >>>>>> AttributeError: 'Network' object has no attribute 'vnicprofiles' >>>>>> >>>>>> The network name and network id is correct. Any help would be >>>>>> appreciated on what I am missing or what I am doing wrong. The actual >>>>>> updating of the name with code isn't written yet as I can't get past this >>>>>> part. >>>>>> >>>>>> Thanks >>>>>> >>>>>> Don >>>>>> _______________________________________________ >>>>>> Users mailing list -- [email protected] >>>>>> To unsubscribe send an email to [email protected] >>>>>> Privacy Statement: https://www.ovirt.org/site/privacy-policy/ >>>>>> oVirt Code of Conduct: >>>>>> https://www.ovirt.org/community/about/community-guidelines/ >>>>>> List Archives: >>>>>> https://lists.ovirt.org/archives/list/[email protected]/message/PRV7MA2X3IS5WSXEEYAY54PPXFIMNRM4/ >>>>>> >>>>>
_______________________________________________ Users mailing list -- [email protected] To unsubscribe send an email to [email protected] Privacy Statement: https://www.ovirt.org/site/privacy-policy/ oVirt Code of Conduct: https://www.ovirt.org/community/about/community-guidelines/ List Archives: https://lists.ovirt.org/archives/list/[email protected]/message/QSP3B3PU5UFFWPJ7467WPWKCMNB5NWND/

