Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added vmhost parameter in the facts template #1329

Closed

Conversation

dineshbaburam91
Copy link
Collaborator

Added vmhost parameter in the facts template to check running device is vmhost supported or not.



If vmhost returns True, then the running device is Vmhost supported device.
If vmhost returns False, then the running device is non-Vmhost-supported device.
If Vmhost returns None, then the running device is Juno’s evolved device or unable to get the vmhost data.

Functional test cases:



from jnpr.junos import Device
dev_vmhost = Device(host=‘x.x.x.x’, user='root', password=‘’xxxx)
dev_evolved = Device(host='x.x.x.x’', user='root', password=‘xxxx’)
dev_non_vmhost = Device(host='x.x.x.x’', user='root', password=‘xxxx’)

dev_vmhost.open()
dev_evolved.open()
dev_non_vmhost.open()

print("The output of facts['vmhost'] in vmhost supported device: " + str(dev_vmhost.facts['vmhost']))
dev_vmhost.facts_refresh()
print("The output of facts['vmhost'] in vmhost supported device after refresh: " + str(dev_vmhost.facts['vmhost']))

print("The output of facts['vmhost'] in junos evolved device:  " + str(dev_evolved.facts['vmhost']))
dev_evolved.facts_refresh()
print("The output of facts['vmhost'] in junos evolved device after refresh:  " + str(dev_evolved.facts['vmhost']))

print("The output of facts['vmhost'] in non vmhost supported device: " + str(dev_non_vmhost.facts['vmhost']))
dev_non_vmhost.facts_refresh()
print("The output of facts['vmhost'] in non vmhost supported device after refresh: " + str(dev_non_vmhost.facts['vmhost']))
O/p:


The output of facts['vmhost'] in vmhost supported device: True
The output of facts['vmhost'] in vmhost supported device after refresh: True
The output of facts['vmhost'] in junos evolved device: None
The output of facts['vmhost'] in junos evolved device after refresh: None
The output of facts['vmhost'] in non vmhost supported device: False
The output of facts['vmhost'] in non vmhost supported device after refresh: False


Unit test cases:

(venv_pyez) py-junos-eznc % nose2 --with-coverage tests.unit.facts.test_vmhost                      
....
----------------------------------------------------------------------
Ran 4 tests in 0.012s

Name                                                       Stmts   Miss  Cover   Missing
----------------------------------------------------------------------------------------
lib/jnpr/junos/facts/vmhost.py                     21      0   100%

@chidanandpujar chidanandpujar self-requested a review October 9, 2024 10:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant