From 6673c2b66e4470d1f34e61c371edcfa4e82b0878 Mon Sep 17 00:00:00 2001 From: amitgandhinz Date: Fri, 27 Jun 2014 10:53:49 -0400 Subject: [PATCH] created a mock db to remove relience on cassandra for testing --- cdn/bootstrap.py | 2 +- cdn/provider/sample/__init__.py | 6 ----- cdn/provider/sample/controllers.py | 27 --------------------- cdn/provider/sample/driver.py | 38 ------------------------------ cdn/provider/sample/services.py | 35 --------------------------- etc/cdn.conf | 5 +++- setup.cfg | 3 ++- 7 files changed, 7 insertions(+), 109 deletions(-) delete mode 100644 cdn/provider/sample/__init__.py delete mode 100644 cdn/provider/sample/controllers.py delete mode 100644 cdn/provider/sample/driver.py delete mode 100644 cdn/provider/sample/services.py diff --git a/cdn/bootstrap.py b/cdn/bootstrap.py index 9fdd9d77..eb4857bb 100644 --- a/cdn/bootstrap.py +++ b/cdn/bootstrap.py @@ -25,7 +25,7 @@ LOG = log.getLogger(__name__) _DRIVER_OPTIONS = [ cfg.StrOpt('transport', default='falcon', help='Transport driver to use'), - cfg.StrOpt('storage', default='mongodb', + cfg.StrOpt('storage', default='mockdb', help='Storage driver to use'), ] diff --git a/cdn/provider/sample/__init__.py b/cdn/provider/sample/__init__.py deleted file mode 100644 index fd7c8917..00000000 --- a/cdn/provider/sample/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -"""CDN Extension for CDN""" - -from cdn.provider.sample import driver - -# Hoist classes into package namespace -CDNProvider = driver.CDNProvider diff --git a/cdn/provider/sample/controllers.py b/cdn/provider/sample/controllers.py deleted file mode 100644 index facdd7fe..00000000 --- a/cdn/provider/sample/controllers.py +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2013 Red Hat, Inc. -# -# 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. - -"""Exports Sample CDN controllers. - -Field Mappings: - In order to reduce the disk / memory space used, - fields name will be, most of the time, the first - letter of their long name. Fields mapping will be - updated and documented in each controller class. -""" - -from cdn.provider.sample import services - -ServiceController = services.ServiceController diff --git a/cdn/provider/sample/driver.py b/cdn/provider/sample/driver.py deleted file mode 100644 index bfc290df..00000000 --- a/cdn/provider/sample/driver.py +++ /dev/null @@ -1,38 +0,0 @@ -# Copyright (c) 2014 Rackspace, Inc. -# -# 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. - -"""CDN Provider implementation.""" - -from cdn.common import decorators -from cdn.openstack.common import log as logging -from cdn import provider -from cdn.provider.sample import controllers - -from oslo.config import cfg - -LOG = logging.getLogger(__name__) - - -class CDNProvider(provider.CDNProviderBase): - - def __init__(self, conf): - super(CDNProvider, self).__init__(conf) - - def is_alive(self): - return True - - @decorators.lazy_property(write=False) - def service_controller(self): - return controllers.ServiceController() diff --git a/cdn/provider/sample/services.py b/cdn/provider/sample/services.py deleted file mode 100644 index 8e5a40ba..00000000 --- a/cdn/provider/sample/services.py +++ /dev/null @@ -1,35 +0,0 @@ -# Copyright (c) 2014 Rackspace, Inc. -# -# 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. - -# stevedore/example/simple.py -from cdn.provider import base - - -class ServiceController(base.ServiceBase): - - def __init__(self): - super(ServiceController, self).__init__() - - self.provider_resp = base.ProviderResponse("sample") - - def update(self): - return self.provider_resp.updated(service_name) - - def create(self, service_name, service_json): - return self.provider_resp.created(service_name) - - def delete(self, service_name): - return self.provider_resp.deleted(service_name) - \ No newline at end of file diff --git a/etc/cdn.conf b/etc/cdn.conf index 239b0be1..5f700eca 100644 --- a/etc/cdn.conf +++ b/etc/cdn.conf @@ -30,7 +30,7 @@ log_file = cdn.log transport = falcon # Storage driver module (e.g., mongodb, sqlite, cassandra) -storage = cassandra +storage = mockdb [drivers:transport:falcon] @@ -45,5 +45,8 @@ database = cdn cluster = "localhost" keyspace = cdn +[drivers:storage:mockdb] +database = cdn + [drivers:provider:fastly] apikey = "MYAPIKEY" \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index d08cc6e9..d0bdef78 100644 --- a/setup.cfg +++ b/setup.cfg @@ -32,10 +32,11 @@ cdn.transport = cdn.storage = mongodb = cdn.storage.mongodb.driver:StorageDriver cassandra = cdn.storage.cassandra.driver:StorageDriver + mockdb = cdn.storage.mockdb.driver:StorageDriver cdn.provider = fastly = cdn.provider.fastly.driver:CDNProvider - sample = cdn.provider.sample.driver:CDNProvider + mock = cdn.provider.mock.driver:CDNProvider [nosetests] where=tests