How to use get_nic_count method in lisa

Best Python code snippet using lisa_python

edit_hardware.py

Source:edit_hardware.py Github

copy

Full Screen

...348 if self.nics is None or self.nic_networks is not None:349 return350 # If we're not creating new NICs, nothing needed351 # If we don't have at least 2 existing NICs, not enough info to infer352 current_nic_count = max(self.vm.get_nic_count(self.profiles).values())353 if self.nics <= current_nic_count or current_nic_count < 2:354 return355 # Only try to infer if there are the same number of NICs and networks356 # TODO: this is a bit overly conservative - if we had an API for357 # retrieving the NIC-to-network mapping list, we could dispense358 # with this check and work on the mapping list instead.359 current_network_count = len(self.vm.networks)360 if current_nic_count != current_network_count:361 return362 # TODO: the below relies on the assumption that the networks list363 # is in the same order as the NICs list, which is not a given.364 logger.notice("Given that all existing NICs are mapped to unique "365 "networks, trying to guess an implicit pattern for "366 "creating new networks.")367 # Can we guess a pattern from vm.networks?368 self.nic_networks = guess_list_wildcard(self.vm.networks)369 if self.nic_networks:370 logger.info('Identified a pattern: --nic-networks "%s"',371 '" "'.join(self.nic_networks))372 else:373 logger.info("No pattern could be identified from existing "374 "network names %s", self.vm.networks)375 # If the user didn't specify the network descriptions, let's376 # see if we can guess that too...377 if self.network_descriptions is None:378 self.network_descriptions = guess_list_wildcard(379 self.vm.network_descriptions)380 if self.network_descriptions:381 logger.info("Identified a pattern: "382 '--network-descriptions "%s"',383 '" "'.join(self.network_descriptions))384 else:385 logger.info("No pattern could be identified from "386 "existing network descriptions %s",387 self.vm.network_descriptions)388 def _run_update_nics(self):389 """Handle NIC changes. Helper for :meth:`run`."""390 vm = self.vm391 nics_dict = vm.get_nic_count(self.profiles)392 if self.nics is not None:393 for (profile, count) in nics_dict.items():394 if self.nics < count:395 self.ui.confirm_or_die(396 "Profile {0} currently has {1} NIC(s). "397 "Delete {2} NIC(s) to reduce to {3} total?"398 .format(profile, count,399 (count - self.nics), self.nics))400 vm.set_nic_count(self.nics, self.profiles)401 if self.nic_types is not None:402 vm.set_nic_types(self.nic_types, self.profiles)403 if self.mac_addresses_list is not None:404 vm.set_nic_mac_addresses(self.mac_addresses_list, self.profiles)405 def _run_update_networks(self):406 """Handle network changes. Helper for :meth:`run`."""407 vm = self.vm408 nics_dict = vm.get_nic_count(self.profiles)409 max_nics = max(nics_dict.values())410 existing_networks = vm.networks411 # Special case:412 # If we added NICs in _run_update_nics to an OVF previously with none,413 # we MUST create a network, as NICs with no Connection are not valid.414 if max_nics > 0 and not existing_networks:415 if self.nic_networks is None:416 self.nic_networks = ['VM Network']417 logger.warning("No network names specified, but NICs must be "418 "mapped to a network. Will add network '%s'.",419 self.nic_networks[0])420 new_descs = expand_list_wildcard(self.network_descriptions,421 max_nics)422 if self.nic_networks is None and self.network_descriptions is not None:423 # Just rename existing networks, instead of making new ones424 for network, desc in zip(vm.networks, new_descs):425 # Despite the name, create_network can also be used to426 # update an existing network.427 vm.create_network(network, desc)428 return429 if self.nic_networks is not None:430 new_networks = expand_list_wildcard(self.nic_networks, max_nics)431 for network in new_networks:432 if new_descs:433 new_desc = new_descs.pop(0)434 else:435 new_desc = None436 if network not in existing_networks:437 self.ui.confirm_or_die(438 "Network {0} is not currently defined. "439 "Create it?".format(network))440 if not new_desc:441 new_desc = self.ui.get_input(442 "Please enter a description for this network",443 network)444 # create or update445 vm.create_network(network, new_desc)446 vm.set_nic_networks(new_networks, self.profiles)447 def _run_update_nic_names(self):448 """Update NIC names. Helper for :meth:`run`."""449 if self.nic_names is not None:450 vm = self.vm451 nics_dict = vm.get_nic_count(self.profiles)452 max_nics = max(nics_dict.values())453 names = expand_list_wildcard(self.nic_names, max_nics)454 vm.set_nic_names(names, self.profiles)455 def _run_update_serial(self):456 """Handle serial port changes. Helper for :meth:`run`."""457 if self.serial_ports is not None:458 serial_dict = self.vm.get_serial_count(self.profiles)459 for (profile, count) in serial_dict.items():460 if self.serial_ports < count:461 self.ui.confirm_or_die(462 "Profile {0} currently has {1} serial port(s). "463 "Delete {2} port(s) to reduce to {3} total?"464 .format(profile, count, (count - self.serial_ports),465 self.serial_ports))...

