mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02: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)
|
||||
|
||||
def populate(self):
|
||||
self.get_virtual_facts()
|
||||
return self.facts
|
||||
|
||||
def get_virtual_facts(self):
|
||||
self.facts['virtualization_type'] = ''
|
||||
self.facts['virtualization_role'] = ''
|
||||
|
||||
class LinuxVirtual(Virtual):
|
||||
"""
|
||||
This is a Linux-specific subclass of Virtual. It defines
|
||||
|
@ -3090,10 +3095,6 @@ class LinuxVirtual(Virtual):
|
|||
"""
|
||||
platform = 'Linux'
|
||||
|
||||
def populate(self):
|
||||
self.get_virtual_facts()
|
||||
return self.facts
|
||||
|
||||
# For more information, check: http://people.redhat.com/~rjones/virt-what/
|
||||
def get_virtual_facts(self):
|
||||
# lxc/docker
|
||||
|
@ -3265,14 +3266,6 @@ class FreeBSDVirtual(Virtual):
|
|||
"""
|
||||
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):
|
||||
platform = 'DragonFly'
|
||||
|
||||
|
@ -3284,10 +3277,6 @@ class OpenBSDVirtual(Virtual):
|
|||
"""
|
||||
platform = 'OpenBSD'
|
||||
|
||||
def populate(self):
|
||||
self.get_virtual_facts()
|
||||
return self.facts
|
||||
|
||||
def get_virtual_facts(self):
|
||||
sysctl_path = self.module.get_bin_path('sysctl')
|
||||
|
||||
|
@ -3332,10 +3321,6 @@ class HPUXVirtual(Virtual):
|
|||
"""
|
||||
platform = 'HP-UX'
|
||||
|
||||
def populate(self):
|
||||
self.get_virtual_facts()
|
||||
return self.facts
|
||||
|
||||
def get_virtual_facts(self):
|
||||
if os.path.exists('/usr/sbin/vecheck'):
|
||||
rc, out, err = self.module.run_command("/usr/sbin/vecheck")
|
||||
|
@ -3369,10 +3354,6 @@ class SunOSVirtual(Virtual):
|
|||
"""
|
||||
platform = 'SunOS'
|
||||
|
||||
def populate(self):
|
||||
self.get_virtual_facts()
|
||||
return self.facts
|
||||
|
||||
def get_virtual_facts(self):
|
||||
|
||||
# Check if it's a zone
|
||||
|
|
Loading…
Reference in a new issue