Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Add call to super().__init__() where appropriate #21

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion taf/testlib/afscross.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __init__(self, config, opts, env):
@type env: Environment
"""
self.class_logger.debug("Create AFS object.")
self.opts = opts
super().__init__(config, opts)

# Correcting AFS port map
if "mapcorrector" in config:
Copy link

Choose a reason for hiding this comment

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

Can we make this:

map_corrector = config.get('mapcorrector', {})
for dev_id, device in mapcorrector.items():
  dev_id_int = int(dev_id)
  valid_dev_set = {int(key) for key in device}
  # remove unnecessary items
  portmap = config['portmap']
  for items in portmap[:]:
    if items[0] == dev_id_int and items[1] not in valid_dev_set:
      portmap.remove(items)
  # correct port IDs
  for items in portmap:
    if items[0] == dev_id_int:
      items[1] = int(device[str(items[1])]

And I think we can drop lines 68 and 69.

Is there significance to the filtering of config? If yes, then perhaps the GenericEntry should allow descendants to give a set of keys that will be used to filter the config:

class GenericEntry(...):
  CONFIG_KEYS_ALLOWED = set()
  ...
  def __init__(...):
    ...
   if self.CONFIG_KEYS_ALLOWED:
      self.config = {key: config[key] for key in self.CONFIG_KEYS_ALLOWED}
   else:
      self.config = config
...
class AFS(...):
  CONFIG_KEYS_ALLOWED = {'id', 'instance_type', 'ip_host', 'user', 'password', 'portmap'}
...

Expand Down
4 changes: 1 addition & 3 deletions taf/testlib/dev_basecross.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,7 @@ def __init__(self, config, opts):
"""
@brief Initialize ZeroCross class
"""
self.id = config['id']
self.type = config['instance_type']
self.opts = opts
super().__init__(config, opts)
self.autoconnect = True

def xconnect(self, connection=None):
Expand Down
5 changes: 1 addition & 4 deletions taf/testlib/dev_onsswcross.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,9 @@ def __init__(self, config, opts):
@param opts: py.test config.option object which contains all py.test cli options.
@type opts: OptionParser
"""
super().__init__(config, opts)
self.class_logger.info("Init ONS Switch Cross object.")
self.id = config['id']
self.type = config['instance_type']
self.name = config['name'] if "name" in config else "noname"
Copy link

Choose a reason for hiding this comment

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

Can we make this self.name = config.get('name', 'noname')?

self.config = config
self.opts = opts
# Connections info:
self.connections = []
# Do xconnect on create?
Expand Down
12 changes: 6 additions & 6 deletions taf/testlib/dev_ovscontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ class OvsControllerGeneralMixin(entry_template.GenericEntry):
"""
class_logger = loggers.ClassLogger()

def __init__(self, config):
def __init__(self, config, opts):
"""
@brief Initialize OvsControllerGeneralMixin class
@param config: Configuration information.
@type config: dict
"""
super().__init__(config, opts)
self.val = config['related_id'][0]
self.sw_type = config['related_conf'][self.val]['instance_type']
if 'ip_host' in list(config.keys()):
Expand Down Expand Up @@ -460,10 +461,9 @@ def __init__(self, config, opts):
@param opts: py.test config.option object which contains all py.test cli options.
@type opts: OptionParser
"""
super(NoxControllerLocal, self).__init__(config)
super(NoxControllerLocal, self).__init__(config, opts)
self.popen = None
self.pid = None
self.opts = opts
self.cmdproxy = JsonCommand(self.json_ipaddr, self.port)
self.waiton_err_message = "OVS controller is started but does not respond."

Expand Down Expand Up @@ -600,7 +600,7 @@ def __init__(self, config, opts):
@param opts: py.test config.option object which contains all py.test cli options.
@type opts: OptionParser
"""
super(FloodlightControllerLocal, self).__init__(config)
super(FloodlightControllerLocal, self).__init__(config, opts)
self.popen = None
self.pid = None
self.opts = opts
Expand Down Expand Up @@ -744,7 +744,7 @@ def __init__(self, config, opts):
@param opts: py.test config.option object which contains all py.test cli options.
@type opts: OptionParser
"""
super(OFtestControllerLocal, self).__init__(config)
super(OFtestControllerLocal, self).__init__(config, opts)
self.popen = None
self.pid = None
self.opts = opts
Expand Down Expand Up @@ -874,7 +874,7 @@ def __init__(self, config, opts):
@param opts: py.test config.option object which contains all py.test cli options.
@type opts: OptionParser
"""
super(OvsControllerRemote, self).__init__(config)
super(OvsControllerRemote, self).__init__(config, opts)
self.popen = None
self.pid = None
self.opts = opts
Expand Down
4 changes: 1 addition & 3 deletions taf/testlib/dev_staticcross_ons.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ def __init__(self, config, opts):
@param opts: py.test config.option object which contains all py.test cli options.
@type opts: OptionParser
"""
self.id = config['id']
self.type = config['instance_type']
self.opts = opts
super().__init__(config, opts)
self.autoconnect = config['autoconnect'] if "autoconnect" in config else True

# Store configuration of related devices
Expand Down
4 changes: 1 addition & 3 deletions taf/testlib/dev_vethcross.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,8 @@ def __init__(self, config, opts):
@param opts: py.test config.option object which contains all py.test cli options.
@type opts: OptionParser
"""
super().__init__(config, opts)
self.class_logger.info("VethCross is selected.")
self.id = config['id']
self.type = config['instance_type']
self.opts = opts
# Connections info:
self.connections = []
# Do xconnect on create?
Expand Down
4 changes: 1 addition & 3 deletions taf/testlib/dev_vlabcross.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,10 @@ def __init__(self, config, opts):
@type opts: OptionParser
@raise CrossException: error in vlab path
"""
self.id = config['id']
self.type = config['instance_type']
super().__init__(config, opts)
self.ipaddr = config['ip_host']
self.port = config['ip_port'] if "ip_port" in config else "8050"
self.ifaces = config['ports']
self.opts = opts
# Do xconnect on create?
self.autoconnect = config['autoconnect'] if "autoconnect" in config else True

Expand Down