How to use list_hypervisors method in tempest

Best Python code snippet using tempest_python

node-fullness.py

Source: node-fullness.py Github

copy

Full Screen

1#!/​usr/​bin/​env python32import shade3from prettytable import PrettyTable4def getHyperSummTable(hlist):5 """Given a shade.list_hypervisors() output munch.Munch object, return a PrettyTable of hypervisor info."""6 hyperInfoTable = PrettyTable(['Node', 'Hyper Type', 'Hyper Version', 'State', 'Status'])7 for host in hlist:8 hyperInfoTable.add_row([host['hypervisor_hostname'],9 host['hypervisor_type'],10 host['hypervisor_version'], 11 host['state'],12 host['status'],13 ])14 return hyperInfoTable15def getMemTable(hlist):16 """Given a shade.list_hypervisors() output munch.Munch object, return a PrettyTable of memory usage."""17 memTotals = [0,0,0]18 # Memory Consumption Table19 memTable = PrettyTable(['Node','Total Mem (GB)', 'Mem in-use (GB)', 'Mem Free (GB)', 'Mem % in-use'])20 memTable.align['Node'] = 'r'21 memTable.align['Total Mem (GB)'] = 'r'22 memTable.align['Mem in-use (GB)'] = 'r'23 memTable.align['Mem Free (GB)'] = 'r'24 memTable.align['Mem % in-use'] = 'r'25 memTable.float_format['Total Mem (GB)'] = '5.1'26 memTable.float_format['Mem in-use (GB)'] = '4.1'27 memTable.float_format['Mem Free (GB)'] = '4.1'28 memTable.float_format['Mem % in-use'] = '2.1'29 30 for host in hlist:31 memTable.add_row([host['hypervisor_hostname'], 32 host['memory_mb'] /​ 1024, 33 host['memory_mb_used'] /​ 1024,34 host['free_ram_mb'] /​ 1024, 35 float(host['memory_mb_used']) /​ float(host['memory_mb']) * 100,36 ])37 memTotals[0] += host['memory_mb'] /​ 102438 memTotals[1] += host['memory_mb_used'] /​ 102439 memTotals[2] += host['free_ram_mb'] /​ 102440 memTable.add_row(['--', '--', '--', '--', '--'])41 memTable.add_row(['TOTAL:'] + memTotals + [float(memTotals[1]) /​ float(memTotals[0]) * 100])42 return memTable43 44def getInstCountTable(hlist):45 """Given a shade.list_hypervisors() munch.Munch object, return a PrettyTable of instance counts."""46 instCountTotal = 047 # Instance Count Table48 instCountTable = PrettyTable(['Node', '# Instances'])49 instCountTable.align['Node'] = 'r'50 instCountTable.align['# Instances'] = 'r'51 for host in hlist:52 instCountTable.add_row([host['hypervisor_hostname'],53 host['running_vms'],54 ])55 instCountTotal += host['running_vms']56 instCountTable.add_row(['--', '--'])57 instCountTable.add_row(['TOTAL:'] + [instCountTotal])58 return instCountTable59def getCPUTable(hlist):60 """Given a shade.list_hypervisors() munch.Munch object. return a PrettyTable of CPu usage."""61 cpuCount = 062 cpuUsed = 063 cpuTable = PrettyTable(['Node', 'vCPUs', 'vCPUs Used', '% in use' ])64 cpuTable.align['Node'] = 'r'65 cpuTable.align['vCPUs'] = 'r'66 cpuTable.align['vCPUs Used'] = 'r'67 cpuTable.align['% in use'] = 'r'68 cpuTable.float_format['% in use'] = '2.2'69 for host in hlist:70 cpuTable.add_row([host['hypervisor_hostname'],71 host['vcpus'],72 host['vcpus_used'],73 float(host['vcpus_used']) /​ float(host['vcpus']) * 100,74 ])75 cpuCount += host['vcpus']76 cpuUsed += host['vcpus_used']77 78 cpuTable.add_row(['--', '--', '--', '--'])79 cpuTable.add_row(['TOTAL:',80 cpuCount,81 cpuUsed,82 float(cpuUsed) /​ float(cpuCount) * 100,83 ])84 85 return cpuTable86def showHyperSum(hlist):87 """Given a shade.list_hypervisors() output munch.Munch object, summarize hypervisor usage."""88 print("Hypervisor Summary:")89 print(getHyperSummTable(hlist))90 print("Memory Summary:")91 print(getMemTable(hlist))92 print("Instance Count:")93 print(getInstCountTable(hlist))94 print("CPU Usage Summary")95 print(getCPUTable(hlist))96def main():97 """The Main Program"""98 cloud = shade.openstack_cloud()99 # Get all servers, across all projects100 #servers = cloud.list_servers(all_projects=True)101 # Get hypervisor info102 hyperlist = cloud.list_hypervisors()103 showHyperSum(hyperlist)104if __name__ == "__main__":...

