Reengineer to work with Winchester for Streams API
Replaced oahu support with Winchester for basic stream api. Change-Id: Iccaeee709fdb1254d8c497543a558854aa0ea7a1
This commit is contained in:
parent
5530d33fc4
commit
55566527f1
5
.gitreview
Normal file
5
.gitreview
Normal file
@ -0,0 +1,5 @@
|
||||
[gerrit]
|
||||
host=review.openstack.org
|
||||
port=29418
|
||||
project=stackforge/stacktach-quince.git
|
||||
|
@ -13,10 +13,28 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import oahu.config
|
||||
import logging
|
||||
|
||||
|
||||
from winchester.config import ConfigManager, ConfigSection, ConfigItem
|
||||
from winchester.db import DBInterface
|
||||
from winchester import models
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class Impl(object):
|
||||
|
||||
@classmethod
|
||||
def config_description(cls):
|
||||
return dict(config_path=ConfigItem(
|
||||
help="Path(s) to find additional config files",
|
||||
multiple=True, default='.'),
|
||||
database=ConfigSection(help="Database connection info.",
|
||||
config_description=DBInterface.config_description()),
|
||||
)
|
||||
|
||||
def __init__(self, config, scratchpad):
|
||||
"""config is a ConfigParser object.
|
||||
Use the scratchpad to ensure we don't create multiple
|
||||
@ -24,24 +42,41 @@ class Impl(object):
|
||||
"""
|
||||
|
||||
if 'quincy_config' not in scratchpad:
|
||||
target = config.get('quince', 'oahu_config')
|
||||
print "Quince is using oahu driver from %s" % target
|
||||
quincy_config = oahu.config.get_config(target)
|
||||
scratchpad['quincy_config'] = quincy_config
|
||||
scratchpad['quincy_driver'] = quincy_config.get_driver()
|
||||
target = config.get('quince', 'winchester_config')
|
||||
logger.debug("Quince is using Winchester config from %s" % target)
|
||||
quincy_config = ConfigManager.load_config_file(target)
|
||||
quincy_config = ConfigManager.wrap(quincy_config,
|
||||
self.config_description())
|
||||
|
||||
self.oahu_config = scratchpad['quincy_config']
|
||||
scratchpad['quincy_config'] = quincy_config
|
||||
scratchpad['quincy_driver'] = DBInterface(quincy_config['database'])
|
||||
|
||||
self.winchester_config = scratchpad['quincy_config']
|
||||
self.driver = scratchpad['quincy_driver']
|
||||
|
||||
def get_streams(self, **kwargs):
|
||||
return self.driver.find_streams(**kwargs)
|
||||
def get_streams(self, state=None, older_than=None, younger_than=None,
|
||||
trigger_name=None, distinguishing_traits=None):
|
||||
|
||||
if state is not None:
|
||||
try:
|
||||
state = models.StreamState[state.lower()]
|
||||
except KeyError:
|
||||
logger.error("invalid stream state %s" % state)
|
||||
raise
|
||||
return self.driver.find_streams(state=state, name=trigger_name,
|
||||
younger_than=younger_than,
|
||||
older_than=older_than,
|
||||
distinguishing_traits=distinguishing_traits)
|
||||
|
||||
def get_stream(self, stream_id, details):
|
||||
stream = int(stream_id)
|
||||
# Returns a list, but should be just one stream.
|
||||
return self.driver.get_stream(stream_id, details)
|
||||
return self.driver.find_streams(stream_id=stream_id,
|
||||
include_events=details)
|
||||
|
||||
def delete_stream(self, stream_id):
|
||||
pass
|
||||
|
||||
def reset_stream(self, stream_id):
|
||||
pass
|
||||
stream = int(stream_id)
|
||||
self.driver.reset_stream(stream_id)
|
||||
|
@ -1 +1 @@
|
||||
oahu
|
||||
winchester
|
||||
|
Loading…
x
Reference in New Issue
Block a user