Merge "add extention router"
This commit is contained in:
@@ -66,6 +66,17 @@ LINUX_BOND_MODE = {'balance-rr': '0', 'active-backup': '1',
|
||||
'balance-alb': '6'}
|
||||
|
||||
|
||||
def check_discover_state(req, host_meta, is_detail=False):
|
||||
if host_meta.get("hwm_id"):
|
||||
daisy_cmn.check_discover_state_with_hwm(req,
|
||||
host_meta,
|
||||
is_detail=is_detail)
|
||||
else:
|
||||
daisy_cmn.check_discover_state_with_no_hwm(req,
|
||||
host_meta,
|
||||
is_detail=is_detail)
|
||||
|
||||
|
||||
def pxe_server_build(req, install_meta):
|
||||
params = {'filters': {'type': 'system'}}
|
||||
try:
|
||||
|
||||
0
code/daisy/daisy/api/v1/ext/__init__.py
Normal file
0
code/daisy/daisy/api/v1/ext/__init__.py
Normal file
@@ -39,9 +39,8 @@ from daisy import notifier
|
||||
import daisy.registry.client.v1.api as registry
|
||||
import threading
|
||||
import daisy.api.backends.common as daisy_cmn
|
||||
from daisy.api.backends.osinstall import osdriver
|
||||
import ConfigParser
|
||||
import socket
|
||||
import netaddr
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
_ = i18n._
|
||||
@@ -71,6 +70,23 @@ ML2_TYPE = [
|
||||
'sriov(macvtap)',
|
||||
'sriov(direct)']
|
||||
SUPPORT_HOST_PAGE_SIZE = ['2M', '1G']
|
||||
config = ConfigParser.ConfigParser()
|
||||
config.read(daisy_cmn.daisy_conf_file)
|
||||
try:
|
||||
OS_INSTALL_TYPE = config.get("OS", "os_install_type")
|
||||
except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
|
||||
OS_INSTALL_TYPE = 'pxe'
|
||||
|
||||
_OS_HANDLE = None
|
||||
|
||||
|
||||
def get_os_handle():
|
||||
global _OS_HANDLE
|
||||
if _OS_HANDLE is not None:
|
||||
return _OS_HANDLE
|
||||
|
||||
_OS_HANDLE = osdriver.load_install_os_driver(OS_INSTALL_TYPE)
|
||||
return _OS_HANDLE
|
||||
|
||||
|
||||
class Controller(controller.BaseController):
|
||||
@@ -611,7 +627,10 @@ class Controller(controller.BaseController):
|
||||
"""
|
||||
self._enforce(req, 'get_host')
|
||||
host_meta = self.get_host_meta_or_404(req, id)
|
||||
self.check_discover_state_with_no_hwm(req, host_meta)
|
||||
os_handle = get_os_handle()
|
||||
os_handle.check_discover_state(req,
|
||||
host_meta,
|
||||
is_detail=True)
|
||||
host_vcpu_pin = vcpu_pin.allocate_cpus(host_meta)
|
||||
host_meta.update(host_vcpu_pin)
|
||||
if 'role' in host_meta and 'CONTROLLER_HA' in host_meta['role']:
|
||||
@@ -686,10 +705,12 @@ class Controller(controller.BaseController):
|
||||
"""
|
||||
self._enforce(req, 'get_hosts')
|
||||
params = self._get_query_params(req)
|
||||
os_handle = get_os_handle()
|
||||
try:
|
||||
nodes = registry.get_hosts_detail(req.context, **params)
|
||||
for node in nodes:
|
||||
self.check_discover_state_with_no_hwm(req, node)
|
||||
os_handle.check_discover_state(req,
|
||||
node)
|
||||
except exception.Invalid as e:
|
||||
raise HTTPBadRequest(explanation=e.msg, request=req)
|
||||
return dict(nodes=nodes)
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
|
||||
|
||||
# from daisy.api.v1 import images
|
||||
import os
|
||||
from oslo_utils import importutils
|
||||
from daisy.api.v1 import hosts
|
||||
from daisy.api.v1 import clusters
|
||||
from daisy.api.v1 import template
|
||||
@@ -35,7 +37,7 @@ from daisy.api.v1 import backup_restore
|
||||
|
||||
class API(wsgi.Router):
|
||||
|
||||
"""WSGI router for Glance v1 API requests."""
|
||||
"""WSGI router for Daisy v1 API requests."""
|
||||
|
||||
def __init__(self, mapper):
|
||||
wsgi.Resource(wsgi.RejectMethodController())
|
||||
@@ -508,4 +510,17 @@ class API(wsgi.Router):
|
||||
controller=backup_restore_resource,
|
||||
action='version',
|
||||
conditions={'method': ['POST']})
|
||||
|
||||
path = os.path.join(os.path.abspath(os.path.dirname(
|
||||
os.path.realpath(__file__))),
|
||||
'ext')
|
||||
for root, dirs, names in os.walk(path):
|
||||
filename = 'router.py'
|
||||
if filename in names:
|
||||
ext_name = root.split(path)[1].strip('/')
|
||||
print 'Found %s' % ext_name
|
||||
hwm_driver = "%s.router.APIExtension" % ext_name
|
||||
extension = importutils.import_object_ns('daisy.api.v1.ext',
|
||||
hwm_driver,
|
||||
mapper)
|
||||
super(API, self).__init__(mapper)
|
||||
|
||||
Reference in New Issue
Block a user