diff options
| author | Jesse Andrews <jesse@ubuntu> | 2010-08-14 18:31:23 -0700 |
|---|---|---|
| committer | Jesse Andrews <jesse@ubuntu> | 2010-08-14 18:31:23 -0700 |
| commit | d64d0fccca94b073760bcfc19b763b2ab64abf08 (patch) | |
| tree | 3e2a0747d9181a5aabbd354805d235ce98a4946f /nova | |
| parent | 1395690e99c41aa14e776e4b94054fde29856c60 (diff) | |
make the fake-ldap system work again
Diffstat (limited to 'nova')
| -rw-r--r-- | nova/datastore.py | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/nova/datastore.py b/nova/datastore.py index e69de29bb..8e2519429 100644 --- a/nova/datastore.py +++ b/nova/datastore.py @@ -0,0 +1,53 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2010 United States Government as represented by the +# Administrator of the National Aeronautics and Space Administration. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +""" +Datastore: + +MAKE Sure that ReDIS is running, and your flags are set properly, +before trying to run this. +""" + +import logging +import redis + +from nova import flags + +FLAGS = flags.FLAGS +flags.DEFINE_string('redis_host', '127.0.0.1', + 'Host that redis is running on.') +flags.DEFINE_integer('redis_port', 6379, + 'Port that redis is running on.') +flags.DEFINE_integer('redis_db', 0, 'Multiple DB keeps tests away') + + +class Redis(object): + def __init__(self): + if hasattr(self.__class__, '_instance'): + raise Exception('Attempted to instantiate singleton') + + @classmethod + def instance(cls): + if not hasattr(cls, '_instance'): + inst = redis.Redis(host=FLAGS.redis_host, + port=FLAGS.redis_port, + db=FLAGS.redis_db) + cls._instance = inst + return cls._instance + + |