Full Screen

Full Screen

test_hypervisor_rbac.py

Source: test_hypervisor_rbac.py Github

copy

Full Screen

...27 @classmethod28 def resource_setup(cls):29 super(HypervisorRbacTest, cls).resource_setup()30 cls.hypervisor =\31 cls.hypervisor_client.list_hypervisors()['hypervisors'][0]32 @decorators.idempotent_id('17bbeb9a-e73e-445f-a771-c794448ef562')33 @rbac_rule_validation.action(34 service="nova",35 rule="os_compute_api:os-hypervisors")36 def test_list_hypervisors(self):37 self.rbac_utils.switch_role(self, toggle_rbac_role=True)38 self.hypervisor_client.list_hypervisors()['hypervisors']39 @decorators.idempotent_id('36b95c7d-1085-487a-a674-b7c1ca35f520')40 @rbac_rule_validation.action(41 service="nova",42 rule="os_compute_api:os-hypervisors")43 def test_list_hypervisors_with_details(self):44 self.rbac_utils.switch_role(self, toggle_rbac_role=True)45 self.hypervisor_client.list_hypervisors(detail=True)['hypervisors']46 @decorators.idempotent_id('8a7f6f9e-34a6-4480-8875-bba566c3a581')47 @rbac_rule_validation.action(48 service="nova",49 rule="os_compute_api:os-hypervisors")50 def test_show_hypervisor(self):51 self.rbac_utils.switch_role(self, toggle_rbac_role=True)52 self.hypervisor_client.show_hypervisor(53 self.hypervisor['id'])['hypervisor']54 @decorators.idempotent_id('b86f03cf-2e79-4d88-9eea-62f761591413')55 @rbac_rule_validation.action(56 service="nova",57 rule="os_compute_api:os-hypervisors")58 def test_list_servers_on_hypervisor(self):59 self.rbac_utils.switch_role(self, toggle_rbac_role=True)...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Rebuild Confidence in Your Test Automation

These days, development teams depend heavily on feedback from automated tests to evaluate the quality of the system they are working on.

What will come after “agile”?

I think that probably most development teams describe themselves as being “agile” and probably most development teams have standups, and meetings called retrospectives.There is also a lot of discussion about “agile”, much written about “agile”, and there are many presentations about “agile”. A question that is often asked is what comes after “agile”? Many testers work in “agile” teams so this question matters to us.

Test strategy and how to communicate it

I routinely come across test strategy documents when working with customers. They are lengthy—100 pages or more—and packed with monotonous text that is routinely reused from one project to another. Yawn once more— the test halt and resume circumstances, the defect management procedure, entrance and exit criteria, unnecessary generic risks, and in fact, one often-used model replicates the requirements of textbook testing, from stress to systems integration.

Do you possess the necessary characteristics to adopt an Agile testing mindset?

To understand the agile testing mindset, we first need to determine what makes a team “agile.” To me, an agile team continually focuses on becoming self-organized and cross-functional to be able to complete any challenge they may face during a project.

How To Refresh Page Using Selenium C# [Complete Tutorial]

When working on web automation with Selenium, I encountered scenarios where I needed to refresh pages from time to time. When does this happen? One scenario is that I needed to refresh the page to check that the data I expected to see was still available even after refreshing. Another possibility is to clear form data without going through each input individually.

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 tempest 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