Reorganize package structure around new product name (libra). Make tests directory NOT be a Python package. Rename executables. Add common source dir.

This commit is contained in:
David Shrewsbury 2012-09-14 07:48:06 -04:00
parent b15f2b4107
commit 81ac6a1fa1
16 changed files with 42 additions and 16 deletions

6
README
View File

@ -36,13 +36,13 @@ mode (-d option) is useful for testing.
Basic commands:
# Getting help
$ lbaas_worker -h
$ libra_worker -h
# Start up as a daemon
$ sudo lbaas_worker
$ sudo libra_worker
# Start up with debugging output in non-daemon mode
$ lbaas_worker --debug -d
$ libra_worker --debug -d
You can verify that the worker is running by using the sample Gearman
client in the bin/ directory:

13
libra/common/__init__.py Normal file
View File

@ -0,0 +1,13 @@
# Copyright 2012 Hewlett-Packard Development Company, L.P.
#
# 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.

View File

@ -17,7 +17,7 @@ import json
import socket
from json_gearman import JSONGearmanWorker
from lbaas_mgm.faults import BadRequest
from libra.mgm.faults import BadRequest
class Listener(object):

View File

@ -19,7 +19,7 @@ import daemon
import signal
import sys
from lbaas_mgm.listener import Listener
from libra.mgm.listener import Listener
class Server(object):

13
libra/worker/__init__.py Normal file
View File

@ -0,0 +1,13 @@
# Copyright 2012 Hewlett-Packard Development Company, L.P.
#
# 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.

View File

@ -21,8 +21,8 @@ import logging
import socket
from time import sleep
from lbaas_worker.json_gearman import JSONGearmanWorker
from lbaas_worker.faults import BadRequest
from libra.worker.json_gearman import JSONGearmanWorker
from libra.worker.faults import BadRequest
def lbaas_task(worker, job):

View File

@ -45,7 +45,7 @@ except Exception:
ci_cmdclass['test'] = PyTest
setuptools.setup(
name="lbaas_devices",
name="libra",
description="Python LBaaS Gearman Worker and Pool Manager",
version="1.0",
author="David Shrewsbury <shrewsbury.dave@gmail.com>, \
@ -53,8 +53,8 @@ setuptools.setup(
packages=setuptools.find_packages(exclude=["*.tests"]),
entry_points={
'console_scripts': [
'lbaas_worker = lbaas_worker.worker:main',
'lbaas_pool_mgm = lbaas_mgm.mgm:main'
'libra_worker = libra.worker.worker:main',
'libra_pool_mgm = libra.mgm.mgm:main'
]
},
cmdclass=ci_cmdclass,

View File

View File

@ -1,15 +1,15 @@
import unittest
import logging
import tests.mock
import mock
from lbaas_mgm.listener import Listener
from libra.mgm.listener import Listener
class TestLBaaSMgmTask(unittest.TestCase):
def setUp(self):
self.logger = logging.getLogger('lbass_mgm_test')
self.lh = tests.mock.MockLoggingHandler()
self.lh = mock.MockLoggingHandler()
self.logger.setLevel(logging.DEBUG)
self.logger.addHandler(self.lh)
@ -19,7 +19,7 @@ class TestLBaaSMgmTask(unittest.TestCase):
def testTaskGet(self):
listener = Listener(self.logger)
data = {'command': 'get'}
job = tests.mock.FakeJob(data)
job = mock.FakeJob(data)
result = listener.task(None, job)
self.assertIn('Command: get', self.lh.messages['debug'])
self.assertEqual(result['command'], data['command'])
@ -27,7 +27,7 @@ class TestLBaaSMgmTask(unittest.TestCase):
def testTaskBad(self):
listener = Listener(self.logger)
data = {'command': 'bad'}
job = tests.mock.FakeJob(data)
job = mock.FakeJob(data)
result = listener.task(None, job)
self.assertIn("badRequest", result)
self.assertIn("validationErrors", result['badRequest'])

View File

@ -1,6 +1,6 @@
import json
import unittest
from lbaas_worker.worker import lbaas_task
from libra.worker.worker import lbaas_task
class FakeJob(object):