Fix deploy show and deploy host-list output
Fix software deploy show and deploy host-list not displaying information issue. Also default the deploy host state to pending when a deploy host entity is created. Story: 2010676 Task: 49645 TCs: passed: software deploy show and software deploy host-list show deploy data after deploy start command accepted. passed: display "No deploy in progress" for software deploy show when there is no deploy. Change-Id: I9dc50804c66d5cb07df7717fd6623c23d0fca522 Signed-off-by: Bin Qian <bin.qian@windriver.com>
This commit is contained in:
parent
3c3a3ecb62
commit
76739676dc
@ -189,8 +189,7 @@ def print_result_list(header_data_list, data_list, has_error, sort_key=0):
|
||||
|
||||
|
||||
def print_software_deploy_host_list_result(req, data):
|
||||
if req.status_code == 200 and data:
|
||||
data = data.get("data", None)
|
||||
if req.status_code == 200:
|
||||
if not data:
|
||||
print("No deploy in progress.\n")
|
||||
return
|
||||
|
@ -122,10 +122,9 @@ class DeployManager(base.Manager):
|
||||
print("Respond code %d. Error: %s" % (req.status_code, req.reason))
|
||||
return 1
|
||||
|
||||
if not data or data.get("data"):
|
||||
if not data:
|
||||
print("No deploy in progress.")
|
||||
else:
|
||||
data = data.get("data")
|
||||
data = data[0]
|
||||
data["reboot_required"] = "Yes" if data.get("reboot_required") else "No"
|
||||
data_list = [[k, v] for k, v in data.items()]
|
||||
|
@ -21,12 +21,14 @@ from software_client.common import utils
|
||||
help="List all deployments that have this state")
|
||||
def do_show(cc, args):
|
||||
"""Show the software deployments states"""
|
||||
# TODO(bqian) modify the cli to display with generic tabulated output
|
||||
return cc.deploy.show()
|
||||
|
||||
|
||||
def do_host_list(cc, args):
|
||||
"""List of hosts for software deployment """
|
||||
req, data = cc.deploy.host_list()
|
||||
# TODO(bqian) modify display with generic tabulated output
|
||||
if args.debug:
|
||||
utils.print_result_debug(req, data)
|
||||
else:
|
||||
|
@ -10,7 +10,6 @@ import logging
|
||||
import os
|
||||
from pecan import expose
|
||||
from pecan import request
|
||||
from pecan import Response
|
||||
import shutil
|
||||
|
||||
from software.exceptions import SoftwareError
|
||||
@ -110,9 +109,8 @@ class SoftwareAPIController(object):
|
||||
def deploy(self):
|
||||
from_release = request.GET.get("from_release")
|
||||
to_release = request.GET.get("to_release")
|
||||
result = dict(data=sc.software_deploy_show_api(from_release, to_release))
|
||||
response_data = json.dumps(result)
|
||||
return Response(body=response_data, status_code=200)
|
||||
result = sc.software_deploy_show_api(from_release, to_release)
|
||||
return result
|
||||
|
||||
@expose('json')
|
||||
@expose('query.xml', content_type='application/xml')
|
||||
@ -194,9 +192,8 @@ class SoftwareAPIController(object):
|
||||
|
||||
@expose('json', method="GET")
|
||||
def host_list(self):
|
||||
query_hosts = dict(data=sc.deploy_host_list())
|
||||
response_data = json.dumps(query_hosts)
|
||||
return Response(body=response_data, status_code=200)
|
||||
result = sc.deploy_host_list()
|
||||
return result
|
||||
|
||||
@expose(method='GET', template='json')
|
||||
def in_sync_controller(self):
|
||||
|
@ -2363,6 +2363,8 @@ class PatchController(PatchService):
|
||||
create_deploy_hosts()
|
||||
self.db_api_instance.begin_update()
|
||||
try:
|
||||
# TODO(bqian) replace SW_VERSION below to current running sw_release
|
||||
# (MM.mm.pp)
|
||||
self.update_and_sync_deploy_state(self.db_api_instance.create_deploy,
|
||||
SW_VERSION, to_release, True)
|
||||
self.update_and_sync_deploy_state(self.db_api_instance.update_deploy,
|
||||
@ -3020,7 +3022,7 @@ class PatchController(PatchService):
|
||||
deploy_hosts = self.db_api_instance.get_deploy_host()
|
||||
deploy = self.db_api_instance.get_deploy_all()
|
||||
if not deploy:
|
||||
return None
|
||||
return []
|
||||
deploy = deploy[0]
|
||||
|
||||
deploy_host_list = []
|
||||
|
@ -325,7 +325,7 @@ class DeployHostHandler(DeployHosts):
|
||||
super().__init__()
|
||||
self.data = get_software_filesystem_data()
|
||||
|
||||
def create(self, hostname, state: DEPLOY_HOST_STATES = None):
|
||||
def create(self, hostname, state: DEPLOY_HOST_STATES = DEPLOY_HOST_STATES.PENDING):
|
||||
super().create(hostname, state)
|
||||
deploy = self.query(hostname)
|
||||
if deploy:
|
||||
|
Loading…
Reference in New Issue
Block a user