Reorganize code
Reorganize code and fix some coding style violation. Change-Id: Ie5e18cf65ad98f07cd2e4edd8690f53df9bedfeb
This commit is contained in:
parent
fd5e79451e
commit
07bb2a1ba5
@ -27,8 +27,8 @@ from werkzeug import serving
|
||||
from tricircle.api import app
|
||||
from tricircle.common import config
|
||||
|
||||
from tricircle.i18n import _LI
|
||||
from tricircle.i18n import _LW
|
||||
from tricircle.common.i18n import _LI
|
||||
from tricircle.common.i18n import _LW
|
||||
|
||||
|
||||
CONF = cfg.CONF
|
||||
|
@ -44,7 +44,7 @@ function configure_tricircle_plugin {
|
||||
echo "Configuring Neutron for Tricircle"
|
||||
|
||||
if is_service_enabled q-svc ; then
|
||||
Q_PLUGIN_CLASS="tricircle.networking_tricircle.plugin.TricirclePlugin"
|
||||
Q_PLUGIN_CLASS="tricircle.networking.plugin.TricirclePlugin"
|
||||
|
||||
#NEUTRON_CONF=/etc/neutron/neutron.conf
|
||||
iniset $NEUTRON_CONF DEFAULT core_plugin "$Q_PLUGIN_CLASS"
|
||||
@ -61,7 +61,7 @@ function configure_tricircle_plugin {
|
||||
|
||||
iniset $TRICIRCLE_DISPATCHER_CONF DEFAULT debug $ENABLE_DEBUG_LOG_LEVEL
|
||||
iniset $TRICIRCLE_DISPATCHER_CONF DEFAULT verbose True
|
||||
setup_colorized_logging $TRICIRCLE_DISPATCHER_CONF DEFAULT tenant_name
|
||||
setup_colorized_logging $TRICIRCLE_DISPATCHER_CONF DEFAULT tenant
|
||||
iniset $TRICIRCLE_DISPATCHER_CONF DEFAULT bind_host $TRICIRCLE_DISPATCHER_LISTEN_ADDRESS
|
||||
iniset $TRICIRCLE_DISPATCHER_CONF DEFAULT use_syslog $SYSLOG
|
||||
iniset_rpc_backend tricircle $TRICIRCLE_DISPATCHER_CONF
|
||||
|
0
requirements.txt
Executable file → Normal file
0
requirements.txt
Executable file → Normal file
@ -21,8 +21,8 @@ from pecan import request
|
||||
from pecan import rest
|
||||
|
||||
from tricircle.common import cascading_site_api
|
||||
import tricircle.common.context as t_context
|
||||
from tricircle.common import utils
|
||||
import tricircle.context as t_context
|
||||
from tricircle.db import client
|
||||
from tricircle.db import exception
|
||||
from tricircle.db import models
|
||||
|
@ -18,8 +18,8 @@ from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
|
||||
from neutron.common import rpc as n_rpc
|
||||
from tricircle.common import topics
|
||||
from tricircle.common.serializer import CascadeSerializer as Serializer
|
||||
from tricircle.common import topics
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -24,11 +24,11 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
from paste import deploy
|
||||
|
||||
from tricircle.i18n import _
|
||||
from tricircle.i18n import _LI
|
||||
from tricircle.common.i18n import _
|
||||
from tricircle.common.i18n import _LI
|
||||
|
||||
# from tricircle import policy
|
||||
from tricircle import version
|
||||
from tricircle.common import version
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -89,7 +89,7 @@ def reset_service():
|
||||
# daemon mode.
|
||||
setup_logging()
|
||||
|
||||
# (TODO) enforce policy later
|
||||
# TODO(zhiyuan) enforce policy later
|
||||
# policy.refresh()
|
||||
|
||||
|
||||
|
@ -19,7 +19,7 @@ Tricircle base exception handling.
|
||||
|
||||
from oslo_utils import excutils
|
||||
import six
|
||||
from tricircle.i18n import _
|
||||
from tricircle.common.i18n import _
|
||||
|
||||
|
||||
class TricircleException(Exception):
|
||||
|
0
tricircle/i18n.py → tricircle/common/i18n.py
Executable file → Normal file
0
tricircle/i18n.py → tricircle/common/i18n.py
Executable file → Normal file
@ -91,7 +91,7 @@ class AutomaticRpcWrapper(object):
|
||||
return cctx.call(context, method, payload=payload)
|
||||
|
||||
def send(self, cast):
|
||||
""" Autowrap an API call with a send_message() call
|
||||
"""Autowrap an API call with a send_message() call
|
||||
|
||||
This function uses python tricks to implement a passthrough call from
|
||||
the calling API to the cascade service
|
||||
|
@ -14,10 +14,10 @@
|
||||
# limitations under the License.
|
||||
import six
|
||||
|
||||
from oslo_messaging import Serializer
|
||||
from neutron.api.v2.attributes import ATTR_NOT_SPECIFIED
|
||||
from oslo_messaging import Serializer
|
||||
|
||||
import tricircle.context as t_context
|
||||
import tricircle.common.context as t_context
|
||||
|
||||
|
||||
class Mapping(object):
|
||||
|
0
tricircle/version.py → tricircle/common/version.py
Executable file → Normal file
0
tricircle/version.py → tricircle/common/version.py
Executable file → Normal file
@ -1,64 +0,0 @@
|
||||
# Copyright 2015 Huawei Technologies Co., Ltd.
|
||||
#
|
||||
# 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.
|
||||
|
||||
from nova.virt import driver
|
||||
from nova.virt.hardware import InstanceInfo
|
||||
import nova.compute.power_state as power_state
|
||||
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
|
||||
TRANSPORT = oslo_messaging.get_transport(cfg.CONF)
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TricircleComputeDriver(driver.ComputeDriver):
|
||||
site_manager = None # will be set later by the ComputeHostManager
|
||||
|
||||
def __init__(self, virtapi):
|
||||
super(TricircleComputeDriver, self).__init__(virtapi)
|
||||
|
||||
def init_host(self, host):
|
||||
self.host = host
|
||||
# NOTE(saggi) There is no way to pass arguments to the driver apart
|
||||
# from the host It's a bit convoluted and if you find a better way
|
||||
# please send a patch
|
||||
self._site = TricircleComputeDriver.site_manager.get_site(host)
|
||||
|
||||
def get_available_nodes(self, refresh=False):
|
||||
return [node.hypervisor_hostname for node in self._site.get_nodes()]
|
||||
|
||||
def get_available_resource(self, nodename):
|
||||
return self._site.get_node(nodename).get_available_resource()
|
||||
|
||||
def get_num_instances(self):
|
||||
return self._site.get_num_instances()
|
||||
|
||||
def spawn(self, context, instance, image_meta, injected_files,
|
||||
admin_password, network_info=None, block_device_info=None):
|
||||
pass
|
||||
|
||||
def get_info(self, instance):
|
||||
# TODO(saggi) will be redirected to cascade service
|
||||
return InstanceInfo(
|
||||
state=power_state.RUNNING,
|
||||
max_mem_kb=500,
|
||||
mem_kb=500,
|
||||
num_cpu=1,
|
||||
cpu_time_ns=100,
|
||||
id=instance.id,
|
||||
)
|
@ -26,7 +26,7 @@ from keystoneclient.v3 import client as keystone_client
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
|
||||
import tricircle.context as tricircle_context
|
||||
import tricircle.common.context as tricircle_context
|
||||
from tricircle.db import exception
|
||||
from tricircle.db import models
|
||||
from tricircle.db import resource_handle
|
||||
|
@ -30,6 +30,7 @@ ModelBase = declarative.declarative_base()
|
||||
|
||||
def _filter_query(model, query, filters):
|
||||
"""Apply filter to query
|
||||
|
||||
:param model:
|
||||
:param query:
|
||||
:param filters: list of filter dict with key 'key', 'comparator', 'value'
|
||||
|
@ -14,12 +14,12 @@
|
||||
# limitations under the License.
|
||||
|
||||
from nova.compute.manager import ComputeManager
|
||||
from nova.virt.fake import FakeDriver
|
||||
|
||||
import nova.rpc as nova_rpc
|
||||
from nova.service import Service
|
||||
import nova.version as nova_version
|
||||
import nova.rpc as nova_rpc
|
||||
|
||||
from tricircle.compute_tricircle.driver import TricircleComputeDriver
|
||||
from tricircle.common.utils import get_import_path
|
||||
|
||||
_REPORT_INTERVAL = 30
|
||||
@ -27,7 +27,7 @@ _REPORT_INTERVAL_MAX = 60
|
||||
|
||||
|
||||
def _patch_nova_service():
|
||||
if (nova_version.loaded):
|
||||
if nova_version.loaded:
|
||||
return
|
||||
|
||||
nova_version.NOVA_PACKAGE = "tricircle"
|
||||
@ -67,8 +67,7 @@ class NovaService(Service):
|
||||
|
||||
|
||||
def _fix_compute_service_exchange(service):
|
||||
"""Fix service exchange value for nova
|
||||
"""
|
||||
"""Fix service exchange value for nova"""
|
||||
|
||||
manager = service.manager
|
||||
for client in (
|
||||
@ -83,7 +82,6 @@ def _fix_compute_service_exchange(service):
|
||||
class ComputeHostManager(object):
|
||||
def __init__(self, site_manager):
|
||||
self._compute_nodes = []
|
||||
TricircleComputeDriver.site_manager = site_manager
|
||||
|
||||
def _create_compute_node_service(self, host):
|
||||
service = NovaService(
|
||||
@ -95,7 +93,10 @@ class ComputeHostManager(object):
|
||||
report_interval=_REPORT_INTERVAL,
|
||||
periodic_interval_max=_REPORT_INTERVAL_MAX,
|
||||
manager=get_import_path(ComputeManager),
|
||||
compute_driver=get_import_path(TricircleComputeDriver),
|
||||
# temporally use FakeDriver, new compute manager doesn't require
|
||||
# compute driver so this can be removed after new compute manager
|
||||
# is finished
|
||||
compute_driver=get_import_path(FakeDriver)
|
||||
)
|
||||
|
||||
_fix_compute_service_exchange(service)
|
||||
@ -103,8 +104,7 @@ class ComputeHostManager(object):
|
||||
return service
|
||||
|
||||
def create_host_adapter(self, host):
|
||||
"""Creates an adapter between the nova compute API and Site object
|
||||
"""
|
||||
"""Creates an adapter between the nova compute API and Site object"""
|
||||
service = self._create_compute_node_service(host)
|
||||
service.start()
|
||||
self._compute_nodes.append(service)
|
||||
|
@ -20,8 +20,8 @@ from oslo_config import cfg
|
||||
from oslo_log import log as logging
|
||||
import oslo_messaging
|
||||
|
||||
from tricircle.common import topics
|
||||
from tricircle.common.serializer import CascadeSerializer as Serializer
|
||||
from tricircle.common import topics
|
||||
from tricircle.dispatcher import site_manager
|
||||
|
||||
# import endpoints here
|
||||
|
@ -15,12 +15,12 @@
|
||||
# TODO(saggi) change to oslo before release
|
||||
from oslo_serialization import jsonutils as json
|
||||
|
||||
import tricircle.common.context as t_context
|
||||
from tricircle.common.singleton import Singleton
|
||||
from tricircle.common import utils
|
||||
import tricircle.context as t_context
|
||||
from tricircle.dispatcher.compute import ComputeHostManager
|
||||
from tricircle.db import client
|
||||
from tricircle.db import models
|
||||
from tricircle.dispatcher.compute import ComputeHostManager
|
||||
|
||||
|
||||
class Node(object):
|
||||
@ -113,9 +113,8 @@ class _SiteManager(object):
|
||||
self.create_site(t_context.get_admin_context(), site['site_name'])
|
||||
|
||||
def create_site(self, context, site_name):
|
||||
"""creates a fake site, in reality the information about available
|
||||
sites should be pulled from the DAL and not created at will.
|
||||
"""
|
||||
"""creates a fake node as nova-compute and add it to az"""
|
||||
|
||||
# TODO(saggi): thread safety
|
||||
if site_name in self._sites:
|
||||
raise RuntimeError("Site already exists in site map")
|
||||
|
@ -31,7 +31,7 @@ from neutron.db import portbindings_db
|
||||
from neutron.db import securitygroups_db
|
||||
from neutron.i18n import _LI
|
||||
from tricircle.common import cascading_networking_api as c_net_api
|
||||
from tricircle.networking_tricircle import rpc as c_net_rpc
|
||||
from tricircle.networking import rpc as c_net_rpc
|
||||
|
||||
LOG = log.getLogger(__name__)
|
||||
|
@ -20,7 +20,7 @@ import unittest
|
||||
import pecan
|
||||
|
||||
import tricircle.api.controllers.root as root_controller
|
||||
from tricircle import context
|
||||
from tricircle.common import context
|
||||
from tricircle.db import client
|
||||
from tricircle.db import core
|
||||
from tricircle.db import models
|
||||
|
@ -20,7 +20,7 @@ import uuid
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
|
||||
from tricircle import context
|
||||
from tricircle.common import context
|
||||
from tricircle.db import client
|
||||
from tricircle.db import core
|
||||
from tricircle.db import exception
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import unittest
|
||||
|
||||
from tricircle import context
|
||||
from tricircle.common import context
|
||||
from tricircle.db import core
|
||||
from tricircle.db import exception
|
||||
from tricircle.db import models
|
||||
|
@ -22,8 +22,8 @@ from neutron.common import exceptions as neutron_exceptions
|
||||
from neutron.common import rpc as neutron_rpc
|
||||
from neutron.db import db_base_plugin_v2
|
||||
|
||||
from tricircle import context
|
||||
from tricircle.networking_tricircle.plugin import TricirclePlugin
|
||||
from tricircle.common import context
|
||||
from tricircle.networking.plugin import TricirclePlugin
|
||||
|
||||
|
||||
FAKE_PORT_ID = 'fake_port_uuid'
|
@ -21,8 +21,8 @@ from neutron.common import constants as neutron_const
|
||||
from neutron.common import rpc as neutron_rpc
|
||||
from neutron import manager
|
||||
|
||||
from tricircle.networking_tricircle import plugin
|
||||
from tricircle.networking_tricircle import rpc
|
||||
from tricircle.networking import plugin
|
||||
from tricircle.networking import rpc
|
||||
|
||||
|
||||
FAKE_PORT_ID = 'fake_port_uuid'
|
Loading…
x
Reference in New Issue
Block a user