Browse Source

FIX-1236 Adds config list in rpc

Change-Id: Ia78893d93209ee7ec68d49ffa062aff649e486e5
Kanagaraj Manickam 3 years ago
parent
commit
c17ee850d2
4 changed files with 48 additions and 9 deletions
  1. 10
    0
      namos/conductor/manager.py
  2. 29
    6
      namos/conductor/rpcapi.py
  3. 4
    2
      namos/db/api.py
  4. 5
    1
      namos/db/sqlalchemy/api.py

+ 10
- 0
namos/conductor/manager.py View File

@@ -106,6 +106,16 @@ class ConductorManager(object):
106 106
     def infra_perspective_get(self, context):
107 107
         return db_api.infra_perspective_get(context)
108 108
 
109
+    @request_context
110
+    def config_get_by_name_for_service_worker(self,
111
+                                              context,
112
+                                              service_worker_id,
113
+                                              name=None,
114
+                                              only_configured=True):
115
+        return db_api.config_get_by_name_for_service_worker(context,
116
+                                                            service_worker_id,
117
+                                                            name,
118
+                                                            only_configured)
109 119
 
110 120
 class ServiceProcessor(object):
111 121
     def __init__(self, registration_info):

+ 29
- 6
namos/conductor/rpcapi.py View File

@@ -96,6 +96,18 @@ class ConductorAPI(object):
96 96
         return self.client.call(context,
97 97
                                 'infra_perspective_get')
98 98
 
99
+    @wrapper_function
100
+    def config_get_by_name_for_service_worker(self,
101
+                                              context,
102
+                                              service_worker_id,
103
+                                              name=None,
104
+                                              only_configured=True):
105
+        return self.client.call(context,
106
+                                'config_get_by_name_for_service_worker',
107
+                                service_worker_id=service_worker_id,
108
+                                name=name,
109
+                                only_configured=only_configured)
110
+
99 111
 if __name__ == '__main__':
100 112
     # from namos.common import config
101 113
 
@@ -105,10 +117,21 @@ if __name__ == '__main__':
105 117
     from oslo_context import context
106 118
 
107 119
     c = ConductorAPI()
108
-    # c.add_region(context.RequestContext(),
109
-    #              {'name': 'RegionOne11',
110
-    #               'keystone_region_id': 'region_one',
111
-    #               'extra': {'location': 'bangalore'},
112
-    #               'id': 'd7dcd175-27ef-46b5-997f-e6e572f320af'})
113 120
 
114
-    print (json.dumps(c.infra_perspective_get(context.RequestContext())))
121
+    def add_sample_region():
122
+        c.add_region(context.RequestContext(),
123
+                     {'name': 'RegionOne11',
124
+                      'keystone_region_id': 'region_one',
125
+                      'extra': {'location': 'bangalore'},
126
+                      'id': 'd7dcd175-27ef-46b5-997f-e6e572f320af'})
127
+
128
+    def print_infra():
129
+        print (json.dumps(c.infra_perspective_get(context.RequestContext())))
130
+
131
+    def print_sample_conf():
132
+        for cf in c.config_get_by_name_for_service_worker(
133
+            context.RequestContext(),
134
+            service_worker_id='fc88fd41-7e9c-42c9-891d-3823efd4824e'):
135
+            print ('%s %s' % (cf['name'], cf['value']))
136
+
137
+    print_sample_conf()

+ 4
- 2
namos/db/api.py View File

@@ -328,10 +328,12 @@ def config_get_by_name(context, name):
328 328
 
329 329
 def config_get_by_name_for_service_worker(context,
330 330
                                           service_worker_id,
331
-                                          name=None):
331
+                                          name=None,
332
+                                          only_configured=True):
332 333
     return IMPL.config_get_by_name_for_service_worker(context,
333 334
                                                       service_worker_id,
334
-                                                      name)
335
+                                                      name,
336
+                                                      only_configured)
335 337
 
336 338
 
337 339
 def config_get_all(context):

+ 5
- 1
namos/db/sqlalchemy/api.py View File

@@ -519,11 +519,15 @@ def config_get_by_name(context, name):
519 519
 
520 520
 def config_get_by_name_for_service_worker(context,
521 521
                                           service_worker_id,
522
-                                          name=None):
522
+                                          name=None,
523
+                                          only_configured=True):
523 524
     query = _model_query(context, models.OsloConfig). \
524 525
         filter_by(service_worker_id=service_worker_id)
525 526
     if name is not None:
526 527
         query = query.filter_by(name=name)
528
+    elif only_configured:
529
+        query = query.filter(
530
+            models.OsloConfig.value != models.OsloConfig.default_value)
527 531
     return query.all()
528 532
 
529 533
 

Loading…
Cancel
Save