Skip to content

QualiSystems/cloudshell-shell-core

Repository files navigation

CloudShell Shell Core

Build status codecov PyPI version Code style: black

Overview

The cloudshell-shell-core open source Python package is the base package for all CloudShell shells. It provides basic shell functionality including:

  • Resource driver interface, which enables CloudShell to use the shell. This interface is automatically added to the shell’s driver when creating a shell via shellfoundry.
  • Definitions of the driver’s context objects, which CloudShell sends to the shell’s commands. For details, see the CloudShell Dev Guide's Getting information from cloudshell
  • cloudshell-automation-api wrapper. Use of the CloudShell Automation API mostly applies to setting live status and writing messages to output. Other API capabilities are outside the scope of the shell and should be implemented on the sandbox orchestration level,
  • cloudshell-logging wrapper

Installation

pip install cloudshell-shell-core

Python 3 is supported starting with version 5.0.x.

Implementation Examples

Driver’s interface - declaring the driver’s interface for shell 'DataModelExample':

from cloudshell.shell.core.resource_driver_interface import ResourceDriverInterface
class DataModelExampleDriver (ResourceDriverInterface):

Api wrapper - returning api session:

from cloudshell.shell.core.session.cloudshell_session import CloudShellSessionContext
with CloudShellSessionContext(context) as session:
    perform_validations(session)
    do_some_logic(session)
    do_some_more_logic(session)

Logging wrapper - how to use the logger:

from cloudshell.shell.core.session.logging_session import LoggingSessionContext 
with LoggingSessionContext(context) as logger:
    do_something(logger)
    do something_else(logger)

or

from cloudshell.shell.core.session.logging_session import LoggingSessionContext 
logger = LoggingSessionContext.get_logger_with_thread_id(context)
do_something(logger)

Driver Context:

The driver context objects are extensively documented in the CloudShell Developer Guide's Getting Information from CloudShell article. We recommend checking the most up to date version as we periodically update the CloudShell Developer Guide.

We use tox and pre-commit for testing. Services description

About

Basic classes, helpers and interfaces for developing a CloudShell Shell

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages