Add upgrade notification for system commands

During upgrade, system commands:
host-pv-list, host-pv-show, host-lvg-list, host-lvg-show,
host-disk-partition-list, and host-disk-partition-show could display
the host configuration that will be applied to host after upgrade. A
notification message is displayed in the above commands to inform
the user.

Test Plan:
    Run commands during an upgrade, verify proper message is displayed.
    Run commands when upgrade is not in progress, the notification
message is not displayed.

Story: 2009303
Task: 46764

Signed-off-by: Bin Qian <bin.qian@windriver.com>
Change-Id: Ie7131f4b7fa6ec9f5ed6de5acf3cf2cde1a53601
This commit is contained in:
Bin Qian 2022-11-08 18:32:29 +00:00
parent 633c9350bd
commit ec1175df87
4 changed files with 34 additions and 3 deletions

View File

@ -111,3 +111,7 @@ NETWORK_TYPE_CLUSTER_HOST = 'cluster-host'
SB_SUPPORTED_NETWORKS = {
SB_TYPE_CEPH: [NETWORK_TYPE_MGMT, NETWORK_TYPE_CLUSTER_HOST]
}
UPGRADE_NOTIFICATION = 'System platform upgrade is in progress.\n' \
'The command may display the target configuration ' \
'that has not yet been applied to the host.'

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2018 Wind River Systems, Inc.
# Copyright (c) 2013-2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -8,6 +8,7 @@
# All Rights Reserved.
#
from cgtsclient.common import constants
from cgtsclient.common import utils
from cgtsclient import exc
from cgtsclient.v1 import ihost as ihost_utils
@ -62,6 +63,10 @@ def _find_lvg(cc, ihost, lvguuid):
help="Name or UUID of lvg [REQUIRED]")
def do_host_lvg_show(cc, args):
"""Show Local Volume Group attributes."""
upgrades = cc.upgrade.list()
if upgrades:
print(constants.UPGRADE_NOTIFICATION)
ihost = ihost_utils._find_ihost(cc, args.hostnameorid)
ilvg = ilvg_utils._find_ilvg(cc, ihost, args.lvgnameoruuid)
_print_ilvg_show(ilvg)
@ -81,6 +86,10 @@ def _adjust_state_data(vg_name, state):
help="Name or ID of host [REQUIRED]")
def do_host_lvg_list(cc, args):
"""List Local Volume Groups."""
upgrades = cc.upgrade.list()
if upgrades:
print(constants.UPGRADE_NOTIFICATION)
ihost = ihost_utils._find_ihost(cc, args.hostnameorid)
ilvgs = cc.ilvg.list(ihost.uuid)

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2013-2017 Wind River Systems, Inc.
# Copyright (c) 2013-2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -8,6 +8,7 @@
# All Rights Reserved.
#
from cgtsclient.common import constants
from cgtsclient.common import utils
from cgtsclient import exc
from cgtsclient.v1 import idisk as idisk_utils
@ -54,6 +55,10 @@ def _find_pv(cc, ihost, pvuuid):
help="UUID of pv")
def do_host_pv_show(cc, args):
"""Show Physical Volume attributes."""
upgrades = cc.upgrade.list()
if upgrades:
print(constants.UPGRADE_NOTIFICATION)
ihost = ihost_utils._find_ihost(cc, args.hostnameorid)
i = _find_pv(cc, ihost, args.pvuuid)
_print_ipv_show(i)
@ -73,6 +78,10 @@ def _adjust_state_data(vg_name, state):
help="Name or ID of host")
def do_host_pv_list(cc, args):
"""List Physical Volumes."""
upgrades = cc.upgrade.list()
if upgrades:
print(constants.UPGRADE_NOTIFICATION)
ihost = ihost_utils._find_ihost(cc, args.hostnameorid)
ipvs = cc.ipv.list(ihost.uuid)

View File

@ -1,5 +1,5 @@
#
# Copyright (c) 2017-2018 Wind River Systems, Inc.
# Copyright (c) 2017-2022 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
@ -41,6 +41,11 @@ def _print_partition_show(partition):
help="Name or UUID of the disk partition")
def do_host_disk_partition_show(cc, args):
"""Show disk partition attributes."""
upgrades = cc.upgrade.list()
if upgrades:
print(constants.UPGRADE_NOTIFICATION)
ihost = ihost_utils._find_ihost(cc, args.hostname_or_id)
ipartition = part_utils._find_partition(cc, ihost,
args.device_path_or_uuid)
@ -62,6 +67,10 @@ def do_host_disk_partition_show(cc, args):
help="uuid of disk")
def do_host_disk_partition_list(cc, args):
"""List disk partitions."""
upgrades = cc.upgrade.list()
if upgrades:
print(constants.UPGRADE_NOTIFICATION)
ihost = ihost_utils._find_ihost(cc, args.hostname_or_id)
if args.disk:
idisk = idisk_utils._find_disk(cc, args.hostname_or_id, args.disk)