Files
update/software-client/software_client/v1/deploy_shell.py
Joseph Vazhappilly 0cd1d59425 Add support for https in USM software client
This change add support for https with SSL protocol and certificate.
The USM client can work with either insecure (disable SSL/TLS
certificate verification) or with SSL certificate. The client is
also modified to support sessions and versions. These changes are
adapted from cgtsclient.

This adds three authorization modes, [token, keystone & local-root].

In token mode, a keystone token and software-url is used for auth.
Eg: $ software \
        --software-url "http://192.168.204.1:5497" \
        --os-auth-token "${TOKEN}" list

In keystone mode, sourced keystone configs in env is used for auth.
Eg: $ source /etc/platform/openrc; software list

In local-root mode, authorization is by privileged user (root/sudo)
of the controller where software application is running.
Eg: $ sudo software list

Optional arguments specific to https:
  -k, --insecure
  --cert-file CERT_FILE
  --key-file KEY_FILE
  --ca-file CA_FILE

Example usage for insecure connection:
  software -k list

Story: 2010676
Task: 49666

Test Plan:
PASS: Verify software cli output for http endpoints
PASS: Verify software cli output for https endpoints

Change-Id: I2e2ff115b8d03cddb02e026da84f389918238dab
Signed-off-by: Joseph Vazhappilly <joseph.vazhappillypaily@windriver.com>
2024-03-14 06:58:50 -04:00

113 lines
3.1 KiB
Python

#
# Copyright (c) 2024 Wind River Systems, Inc.
#
# SPDX-License-Identifier: Apache-2.0
#
from software_client.common import utils
# --deployment is an optional argument
@utils.arg('--deployment',
required=False,
help='List the deployment specified')
# --state is an optional argument.
# default: "all"
# acceptable values: inactive, active, prestaging, prestaged, all
@utils.arg('--state',
choices=['inactive', 'active', 'prestaging', 'prestaged', 'all'],
default="all",
required=False,
help="List all deployments that have this state")
def do_show(cc, args):
"""Show the software deployments states"""
return cc.deploy.show()
def do_host_list(cc, args):
"""List of hosts for software deployment """
req, data = cc.deploy.host_list()
if args.debug:
utils.print_result_debug(req, data)
else:
utils.print_software_deploy_host_list_result(req, data)
return utils.check_rc(req, data)
@utils.arg('deployment',
help='Verify if prerequisites are met for this Deployment ID')
@utils.arg('-f',
'--force',
action='store_true',
required=False,
help='Allow bypassing non-critical checks')
@utils.arg('--region_name',
default='RegionOne',
required=False,
help='Run precheck against a subcloud')
def do_precheck(cc, args):
"""Verify whether prerequisites for installing the software deployment are satisfied"""
req, data = cc.deploy.precheck(args)
if args.debug:
utils.print_result_debug(req, data)
else:
utils.print_software_op_result(req, data)
return utils.check_rc(req, data)
@utils.arg('deployment',
help='Deployment ID to start')
@utils.arg('-f',
'--force',
action='store_true',
required=False,
help='Allow bypassing non-critical checks')
def do_start(cc, args):
"""Start the software deployment"""
req, data = cc.deploy.start(args)
if args.debug:
utils.print_result_debug(req, data)
else:
utils.print_software_op_result(req, data)
return utils.check_rc(req, data)
@utils.arg('agent',
help="Agent on which host deploy is triggered")
@utils.arg('-f',
'--force',
action='store_true',
required=False,
help="Force deploy host")
def do_host(cc, args):
"""Deploy prestaged software deployment to the host"""
return cc.deploy.host(args)
@utils.arg('deployment',
help='Deployment ID to activate')
def do_activate(cc, args):
"""Activate the software deployment"""
req, data = cc.deploy.activate(args)
if args.debug:
utils.print_result_debug(req, data)
else:
utils.print_software_op_result(req, data)
return utils.check_rc(req, data)
@utils.arg('deployment',
help='Deployment ID to complete')
def do_complete(cc, args):
"""Complete the software deployment"""
req, data = cc.deploy.complete(args)
if args.debug:
utils.print_result_debug(req, data)
else:
utils.print_software_op_result(req, data)
return utils.check_rc(req, data)