Browse Source

Propagate refresh flag through API and RPC layers

Signed-off-by: Mihaela Balutoiu <mbalutoiu@cloudbasesolutions.com>
Mihaela Balutoiu 4 tháng trước cách đây
mục cha
commit
c57e19a673

+ 4 - 1
coriolis/api/v1/endpoint_instances.py

@@ -2,6 +2,7 @@
 # All Rights Reserved.
 
 from coriolis.api import common
+from coriolis.api.v1 import utils as api_utils
 from coriolis.api.v1.views import endpoint_resources_view
 from coriolis.api import wsgi as api_wsgi
 from coriolis.endpoint_resources import api
@@ -24,6 +25,8 @@ class EndpointInstanceController(api_wsgi.Controller):
             endpoint_policies.ENDPOINTS_POLICY_PREFIX))
         marker, limit = common.get_paging_params(req)
         instance_name_pattern = req.GET.get("name")
+        refresh = api_utils.get_bool_url_arg(
+            req, "refresh", default=False)
 
         env = req.GET.get("env")
         if env is not None:
@@ -34,7 +37,7 @@ class EndpointInstanceController(api_wsgi.Controller):
         return endpoint_resources_view.instances_collection(
             self._instance_api.get_endpoint_instances(
                 context, endpoint_id, env, marker, limit,
-                instance_name_pattern))
+                instance_name_pattern, refresh=refresh))
 
     def show(self, req, endpoint_id, id):
         context = req.environ['coriolis.context']

+ 3 - 2
coriolis/conductor/rpc/client.py

@@ -58,14 +58,15 @@ class ConductorClient(rpc.BaseRPCClient):
 
     def get_endpoint_instances(self, ctxt, endpoint_id, source_environment,
                                marker=None, limit=None,
-                               instance_name_pattern=None):
+                               instance_name_pattern=None, refresh=False):
         return self._call(
             ctxt, 'get_endpoint_instances',
             endpoint_id=endpoint_id,
             source_environment=source_environment,
             marker=marker,
             limit=limit,
-            instance_name_pattern=instance_name_pattern)
+            instance_name_pattern=instance_name_pattern,
+            refresh=refresh)
 
     def get_endpoint_instance(
             self, ctxt, endpoint_id, source_environment, instance_name):

+ 4 - 2
coriolis/conductor/rpc/server.py

@@ -493,7 +493,8 @@ class ConductorServerEndpoint(object):
         db_api.delete_endpoint(ctxt, endpoint_id)
 
     def get_endpoint_instances(self, ctxt, endpoint_id, source_environment,
-                               marker, limit, instance_name_pattern):
+                               marker, limit, instance_name_pattern,
+                               refresh=False):
         endpoint = self.get_endpoint(ctxt, endpoint_id)
 
         worker_rpc = self._get_worker_service_rpc_for_specs(
@@ -503,7 +504,8 @@ class ConductorServerEndpoint(object):
                 endpoint.type: [constants.PROVIDER_TYPE_ENDPOINT_INSTANCES]})
         return worker_rpc.get_endpoint_instances(
             ctxt, endpoint.type, endpoint.connection_info,
-            source_environment, marker, limit, instance_name_pattern)
+            source_environment, marker, limit, instance_name_pattern,
+            refresh=refresh)
 
     def get_endpoint_instance(
             self, ctxt, endpoint_id, source_environment, instance_name):

+ 2 - 2
coriolis/endpoint_resources/api.py

@@ -10,10 +10,10 @@ class API(object):
 
     def get_endpoint_instances(self, ctxt, endpoint_id, source_environment,
                                marker=None, limit=None,
-                               instance_name_pattern=None):
+                               instance_name_pattern=None, refresh=False):
         return self._rpc_client.get_endpoint_instances(
             ctxt, endpoint_id, source_environment, marker,
-            limit, instance_name_pattern)
+            limit, instance_name_pattern, refresh=refresh)
 
     def get_endpoint_instance(
             self, ctxt, endpoint_id, source_environment, instance_name):

+ 3 - 2
coriolis/worker/rpc/client.py

@@ -72,7 +72,7 @@ class WorkerClient(rpc.BaseRPCClient):
 
     def get_endpoint_instances(self, ctxt, platform_name, connection_info,
                                source_environment, marker=None, limit=None,
-                               instance_name_pattern=None):
+                               instance_name_pattern=None, refresh=False):
         return self._call(
             ctxt, 'get_endpoint_instances',
             platform_name=platform_name,
@@ -80,7 +80,8 @@ class WorkerClient(rpc.BaseRPCClient):
             source_environment=source_environment,
             marker=marker,
             limit=limit,
-            instance_name_pattern=instance_name_pattern)
+            instance_name_pattern=instance_name_pattern,
+            refresh=refresh)
 
     def get_endpoint_instance(self, ctxt, platform_name, connection_info,
                               source_environment, instance_name):

+ 2 - 2
coriolis/worker/rpc/server.py

@@ -334,7 +334,7 @@ class WorkerServerEndpoint(object):
 
     def get_endpoint_instances(self, ctxt, platform_name, connection_info,
                                source_environment, marker, limit,
-                               instance_name_pattern):
+                               instance_name_pattern, refresh=False):
         export_provider = providers_factory.get_provider(
             platform_name, constants.PROVIDER_TYPE_ENDPOINT_INSTANCES, None)
 
@@ -344,7 +344,7 @@ class WorkerServerEndpoint(object):
         instances_info = export_provider.get_instances(
             ctxt, secret_connection_info, source_environment,
             last_seen_id=marker, limit=limit,
-            instance_name_pattern=instance_name_pattern)
+            instance_name_pattern=instance_name_pattern, refresh=refresh)
         for instance_info in instances_info:
             schemas.validate_value(
                 instance_info, schemas.CORIOLIS_VM_INSTANCE_INFO_SCHEMA)