view 360
Change-Id: Ibb645261bdc9af1a582ad4102c69340c49916d4e
This commit is contained in:
parent
c17ee850d2
commit
eca5fb1b5c
|
@ -106,6 +106,10 @@ class ConductorManager(object):
|
||||||
def infra_perspective_get(self, context):
|
def infra_perspective_get(self, context):
|
||||||
return db_api.infra_perspective_get(context)
|
return db_api.infra_perspective_get(context)
|
||||||
|
|
||||||
|
@request_context
|
||||||
|
def view_360(self, context):
|
||||||
|
return db_api.view_360(context)
|
||||||
|
|
||||||
@request_context
|
@request_context
|
||||||
def config_get_by_name_for_service_worker(self,
|
def config_get_by_name_for_service_worker(self,
|
||||||
context,
|
context,
|
||||||
|
@ -117,6 +121,7 @@ class ConductorManager(object):
|
||||||
name,
|
name,
|
||||||
only_configured)
|
only_configured)
|
||||||
|
|
||||||
|
|
||||||
class ServiceProcessor(object):
|
class ServiceProcessor(object):
|
||||||
def __init__(self, registration_info):
|
def __init__(self, registration_info):
|
||||||
self.registration_info = registration_info
|
self.registration_info = registration_info
|
||||||
|
|
|
@ -96,6 +96,11 @@ class ConductorAPI(object):
|
||||||
return self.client.call(context,
|
return self.client.call(context,
|
||||||
'infra_perspective_get')
|
'infra_perspective_get')
|
||||||
|
|
||||||
|
@wrapper_function
|
||||||
|
def view_360(self, context):
|
||||||
|
return self.client.call(context,
|
||||||
|
'view_360')
|
||||||
|
|
||||||
@wrapper_function
|
@wrapper_function
|
||||||
def config_get_by_name_for_service_worker(self,
|
def config_get_by_name_for_service_worker(self,
|
||||||
context,
|
context,
|
||||||
|
@ -128,10 +133,14 @@ if __name__ == '__main__':
|
||||||
def print_infra():
|
def print_infra():
|
||||||
print (json.dumps(c.infra_perspective_get(context.RequestContext())))
|
print (json.dumps(c.infra_perspective_get(context.RequestContext())))
|
||||||
|
|
||||||
|
def print_view_360():
|
||||||
|
print (json.dumps(c.view_360(context.RequestContext())))
|
||||||
|
|
||||||
def print_sample_conf():
|
def print_sample_conf():
|
||||||
for cf in c.config_get_by_name_for_service_worker(
|
for cf in c.config_get_by_name_for_service_worker(
|
||||||
context.RequestContext(),
|
context.RequestContext(),
|
||||||
service_worker_id='fc88fd41-7e9c-42c9-891d-3823efd4824e'):
|
service_worker_id='06e64e74-09b3-4721-8e5d-39ae40ed34f3'):
|
||||||
print ('%s %s' % (cf['name'], cf['value']))
|
print ('%s %s' % (cf['name'], cf['value']))
|
||||||
|
|
||||||
print_sample_conf()
|
print_view_360()
|
||||||
|
# print_sample_conf()
|
||||||
|
|
|
@ -367,3 +367,7 @@ def region_perspective_get(context, region_id,
|
||||||
|
|
||||||
def infra_perspective_get(context):
|
def infra_perspective_get(context):
|
||||||
return IMPL.infra_perspective_get(context)
|
return IMPL.infra_perspective_get(context)
|
||||||
|
|
||||||
|
|
||||||
|
def view_360(context):
|
||||||
|
return IMPL.view_360(context)
|
||||||
|
|
|
@ -772,6 +772,133 @@ def infra_perspective_get(context):
|
||||||
|
|
||||||
return infra_perspective
|
return infra_perspective
|
||||||
|
|
||||||
|
|
||||||
|
def view_360(context):
|
||||||
|
view = dict()
|
||||||
|
|
||||||
|
view['region'] = dict()
|
||||||
|
view['service_node'] = dict()
|
||||||
|
view['service_component'] = dict()
|
||||||
|
view['service'] = dict()
|
||||||
|
view['service_worker'] = dict()
|
||||||
|
view['device_driver'] = dict()
|
||||||
|
view['device_driver_class'] = dict()
|
||||||
|
view['device_endpoint'] = dict()
|
||||||
|
view['device'] = dict()
|
||||||
|
|
||||||
|
region_list = region_get_all(context)
|
||||||
|
for rg in region_list:
|
||||||
|
# region
|
||||||
|
view['region'][rg.id] = region_get(context, rg.id).to_dict()
|
||||||
|
|
||||||
|
view['region'][rg.id]['service_node'] = dict()
|
||||||
|
srv_nd_lst = _service_node_get_all_by(context,
|
||||||
|
region_id=rg.id)
|
||||||
|
for srv_nd in srv_nd_lst:
|
||||||
|
# service node
|
||||||
|
view['service_node'][srv_nd.id] = service_node_get(
|
||||||
|
context,
|
||||||
|
srv_nd.id
|
||||||
|
).to_dict()
|
||||||
|
|
||||||
|
view['region'][rg.id]['service_node'][srv_nd.id] = dict()
|
||||||
|
view['region'][rg.id]['service_node'][srv_nd.id][
|
||||||
|
'service_component'] = dict()
|
||||||
|
srv_cmp_lst = service_component_get_all_by_node_for_service(
|
||||||
|
context,
|
||||||
|
srv_nd.id
|
||||||
|
)
|
||||||
|
for srv_cmp in srv_cmp_lst:
|
||||||
|
# service component
|
||||||
|
view['service_component'][
|
||||||
|
srv_cmp.id] = service_component_get(context,
|
||||||
|
srv_cmp.id).to_dict()
|
||||||
|
|
||||||
|
# service
|
||||||
|
srv_id = view['service_component'][srv_cmp.id]['service_id']
|
||||||
|
if srv_id not in view['service']:
|
||||||
|
view['service'][srv_id] = service_get(context,
|
||||||
|
srv_id).to_dict()
|
||||||
|
|
||||||
|
view['region'][rg.id]['service_node'][srv_nd.id][
|
||||||
|
'service_component'][srv_cmp.id] = dict()
|
||||||
|
view['region'][rg.id]['service_node'][srv_nd.id][
|
||||||
|
'service_component'][srv_cmp.id]['service'] = srv_id
|
||||||
|
view['region'][rg.id]['service_node'][srv_nd.id][
|
||||||
|
'service_component'][srv_cmp.id][
|
||||||
|
'service_worker'] = dict()
|
||||||
|
srv_wkr_lst = service_worker_get_by_host_for_service_component(
|
||||||
|
context,
|
||||||
|
srv_cmp.id
|
||||||
|
)
|
||||||
|
for srv_wkr in srv_wkr_lst:
|
||||||
|
# service worker
|
||||||
|
view['service_worker'][
|
||||||
|
srv_wkr.id] = service_worker_get(context,
|
||||||
|
srv_wkr.id).to_dict()
|
||||||
|
|
||||||
|
view['region'][rg.id]['service_node'][srv_nd.id][
|
||||||
|
'service_component'][srv_cmp.id][
|
||||||
|
'service_worker'][srv_wkr.id] = dict()
|
||||||
|
view['region'][rg.id]['service_node'][srv_nd.id][
|
||||||
|
'service_component'][srv_cmp.id][
|
||||||
|
'service_worker'][srv_wkr.id]['device_driver'] = dict()
|
||||||
|
dvc_drv_list = _device_driver_get_all_by(
|
||||||
|
context,
|
||||||
|
service_worker_id=srv_wkr.id
|
||||||
|
)
|
||||||
|
for dvc_drv in dvc_drv_list:
|
||||||
|
# device driver
|
||||||
|
view['device_driver'][
|
||||||
|
dvc_drv.id] = device_driver_get(
|
||||||
|
context,
|
||||||
|
dvc_drv.id).to_dict()
|
||||||
|
|
||||||
|
view['region'][rg.id]['service_node'][srv_nd.id][
|
||||||
|
'service_component'][srv_cmp.id][
|
||||||
|
'service_worker'][srv_wkr.id]['device_driver'][
|
||||||
|
dvc_drv.id] = dict()
|
||||||
|
|
||||||
|
# device driver class
|
||||||
|
dvc_drv_cls_id = view['device_driver'][
|
||||||
|
dvc_drv.id]['device_driver_class_id']
|
||||||
|
if dvc_drv_cls_id not in view['device_driver_class']:
|
||||||
|
view['device_driver_class'][
|
||||||
|
dvc_drv_cls_id] = device_driver_class_get(
|
||||||
|
context,
|
||||||
|
dvc_drv_cls_id).to_dict()
|
||||||
|
view['region'][rg.id]['service_node'][srv_nd.id][
|
||||||
|
'service_component'][srv_cmp.id][
|
||||||
|
'service_worker'][srv_wkr.id]['device_driver'][
|
||||||
|
dvc_drv.id]['device_driver_class'] = dvc_drv_cls_id
|
||||||
|
|
||||||
|
# device endpoint
|
||||||
|
dvc_endp_id = view['device_driver'][
|
||||||
|
dvc_drv.id]['endpoint_id']
|
||||||
|
view['device_endpoint'][
|
||||||
|
dvc_endp_id] = device_endpoint_get(
|
||||||
|
context,
|
||||||
|
dvc_endp_id).to_dict()
|
||||||
|
view['region'][rg.id]['service_node'][srv_nd.id][
|
||||||
|
'service_component'][srv_cmp.id][
|
||||||
|
'service_worker'][srv_wkr.id]['device_driver'][
|
||||||
|
dvc_drv.id]['device_endpoint'] = dvc_endp_id
|
||||||
|
|
||||||
|
# device
|
||||||
|
dvc_id = view['device_driver'][
|
||||||
|
dvc_drv.id]['device_id']
|
||||||
|
if dvc_id not in view['device']:
|
||||||
|
view['device'][
|
||||||
|
dvc_id] = device_get(
|
||||||
|
context,
|
||||||
|
dvc_id).to_dict()
|
||||||
|
view['region'][rg.id]['service_node'][srv_nd.id][
|
||||||
|
'service_component'][srv_cmp.id][
|
||||||
|
'service_worker'][srv_wkr.id]['device_driver'][
|
||||||
|
dvc_drv.id]['device'] = dvc_id
|
||||||
|
|
||||||
|
return view
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
from namos.common import config
|
from namos.common import config
|
||||||
|
|
||||||
|
@ -796,3 +923,6 @@ if __name__ == '__main__':
|
||||||
# import json
|
# import json
|
||||||
# perp_json = json.dumps(persp, indent=4)
|
# perp_json = json.dumps(persp, indent=4)
|
||||||
# print perp_json
|
# print perp_json
|
||||||
|
|
||||||
|
import json
|
||||||
|
print (json.dumps(view_360(None)))
|
||||||
|
|
Loading…
Reference in New Issue