Description of problem: ovirt4.x cluster, sharestorage and localstorage ,but this two cluster vnic is the same,use pysdk add nic is error。 Version-Release number of selected component (if applicable): How reproducible: Steps to Reproduce: 1.debug add_vm_nic.py 2.profiles_service = connection.system_service().vnic_profiles_service() profile_id = None for profile in profiles_service.list(): if profile.name == 'mynetwork': profile_id = profile.id cluster_network 、comment、desc and more this value is none, filter cluster vNIC is error。 3. add NIC failed Actual results: Expected results: Additional info:
I don't quite understand the description, but moving to network if it rings any bell
曾浩, please provide a complete script that reproduces your problem, specify your ovirt-engine.rpm version, and include engine.log. Then I may understand what is the problem that you see. 谢谢.
(In reply to Dan Kenigsberg from comment #2) > 曾浩, please provide a complete script that reproduces your problem, specify > your ovirt-engine.rpm version, and include engine.log. Then I may understand > what is the problem that you see. 谢谢. chinese is great
Created attachment 1474907 [details] pic comment description cluster data_center is None name is vNICname。 Aug 07 15:18:27 Installed: python-ovirt-engine-sdk4-4.2.7-2.el7.x86_64 Aug 07 15:18:27 Installed: ovirt-engine-extensions-api-impl-4.2.5.2-1.el7.noarch Aug 07 15:18:27 Installed: ovirt-engine-extension-aaa-jdbc-1.1.7-1.el7.centos.noarch Aug 07 15:18:28 Installed: ovirt-engine-sdk-python-3.6.9.1-1.el7.noarch Aug 07 15:19:00 Installed: ovirt-engine-wildfly-13.0.0-1.el7.x86_64 Aug 07 15:19:00 Installed: ovirt-engine-wildfly-overlay-13.0.0-1.el7.noarch Aug 07 15:19:11 Installed: ovirt-engine-cli-3.6.9.2-1.el7.centos.noarch Aug 07 15:19:19 Installed: ovirt-engine-lib-4.2.5.2-1.el7.noarch Aug 07 15:19:20 Installed: ovirt-engine-setup-base-4.2.5.2-1.el7.noarch Aug 07 15:19:59 Installed: ovirt-engine-metrics-1.1.6.1-1.el7.noarch Aug 07 15:20:02 Installed: ovirt-engine-setup-plugin-ovirt-engine-common-4.2.5.2-1.el7.noarch Aug 07 15:20:24 Installed: ovirt-engine-dwh-setup-4.2.4.3-1.el7.noarch Aug 07 15:20:25 Installed: ovirt-engine-dwh-4.2.4.3-1.el7.noarch Aug 07 15:20:25 Installed: ovirt-engine-tools-backup-4.2.5.2-1.el7.noarch Aug 07 15:20:25 Installed: ovirt-engine-setup-plugin-websocket-proxy-4.2.5.2-1.el7.noarch Aug 07 15:20:25 Installed: ovirt-engine-websocket-proxy-4.2.5.2-1.el7.noarch Aug 07 15:21:26 Installed: ovirt-engine-vmconsole-proxy-helper-4.2.5.2-1.el7.noarch Aug 07 15:21:26 Installed: ovirt-engine-setup-plugin-vmconsole-proxy-helper-4.2.5.2-1.el7.noarch Aug 07 15:21:27 Installed: ovirt-engine-dashboard-1.2.4-1.el7.noarch Aug 07 15:21:48 Installed: ovirt-engine-webadmin-portal-4.2.5.2-1.el7.noarch Aug 07 15:21:49 Installed: ovirt-engine-dbscripts-4.2.5.2-1.el7.noarch Aug 07 15:21:50 Installed: ovirt-engine-restapi-4.2.5.2-1.el7.noarch Aug 07 15:21:50 Installed: ovirt-engine-api-explorer-0.0.2-1.el7.centos.noarch Aug 07 15:21:51 Installed: ovirt-engine-tools-4.2.5.2-1.el7.noarch Aug 07 15:21:53 Installed: ovirt-engine-backend-4.2.5.2-1.el7.noarch Aug 07 15:21:54 Installed: ovirt-engine-4.2.5.2-1.el7.noarch Aug 07 15:21:54 Installed: ovirt-engine-setup-plugin-ovirt-engine-4.2.5.2-1.el7.noarch Aug 07 15:21:54 Installed: ovirt-engine-setup-4.2.5.2-1.el7.noarch
query cluster_network to filter cluser`s vNIC name,i cant found this items. def addVMNIC(self,vmname,network,nicname): vms_service = self.connection.system_service().vms_service() vm = vms_service.list(search='name=%s'%vmname)[0] profiles_service = self.connection.system_service().vnic_profiles_service() profile_id = None # network的网卡编号UUID network_list = profiles_service.list() for profile in network_list: if profile.name == network: # 判断网卡名是否是network传来的名称 profile_id = profile.id # 获取network对应网卡名的UUID try: nics_service = vms_service.vm_service(vm.id).nics_service() nics_service.add( types.Nic( name=nicname, # 虚拟机新增网卡 description='My network interface', # 描述,这里默认描述 vnic_profile=types.VnicProfile( id=profile_id, # 选择添加网卡关联的nic,这个与ovirt的网络关联,网络关联的是vlanid ), ), ) break # 停止查找 except: pass
Can you please review the example? https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples/add_vm_nic.py I think if you follow this you should be good.
btw, one must never use except: pass in python, as it silently hides all sort of errors. You should always ignore only a limited set of exception.
(In reply to Yaniv Lavi from comment #6) > Can you please review the example? > https://github.com/oVirt/ovirt-engine-sdk/blob/master/sdk/examples/ > add_vm_nic.py > > I think if you follow this you should be good. one datacenter use to example with github is success, but i have three datacenter and the vnic is the same, github use vnic name to filter,but i have three datacenter and the vnic is same, Exapmle: datacenter: A B C cluster : a b c cluster a with vinc: vnic1 vnic2 vnic3 cluster b with vinc: vnic1 vnic2 vnic3 cluster c with vinc: vnic1 vnic2 vnic3 now i want to add vinc1 with vm in cluster b. but i use to examplie in github,this filter use vnic name ,when find vnic1 name in profiles_service.list() and the cluster is the clustera, and add vinc1 is error.
(In reply to Dan Kenigsberg from comment #7) > btw, one must never use > > except: > pass > > in python, as it silently hides all sort of errors. You should always ignore > only a limited set of exception. THS for your adv
Do you know if we can search vnic profile by its name AND its datacenter?
Can you please check following patch: https://gerrit.ovirt.org/#/c/94030/ I've edited the example, with your needs.
(In reply to Ondra Machacek from comment #11) > Can you please check following patch: > > https://gerrit.ovirt.org/#/c/94030/ > > I've edited the example, with your needs. 3Q