Skip to main content

CompShare CLI

在终端管理优云智算 GPU 实例、镜像、云盘、US3 挂载和团队资源。

  • 交互式创建实例,实时查询规格、库存和价格
  • 支持批量生命周期操作、等待状态和跨地域查询
  • 支持社区/自定义镜像、云盘、团队额度与账单
  • 默认中文帮助,可切换英文;所有命令支持 JSON 输出
  • 基于官方 ucloud-sdk-python3

当前版本:0.2.1,要求 Python 3.9 或更高版本。

安装

python -m pip install "git+https://github.com/BennielAllan/compshare-cli.git"
compshare -h

本地开发:

git clone https://github.com/BennielAllan/compshare-cli.git
cd compshare-cli
python -m venv .venv
source .venv/bin/activate
python -m pip install -e '.[dev]'

Windows 激活虚拟环境时使用:

.\.venv\Scripts\Activate.ps1

配置

compshare config --name default

凭证保存在 ~/.config/compshare/config.json,支持多个配置:

compshare config list
compshare config use production
compshare --profile production instance list

也可以使用环境变量:

export COMPSHARE_PUBLIC_KEY='...'
export COMPSHARE_PRIVATE_KEY='...'

快速开始

# 查规格、库存和实例
compshare instance search
compshare instance search --gpu 4090 --image IMAGE_ID --available
compshare instance list --all

# 交互式创建
compshare instance create

# 批量操作与等待
compshare instance stop INSTANCE_1 INSTANCE_2
compshare instance start INSTANCE_1 INSTANCE_2
compshare instance wait INSTANCE_1 INSTANCE_2 --state Running

# SSH
compshare instance ssh INSTANCE_ID

自动化创建示例:

compshare instance create \
  --gpu 4090 \
  --count 1 \
  --cpu 16 \
  --memory 64GiB \
  --image IMAGE_ID \
  --disk 100GiB \
  --charge Postpay \
  --max-price 20 \
  --yes

使用 --dry-run 只检查库存、价格和请求,不创建资源。

功能入口

compshare instance   GPU 实例、规格、库存、价格和生命周期
compshare image      平台、自定义、社区及共享镜像
compshare storage    云盘和 US3 挂载
compshare team       团队、邀请、成员额度、账单和审计
compshare doctor     配置、鉴权、网络与 SSH 环境诊断

查看完整命令和参数:

compshare -h
compshare instance -h
compshare instance create -h

脚本调用

--json 和 --profile 是全局选项,必须放在子命令前:

compshare --json instance list --status Running --all
compshare --profile production image list --source community

JSON 模式不会启动交互向导。生命周期操作可使用 --wait、--no-wait 和 --timeout 控制等待行为;部分批量操作失败时,CLI 返回非零退出码。

Region 和 Zone 是资源参数,放在对应子命令后:

compshare instance list --region cn-sh2
compshare instance create --zone cn-sh2-02

语言

compshare lang en
compshare lang zh
compshare lang       # 查看当前语言

也可以通过 COMPSHARE_LANG=en 临时覆盖。

安全说明

  • 配置目录和文件分别使用 0700、0600 权限。
  • API 私钥不会出现在命令输出中。
  • instance create 和 instance ssh 会显示 API 返回的实例登录密码,请妥善保管终端输出。
  • 删除、关机、重启、重装和改配等操作默认要求确认。

开发校验

ruff check .
ruff format --check .
pytest

公开 API 覆盖范围和版本变化见 CHANGELOG.md。

Metadata

Release files for compshare-cli 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for compshare-cli 0.2.1
File Size Uploaded Provenance Actions
compshare_cli-0.2.1.tar.gz 63.5 kB With provenance Details for compshare_cli-0.2.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for compshare-cli 0.2.1
File Interpreter ABI Platform Actions
compshare_cli-0.2.1-py3-none-any.whl Python 3 none any Details for compshare_cli-0.2.1-py3-none-any.whl

Total release size: 123.3 kB

Release files / compshare_cli-0.2.1.tar.gz

Download URL compshare_cli-0.2.1.tar.gz
Size 63.5 kB
Tags Source
SHA-256 checksum
How to use checksums
c2641ed898d6678c2e217ca7bcabc3e4ef09ff6884b9bdd6a1146aa212a7988b
BLAKE2b-256 checksum
How to use checksums
4cc4623d02f8910069d675396246f05bd8d1c5ee7129e79b56f205517ae298cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 16, 2026.

Transparency log

Release files / compshare_cli-0.2.1-py3-none-any.whl

Download URL compshare_cli-0.2.1-py3-none-any.whl
Size 59.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
420ec61fb9a7c14276a3c410444239e55abc8bfd822be66f79a94e313a45b0e9
BLAKE2b-256 checksum
How to use checksums
c97e30fd39911bb047308a1bdc2668e425e7506bb394ee440fd988de2a736bfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.13

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 16, 2026.

Transparency log

Security for compshare-cli 0.2.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for compshare_cli-0.2.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 16, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page