https://github.com/qualisystems/cloudshell-shell-core
Basic classes, helpers and interfaces for developing a CloudShell Shell
https://github.com/qualisystems/cloudshell-shell-core
Last synced: about 1 year ago
JSON representation
Basic classes, helpers and interfaces for developing a CloudShell Shell
- Host: GitHub
- URL: https://github.com/qualisystems/cloudshell-shell-core
- Owner: QualiSystems
- Created: 2016-02-08T16:19:48.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2023-10-25T14:12:29.000Z (over 2 years ago)
- Last Synced: 2024-11-03T14:12:19.317Z (over 1 year ago)
- Language: Python
- Homepage: http://www.quali.com
- Size: 385 KB
- Stars: 1
- Watchers: 15
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# CloudShell Shell Core
[](https://github.com/QualiSystems/cloudshell-shell-core/actions?query=branch%3Amaster)
[](https://codecov.io/gh/QualiSystems/cloudshell-shell-core)
[](https://badge.fury.io/py/cloudshell-shell-core)
[](https://github.com/python/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](https://devguide.quali.com/shells/9.3.0/getting-information-from-cloudshell.html)
- [cloudshell-automation-api](https://help.quali.com/Online%20Help/0.0/Python-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](https://github.com/QualiSystems/cloudshell-logging/blob/dev/README.md) wrapper
## Installation
```bash
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':**
```python
from cloudshell.shell.core.resource_driver_interface import ResourceDriverInterface
class DataModelExampleDriver (ResourceDriverInterface):
```
#### Api wrapper - returning api session:
```python
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:
```python
from cloudshell.shell.core.session.logging_session import LoggingSessionContext
with LoggingSessionContext(context) as logger:
do_something(logger)
do something_else(logger)
```
or
```python
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](https://devguide.quali.com/shells/9.3.0/getting-information-from-cloudshell.html) 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](https://github.com/QualiSystems/cloudshell-package-repo-template#description-of-services)