|
|
|
@ -32,6 +32,7 @@ import datetime
|
|
|
|
|
import getpass
|
|
|
|
|
import pwd
|
|
|
|
|
import ConfigParser
|
|
|
|
|
from basic import get_all_subclasses
|
|
|
|
|
|
|
|
|
|
# py2 vs py3; replace with six via ziploader
|
|
|
|
|
try:
|
|
|
|
@ -867,7 +868,7 @@ class Hardware(Facts):
|
|
|
|
|
|
|
|
|
|
def __new__(cls, *arguments, **keyword):
|
|
|
|
|
subclass = cls
|
|
|
|
|
for sc in Hardware.__subclasses__():
|
|
|
|
|
for sc in get_all_subclasses(Hardware):
|
|
|
|
|
if sc.platform == platform.system():
|
|
|
|
|
subclass = sc
|
|
|
|
|
return super(cls, subclass).__new__(subclass, *arguments, **keyword)
|
|
|
|
@ -1949,23 +1950,9 @@ class Network(Facts):
|
|
|
|
|
|
|
|
|
|
def __new__(cls, *arguments, **keyword):
|
|
|
|
|
subclass = cls
|
|
|
|
|
# Retrieve direct subclasses
|
|
|
|
|
to_visit = Network.__subclasses__()
|
|
|
|
|
# Then visit all subclasses
|
|
|
|
|
while to_visit:
|
|
|
|
|
for sc in to_visit:
|
|
|
|
|
# Check if current class is the good one
|
|
|
|
|
if sc.platform == platform.system():
|
|
|
|
|
subclass = sc
|
|
|
|
|
to_visit = []
|
|
|
|
|
break
|
|
|
|
|
# The current class is now visited, so remove it from list
|
|
|
|
|
to_visit.remove(sc)
|
|
|
|
|
# Appending all subclasses to visit and keep a reference of available class
|
|
|
|
|
for ssc in sc.__subclasses__():
|
|
|
|
|
to_visit.append(ssc)
|
|
|
|
|
|
|
|
|
|
# Now, return corresponding subclass
|
|
|
|
|
for sc in get_all_subclasses(Network):
|
|
|
|
|
if sc.platform == platform.system():
|
|
|
|
|
subclass = sc
|
|
|
|
|
return super(cls, subclass).__new__(subclass, *arguments, **keyword)
|
|
|
|
|
|
|
|
|
|
def populate(self):
|
|
|
|
@ -2725,7 +2712,7 @@ class Virtual(Facts):
|
|
|
|
|
|
|
|
|
|
def __new__(cls, *arguments, **keyword):
|
|
|
|
|
subclass = cls
|
|
|
|
|
for sc in Virtual.__subclasses__():
|
|
|
|
|
for sc in get_all_subclasses(Virtual):
|
|
|
|
|
if sc.platform == platform.system():
|
|
|
|
|
subclass = sc
|
|
|
|
|
return super(cls, subclass).__new__(subclass, *arguments, **keyword)
|
|
|
|
|