コード例 #1
0
def cli():
    """psuutil - Command line utility for providing PSU status"""

    global platform_psuutil
    global platform_chassis

    if os.geteuid() != 0:
        click.echo("Root privileges are required for this operation")
        sys.exit(1)

    # Load the helper class
    helper = UtilHelper()

    if not helper.check_pddf_mode():
        click.echo(
            "PDDF mode should be supported and enabled for this platform for this operation"
        )
        sys.exit(1)

    # Load new platform api class
    try:
        import sonic_platform.platform
        platform_chassis = sonic_platform.platform.Platform().get_chassis()
    except Exception as e:
        click.echo("Failed to load chassis due to {}".format(str(e)))

    # Load platform-specific psuutil class if 2.0 implementation is not present
    if platform_chassis is None:
        try:
            platform_psuutil = helper.load_platform_util(
                PLATFORM_SPECIFIC_MODULE_NAME, PLATFORM_SPECIFIC_CLASS_NAME)
        except Exception as e:
            click.echo("Failed to load {}: {}".format(
                PLATFORM_SPECIFIC_MODULE_NAME, str(e)))
            sys.exit(2)
コード例 #2
0
def cli():
    """pddf_thermalutil - Command line utility for providing Temp Sensors information"""

    if os.geteuid() != 0:
        click.echo("Root privileges are required for this operation")
        sys.exit(1)

    # Load the helper class
    helper = UtilHelper()

    if not helper.check_pddf_mode():
        click.echo(
            "PDDF mode should be supported and enabled for this platform for this operation"
        )
        sys.exit(1)

    # Load platform-specific fanutil class
    global platform_thermalutil
    try:
        platform_thermalutil = helper.load_platform_util(
            PLATFORM_SPECIFIC_MODULE_NAME, PLATFORM_SPECIFIC_CLASS_NAME)
    except Exception as e:
        click.echo("Failed to load {}: {}".format(
            PLATFORM_SPECIFIC_MODULE_NAME, str(e)))
        sys.exit(2)
コード例 #3
0
    from utilities_common.util_base import UtilHelper
except ImportError as e:
    raise ImportError("%s - required module not found" % str(e))

VERSION = '2.0'

ERROR_PERMISSIONS = 1
ERROR_CHASSIS_LOAD = 2
ERROR_NOT_IMPLEMENTED = 3
ERROR_PDDF_NOT_SUPPORTED = 4

# Global platform-specific chassis class instance
platform_chassis = None

# Load the helper class
helper = UtilHelper()

# ==================== CLI commands and groups ====================


# This is our main entrypoint - the main 'thermalutil' command
@click.group()
def cli():
    """pddf_thermalutil - Command line utility for providing Temp Sensors information"""

    global platform_chassis

    if os.geteuid() != 0:
        click.echo("Root privileges are required for this operation")
        sys.exit(1)