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)
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 <majunjiev(a)gmail.com> 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 <dondster(a)gmail.com> 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 -- users(a)ovirt.org
> To unsubscribe send an email to users-leave(a)ovirt.org
> 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/users@ovirt.org/message/PRV7MA2X3IS...
>