Skip to content

Commit

Permalink
Closes-Bug: #1594917 - SSH Key setup should be done only in add keys
Browse files Browse the repository at this point in the history
Currently it is being done for modify keys as well as happening in the foreground
This check-in moves it to gevent to prevent it from being a blocking call

Change-Id: Ib08a6694154263faf1a68c78868a16d16edbd510
  • Loading branch information
nitishkrishna committed Jun 21, 2016
1 parent 436e19b commit 4a3469e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/server_mgr_main.py
Expand Up @@ -1717,6 +1717,7 @@ def put_server(self):
try:
self.validate_smgr_entity("server", entity)
servers = entity.get("server", None)
new_servers = []
for server in servers:
self.plug_mgmt_intf_details(server)
self.validate_server_mgr_tags(server)
Expand All @@ -1741,6 +1742,7 @@ def put_server(self):
self._serverDb.modify_server(server)
server_fields['primary_keys'] = "['id', 'mac_address']"
else:
new_servers.append(server)
self.validate_smgr_request("SERVER", "PUT",
bottle.request, server)
server['status'] = "server_added"
Expand All @@ -1749,9 +1751,8 @@ def put_server(self):
# Trigger to collect monitoring info

# End of for
self._monitoring_base_plugin_obj.setup_keys(new_servers=servers)
if self._server_inventory_obj:
gevent.spawn(self._server_inventory_obj.handle_inventory_trigger, "add", servers)
if len(new_servers):
gevent.spawn(self._monitoring_base_plugin_obj.setup_keys, None, new_servers)
except ServerMgrException as e:
self._smgr_trans_log.log(bottle.request,
self._smgr_trans_log.PUT_SMGR_CFG_SERVER, False)
Expand Down
3 changes: 2 additions & 1 deletion src/server_mgr_mon_base_plugin.py
Expand Up @@ -654,7 +654,6 @@ def initialize_features(self, sm_args, serverdb):
self.server_inventory_obj.set_ipmi_defaults(sm_args.ipmi_username, sm_args.ipmi_password)
self.server_inventory_obj.add_inventory()
else:
#gevent.spawn(self.setup_keys, serverdb)
self._smgr_log.log(self._smgr_log.ERROR, "Inventory configuration not set. "
"You will be unable to get Inventory information from servers.")

Expand All @@ -670,6 +669,8 @@ def setup_keys(self, server_db=None, new_servers=None):
#If keys are the deleted from the DB then create and copy them to the target
elif server['ssh_private_key'] is None and 'id' in server and 'ip_address' in server and server['id']:
self.create_store_copy_ssh_keys(server['id'], server['ip_address'])
if self.inventory_config_set and new_servers:
self.server_inventory_obj.handle_inventory_trigger("add", servers)

def create_server_dict(self, servers):
return_dict = dict()
Expand Down

0 comments on commit 4a3469e

Please sign in to comment.