Merge "Revert "Added enum type in the parser file""

This commit is contained in:
Zuul 2023-07-04 15:27:06 +00:00 committed by Gerrit Code Review
commit e45f694bc6

View File

@ -1,5 +1,5 @@
# pylint: disable=invalid-name # pylint: disable=invalid-name
# !/usr/bin/python3 #!/usr/bin/python3
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
@ -7,56 +7,10 @@
""" """
Parser to handle command line arguments Parser to handle command line arguments
""" """
import argparse import argparse
import re import re
from argparse import ArgumentParser, RawTextHelpFormatter from argparse import ArgumentParser, RawTextHelpFormatter
import getpass import getpass
from enum import Enum
class StringEnum(Enum):
"""This class aims to serve as a parent class for a parser
type checker"""
@classmethod
def get_members_values(cls):
"""Static method that returns a list of enum members values"""
return [v.value for v in cls.__members__.values()]
class SetupType(StringEnum):
"""Class aimed to help parser choose between installation
predefined types"""
AIO_SX = 'AIO-SX'
AIO_DX = 'AIO-DX'
STANDARD = 'STANDARD'
STORAGE = 'STORAGE'
class VboxNetworkType(StringEnum):
"""Class aimed to help parser choose between virtual box
network types"""
HOST_ONLY = 'hostonly'
NAT = 'nat'
class SecurityProfile(StringEnum):
"""Class aimed to help parser choose between
security profile types"""
STANDARD = 'standard'
EXTENDED = 'extended'
class LabInstallationType(StringEnum):
"""Class aimed to help parser choose between
lab installation types"""
GRAPHICAL = 'graphical'
SERIAL = 'serial'
def validate_password(pwd: str): def validate_password(pwd: str):
@ -101,9 +55,16 @@ def parse_setup_config(parser: ArgumentParser):
""" """
Mutate parser with CLI arguments related to the setup type Mutate parser with CLI arguments related to the setup type
""" """
parser.add_argument("--setup-type", parser.add_argument("--setup-type", help=
help=f"Expected value is one of {SetupType.get_members_values()}", """
type=SetupType, Type of setup:
AIO-SX
AIO-DX
STANDARD
STORAGE
""",
choices=['AIO-SX', 'AIO-DX', 'STANDARD', 'STORAGE'],
type=str,
required=True) required=True)
parser.add_argument("--controllers", help= parser.add_argument("--controllers", help=
""" """
@ -213,8 +174,7 @@ def parse_config_location(parser: ArgumentParser):
parser.add_argument("--ansible-controller-config", help= parser.add_argument("--ansible-controller-config", help=
""" """
Path to a local YAML file to be copied as localhost.yml Path to a local YAML file to be copied as localhost.yml
to the home directory of the controller-0. to the home directory of the controller-0. NOTE: System password value is updated dynamically with user defined --password.
NOTE: System password value is updated dynamically with user defined --password.
""", """,
type=str) type=str)
parser.add_argument("--vbox-home-dir", help= parser.add_argument("--vbox-home-dir", help=
@ -284,7 +244,7 @@ def parse_networking(parser: ArgumentParser):
parser.add_argument("--vboxnet-name", help= parser.add_argument("--vboxnet-name", help=
""" """
Which network to use for setup. Which host only network to use for setup.
""", """,
type=str) type=str)
parser.add_argument("--vboxnet-ip", help= parser.add_argument("--vboxnet-ip", help=
@ -298,10 +258,13 @@ def parse_networking(parser: ArgumentParser):
Add a new NAT interface to hosts. Add a new NAT interface to hosts.
""", """,
action='store_true') action='store_true')
parser.add_argument("--vboxnet-type", parser.add_argument("--vboxnet-type", help=
help=f"Expected value is one of {VboxNetworkType.get_members_values()}", """
type=VboxNetworkType, Type of vbox network, either hostonly on nat
default=VboxNetworkType.HOST_ONLY) """,
choices=['hostonly', 'nat'],
type=str,
default='hostonly')
parser.add_argument("--nat-controller-floating-local-ssh-port", help= parser.add_argument("--nat-controller-floating-local-ssh-port", help=
""" """
When oam network is configured as 'nat' a port on When oam network is configured as 'nat' a port on