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 paramater in dev.facts #1333

Merged
merged 4 commits into from
Oct 14, 2024

Conversation

dineshbaburam91
Copy link
Collaborator

@dineshbaburam91 dineshbaburam91 commented Oct 14, 2024

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 and Junos evolved device.
If Vmhost returns None, in case of error to fetch 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: False
The output of facts['vmhost'] in junos evolved device after refresh: False
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%

Copy link
Collaborator

@chidanandpujar chidanandpujar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@chidanandpujar chidanandpujar merged commit e5e06e8 into Juniper:master Oct 14, 2024
7 checks passed
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.

2 participants