Full Screen

Full Screen

edge70_vm_impl.py

Source:edge70_vm_impl.py Github

copy

Full Screen

...28 pylogger.debug("actual_cpu_count retrieved ...%s ", actual_cpu_count)29 pydict = {'expected_cpu_count': actual_cpu_count}30 return pydict31 @classmethod32 def get_nic_count(cls, client_object, vm_ip_address=None,33 esx_host_ip=None, esx_username=None,34 esx_password=None, **kwargs):35 """36 Fetches the NIC COUNT for given VM IP Addr37 The method uses the ESX ip and credentials to create the38 ESX managed object reference.39 Next it uses the ESX mor to fetch MOID of given vm_ip_address40 Thereafter it fetches the NIC Count using the moid41 Finally returns the fetched value to calling method42 @type client_object: instance43 @param client_object: VMAPIClient object.44 @rtype: int45 @param: NIC Count46 """47 hc = esx_facade.ESXFacade(esx_host_ip, esx_username, esx_password)48 edge_moid = hc.fetch_moid_from_ip(vm_ip_address=vm_ip_address)49 vm = vm_facade.VMFacade(edge_moid, parent=hc)50 actual_nic_count = vm.get_nic_count()51 pylogger.debug("actual_nic_count retrieved ...%s ", actual_nic_count)52 pydict = {'expected_nic_count': actual_nic_count}53 return pydict54 @classmethod55 def get_virtual_disk_count(cls, client_object, vm_ip_address=None,56 esx_host_ip=None, esx_username=None,57 esx_password=None, **kwargs):58 """59 Fetches the VIRTUAL DISK COUNT for given VM IP Addr60 The method uses the ESX ip and credentials to create61 the ESX managed object reference.62 Next it uses the ESX mor to fetch MOID of given vm_ip_address63 Thereafter it fetches the Disk Count using the moid64 Finally returns the fetched value to calling method...

Full Screen

Full Screen

network_interface.py

Source:network_interface.py Github

copy

Full Screen

...27 def remove_extra_nics(self) -> None:28 raise NotImplementedError29 def reload_module(self) -> None:30 raise NotImplementedError31 def get_nic_count(self, is_sriov_enabled: bool = True) -> int:32 raise NotImplementedError33 def _initialize(self, *args: Any, **kwargs: Any) -> None:34 self.origin_extra_synthetic_nics_count: int = 035 self.origin_extra_sriov_nics_count: int = 036Sriov = partial(NetworkInterfaceOptionSettings, data_path=schema.NetworkDataPath.Sriov)37Synthetic = partial(38 NetworkInterfaceOptionSettings, data_path=schema.NetworkDataPath.Synthetic...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run lisa automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful