Merge "Database interface using sqlalchemy"

This commit is contained in:
Jenkins 2017-08-09 19:06:13 +00:00 committed by Gerrit Code Review
commit 005273fce4
8 changed files with 36 additions and 11 deletions

View File

@ -16,4 +16,4 @@ import pbr.version
__version__ = pbr.version.VersionInfo(
'nomad').version_string()
'cyborg').version_string()

View File

@ -14,9 +14,19 @@
# License for the specific language governing permissions and limitations
# under the License.
from sqlalchemy import Column, Integer, String
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
# A common internal acclerator object for internal use.
class accelerator(object):
class accelerator(Base):
__tablename__ = 'accelerators'
accelerator_id = Column(String, primary_key=True)
device_type = Column(String)
remoteable = Column(Integer)
vender_id = Column(String)
product_id = Column(String)
def __init__(self, **kwargs):
self.accelerator_id = kwargs['accelerator_id']

View File

@ -1,3 +1,3 @@
[DEFAULT]
[cyborg]
transport_url=
server_id=

View File

@ -31,7 +31,9 @@ LOG = logging.getLogger(__name__)
logging.register_options(CONF)
logging.setup(CONF, 'Cyborg.Agent')
url = messaging.TransportURL.parse(CONF, url=CONF.transport_url)
CONF(['--config-file', 'agent.conf'])
url = messaging.TransportURL.parse(CONF, url=CONF.cyborg.transport_url)
transport = messaging.get_notification_transport(CONF, url)
notifier = messaging.Notifier(transport,
@ -39,7 +41,8 @@ notifier = messaging.Notifier(transport,
publisher_id='Cyborg.Agent',
topic='info')
rpc_targets = messaging.Target(topic='cyborg_control', server=CONF.server_id)
rpc_targets = messaging.Target(topic='cyborg_control',
server=CONF.cyborg.server_id)
rpc_endpoints = [
rpcapi.RPCEndpoint()
]

View File

@ -25,4 +25,4 @@ default_opts = [
def register_opts(conf):
conf.register_opts(default_opts)
conf.register_opts(default_opts, group='cyborg')

View File

@ -1,3 +1,4 @@
[DEFAULT]
[cyborg]
transport_url=
server_id=
database_url=

View File

@ -19,6 +19,7 @@ from oslo_config import cfg
from oslo_log import log as logging
import oslo_messaging as messaging
import rpcapi
from sqlalchemy import create_engine
import time
eventlet.monkey_patch()
@ -30,7 +31,8 @@ LOG = logging.getLogger(__name__)
logging.register_options(CONF)
logging.setup(CONF, 'Cyborg.Conductor')
url = messaging.TransportURL.parse(CONF, url=CONF.transport_url)
CONF(['--config-file', 'conductor.conf'])
url = messaging.TransportURL.parse(CONF, url=CONF.cyborg.transport_url)
transport = messaging.get_notification_transport(CONF, url)
message_endpoints = [
@ -42,7 +44,8 @@ message_targets = [
messaging.Target(topic='warn'),
messaging.Target(topic='error')
]
rpc_targets = messaging.Target(topic='cyborg_control', server=CONF.server_id)
rpc_targets = messaging.Target(topic='cyborg_control',
server=CONF.cyborg.server_id)
rpc_endpoints = [
rpcapi.RPCEndpoint()
]
@ -59,6 +62,9 @@ message_server = messaging.get_notification_listener(transport,
executor='eventlet',
allow_requeue=True)
engine = create_engine(CONF.cyborg.connection, echo=True)
engine.connect()
try:
message_server.start()
rpc_server.start()

View File

@ -17,7 +17,12 @@ import uuid
default_opts = [
cfg.StrOpt('transport_url',
default='',
help='Transport url for messating'),
help='Transport url for messating, copy from transport_url= in \
your Nova config default section'),
cfg.StrOpt('database_url',
default='',
help='Database url for storage, copy from connection= in your \
Nova db config section'),
cfg.StrOpt('server_id',
default=uuid.uuid4(),
help='Unique ID for this conductor instance'),
@ -25,4 +30,4 @@ default_opts = [
def register_opts(conf):
conf.register_opts(default_opts)
conf.register_opts(default_opts, group='cyborg')