### Example Python Command for OVHcloud Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_ovh/README.rst This example demonstrates how to create a Cetmix Tower command to interact with OVHcloud services using Python. It covers configuring command settings, adding required variables and secrets, and writing the Python code to execute the command. ```rst - **Navigate to Command Creation** - Go to ``Cetmix Tower > Commands > Commands`` - Click the ``Create`` button - **Configure Command Settings** - Set a descriptive ``Name`` (e.g., "List OVHcloud Instances") - Leave ``Reference`` blank to generate automatically (or set a custom reference) - Select ``Action``: "Execute Python code" - Set ``Access Level``: Choose appropriate level (e.g., "Manager") - Optional: Set ``Default Path`` if needed - Optional: Add ``Tags`` (e.g., "ovh", "cloud", "instance") for better organization - **Add Required Variables** - In the ``Variables`` tab, add the previously configured variable: - ``ovh_endpoint`` (e.g., "ovh-eu") - **Add Required Secrets** - In the ``Secrets`` field, add the previously configured secrets: - ``ovh_application_key`` - ``ovh_application_secret`` - ``ovh_consumer_key`` - **Write Python Code** - Go to the ``Code`` tab - Enter the following Python code: .. code:: python ``` -------------------------------- ### Example AWS EC2 Command Output Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_aws/README.rst Provides example outputs for the AWS EC2 command execution within Cetmix Tower, illustrating both scenarios where EC2 instances are found and when none are detected. ```bash Found 3 EC2 instances: Instance ID: i-0abc123def456789, Type: t2.micro, State: running Instance ID: i-0def456abc789123, Type: t3.medium, State: stopped Instance ID: i-0789abc123def456, Type: m5.large, State: running ``` ```bash No EC2 instances found ``` -------------------------------- ### Cetmix Tower OVHcloud Command Usage Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_ovh/static/description/index.html Demonstrates how to use Cetmix Tower's integrated OVHcloud commands for managing cloud resources. This includes examples for creating DNS records and running instance commands. ```python from cetmix_tower_ovh.models.ovh_dns import OvhDns def create_dns_record(domain, sub_domain, record_type, value, ttl=3600): """Creates a DNS record in OVH. Args: domain (str): The domain name. sub_domain (str): The subdomain for the record. record_type (str): The type of DNS record (e.g., A, CNAME, MX). value (str): The value of the DNS record. ttl (int, optional): The Time To Live for the record. Defaults to 3600. Returns: dict: The result of the DNS record creation operation. """ ovh_dns = OvhDns() return ovh_dns.create_dns_record(domain, sub_domain, record_type, value, ttl) # Example Usage: # create_dns_record('example.com', 'www', 'A', '192.168.1.1') ``` ```APIDOC Cetmix Tower OVHcloud Instance Commands: # To list available OVHcloud instances: ovhcloud instance list # To get details of a specific instance: ovhcloud instance show # To create a new instance: ovhcloud instance create --name --region --flavor --image # To delete an instance: ovhcloud instance delete # To manage DNS records: ovhcloud dns create --domain --subdomain --type --value [--ttl ] ovhcloud dns list --domain ovhcloud dns delete --domain --record-id ``` -------------------------------- ### Example Output for Listing EC2 Instances Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_aws/readme/USAGE.md Demonstrates the expected output format when the AWS EC2 instance listing command is executed successfully, both when instances are found and when none are present. ```bash Found 3 EC2 instances: Instance ID: i-0abc123def456789, Type: t2.micro, State: running Instance ID: i-0def456abc789123, Type: t3.medium, State: stopped Instance ID: i-0789abc123def456, Type: m5.large, State: running ``` ```bash No EC2 instances found ``` -------------------------------- ### Install boto3 Dependency Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_aws/readme/CONFIGURE.md Installs the Python boto3 package, which is a required external dependency for the AWS integration module in Cetmix Tower. ```bash pip install boto3 ``` -------------------------------- ### Install Boto3 Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_aws/README.rst Installs the Boto3 Python package, which is a required external dependency for the Cetmix Tower AWS module. ```bash pip install boto3 ``` -------------------------------- ### List AWS EC2 Instances using Python Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_aws/README.rst An example of creating a Cetmix Tower command to execute Python code that lists AWS EC2 instances using the Boto3 library. ```python # Example Python code for Cetmix Tower command import boto3 # Retrieve AWS credentials and region from Cetmix Tower secrets and variables aws_access_key_id = "#!cxtower.secret.aws_access_key!#" aws_secret_access_key = "#!cxtower.secret.aws_secret_access_key!#" aws_region = "#!cxtower.variable.aws_region_name!#" # Initialize Boto3 client for EC2 ec2_client = boto3.client( 'ec2', aws_access_key_id=aws_access_key_id, aws_secret_access_key=aws_secret_access_key, region_name=aws_region ) # Describe EC2 instances try: response = ec2_client.describe_instances() instances = [] for reservation in response["Reservations"]: for instance in reservation["Instances"]: instances.append({ 'InstanceId': instance['InstanceId'], 'InstanceType': instance['InstanceType'], 'State': instance['State']['Name'], 'PublicIpAddress': instance.get('PublicIpAddress', 'N/A') }) print("EC2 Instances:") for inst in instances: print(f" ID: {inst['InstanceId']}, Type: {inst['InstanceType']}, State: {inst['State']}, IP: {inst['PublicIpAddress']}") except Exception as e: print(f"Error listing EC2 instances: {e}") ``` -------------------------------- ### Cetmix Tower Git Module Overview Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_git/static/description/index.html Provides an overview of the Cetmix Tower Git module, its purpose, and links to external resources for detailed information. It also includes metadata about the module's license and development status. ```APIDOC Project: /cetmix/cetmix-tower Cetmix Tower Git Module ======================== [![Beta](https://img.shields.io/badge/maturity-Beta-yellow.png)](https://odoo-community.org/page/development-status) [![License: AGPL-3](https://img.shields.io/badge/license-AGPL--3-blue.png)](http://www.gnu.org/licenses/agpl-3.0-standalone.html) [![cetmix/cetmix-tower](https://img.shields.io/badge/github-cetmix%2Fcetmix--tower-lightgray.png?logo=github)](https://github.com/cetmix/cetmix-tower/tree/16.0/cetmix_tower_git) This module implements Git Management functionality for [Cetmix Tower](https://cetmix.com/tower). Refer to the [official documentation](https://cetmix.com/tower) for detailed information. ``` -------------------------------- ### Pin paramiko version Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_server/readme/HISTORY.md Pins the paramiko library version to '<4' to ensure compatibility with legacy installations. This is a bugfix to prevent issues arising from newer paramiko versions. ```python paramiko<4 ``` -------------------------------- ### Boto3 Client Initialization for AWS Services Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_aws/static/description/index.html This snippet shows the standard pattern for initializing a boto3 client to interact with various AWS services. It requires the service name, region, access key, and secret access key, which are typically provided via Cetmix Tower variables and secrets. ```python # Standard client initialization pattern client = boto3.client( 'service_name', # Replace with: ec2, s3, rds, cloudwatch, etc. region_name={{ aws_region_name }}, aws_access_key_id=#!cxtower.secret.aws_access_key!#, aws_secret_access_key=#!cxtower.secret.aws_secret_access_key!# ) ``` -------------------------------- ### Add tldextract and dnspython libraries Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_server/readme/HISTORY.md Includes the tldextract and dnspython libraries to enhance domain name and DNS resolution capabilities within the project. ```python tldextract dnspython ``` -------------------------------- ### Cetmix Tower OVH Endpoint Configuration Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_ovh/readme/CONFIGURE.md This section describes how to configure the OVH API endpoint as a variable in Cetmix Tower. It specifies the name, reference, type, and example values for the endpoint variable. ```APIDOC Variable Configuration: - Name: `OVH Endpoint` - Reference: `ovh_endpoint` - Type: `String` - Value: Your OVH API endpoint (e.g., `ovh-eu`, `ovh-ca`, `ovh-us`) ``` -------------------------------- ### Add tldextract and dnspython Libraries Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_server/static/description/index.html This entry details the addition of the tldextract and dnspython libraries to the project, likely for enhanced domain and DNS resolution capabilities. ```python import tldextract import dns.resolver ``` -------------------------------- ### AWS Boto3 Client and Resource Initialization Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_aws/README.rst Demonstrates the standard patterns for initializing AWS clients and resources using the boto3 Python library. This includes specifying the service name, region, and AWS credentials. ```python # Standard client initialization pattern client = boto3.client( 'service_name', # Replace with: ec2, s3, rds, cloudwatch, etc. region_name={{ aws_region_name }}, aws_access_key_id=#!cxtower.secret.aws_access_key!#, aws_secret_access_key=#!cxtower.secret.aws_secret_access_key!# ) # Or use resource interface for object-oriented access resource = boto3.resource( 'service_name', # Replace with: ec2, s3, etc. region_name={{ aws_region_name }}, aws_access_key_id=#!cxtower.secret.aws_access_key!#, aws_secret_access_key=#!cxtower.secret.aws_secret_access_key!# ) ``` -------------------------------- ### Cetmix Tower AWS Configuration Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_aws/readme/CONFIGURE.md Details the process of configuring AWS credentials and region within Cetmix Tower using its settings interface. This involves creating secrets for access keys and a variable for the region. ```APIDOC APIDOC: Settings > Keys and Secrets: Create Secret: Name: AWS Access Key Reference: aws_access_key Key Type: Secret Secret Value: Create Secret: Name: AWS Secret Access Key Reference: aws_secret_access_key Key Type: Secret Secret Value: Settings > Variables: Create Variable: Name: AWS Region Name Reference: aws_region_name Type: String Value: Usage in Commands: #!cxtower.secret.aws_access_key!# #!cxtower.secret.aws_secret_access_key!# #!cxtower.variable.aws_region_name!# ``` -------------------------------- ### Initialize Boto3 Resource for AWS Services Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_aws/static/description/index.html This snippet demonstrates how to initialize a Boto3 resource for interacting with AWS services. It requires specifying the service name, region, and AWS credentials. The resource interface allows for object-oriented access to AWS services. ```python import boto3 # Or use resource interface for object-oriented access resource = boto3.resource( 'service_name', # Replace with: ec2, s3, etc. region_name={{ aws_region_name }}, aws_access_key_id=#!cxtower.secret.aws_access_key!#, aws_secret_access_key=#!cxtower.secret.aws_secret_access_key!# ) ``` -------------------------------- ### Release for Odoo 16.0 Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_server_queue/static/description/index.html This entry signifies the initial release of the module for Odoo version 16.0. It includes the foundational code and features for the Cetmix Tower Server Queue. ```xml ``` -------------------------------- ### AWS Configuration and Access Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_aws/static/description/index.html This section details the prerequisites and steps for configuring AWS access within Cetmix Tower. It emphasizes the need to install the boto3 Python package and create AWS access keys, storing them as secrets in Cetmix Tower for secure access. ```APIDOC Prerequisites: - Install boto3 Python package: pip install boto3 AWS Access Setup: 1. Create AWS Access Keys: - Refer to AWS documentation for creating IAM access keys: https://docs.aws.amazon.com/IAM/latest/UserGuide/security-creds.html - Recommended: Create a dedicated IAM user with appropriate permissions. - Securely store your access key ID and secret access key. 2. Configure AWS Secrets in Cetmix Tower: - Navigate to Cetmix Tower > Settings > Keys and Secrets. - Create a Secret: - Name: AWS Access Key - Reference: aws_access_key - Key Type: Secret - Value: Your AWS access key ID - Create another Secret: - Name: AWS Secret Access Key - Reference: aws_secret_access_key - Key Type: Secret - Value: Your AWS secret access key ``` -------------------------------- ### Cetmix Tower Server Notify Backend Module Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_server_notify_backend/static/description/index.html This snippet provides an overview of the Cetmix Tower Server Notify Backend module. It highlights its purpose, dependency on the web_notify module, and links to official documentation and the project's GitHub repository. ```markdown Cetmix Tower Server Notify Backend ================================== [![Beta](https://img.shields.io/badge/maturity-Beta-yellow.png)](https://odoo-community.org/page/development-status) [![License: AGPL-3](https://img.shields.io/badge/license-AGPL--3-blue.png)](http://www.gnu.org/licenses/agpl-3.0-standalone.html) [![cetmix/cetmix-tower](https://img.shields.io/badge/github-cetmix%2Fcetmix--tower-lightgray.png?logo=github)](https://github.com/cetmix/cetmix-tower/tree/16.0/cetmix_tower_server_notify_backend) This module implements notifications in the backend UI for [Cetmix Tower](https://cetmix.com/tower). It requires the [web_notify](https://github.com/OCA/web/web_notify) module to be installed and configured in the Odoo instance. Please refer to the [official documentation](https://cetmix.com/tower) for detailed information. **Table of contents** * [Configuration](#configuration) * [Usage](#usage) * [Changelog](#changelog) * [16.0.1.0.0](#section-1) * [Bug Tracker](#bug-tracker) * [Credits](#credits) * [Authors](#authors) * [Maintainers](#maintainers) [Configuration](#toc-entry-1) ============================= Please refer to the [official documentation](https://cetmix.com/tower) for detailed configuration instructions. [Usage](#toc-entry-2) ===================== Please refer to the [official documentation](https://cetmix.com/tower) for detailed usage instructions. [Changelog](#toc-entry-3) ========================= [16.0.1.0.0](#toc-entry-4) -------------------------- Release for Odoo 16.0 [Bug Tracker](#toc-entry-5) =========================== Bugs are tracked on [GitHub Issues](https://github.com/cetmix/cetmix-tower/issues). In case of trouble, please check there if your issue has already been reported. If you spotted it first, help us to smash it by providing a detailed and welcomed [feedback](https://github.com/cetmix/cetmix-tower/issues/new?body=module:%20cetmix_tower_server_notify_backend%0Aversion:%2016.0%0A%0A**Steps%20to%20reproduce**%0A-%20...%0A%0A**Current%20behavior**%0A%0A**Expected%20behavior**). Do not contact contributors directly about support or help with technical issues. [Credits](#toc-entry-6) ======================= [Authors](#toc-entry-7) ----------------------- * Cetmix [Maintainers](#toc-entry-8) --------------------------- This module is part of the [cetmix/cetmix-tower](https://github.com/cetmix/cetmix-tower/tree/16.0/cetmix_tower_server_notify_backend) project on GitHub. You are welcome to contribute. ``` -------------------------------- ### Cetmix Tower Addons Summary Source: https://github.com/cetmix/cetmix-tower/blob/16.0/README.md This section provides a summary of available Cetmix Tower addons, including their versions, maintainers, and a brief description of their functionality. ```APIDOC Available addons: addon | version | maintainers | summary --- | --- | --- | --- [cetmix_tower](cetmix_tower/) | 16.0.1.1.0 | | Odoo SAAS Server Application Management [cetmix_tower_aws](cetmix_tower_aws/) | 16.0.1.1.0 | | Cetmix Tower AWS EC2 API integration [cetmix_tower_git](cetmix_tower_git/) | 16.0.1.0.5 | | Cetmix Tower Git Management Tools [cetmix_tower_ovh](cetmix_tower_ovh/) | 16.0.1.0.0 | GSLabIt | Cetmix Tower OVH API integration [cetmix_tower_server](cetmix_tower_server/) | 16.0.1.6.3 | | Manage servers and applications from Odoo [cetmix_tower_server_notify_backend](cetmix_tower_server_notify_backend/) | 16.0.1.0.0 | | Backend notifications for Cetmix Tower [cetmix_tower_server_queue](cetmix_tower_server_queue/) | 16.0.1.1.1 | | Cetmix Tower asynchronous task execution using 'queue_job' [cetmix_tower_yaml](cetmix_tower_yaml/) | 16.0.1.3.0 | | Cetmix Tower YAML export/import ``` -------------------------------- ### Cetmix Tower Sudo Parameter Handling Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_server_queue/readme/HISTORY.md This entry addresses an issue where the 'sudo' parameter was not correctly passed to commands. It clarifies the expected behavior and implementation for passing sudo privileges to executed commands. ```APIDOC cetmix_tower_command_executor: execute(command: str, sudo: bool = False, **kwargs) Executes a given command, with an option to use sudo privileges. Ensures the 'sudo' parameter is correctly passed to the underlying execution mechanism. command: The command string to execute. sudo: Boolean indicating whether to execute the command with sudo privileges. kwargs: Additional arguments for command execution. Returns: Result of the command execution. ``` -------------------------------- ### Boto3 Client and Resource Initialization Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_aws/readme/USAGE.md Provides standard patterns for initializing Boto3 clients and resources in Python. This allows interaction with various AWS services like EC2, S3, RDS, and CloudWatch. It requires specifying the service name, region, and AWS credentials. ```python # Standard client initialization pattern client = boto3.client( 'service_name', # Replace with: ec2, s3, rds, cloudwatch, etc. region_name={{ aws_region_name }}, aws_access_key_id=#!cxtower.secret.aws_access_key!#, aws_secret_access_key=#!cxtower.secret.aws_secret_access_key!# ) # Or use resource interface for object-oriented access resource = boto3.resource( 'service_name', # Replace with: ec2, s3, etc. region_name={{ aws_region_name }}, aws_access_key_id=#!cxtower.secret.aws_access_key!#, aws_secret_access_key=#!cxtower.secret.aws_secret_access_key!# ) ``` -------------------------------- ### AWS Boto3 Documentation Reference Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_aws/static/description/index.html Provides a reference to the official AWS Boto3 documentation for detailed information on available services, methods, and usage patterns. ```APIDOC AWS Boto3 Documentation: URL: https://boto3.amazonaws.com/v1/documentation/api/latest/index.html Description: Comprehensive documentation for the AWS SDK for Python (Boto3), covering all AWS services, client and resource interfaces, and examples. ``` -------------------------------- ### OVHcloud API Client Initialization Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_ovh/README.rst This snippet shows the initialization of the OVHcloud API client using provided credentials and endpoint. It highlights the use of secret variables managed by the Cetmix Tower environment. ```python import ovh client = ovh.Client( endpoint={{ ovh_endpoint }}, application_key=#!cxtower.secret.ovh_application_key!#, application_secret=#!cxtower.secret.ovh_application_secret!#, consumer_key=#!cxtower.secret.ovh_consumer_key!# ) ``` -------------------------------- ### Cetmix Tower API Documentation Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower/static/description/index.html Provides API endpoints for interacting with Cetmix Tower functionalities, including server management, command execution, and file operations. ```APIDOC Base URL: /api/v1 Server Management: GET /servers Description: Retrieve a list of all managed servers. Response: 200 OK: Array of server objects. POST /servers Description: Create a new server. Request Body: server_template: string (name of the template) variables: object (key-value pairs for configuration) Response: 201 Created: Server object. Command Execution: POST /commands/ssh Description: Execute an SSH command on a remote server. Request Body: server_alias: string command: string Response: 200 OK: Command output and exit code. POST /commands/python Description: Execute a Python command on the Tower Odoo server. Request Body: command: string Response: 200 OK: Command output. File Management: POST /files/upload Description: Upload a file to a remote server. Request Body: server_alias: string remote_path: string file_content: string (base64 encoded) file_format: string (text or binary) Response: 201 Created: Success message. GET /files/download Description: Download a file from a remote server. Parameters: server_alias: string remote_path: string Response: 200 OK: File content (base64 encoded). ``` -------------------------------- ### Cetmix Tower Flight Plans Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower/static/description/index.html Enables sequential execution of multiple commands with conditional logic based on Python syntax or previous command exit codes. Facilitates complex workflow automation. ```Python class FlightPlan: def __init__(self, name): self.name = name self.steps = [] def add_command(self, command, condition=None): self.steps.append({'type': 'command', 'command': command, 'condition': condition}) def add_conditional_step(self, command, condition_expression): self.steps.append({'type': 'conditional', 'command': command, 'condition': condition_expression}) def execute(self): # Logic to execute steps sequentially with conditions pass ``` -------------------------------- ### Add async file upload/download via job queue Source: https://github.com/cetmix/cetmix-tower/blob/16.0/cetmix_tower_server_queue/static/description/index.html Introduces asynchronous file upload and download capabilities by leveraging the job queue system. This enhancement aims to improve performance and responsiveness for file-related operations. ```python def _add_async_file_operations(): # Implementation details for async file upload/download pass ```