config file update
Change-Id: Ibb1f0bcb8aee568814ebb85864b9eaff0ef3dccf
This commit is contained in:
parent
350f37bbc5
commit
b4863bfd2b
|
@ -11,7 +11,7 @@ rabbit_hosts = 172.241.0.101
|
|||
connection = mysql+pymysql://root:password@172.241.0.101/namos?charset=utf8
|
||||
|
||||
[os_manager]
|
||||
workers=20
|
||||
workers=2
|
||||
|
||||
[os_namos]
|
||||
region_name=RegionTwo
|
||||
|
|
|
@ -32,7 +32,8 @@ SCvsNT = dict(
|
|||
'heat-engine',
|
||||
'namos-manager',
|
||||
'ceilometer-api', 'ceilometer-polling', 'ceilometer-collector',
|
||||
'ceilometer-agent-notification',
|
||||
'ceilometer-agent-notification', 'aodh-evaluator',
|
||||
'aodh-notifier', 'aodh-api', 'aodh-listener',
|
||||
'tacker-server'
|
||||
],
|
||||
compute=['nova-compute', 'neutron-openvswitch-agent',
|
||||
|
|
|
@ -91,7 +91,7 @@ def get_rpc_server(host, exchange, topic, version, endpoint):
|
|||
serializer=serializer)
|
||||
|
||||
|
||||
def get_rpc_client(topic, exchange, version, retry=None, **kwargs):
|
||||
def get_rpc_client(topic, exchange, version, retry=None, timeout=60, **kwargs):
|
||||
"""Return a configured olso.messaging RPCClient."""
|
||||
oslo_messaging.set_transport_defaults(exchange)
|
||||
target = oslo_messaging.Target(version=version,
|
||||
|
@ -101,7 +101,8 @@ def get_rpc_client(topic, exchange, version, retry=None, **kwargs):
|
|||
return oslo_messaging.RPCClient(transport, target,
|
||||
serializer=serializer,
|
||||
retry=retry,
|
||||
version_cap=version)
|
||||
version_cap=version,
|
||||
timeout=timeout)
|
||||
|
||||
|
||||
def cleanup():
|
||||
|
|
|
@ -141,21 +141,24 @@ class ConductorManager(object):
|
|||
return service_worker_id
|
||||
|
||||
def _regisgration_ackw(self, context, identification):
|
||||
client = messaging.get_rpc_client(topic='namos.CONF.%s' %
|
||||
identification,
|
||||
version=self.RPC_API_VERSION,
|
||||
exchange=namos_config.PROJECT_NAME)
|
||||
client = messaging.get_rpc_client(
|
||||
topic=self.os_namos_listener_topic(identification),
|
||||
version=self.RPC_API_VERSION,
|
||||
exchange=namos_config.PROJECT_NAME)
|
||||
client.cast(context,
|
||||
'regisgration_ackw',
|
||||
identification=identification)
|
||||
LOG.info("REGISTER [%s] ACK" % identification)
|
||||
|
||||
@request_context
|
||||
def ping(self, context, identification):
|
||||
def os_namos_listener_topic(self, identification):
|
||||
return 'namos.CONF.%s' % identification
|
||||
|
||||
def _ping(self, context, identification):
|
||||
client = messaging.get_rpc_client(
|
||||
topic='namos.CONF.%s' % identification,
|
||||
topic=self.os_namos_listener_topic(identification),
|
||||
version=self.RPC_API_VERSION,
|
||||
exchange=namos_config.PROJECT_NAME)
|
||||
exchange=namos_config.PROJECT_NAME,
|
||||
timeout=1)
|
||||
try:
|
||||
client.call(context,
|
||||
'ping_me',
|
||||
|
@ -167,6 +170,19 @@ class ConductorManager(object):
|
|||
LOG.info("PING [%s] FAILED" % identification)
|
||||
return False
|
||||
|
||||
def update_config_file(self, context, identification, name, content):
|
||||
client = messaging.get_rpc_client(
|
||||
topic=self.os_namos_listener_topic(identification),
|
||||
version=self.RPC_API_VERSION,
|
||||
exchange=namos_config.PROJECT_NAME,
|
||||
timeout=2)
|
||||
client.call(context,
|
||||
'update_config_file',
|
||||
identification=identification,
|
||||
name=name,
|
||||
content=content)
|
||||
LOG.info("CONF FILE [%s] UPDATE [%s] DONE" % (name, identification))
|
||||
|
||||
@request_context
|
||||
def heart_beat(self, context, identification, dieing=False):
|
||||
try:
|
||||
|
@ -261,6 +277,46 @@ class ConductorManager(object):
|
|||
)
|
||||
return dict(file=file, entry=cfg_es)
|
||||
|
||||
@request_context
|
||||
def config_file_update(self, context, config_file_id, content):
|
||||
# update the db
|
||||
db_api.config_file_update(context, config_file_id, {'file': content})
|
||||
cf = self.config_file_get(context, config_file_id)['file']
|
||||
|
||||
# update the corresponding file in the respetive node
|
||||
sc_list = db_api.service_component_get_all_by_config_file(
|
||||
context,
|
||||
config_file_id
|
||||
)
|
||||
|
||||
# TODO(mrkanag) update the config file entries
|
||||
|
||||
# Find the first active service workr launcher to update the conf file
|
||||
if sc_list:
|
||||
for sc in sc_list:
|
||||
sw_list = db_api.service_worker_get_all_by(
|
||||
context,
|
||||
service_component_id=sc_list[0].id,
|
||||
is_launcher=True
|
||||
)
|
||||
if sw_list:
|
||||
for sw in sw_list:
|
||||
# TODO(mrkanag) is ping() better option instead?
|
||||
if utils.find_status(sw):
|
||||
try:
|
||||
self.update_config_file(context,
|
||||
sw.pid,
|
||||
cf.name,
|
||||
cf.file)
|
||||
cf['status'] = 'completed'
|
||||
return cf
|
||||
except: # noqa
|
||||
# try on next available sw
|
||||
pass
|
||||
|
||||
cf['status'] = 'failed'
|
||||
return cf
|
||||
|
||||
@request_context
|
||||
def config_schema(self, context, project, with_file_link=False):
|
||||
# provide the manage oslo_config_schema --gen
|
||||
|
|
|
@ -190,6 +190,13 @@ class ConductorAPI(object):
|
|||
'config_file_get',
|
||||
config_file_id=config_file_id)
|
||||
|
||||
@wrapper_function
|
||||
def config_file_update(self, context, config_file_id, content):
|
||||
return self.client.call(context,
|
||||
'config_file_update',
|
||||
config_file_id=config_file_id,
|
||||
content=content)
|
||||
|
||||
@wrapper_function
|
||||
def config_schema(self, context, project, with_file_link=False):
|
||||
return self.client.call(context,
|
||||
|
@ -233,5 +240,14 @@ if __name__ == '__main__':
|
|||
with_file_link=True
|
||||
)))
|
||||
|
||||
print_config_schema()
|
||||
print_view_360()
|
||||
def sample_config_update():
|
||||
with open('/tmp/sample.conf', 'r') as content_file:
|
||||
content = content_file.read()
|
||||
|
||||
print (c.config_file_update(context.RequestContext(),
|
||||
'dcf0f17b-99f6-49e9-8d5f-23b3ad1167dc',
|
||||
content))
|
||||
|
||||
# print_config_schema()
|
||||
# print_view_360()
|
||||
sample_config_update()
|
||||
|
|
|
@ -270,6 +270,11 @@ def service_component_get_all(context):
|
|||
return IMPL.service_component_get_all(context)
|
||||
|
||||
|
||||
def service_component_get_all_by_config_file(context, config_file_id):
|
||||
return IMPL.service_component_get_all_by_config_file(context,
|
||||
config_file_id)
|
||||
|
||||
|
||||
def service_component_delete(context, _id):
|
||||
return IMPL.service_component_delete(context, _id)
|
||||
|
||||
|
|
|
@ -445,6 +445,17 @@ def service_component_get_all_by_node_for_service(context,
|
|||
return query.all()
|
||||
|
||||
|
||||
def service_component_get_all_by_config_file(context, config_file_id):
|
||||
query = _model_query(context,
|
||||
models.OsloConfigFileEntry.service_component_id). \
|
||||
filter_by(oslo_config_file_id=config_file_id).distinct()
|
||||
query_sc = _model_query(context, models.ServiceComponent).filter(
|
||||
models.ServiceComponent.id.in_(query)
|
||||
)
|
||||
|
||||
return query_sc.all()
|
||||
|
||||
|
||||
def service_component_get_all(context):
|
||||
return _get_all(context, models.ServiceComponent)
|
||||
|
||||
|
@ -1152,5 +1163,12 @@ if __name__ == '__main__':
|
|||
# perp_json = json.dumps(persp, indent=4)
|
||||
# print perp_json
|
||||
|
||||
import json
|
||||
print (json.dumps(view_360(None, True, True)))
|
||||
# import json
|
||||
# print (json.dumps(view_360(None, True, True)))
|
||||
|
||||
sc = service_component_get_all_by_config_file(
|
||||
None,
|
||||
'03cccfb4-5433-47fc-af3c-63869f270d78')
|
||||
print (service_worker_get_all_by(None,
|
||||
service_component_id=sc[0].id,
|
||||
is_launcher=True))
|
||||
|
|
Loading…
Reference in New Issue