Skip to content

Commit

Permalink
Starting HTTP Introspect after full CVM sync
Browse files Browse the repository at this point in the history
Validation for Introspect forms input

Change-Id: Ie92a5e6f843d39e524cc68e51c99b5c7f1cc6d73
Partial-Bug: #1778931
  • Loading branch information
krzysztofg256 committed Jun 27, 2018
1 parent c5ba52c commit be6aa47
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions cvm/__main__.py
Expand Up @@ -86,6 +86,7 @@ def run_introspect(args, database):
def main(args):
database = Database()
vmware_monitor = build_monitor(args.config_file, database)
vmware_monitor.sync()
run_introspect(args, database)
greenlets = [
gevent.spawn(vmware_monitor.start()),
Expand Down
4 changes: 3 additions & 1 deletion cvm/monitors.py
Expand Up @@ -3,8 +3,10 @@ def __init__(self, esxi_api_client, vmware_controller):
self._esxi_api_client = esxi_api_client
self._controller = vmware_controller

def start(self):
def sync(self):
self._controller.initialize_database()

def start(self):
while True:
update_set = self._esxi_api_client.wait_for_updates()
if update_set:
Expand Down
14 changes: 10 additions & 4 deletions cvm/sandesh_handler.py
Expand Up @@ -23,7 +23,9 @@ def handle_virtual_machine_request(self, request):
vm_models = [self._database.get_vm_model_by_name(request.name)]
else:
vm_models = self._database.get_all_vm_models()
virtual_machines_data = [self._converter.convert_vm(vm_model) for vm_model in vm_models]
virtual_machines_data = [
self._converter.convert_vm(vm_model) for vm_model in vm_models if vm_model is not None
]
response = VirtualMachineResponse(virtual_machines_data)
response.response(request.context())

Expand All @@ -34,7 +36,9 @@ def handle_virtual_network_request(self, request):
vn_models = [self._database.get_vn_model_by_key(request.key)]
else:
vn_models = self._database.get_all_vn_models()
virtual_networks_data = [self._converter.convert_vn(vn_model) for vn_model in vn_models]
virtual_networks_data = [
self._converter.convert_vn(vn_model) for vn_model in vn_models if vn_model is not None
]
response = VirtualNetworkResponse(virtual_networks_data)
response.response(request.context())

Expand All @@ -43,8 +47,10 @@ def handle_virtual_machine_interface_request(self, request):
vmi_models = [self._database.get_vmi_model_by_uuid(request.uuid)]
else:
vmi_models = self._database.get_all_vmi_models()
virtual_interfaces_data = [self._converter.convert_vmi(vmi_model) for vmi_model in vmi_models]
response = VirtualNetworkResponse(virtual_interfaces_data)
virtual_interfaces_data = [
self._converter.convert_vmi(vmi_model) for vmi_model in vmi_models if vmi_model is not None
]
response = VirtualMachineInterfaceResponse(virtual_interfaces_data)
response.response(request.context())


Expand Down

0 comments on commit be6aa47

Please sign in to comment.