Remove deepsix reference in datasource drivers

Change-Id: Icfbf617873fa10f209fd498f439f744fc5878926
This commit is contained in:
Anusha Ramineni 2016-08-25 14:46:55 +05:30
parent 9338f3f367
commit 05b0714b4b
22 changed files with 95 additions and 239 deletions

View File

@ -29,17 +29,6 @@ from congress.datasources import datasource_utils as ds_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def d6service(name, keys, inbox, datapath, args):
"""Create a dataservice instance.
This method is called by d6cage to create a dataservice
instance. There are a couple of parameters we found useful
to add to that call, so we included them here instead of
modifying d6cage (and all the d6cage.createservice calls).
"""
return CeilometerDriver(name, keys, inbox, datapath, args)
# TODO(thinrichs): figure out how to move even more of this boilerplate # TODO(thinrichs): figure out how to move even more of this boilerplate
# into DataSourceDriver. E.g. change all the classes to Driver instead of # into DataSourceDriver. E.g. change all the classes to Driver instead of
# NeutronDriver, CeilometerDriver, etc. and move the d6instantiate function # NeutronDriver, CeilometerDriver, etc. and move the d6instantiate function
@ -156,9 +145,8 @@ class CeilometerDriver(datasource_driver.PollingDataSourceDriver,
TRANSLATORS = [meters_translator, alarms_translator, events_translator, TRANSLATORS = [meters_translator, alarms_translator, events_translator,
statistics_translator] statistics_translator]
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None): def __init__(self, name='', args=None):
super(CeilometerDriver, self).__init__(name, keys, inbox, super(CeilometerDriver, self).__init__(name, args=args)
datapath, args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
session = ds_utils.get_keystone_session(args) session = ds_utils.get_keystone_session(args)
self.ceilometer_client = cc.get_client(version='2', session=session) self.ceilometer_client = cc.get_client(version='2', session=session)

View File

@ -23,11 +23,6 @@ from congress.datasources import datasource_driver
from congress.datasources import datasource_utils as ds_utils from congress.datasources import datasource_utils as ds_utils
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
return CinderDriver(name, keys, inbox, datapath, args)
class CinderDriver(datasource_driver.PollingDataSourceDriver, class CinderDriver(datasource_driver.PollingDataSourceDriver,
datasource_driver.ExecutionDriver): datasource_driver.ExecutionDriver):
VOLUMES = "volumes" VOLUMES = "volumes"
@ -80,8 +75,8 @@ class CinderDriver(datasource_driver.PollingDataSourceDriver,
TRANSLATORS = [volumes_translator, snapshots_translator, TRANSLATORS = [volumes_translator, snapshots_translator,
services_translator] services_translator]
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None): def __init__(self, name='', args=None):
super(CinderDriver, self).__init__(name, keys, inbox, datapath, args) super(CinderDriver, self).__init__(name, args=args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
session = ds_utils.get_keystone_session(args) session = ds_utils.get_keystone_session(args)
self.cinder_client = cinderclient.client.Client(version='2', self.cinder_client = cinderclient.client.Client(version='2',

View File

@ -27,11 +27,6 @@ from congress.datasources import datasource_utils as ds_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
return CloudFoundryV2Driver(name, keys, inbox, datapath, args)
class CloudFoundryV2Driver(datasource_driver.PollingDataSourceDriver, class CloudFoundryV2Driver(datasource_driver.PollingDataSourceDriver,
datasource_driver.ExecutionDriver): datasource_driver.ExecutionDriver):
ORGANIZATIONS = 'organizations' ORGANIZATIONS = 'organizations'
@ -122,10 +117,8 @@ class CloudFoundryV2Driver(datasource_driver.PollingDataSourceDriver,
TRANSLATORS = [organizations_translator, TRANSLATORS = [organizations_translator,
spaces_translator, services_translator] spaces_translator, services_translator]
def __init__(self, name='', keys='', inbox=None, def __init__(self, name='', args=None):
datapath=None, args=None): super(CloudFoundryV2Driver, self).__init__(name, args=args)
super(CloudFoundryV2Driver, self).__init__(name, keys, inbox,
datapath, args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
self.creds = args self.creds = args
self.cloudfoundry = client.Client(username=self.creds['username'], self.cloudfoundry = client.Client(username=self.creds['username'],

View File

@ -17,10 +17,12 @@ from __future__ import print_function
from __future__ import division from __future__ import division
from __future__ import absolute_import from __future__ import absolute_import
from congress.dse2 import deepsix2 as deepsix import datetime
from functools import cmp_to_key from functools import cmp_to_key
from functools import reduce from functools import reduce
import hashlib
import json
import time
import eventlet import eventlet
from oslo_log import log as logging from oslo_log import log as logging
@ -35,16 +37,11 @@ from congress.dse2 import data_service
from congress import exception from congress import exception
from congress import utils from congress import utils
import datetime
import hashlib
import json
import time
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
class DataSourceDriver(deepsix.deepSix): class DataSourceDriver(data_service.DataService):
"""A super-class for datasource drivers. """A super-class for datasource drivers.
This class implements a polling mechanism for polling a datasource. This class implements a polling mechanism for polling a datasource.
@ -286,7 +283,8 @@ class DataSourceDriver(deepsix.deepSix):
TRANSLATORS = [] TRANSLATORS = []
def __init__(self, name, keys, inbox, datapath, args): def __init__(self, name='', args=None):
self.name = name
self.type = 'datasource_driver' self.type = 'datasource_driver'
self.initialized = False self.initialized = False
self.last_updated_time = None self.last_updated_time = None
@ -296,7 +294,6 @@ class DataSourceDriver(deepsix.deepSix):
# best done along with cleaning out the dse1-related params # best done along with cleaning out the dse1-related params
# now made unnecessary # now made unnecessary
self.ds_id = args.get('ds_id') if args is not None else None self.ds_id = args.get('ds_id') if args is not None else None
# a dictionary from tablename to the SET of tuples, both currently # a dictionary from tablename to the SET of tuples, both currently
# and in the past. # and in the past.
self.prior_state = dict() self.prior_state = dict()
@ -328,7 +325,7 @@ class DataSourceDriver(deepsix.deepSix):
# Make sure all data structures above are set up *before* calling # Make sure all data structures above are set up *before* calling
# this because it will publish info to the bus. # this because it will publish info to the bus.
super(DataSourceDriver, self).__init__(name, keys, inbox, datapath) super(DataSourceDriver, self).__init__(name)
# For DSE2. Must go after __init__ # For DSE2. Must go after __init__
if hasattr(self, 'add_rpc_endpoint'): if hasattr(self, 'add_rpc_endpoint'):
@ -1189,9 +1186,9 @@ class PushedDataSourceDriver(DataSourceDriver):
This DataSource Driver is a base class for push type datasource driver. This DataSource Driver is a base class for push type datasource driver.
""" """
def __init__(self, name, keys, inbox, datapath, args): def __init__(self, name='', args=None):
super(PushedDataSourceDriver, self).__init__(name, keys, inbox, self.persist_data = False
datapath, args) super(PushedDataSourceDriver, self).__init__(name, args)
# For DSE2. Must go after __init__ # For DSE2. Must go after __init__
if hasattr(self, 'add_rpc_endpoint'): if hasattr(self, 'add_rpc_endpoint'):
@ -1200,8 +1197,6 @@ class PushedDataSourceDriver(DataSourceDriver):
if args is not None: if args is not None:
self.persist_data = strutils.bool_from_string( self.persist_data = strutils.bool_from_string(
args.get('persist_data', 'False'), strict=True) args.get('persist_data', 'False'), strict=True)
else:
self.persist_data = False
if self.persist_data: if self.persist_data:
if self.ds_id is None: if self.ds_id is None:
@ -1261,7 +1256,7 @@ class PushedDataSourceDriverEndpoints(data_service.DataServiceEndPoints):
class PollingDataSourceDriver(DataSourceDriver): class PollingDataSourceDriver(DataSourceDriver):
def __init__(self, name, keys, inbox, datapath, args): def __init__(self, name='', args=None):
if args is None: if args is None:
args = dict() args = dict()
@ -1284,8 +1279,7 @@ class PollingDataSourceDriver(DataSourceDriver):
self.refresh_request_queue = eventlet.Queue(maxsize=1) self.refresh_request_queue = eventlet.Queue(maxsize=1)
self.worker_greenthread = None self.worker_greenthread = None
super(PollingDataSourceDriver, self).__init__(name, keys, inbox, super(PollingDataSourceDriver, self).__init__(name, args=args)
datapath, args)
def _init_end_start_poll(self): def _init_end_start_poll(self):
"""Mark initializes the success and launch poll loop. """Mark initializes the success and launch poll loop.

View File

@ -23,11 +23,6 @@ from congress.datasources import constants
from congress.datasources import datasource_driver from congress.datasources import datasource_driver
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
return DoctorDriver(name, keys, inbox, datapath, args)
class DoctorDriver(datasource_driver.PushedDataSourceDriver): class DoctorDriver(datasource_driver.PushedDataSourceDriver):
"""A DataSource Driver for OPNFV Doctor project. """A DataSource Driver for OPNFV Doctor project.
@ -97,8 +92,8 @@ class DoctorDriver(datasource_driver.PushedDataSourceDriver):
TRANSLATORS = [events_translator] TRANSLATORS = [events_translator]
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None): def __init__(self, name='', args=None):
super(DoctorDriver, self).__init__(name, keys, inbox, datapath, args) super(DoctorDriver, self).__init__(name, args=args)
@staticmethod @staticmethod
def get_datasource_info(): def get_datasource_info():

View File

@ -26,11 +26,6 @@ from congress.datasources import datasource_utils as ds_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
return GlanceV2Driver(name, keys, inbox, datapath, args)
class GlanceV2Driver(datasource_driver.PollingDataSourceDriver, class GlanceV2Driver(datasource_driver.PollingDataSourceDriver,
datasource_driver.ExecutionDriver): datasource_driver.ExecutionDriver):
@ -102,8 +97,8 @@ class GlanceV2Driver(datasource_driver.PollingDataSourceDriver,
TRANSLATORS = [images_translator] TRANSLATORS = [images_translator]
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None): def __init__(self, name='', args=None):
super(GlanceV2Driver, self).__init__(name, keys, inbox, datapath, args) super(GlanceV2Driver, self).__init__(name, args=args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
self.creds = args self.creds = args
session = ds_utils.get_keystone_session(self.creds) session = ds_utils.get_keystone_session(self.creds)

View File

@ -23,11 +23,6 @@ from congress.datasources import datasource_utils as ds_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
return HeatV1Driver(name, keys, inbox, datapath, args)
class HeatV1Driver(datasource_driver.PollingDataSourceDriver, class HeatV1Driver(datasource_driver.PollingDataSourceDriver,
datasource_driver.ExecutionDriver): datasource_driver.ExecutionDriver):
@ -147,8 +142,8 @@ class HeatV1Driver(datasource_driver.PollingDataSourceDriver,
TRANSLATORS = [stacks_translator, software_deployment_translator, TRANSLATORS = [stacks_translator, software_deployment_translator,
resources_translator, events_translator] resources_translator, events_translator]
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None): def __init__(self, name='', args=None):
super(HeatV1Driver, self).__init__(name, keys, inbox, datapath, args) super(HeatV1Driver, self).__init__(name, args=args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
self.creds = args self.creds = args
session = ds_utils.get_keystone_session(self.creds) session = ds_utils.get_keystone_session(self.creds)

View File

@ -24,11 +24,6 @@ from congress.datasources import datasource_driver
from congress.datasources import datasource_utils as ds_utils from congress.datasources import datasource_utils as ds_utils
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
return IronicDriver(name, keys, inbox, datapath, args)
class IronicDriver(datasource_driver.PollingDataSourceDriver, class IronicDriver(datasource_driver.PollingDataSourceDriver,
datasource_driver.ExecutionDriver): datasource_driver.ExecutionDriver):
CHASSISES = "chassises" CHASSISES = "chassises"
@ -135,8 +130,8 @@ class IronicDriver(datasource_driver.PollingDataSourceDriver,
TRANSLATORS = [chassises_translator, nodes_translator, ports_translator, TRANSLATORS = [chassises_translator, nodes_translator, ports_translator,
drivers_translator] drivers_translator]
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None): def __init__(self, name='', args=None):
super(IronicDriver, self).__init__(name, keys, inbox, datapath, args) super(IronicDriver, self).__init__(name, args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
self.creds = self.get_ironic_credentials(args) self.creds = self.get_ironic_credentials(args)
session = ds_utils.get_keystone_session(self.creds) session = ds_utils.get_keystone_session(self.creds)

View File

@ -23,12 +23,6 @@ from congress.datasources import datasource_driver
from congress.datasources import datasource_utils as ds_utils from congress.datasources import datasource_utils as ds_utils
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
d = KeystoneDriver(name, keys, inbox, datapath, args)
return d
class KeystoneDriver(datasource_driver.PollingDataSourceDriver, class KeystoneDriver(datasource_driver.PollingDataSourceDriver,
datasource_driver.ExecutionDriver): datasource_driver.ExecutionDriver):
# Table names # Table names
@ -71,8 +65,8 @@ class KeystoneDriver(datasource_driver.PollingDataSourceDriver,
TRANSLATORS = [users_translator, roles_translator, tenants_translator] TRANSLATORS = [users_translator, roles_translator, tenants_translator]
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None): def __init__(self, name='', args=None):
super(KeystoneDriver, self).__init__(name, keys, inbox, datapath, args) super(KeystoneDriver, self).__init__(name, args=args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
self.creds = self.get_keystone_credentials_v2(args) self.creds = self.get_keystone_credentials_v2(args)
self.creds['auth_url'] = self.creds['auth_url'].replace('v3', 'v2.0') self.creds['auth_url'] = self.creds['auth_url'].replace('v3', 'v2.0')

View File

@ -23,12 +23,6 @@ from congress.datasources import datasource_driver
from congress.datasources import datasource_utils as ds_utils from congress.datasources import datasource_utils as ds_utils
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
d = KeystoneV3Driver(name, keys, inbox, datapath, args)
return d
class KeystoneV3Driver(datasource_driver.PollingDataSourceDriver, class KeystoneV3Driver(datasource_driver.PollingDataSourceDriver,
datasource_driver.ExecutionDriver): datasource_driver.ExecutionDriver):
# Table names # Table names
@ -105,9 +99,8 @@ class KeystoneV3Driver(datasource_driver.PollingDataSourceDriver,
TRANSLATORS = [users_translator, roles_translator, projects_translator, TRANSLATORS = [users_translator, roles_translator, projects_translator,
domains_translator] domains_translator]
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None): def __init__(self, name='', args=None):
super(KeystoneV3Driver, self).__init__(name, keys, inbox, datapath, super(KeystoneV3Driver, self).__init__(name, args=args)
args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
self.creds = args self.creds = args
session = ds_utils.get_keystone_session(args) session = ds_utils.get_keystone_session(args)

View File

@ -26,17 +26,6 @@ from congress.datasources import datasource_utils as ds_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def d6service(name, keys, inbox, datapath, args):
"""Create a dataservice instance.
This method is called by d6cage to create a dataservice
instance. There are a couple of parameters we found useful
to add to that call, so we included them here instead of
modifying d6cage (and all the d6cage.createservice calls).
"""
return MonascaDriver(name, keys, inbox, datapath, args)
# TODO(thinrichs): figure out how to move even more of this boilerplate # TODO(thinrichs): figure out how to move even more of this boilerplate
# into DataSourceDriver. E.g. change all the classes to Driver instead of # into DataSourceDriver. E.g. change all the classes to Driver instead of
# NeutronDriver, CeilometerDriver, etc. and move the d6instantiate function # NeutronDriver, CeilometerDriver, etc. and move the d6instantiate function
@ -85,9 +74,8 @@ class MonascaDriver(datasource_driver.PollingDataSourceDriver,
TRANSLATORS = [metric_translator, statistics_translator] TRANSLATORS = [metric_translator, statistics_translator]
def __init__(self, name='', keys='', inbox=None, datapath=None, def __init__(self, name='', args=None):
args=None): super(MonascaDriver, self).__init__(name, args=args)
super(MonascaDriver, self).__init__(name, keys, inbox, datapath, args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
self.creds = args self.creds = args
if not self.creds.get('project_name'): if not self.creds.get('project_name'):

View File

@ -34,11 +34,6 @@ from congress import utils
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
return MuranoDriver(name, keys, inbox, datapath, args)
class MuranoDriver(datasource_driver.PollingDataSourceDriver, class MuranoDriver(datasource_driver.PollingDataSourceDriver,
datasource_driver.ExecutionDriver): datasource_driver.ExecutionDriver):
OBJECTS = "objects" OBJECTS = "objects"
@ -52,8 +47,8 @@ class MuranoDriver(datasource_driver.PollingDataSourceDriver,
UNUSED_ENV_PROPERTIES = ['id', 'tenant_id'] UNUSED_ENV_PROPERTIES = ['id', 'tenant_id']
APPS_TYPE_PREFIXES = ['io.murano.apps', 'io.murano.databases'] APPS_TYPE_PREFIXES = ['io.murano.apps', 'io.murano.databases']
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None): def __init__(self, name='', args=None):
super(MuranoDriver, self).__init__(name, keys, inbox, datapath, args) super(MuranoDriver, self).__init__(name, args=args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
self.creds = args self.creds = args
session = datasource_utils.get_keystone_session(self.creds) session = datasource_utils.get_keystone_session(self.creds)

View File

@ -26,11 +26,6 @@ from congress.datasources import datasource_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
return NeutronDriver(name, keys, inbox, datapath, args)
class NeutronDriver(datasource_driver.PollingDataSourceDriver, class NeutronDriver(datasource_driver.PollingDataSourceDriver,
datasource_driver.ExecutionDriver): datasource_driver.ExecutionDriver):
@ -163,8 +158,8 @@ class NeutronDriver(datasource_driver.PollingDataSourceDriver,
TRANSLATORS = [networks_translator, ports_translator, routers_translator, TRANSLATORS = [networks_translator, ports_translator, routers_translator,
security_groups_translator] security_groups_translator]
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None): def __init__(self, name='', args=None):
super(NeutronDriver, self).__init__(name, keys, inbox, datapath, args) super(NeutronDriver, self).__init__(name, args=args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
self.creds = self.get_neutron_credentials(args) self.creds = self.get_neutron_credentials(args)
self.neutron = neutronclient.v2_0.client.Client(**self.creds) self.neutron = neutronclient.v2_0.client.Client(**self.creds)

View File

@ -26,11 +26,6 @@ from congress.datasources import datasource_utils as ds_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
return NeutronV2Driver(name, keys, inbox, datapath, args)
class NeutronV2Driver(datasource_driver.PollingDataSourceDriver, class NeutronV2Driver(datasource_driver.PollingDataSourceDriver,
datasource_driver.ExecutionDriver): datasource_driver.ExecutionDriver):
@ -335,10 +330,8 @@ class NeutronV2Driver(datasource_driver.PollingDataSourceDriver,
routers_translator, security_group_translator, routers_translator, security_group_translator,
floating_ips_translator] floating_ips_translator]
def __init__(self, name='', keys='', inbox=None, def __init__(self, name='', args=None):
datapath=None, args=None): super(NeutronV2Driver, self).__init__(name, args=args)
super(NeutronV2Driver, self).__init__(name, keys, inbox,
datapath, args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
self.creds = args self.creds = args
session = ds_utils.get_keystone_session(self.creds) session = ds_utils.get_keystone_session(self.creds)

View File

@ -28,11 +28,6 @@ from congress.datasources import datasource_utils as ds_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
return NovaDriver(name, keys, inbox, datapath, args)
class NovaDriver(datasource_driver.PollingDataSourceDriver, class NovaDriver(datasource_driver.PollingDataSourceDriver,
datasource_driver.ExecutionDriver): datasource_driver.ExecutionDriver):
SERVERS = "servers" SERVERS = "servers"
@ -172,8 +167,8 @@ class NovaDriver(datasource_driver.PollingDataSourceDriver,
floating_ips_translator, services_translator, floating_ips_translator, services_translator,
availability_zones_translator] availability_zones_translator]
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None): def __init__(self, name='', args=None):
super(NovaDriver, self).__init__(name, keys, inbox, datapath, args) super(NovaDriver, self).__init__(name, args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
self.creds = args self.creds = args
session = ds_utils.get_keystone_session(self.creds) session = ds_utils.get_keystone_session(self.creds)

View File

@ -43,12 +43,6 @@ from congress.datasources import datasource_driver
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
return PlexxiDriver(name, keys, inbox, datapath, args)
class PlexxiDriver(datasource_driver.PollingDataSourceDriver, class PlexxiDriver(datasource_driver.PollingDataSourceDriver,
datasource_driver.ExecutionDriver): datasource_driver.ExecutionDriver):
HOSTS = "hosts" HOSTS = "hosts"
@ -65,9 +59,8 @@ class PlexxiDriver(datasource_driver.PollingDataSourceDriver,
PORTS = "ports" PORTS = "ports"
NETWORKLINKS = "networklinks" NETWORKLINKS = "networklinks"
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None, def __init__(self, name='', args=None, session=None):
session=None): super(PlexxiDriver, self).__init__(name, args=args)
super(PlexxiDriver, self).__init__(name, keys, inbox, datapath, args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
self.exchange = session self.exchange = session
self.creds = args self.creds = args

View File

@ -26,11 +26,6 @@ from congress.datasources import datasource_driver
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
return PushDriver(name, keys, inbox, datapath, args)
class PushDriver(datasource_driver.PushedDataSourceDriver): class PushDriver(datasource_driver.PushedDataSourceDriver):
"""A DataSource Driver for pushing tuples of data. """A DataSource Driver for pushing tuples of data.
@ -46,8 +41,8 @@ class PushDriver(datasource_driver.PushedDataSourceDriver):
[ [1,2], [3,4] ] [ [1,2], [3,4] ]
""" """
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None): def __init__(self, name='', args=None):
super(PushDriver, self).__init__(name, keys, inbox, datapath, args) super(PushDriver, self).__init__(name, args=args)
self._table_deps['data'] = ['data'] self._table_deps['data'] = ['data']
@classmethod @classmethod

View File

@ -26,11 +26,6 @@ from congress.datasources import datasource_utils as ds_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
return SwiftDriver(name, keys, inbox, datapath, args)
class SwiftDriver(datasource_driver.PollingDataSourceDriver, class SwiftDriver(datasource_driver.PollingDataSourceDriver,
datasource_driver.ExecutionDriver): datasource_driver.ExecutionDriver):
@ -62,10 +57,10 @@ class SwiftDriver(datasource_driver.PollingDataSourceDriver,
TRANSLATORS = [containers_translator, objects_translator] TRANSLATORS = [containers_translator, objects_translator]
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None): def __init__(self, name='', args=None):
if args is None: if args is None:
args = self.empty_credentials() args = self.empty_credentials()
super(SwiftDriver, self).__init__(name, keys, inbox, datapath, args) super(SwiftDriver, self).__init__(name, args=args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
options = self.get_swift_credentials_v1(args) options = self.get_swift_credentials_v1(args)
# TODO(ramineni): Enable v3 support # TODO(ramineni): Enable v3 support

View File

@ -30,14 +30,6 @@ from congress.datasources import datasource_utils as ds_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance.
"""
return VCenterDriver(name, keys, inbox, datapath, args)
class VCenterDriver(datasource_driver.PollingDataSourceDriver, class VCenterDriver(datasource_driver.PollingDataSourceDriver,
datasource_driver.ExecutionDriver): datasource_driver.ExecutionDriver):
@ -107,13 +99,12 @@ class VCenterDriver(datasource_driver.PollingDataSourceDriver,
TRANSLATORS = [hosts_translator, pnic_translator, vnic_translator, TRANSLATORS = [hosts_translator, pnic_translator, vnic_translator,
vms_translator] vms_translator]
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None, def __init__(self, name='', args=None, session=None):
session=None):
if args is None: if args is None:
args = self.empty_credentials() args = self.empty_credentials()
else: else:
args['tenant_name'] = None args['tenant_name'] = None
super(VCenterDriver, self).__init__(name, keys, inbox, datapath, args) super(VCenterDriver, self).__init__(name, args=args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
try: try:
self.max_VMs = int(args['max_vms']) self.max_VMs = int(args['max_vms'])

View File

@ -20,17 +20,6 @@ from __future__ import absolute_import
from congress.datasources import datasource_driver from congress.datasources import datasource_driver
def d6service(name, keys, inbox, datapath, args):
"""Create dataservice instance.
This method is called by d6cage to create a dataservice
instance. There are a couple of parameters we found useful
to add to that call, so we included them here instead of
modifying d6cage (and all the d6cage.createservice calls).
"""
return PerformanceTestDriver(name, keys, inbox, datapath, args)
class PerformanceTestDriver(datasource_driver.PollingDataSourceDriver): class PerformanceTestDriver(datasource_driver.PollingDataSourceDriver):
TABLE = 'p' TABLE = 'p'
@ -49,11 +38,10 @@ class PerformanceTestDriver(datasource_driver.PollingDataSourceDriver):
{'fieldname': 'field5', 'translator': value_trans}, {'fieldname': 'field5', 'translator': value_trans},
{'fieldname': 'field6', 'translator': value_trans})} {'fieldname': 'field6', 'translator': value_trans})}
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None): def __init__(self, name='', args=None):
# if args is None: # if args is None:
# args = self._empty_openstack_credentials() # args = self._empty_openstack_credentials()
super(PerformanceTestDriver, self).__init__( super(PerformanceTestDriver, self).__init__(name, args)
name, keys, inbox, datapath, args)
self.client_data = None self.client_data = None
self.register_translator(PerformanceTestDriver.p_translator) self.register_translator(PerformanceTestDriver.p_translator)
self._init_end_start_poll() self._init_end_start_poll()

View File

@ -91,7 +91,7 @@ class TestDatasourceDriver(base.TestCase):
{'fieldname': 'fixed_ips', {'fieldname': 'fixed_ips',
'translator': ports_fixed_ips_translator})} 'translator': ports_fixed_ips_translator})}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
driver.register_translator(ports_translator) driver.register_translator(ports_translator)
ports = [{'id': '12345', ports = [{'id': '12345',
'fixed_ips': [{'ip_address': '1.1.1.1', 'subnet_id': 'aa'}, 'fixed_ips': [{'ip_address': '1.1.1.1', 'subnet_id': 'aa'},
@ -131,7 +131,7 @@ class TestDatasourceDriver(base.TestCase):
{'fieldname': 'level2', {'fieldname': 'level2',
'translator': level2_translator})} 'translator': level2_translator})}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
driver.register_translator(level1_translator) driver.register_translator(level1_translator)
data = [ data = [
{'id': 11, 'level2': {'id': 11, 'level2':
@ -162,7 +162,7 @@ class TestDatasourceDriver(base.TestCase):
{'fieldname': 'level2', {'fieldname': 'level2',
'translator': level2_translator})} 'translator': level2_translator})}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
datasource_driver.DataSourceDriver.TRANSLATORS = [level1_translator] datasource_driver.DataSourceDriver.TRANSLATORS = [level1_translator]
driver.register_translator(level1_translator) driver.register_translator(level1_translator)
# test schema # test schema
@ -197,7 +197,7 @@ class TestDatasourceDriver(base.TestCase):
{'fieldname': 'level2', {'fieldname': 'level2',
'translator': level2_translator})} 'translator': level2_translator})}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
datasource_driver.DataSourceDriver.TRANSLATORS = [level1_translator] datasource_driver.DataSourceDriver.TRANSLATORS = [level1_translator]
# test schema # test schema
schema = driver.get_schema() schema = driver.get_schema()
@ -231,7 +231,7 @@ class TestDatasourceDriver(base.TestCase):
{'fieldname': 'level2', {'fieldname': 'level2',
'translator': level2_translator})} 'translator': level2_translator})}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
datasource_driver.DataSourceDriver.TRANSLATORS = [level1_translator] datasource_driver.DataSourceDriver.TRANSLATORS = [level1_translator]
# test schema # test schema
schema = driver.get_schema() schema = driver.get_schema()
@ -259,7 +259,7 @@ class TestDatasourceDriver(base.TestCase):
'table-name': 'table1', 'table-name': 'table1',
'val-col': 'tag', 'val-col': 'tag',
'translator': self.val_trans}},)} 'translator': self.val_trans}},)}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
self.assertRaises(exception.DuplicateTableName, self.assertRaises(exception.DuplicateTableName,
driver.register_translator, driver.register_translator,
translator) translator)
@ -272,7 +272,7 @@ class TestDatasourceDriver(base.TestCase):
'table-name': 'testtable', 'table-name': 'testtable',
'id-col': 'id', 'val-col': 'val', 'id-col': 'id', 'val-col': 'val',
'translator': self.val_trans}} 'translator': self.val_trans}}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
self.assertRaises(exception.DuplicateTableName, self.assertRaises(exception.DuplicateTableName,
driver.register_translator, translator) driver.register_translator, translator)
@ -287,7 +287,7 @@ class TestDatasourceDriver(base.TestCase):
'table-name': 'table2', 'table-name': 'table2',
'val-col': 'tag', 'val-col': 'tag',
'translator': self.val_trans}},)} 'translator': self.val_trans}},)}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
driver.register_translator(translator) driver.register_translator(translator)
self.assertRaises(exception.DuplicateTableName, self.assertRaises(exception.DuplicateTableName,
driver.register_translator, driver.register_translator,
@ -307,7 +307,7 @@ class TestDatasourceDriver(base.TestCase):
({'fieldname': 'x', ({'fieldname': 'x',
'translator': self.val_trans},)}},)} 'translator': self.val_trans},)}},)}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
self.assertRaises(exception.DuplicateTableName, self.assertRaises(exception.DuplicateTableName,
driver.register_translator, driver.register_translator,
translator) translator)
@ -315,14 +315,14 @@ class TestDatasourceDriver(base.TestCase):
def test_invalid_translation_type(self): def test_invalid_translation_type(self):
translator = {'translation-type': 'YOYO', translator = {'translation-type': 'YOYO',
'table-name': 'table1'} 'table-name': 'table1'}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
self.assertRaises(exception.InvalidTranslationType, self.assertRaises(exception.InvalidTranslationType,
driver.register_translator, driver.register_translator,
translator) translator)
translator = {'translation-type': 'LIS', translator = {'translation-type': 'LIS',
'table-name': 'table1'} 'table-name': 'table1'}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
self.assertRaises(exception.InvalidTranslationType, self.assertRaises(exception.InvalidTranslationType,
driver.register_translator, driver.register_translator,
translator) translator)
@ -331,7 +331,7 @@ class TestDatasourceDriver(base.TestCase):
translator = {'translation-type': 'VDICT', translator = {'translation-type': 'VDICT',
'table-name': 'table1', 'table-name': 'table1',
'val-col': 'id-col'} 'val-col': 'id-col'}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
self.assertRaises(exception.InvalidParamException, self.assertRaises(exception.InvalidParamException,
driver.register_translator, driver.register_translator,
translator) translator)
@ -340,7 +340,7 @@ class TestDatasourceDriver(base.TestCase):
translator = {'translation-type': 'VDICT', translator = {'translation-type': 'VDICT',
'table-name': 'table1', 'table-name': 'table1',
'key-col': 'id-col'} 'key-col': 'id-col'}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
self.assertRaises(exception.InvalidParamException, self.assertRaises(exception.InvalidParamException,
driver.register_translator, driver.register_translator,
translator) translator)
@ -348,7 +348,7 @@ class TestDatasourceDriver(base.TestCase):
def test_no_val_col_in_list(self): def test_no_val_col_in_list(self):
translator = {'translation-type': 'LIST', translator = {'translation-type': 'LIST',
'table-name': 'table1'} 'table-name': 'table1'}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
self.assertRaises(exception.InvalidParamException, self.assertRaises(exception.InvalidParamException,
driver.register_translator, driver.register_translator,
translator) translator)
@ -360,19 +360,19 @@ class TestDatasourceDriver(base.TestCase):
'parent-key': 'parent_key_column'} 'parent-key': 'parent_key_column'}
# Test LIST # Test LIST
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
self.assertRaises(exception.InvalidParamException, self.assertRaises(exception.InvalidParamException,
driver.register_translator, driver.register_translator,
translator) translator)
# Test HDICT # Test HDICT
translator['translation-type'] = 'VDICT' translator['translation-type'] = 'VDICT'
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
self.assertRaises(exception.InvalidParamException, self.assertRaises(exception.InvalidParamException,
driver.register_translator, driver.register_translator,
translator) translator)
# Test HDICT # Test HDICT
translator['translation-type'] = 'HDICT' translator['translation-type'] = 'HDICT'
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
self.assertRaises(exception.InvalidParamException, self.assertRaises(exception.InvalidParamException,
driver.register_translator, driver.register_translator,
translator) translator)
@ -383,7 +383,7 @@ class TestDatasourceDriver(base.TestCase):
'id-col': 'id-col', 'id-col': 'id-col',
'invalid_column': 'blah'} 'invalid_column': 'blah'}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
self.assertRaises(exception.InvalidParamException, self.assertRaises(exception.InvalidParamException,
driver.register_translator, driver.register_translator,
translator) translator)
@ -403,7 +403,7 @@ class TestDatasourceDriver(base.TestCase):
({'fieldname': 'x', ({'fieldname': 'x',
'translator': self.val_trans},)}},)} 'translator': self.val_trans},)}},)}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
self.assertRaises(exception.InvalidParamException, self.assertRaises(exception.InvalidParamException,
driver.register_translator, driver.register_translator,
translator) translator)
@ -422,7 +422,7 @@ class TestDatasourceDriver(base.TestCase):
({'fieldname': 'ip_address', ({'fieldname': 'ip_address',
'translator': self.val_trans},)}} 'translator': self.val_trans},)}}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
self.assertRaises(exception.InvalidParamException, self.assertRaises(exception.InvalidParamException,
driver.register_translator, driver.register_translator,
translator) translator)
@ -994,8 +994,7 @@ class TestDatasourceDriver(base.TestCase):
def test_convert_bad_params(self): def test_convert_bad_params(self):
def verify_invalid_params(translator, err_msg): def verify_invalid_params(translator, err_msg):
args = helper.datasource_openstack_args() args = helper.datasource_openstack_args()
driver = datasource_driver.DataSourceDriver('', '', None, None, driver = datasource_driver.DataSourceDriver('', args=args)
args=args)
try: try:
driver.register_translator(translator) driver.register_translator(translator)
except exception.InvalidParamException as e: except exception.InvalidParamException as e:
@ -1138,7 +1137,7 @@ class TestDatasourceDriver(base.TestCase):
TRANSLATORS = [translator] TRANSLATORS = [translator]
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
schema = TestDriver().get_schema() schema = TestDriver().get_schema()
self.assertEqual(7, len(schema)) self.assertEqual(7, len(schema))
@ -1179,7 +1178,7 @@ class TestDatasourceDriver(base.TestCase):
TRANSLATORS = [translator] TRANSLATORS = [translator]
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
try: try:
TestDriver().get_schema() TestDriver().get_schema()
@ -1207,7 +1206,7 @@ class TestDatasourceDriver(base.TestCase):
TRANSLATORS = [translator] TRANSLATORS = [translator]
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
schema = TestDriver().get_schema() schema = TestDriver().get_schema()
@ -1236,7 +1235,7 @@ class TestDatasourceDriver(base.TestCase):
TRANSLATORS = [translator] TRANSLATORS = [translator]
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
schema = TestDriver().get_schema() schema = TestDriver().get_schema()
@ -1263,7 +1262,7 @@ class TestDatasourceDriver(base.TestCase):
TRANSLATORS = [translator] TRANSLATORS = [translator]
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
schema = TestDriver().get_schema() schema = TestDriver().get_schema()
@ -1286,7 +1285,7 @@ class TestDatasourceDriver(base.TestCase):
TRANSLATORS = [translator1] TRANSLATORS = [translator1]
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
expected_ret = 'table-name1' expected_ret = 'table-name1'
ret = TestDriver().get_tablename('table-name1') ret = TestDriver().get_tablename('table-name1')
@ -1314,7 +1313,7 @@ class TestDatasourceDriver(base.TestCase):
TRANSLATORS = [translator1, translator2] TRANSLATORS = [translator1, translator2]
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
expected_ret = ['table-name1', 'table-name2'] expected_ret = ['table-name1', 'table-name2']
ret = TestDriver().get_tablenames() ret = TestDriver().get_tablenames()
@ -1323,7 +1322,7 @@ class TestDatasourceDriver(base.TestCase):
def test_get_row_data(self): def test_get_row_data(self):
class TestDriver(datasource_driver.DataSourceDriver): class TestDriver(datasource_driver.DataSourceDriver):
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
test_driver = TestDriver() test_driver = TestDriver()
test_driver.state = {'fake_table': [('d1', 'd2'), ('d3', 'd4')]} test_driver.state = {'fake_table': [('d1', 'd2'), ('d3', 'd4')]}
@ -1355,7 +1354,7 @@ class TestDatasourceDriver(base.TestCase):
TRANSLATORS = [translator1] TRANSLATORS = [translator1]
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
expected_ret = ['table-name1', 'table-name2'] expected_ret = ['table-name1', 'table-name2']
ret = TestDriver().get_tablenames() ret = TestDriver().get_tablenames()
@ -1446,7 +1445,7 @@ class TestDatasourceDriver(base.TestCase):
def test_update_state(self): def test_update_state(self):
class TestDriver(datasource_driver.DataSourceDriver): class TestDriver(datasource_driver.DataSourceDriver):
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
test_driver = TestDriver() test_driver = TestDriver()
test_driver.state = {'fake_table': set(), 'foo_table': set(), test_driver.state = {'fake_table': set(), 'foo_table': set(),
@ -1469,7 +1468,7 @@ class TestDatasourceDriver(base.TestCase):
def test_update_state_with_undefined_table(self): def test_update_state_with_undefined_table(self):
class TestDriver(datasource_driver.DataSourceDriver): class TestDriver(datasource_driver.DataSourceDriver):
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
test_driver = TestDriver() test_driver = TestDriver()
test_driver.state = {'fake_table': set(), 'foo_table': set()} test_driver.state = {'fake_table': set(), 'foo_table': set()}
@ -1488,7 +1487,7 @@ class TestDatasourceDriver(base.TestCase):
def test_update_state_with_none_row_data(self): def test_update_state_with_none_row_data(self):
class TestDriver(datasource_driver.DataSourceDriver): class TestDriver(datasource_driver.DataSourceDriver):
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
test_driver = TestDriver() test_driver = TestDriver()
test_driver.state = {'fake_table': {mock.sentinel.data1}, test_driver.state = {'fake_table': {mock.sentinel.data1},
@ -1503,7 +1502,7 @@ class TestDatasourceDriver(base.TestCase):
def test_update_state_with_part_none_row_data(self): def test_update_state_with_part_none_row_data(self):
class TestDriver(datasource_driver.DataSourceDriver): class TestDriver(datasource_driver.DataSourceDriver):
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
test_driver = TestDriver() test_driver = TestDriver()
test_driver.state = {'fake_table': set(), test_driver.state = {'fake_table': set(),
@ -1558,7 +1557,7 @@ class TestDatasourceDriver(base.TestCase):
{'fieldname': 'level2', {'fieldname': 'level2',
'translator': level2_translator})} 'translator': level2_translator})}
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
driver.register_translator(level1_translator) driver.register_translator(level1_translator)
driver.register_translator(level10_translator) driver.register_translator(level10_translator)
expected_table_deps = {'level1': ['level1', 'level2', 'level3'], expected_table_deps = {'level1': ['level1', 'level2', 'level3'],
@ -1569,7 +1568,7 @@ class TestDatasourceDriver(base.TestCase):
def test_init_consistence_with_exception(self, mock_spawn): def test_init_consistence_with_exception(self, mock_spawn):
class TestDriver(datasource_driver.DataSourceDriver): class TestDriver(datasource_driver.DataSourceDriver):
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
self.do_something() self.do_something()
self._init_end_start_poll() self._init_end_start_poll()
@ -1620,7 +1619,7 @@ class TestDatasourceDriver(base.TestCase):
expected_ret = [('test', ('key1', 'value1')), expected_ret = [('test', ('key1', 'value1')),
('test', ('key2', 'value2'))] ('test', ('key2', 'value2'))]
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
driver.register_translator(test_translator) driver.register_translator(test_translator)
ret = driver.convert_objs(objs, test_translator) ret = driver.convert_objs(objs, test_translator)
@ -1676,7 +1675,7 @@ class TestDatasourceDriver(base.TestCase):
} }
}] }]
driver = datasource_driver.DataSourceDriver('', '', None, None, None) driver = datasource_driver.DataSourceDriver('', None)
driver.register_translator(test_parent_translator) driver.register_translator(test_parent_translator)
ret = driver.convert_objs(objs, test_parent_translator) ret = driver.convert_objs(objs, test_parent_translator)
@ -1724,8 +1723,7 @@ class TestDatasourceDriver(base.TestCase):
class TestPollingDataSourceDriver(base.TestCase): class TestPollingDataSourceDriver(base.TestCase):
class TestDriver(datasource_driver.PollingDataSourceDriver): class TestDriver(datasource_driver.PollingDataSourceDriver):
def __init__(self): def __init__(self):
super(TestPollingDataSourceDriver.TestDriver, self).__init__( super(TestPollingDataSourceDriver.TestDriver, self).__init__()
'', '', None, None, None)
self.node = 'node' self.node = 'node'
self._rpc_server = mock.MagicMock() self._rpc_server = mock.MagicMock()
self._init_end_start_poll() self._init_end_start_poll()
@ -1782,7 +1780,7 @@ class TestPollingDataSourceDriver(base.TestCase):
} }
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
self.add_update_method(self.update_method, self.add_update_method(self.update_method,
self.test_translator) self.test_translator)
@ -1800,7 +1798,7 @@ class TestPollingDataSourceDriver(base.TestCase):
} }
def __init__(self): def __init__(self):
super(TestDriver, self).__init__('', '', None, None, None) super(TestDriver, self).__init__('', None)
self.add_update_method(self.update_method, self.add_update_method(self.update_method,
self.test_translator) self.test_translator)
@ -1830,8 +1828,7 @@ class TestPushedDriver(base.SqlTestCase):
def __init__(self, args=None): def __init__(self, args=None):
super(TestPushedDriver.TestDriver, self).__init__('test-pushed', super(TestPushedDriver.TestDriver, self).__init__('test-pushed',
'', None, args)
None, args)
def setUp(self): def setUp(self):
super(TestPushedDriver, self).setUp() super(TestPushedDriver, self).setUp()

View File

@ -25,11 +25,6 @@ from congress.datasources import datasource_utils
LOG = logging.getLogger(__name__) LOG = logging.getLogger(__name__)
def d6service(name, keys, inbox, datapath, args):
"""This method is called by d6cage to create a dataservice instance."""
return FakeDataSource(name, keys, inbox, datapath, args)
class FakeDataSource(datasource_driver.PollingDataSourceDriver, class FakeDataSource(datasource_driver.PollingDataSourceDriver,
datasource_driver.PushedDataSourceDriver, datasource_driver.PushedDataSourceDriver,
datasource_driver.ExecutionDriver): datasource_driver.ExecutionDriver):
@ -45,9 +40,8 @@ class FakeDataSource(datasource_driver.PollingDataSourceDriver,
TRANSLATORS = [fake_translator] TRANSLATORS = [fake_translator]
def __init__(self, name='', keys='', inbox=None, datapath=None, args=None): def __init__(self, name='', args=None):
super(FakeDataSource, self).__init__(name, keys, inbox, super(FakeDataSource, self).__init__(name, args)
datapath, args)
datasource_driver.ExecutionDriver.__init__(self) datasource_driver.ExecutionDriver.__init__(self)
self.add_executable_method('fake_act', self.add_executable_method('fake_act',
[{'name': 'server_id', [{'name': 'server_id',