跳转到主要内容

DCI控制服务器的Python客户端

项目描述

python-dciclient

《python-dciclient》项目为DCI控制服务器提供了Python绑定和CLI

安装

项目背后的团队为Red Hat/CentOS提供了仓库

  • yum -y install https://packages.distributed-ci.io/dci-release.el7.noarch.rpm

然后只需运行yum install python2-dciclient来安装Python 2或yum install python3-dciclient来安装Python 3。

如上所述,该软件包提供两个功能

  • CLI:提供了一个dcictl命令。更多详细信息请使用dcictl --help
  • API:一个可以用来与控制服务器交互的Python模块(dciclient.v1.api.*

凭证

承认您有使用DCI控制服务器平台的有效凭证,在使用dcictl时,有两种方式指定这些信息

  • dcirc文件

一个存储必要凭证的文件。然后需要在使用dcictl之前源这个文件。例如

export DCI_LOGIN=foo
export DCI_PASSWORD=bar
export DCI_CS_URL=https://api.distributed-ci.io

或使用API密钥方法

export DCI_CLIENT_ID=<client_type>/<client_id>
export DCI_API_SECRET=<api_secret>
export DCI_CS_URL=https://api.distributed-ci.io

其中client_type可以是当前的有效值remotecifeeder

这将允许用户运行命令:dcictl team-list

  • 在命令行级别

可以在命令行级别传递这些信息。例如:dcictl --dci-login jdoe --dci-password jdoe --dci-cs-url 'https://api.distributed-ci.io' team-listdcictl --dci-client-id <client_type>/<client_id> --dci-api-secret <api_secret> --dci-cs-url 'https://api.distributed-ci.io' team-list

其中client_type可以是当前的有效值remotecifeeder

对于RemoteCIs或Feeders,请使用API密钥进行认证。

可用命令列表

运行 dcictl --help 命令以查看可用命令列表

Commands:
  component-create             Create a component.
  component-delete             Delete a component.
  component-file-delete        Delete a component file.
  component-file-download      Retrieve a component file.
  component-file-list          List files attached to a component.
  component-file-show          Show a component file.
  component-file-upload        Attach a file to a component.
  component-list               List all components.
  component-show               Show a component.
  component-status             Show an overview of the last jobs associated...
  component-update             Update a component.
  file-delete                  Delete a file.
  file-list                    List all files.
  file-show                    Show a file.
  job-delete                   Delete a job.
  job-list                     List all jobs.
  job-output                   Show the job output.
  job-recheck                  Recheck a job.
  job-results                  List all job results.
  job-show                     Show a job.
  jobdefinition-annotate       Annotate a jobdefinition.
  jobdefinition-attach-test    Attach a test to a jobdefinition.
  jobdefinition-create         Create a jobdefinition.
  jobdefinition-delete         Delete a jobdefinition.
  jobdefinition-list           List all jobdefinitions.
  jobdefinition-list-test      List tests attached to a jobdefinition.
  jobdefinition-set-active     Annotate a jobdefinition.
  jobdefinition-show           Show a jobdefinition.
  jobdefinition-unattach-test  Unattach a test to a jobdefinition.
  jobdefinition-update         Update a jobdefinition.
  jobstate-list                List all jobstates.
  jobstate-show                Show a jobstate.
  purge                        Purge soft-deleted resources.
  remoteci-create              Create a remoteci.
  remoteci-delete              Delete a remoteci.
  remoteci-get-data            Retrieve data field from a remoteci.
  remoteci-list                List all remotecis.
  remoteci-reset-api-secret    Reset a remoteci api secret.
  remoteci-show                Show a remoteci.
  remoteci-update              Update a remoteci.
  team-create                  Create a team.
  team-delete                  Delete a team.
  team-list                    List all teams.
  team-show                    Show a team.
  team-update                  Update a team.
  topic-create                 Create a topic.
  topic-delete                 Delete a topic.
  topic-list                   List all topics.
  topic-show                   Show a topic.
  user-create                  Create a user.
  user-delete                  Delete a user.
  user-list                    List all users.
  user-show                    Show a user.
  user-update                  Update a user.

dci-vault

如果您想在YAML配置文件(设置或清单)中存储密钥,可以使用 dci-vault 命令来执行此操作。然后,各种代理将透明地解密密钥。例如

$ source dcirc.sh
$ echo -n 42 | dci-vault encrypt_string --stdin-name answer
Reading plaintext input from stdin. (ctrl-d to end input)
answer: !vault |
          $ANSIBLE_VAULT;1.1;AES256
          36373332616633313866333234303166616237613332316534393834663934663463353433363464
          6363626133323036383939633566383139373636633533390a316363393437653663363538343730
          65333862633131353030353137636236663036656264393638353464343138623664323731613331
          6466636637393865380a336365633465633037623935633866366562373732356635343361353334
          3732
Encryption successful

dci-vault 是在 ansible-vault 之上的一个薄层,因此所有 ansible-vault 的子命令都可用。

dci-rhel-latest-kernel-version

dci-rhel-latest-kernel-version 是一个实用命令,可以轻松获取RHEL产品可用的最新内核。

$ source dcirc.sh
$ dci-rhel-latest-kernel-version --topic RHEL-not-existing
topic RHEL-not-existing not found

- available topics:
RHEL-9.2
RHEL-9.1
RHEL-8.7
RHEL-8.6
RHEL-8.5
RHEL-9.0
RHEL-8.4
RHEL-8.0
RHEL-8.1
RHEL-7.6
RHEL-7.7
RHEL-8.3
RHEL-8.2
RHEL-7.8
RHEL-7.9
RHEL-7-nightly
RHEL-7-milestone
$ dci-rhel-latest-kernel-version --topic-list
available topics:
RHEL-9.2
RHEL-9.1
RHEL-9.0
RHEL-8.7
RHEL-8.6
RHEL-8.5
RHEL-8.4
RHEL-8.3
RHEL-8.2
RHEL-8.1
RHEL-8.0
RHEL-7.9
$ dci-rhel-latest-kernel-version --topic RHEL-9.2
5.14.0-160.el9

dci-create-component

要创建组件,可以使用 dci-create-component 实用程序。例如,要创建名为 My product 且版本为 1.0ga 组件,在 OCP-4.11 主题上使用它,可以这样操作

$ source dcirc.sh
$ dci-create-component OCP-4.11 "My Product" 1.0 ga

dci-find-latest-component

dci-find-latest-component 允许查找产品的最新组件。例如,要查找最新GA OCP组件在最新主题上,可以这样操作

$ source dcirc.sh
$ dci-find-latest-component --tags build:ga OpenShift ocp

要查找特定主题(例如OCP-4.11)的最新GA OCP组件,可以这样操作

$ source dcirc.sh
$ dci-find-latest-component --topic OCP-4.11 --tags build:ga OpenShift ocp

dci-diff-jobs

dci-diff-jobs 允许比较两个作业的组件

$ source dcirc.sh
$ dci-diff-jobs --job_id_1 9e3f3a4f-74c5-4bce-9c45-450b27006bed --job_id_2 b55fb5d6-3f01-44ce-9034-26a53e086137
+-----------------------+--------------------------------------+--------------------------------------+
|       component       | 9e3f3a4f-74c5-4bce-9c45-450b27006bed | b55fb5d6-3f01-44ce-9034-26a53e086137 |
+-----------------------+--------------------------------------+--------------------------------------+
|          ocp          |                4.9.50                |                4.8.52                |
| redhat-operator-index |                 v4.9                 |                 v4.8                 |
+-----------------------+--------------------------------------+--------------------------------------+

或它们的标签

$ source dcirc.sh
$ dci-diff-jobs --tags --job_id_1 9e3f3a4f-74c5-4bce-9c45-450b27006bed --job_id_2 b55fb5d6-3f01-44ce-9034-26a53e086137
+--------------------------------------+--------------------------------------+
| 9e3f3a4f-74c5-4bce-9c45-450b27006bed | b55fb5d6-3f01-44ce-9034-26a53e086137 |
+--------------------------------------+--------------------------------------+
|       pipeline-id:8nodes.8225        |              Not found               |
|          inventory:cluster6          |              Not found               |
|         pipeline:install-4.9         |              Not found               |
|           cluster:cluster6           |              Not found               |
|              Not found               |       pipeline-id:8nodes.8239        |
|              Not found               |          inventory:cluster4          |
|              Not found               |         pipeline:install-4.8         |
|              Not found               |           cluster:cluster4           |
+--------------------------------------+--------------------------------------+

如果未指定 --job_id_1,则搜索状态成功的最后作业。

如果未指定 --job_id_2,则搜索与作业1具有相同名称、remoteci、主题、配置和url的作业。

dci-create-job

要创建不运行DCI代理的作业,可以使用 dci-create-job 实用程序。如果您想关联一个不是DCI作业的CI作业,这将很有用。

$ source dcirc.sh
$ dci-create-job --topic OCP-4.14 --remoteci my-remoteci --name jenkins-job --comment "my comment"  --comp 'OpenShift 4.14.10' --tag my-tag --key-value key=42 --data '{"jenkins_url": "https://jenkins.corp.com/job/name/42"}'

许可协议

Apache 2.0

作者信息

分布式-CI 团队 distributed-ci@redhat.com

项目详情


下载文件

下载适合您平台的文件。如果您不确定该选择哪个,请了解更多关于安装包的信息。

源分布

dciclient-4.0.1.post202410021140.tar.gz (35.1 kB 查看哈希值)

上传时间:

构建分布

dciclient-4.0.1.post202410021140-py3-none-any.whl (60.8 kB 查看哈希值)

上传时间: Python 3

由以下支持