Merge "software deploy start implementation"

This commit is contained in:
Zuul 2023-05-29 20:43:31 +00:00 committed by Gerrit Code Review
commit 0f76dd885f
3 changed files with 35 additions and 15 deletions

View File

@ -47,8 +47,6 @@ class SoftwareAPIController(object):
except SoftwareError as e:
return dict(error="Error: %s" % str(e))
sc.send_latest_feed_commit_to_agent()
sc.software_sync()
return result
@ -57,19 +55,27 @@ class SoftwareAPIController(object):
@expose('query.xml', content_type='application/xml')
def deploy_delete(self, *args, **kwargs):
if sc.any_patch_host_installing():
return dict(error="Rejected: One or more nodes are installing releases.")
return dict(error="Rejected: One or more nodes are installing a release.")
try:
result = sc.software_deploy_delete_api(list(args), **kwargs)
except SoftwareError as e:
return dict(error="Error: %s" % str(e))
sc.send_latest_feed_commit_to_agent()
sc.software_sync()
return result
@expose('json')
@expose('query.xml', content_type='application/xml')
def deploy_start(self, *args):
if sc.any_patch_host_installing():
return dict(error="Rejected: One or more nodes are installing a release.")
sc.send_latest_feed_commit_to_agent()
sc.software_sync()
return dict(info="%s is ready to be deployed on all hosts" % list(args)[0])
@expose('json')
@expose('query.xml', content_type='application/xml')
def deploy_host(self, *args):

View File

@ -805,8 +805,25 @@ def deploy_precheck_req(args):
def deploy_start_req(args):
print(args.deployment)
return 1
# args.deployment is a list
deployment = args.deployment
# Ignore interrupts during this function
signal.signal(signal.SIGINT, signal.SIG_IGN)
# Issue deploy_start request
url = "http://%s/software/deploy_start/%s" % (api_addr, deployment)
headers = {}
append_auth_token_if_required(headers)
req = requests.post(url, headers=headers)
if args.debug:
print_result_debug(req)
else:
print_software_op_result(req)
return check_rc(req)
def deploy_activate_req(args):

View File

@ -1662,14 +1662,11 @@ class PatchController(PatchService):
def any_patch_host_installing(self):
rc = False
self.hosts_lock.acquire()
for host in self.hosts.values():
if host.state == constants.PATCH_AGENT_STATE_INSTALLING:
rc = True
break
self.hosts_lock.release()
with self.hosts_lock:
for host in self.hosts.values():
if host.state == constants.PATCH_AGENT_STATE_INSTALLING:
rc = True
break
return rc
def copy_restart_scripts(self):