mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 22:51:23 -07:00
Refactor code for VirtualFacts (#18122)
The populate method is cut and paste on every subclass, so we should push it up, and add a default method that is overloaded
This commit is contained in:
parent
d4ac0bdea9
commit
4c85a1fa05
1 changed files with 5 additions and 24 deletions
|
@ -3080,8 +3080,13 @@ class Virtual(Facts):
|
||||||
return super(cls, subclass).__new__(subclass, *arguments, **keyword)
|
return super(cls, subclass).__new__(subclass, *arguments, **keyword)
|
||||||
|
|
||||||
def populate(self):
|
def populate(self):
|
||||||
|
self.get_virtual_facts()
|
||||||
return self.facts
|
return self.facts
|
||||||
|
|
||||||
|
def get_virtual_facts(self):
|
||||||
|
self.facts['virtualization_type'] = ''
|
||||||
|
self.facts['virtualization_role'] = ''
|
||||||
|
|
||||||
class LinuxVirtual(Virtual):
|
class LinuxVirtual(Virtual):
|
||||||
"""
|
"""
|
||||||
This is a Linux-specific subclass of Virtual. It defines
|
This is a Linux-specific subclass of Virtual. It defines
|
||||||
|
@ -3090,10 +3095,6 @@ class LinuxVirtual(Virtual):
|
||||||
"""
|
"""
|
||||||
platform = 'Linux'
|
platform = 'Linux'
|
||||||
|
|
||||||
def populate(self):
|
|
||||||
self.get_virtual_facts()
|
|
||||||
return self.facts
|
|
||||||
|
|
||||||
# For more information, check: http://people.redhat.com/~rjones/virt-what/
|
# For more information, check: http://people.redhat.com/~rjones/virt-what/
|
||||||
def get_virtual_facts(self):
|
def get_virtual_facts(self):
|
||||||
# lxc/docker
|
# lxc/docker
|
||||||
|
@ -3265,14 +3266,6 @@ class FreeBSDVirtual(Virtual):
|
||||||
"""
|
"""
|
||||||
platform = 'FreeBSD'
|
platform = 'FreeBSD'
|
||||||
|
|
||||||
def populate(self):
|
|
||||||
self.get_virtual_facts()
|
|
||||||
return self.facts
|
|
||||||
|
|
||||||
def get_virtual_facts(self):
|
|
||||||
self.facts['virtualization_type'] = ''
|
|
||||||
self.facts['virtualization_role'] = ''
|
|
||||||
|
|
||||||
class DragonFlyVirtual(FreeBSDVirtual):
|
class DragonFlyVirtual(FreeBSDVirtual):
|
||||||
platform = 'DragonFly'
|
platform = 'DragonFly'
|
||||||
|
|
||||||
|
@ -3284,10 +3277,6 @@ class OpenBSDVirtual(Virtual):
|
||||||
"""
|
"""
|
||||||
platform = 'OpenBSD'
|
platform = 'OpenBSD'
|
||||||
|
|
||||||
def populate(self):
|
|
||||||
self.get_virtual_facts()
|
|
||||||
return self.facts
|
|
||||||
|
|
||||||
def get_virtual_facts(self):
|
def get_virtual_facts(self):
|
||||||
sysctl_path = self.module.get_bin_path('sysctl')
|
sysctl_path = self.module.get_bin_path('sysctl')
|
||||||
|
|
||||||
|
@ -3332,10 +3321,6 @@ class HPUXVirtual(Virtual):
|
||||||
"""
|
"""
|
||||||
platform = 'HP-UX'
|
platform = 'HP-UX'
|
||||||
|
|
||||||
def populate(self):
|
|
||||||
self.get_virtual_facts()
|
|
||||||
return self.facts
|
|
||||||
|
|
||||||
def get_virtual_facts(self):
|
def get_virtual_facts(self):
|
||||||
if os.path.exists('/usr/sbin/vecheck'):
|
if os.path.exists('/usr/sbin/vecheck'):
|
||||||
rc, out, err = self.module.run_command("/usr/sbin/vecheck")
|
rc, out, err = self.module.run_command("/usr/sbin/vecheck")
|
||||||
|
@ -3369,10 +3354,6 @@ class SunOSVirtual(Virtual):
|
||||||
"""
|
"""
|
||||||
platform = 'SunOS'
|
platform = 'SunOS'
|
||||||
|
|
||||||
def populate(self):
|
|
||||||
self.get_virtual_facts()
|
|
||||||
return self.facts
|
|
||||||
|
|
||||||
def get_virtual_facts(self):
|
def get_virtual_facts(self):
|
||||||
|
|
||||||
# Check if it's a zone
|
# Check if it's a zone
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue