Solum/CLI
< Solum
Solum 命令行界面
安装
要在任何安装了 Python 和 pip 的主机上安装 solum CLI
pip install python-solumclient solum -h
身份验证凭据
Solum 的工作方式与现有的 OpenStack CLI 命令类似。 如果您不熟悉使用这些工具的先决条件,可以使用 DevStack,并像这样 source devstack/openrc 脚本
source devstack/openrc
使用
要使用 Solum 构建和运行应用程序,可以使用名为 app file 的 YAML 文件注册您的应用程序。 例如
version: 1 name: cherrypy description: python web app languagepack: python source: repository: https://github.com/rackspace-solum-samples/solum-python-sample-app.git revision: master workflow_config: test_cmd: ./unit_tests.sh run_cmd: python app.py trigger_actions: - unittest - build - deploy ports: - 80
为了演示目的,我已将其保存到名为 ex1.yaml 的文件中。 首先注册应用程序
$ solum app create --app-file ex1.yaml
+-------------+---------------------------------------------------------------------+ | Property | Value | +-------------+---------------------------------------------------------------------+ | description | python web app | | uri | http://10.0.2.15:9777/v1/apps/6b240789-cfe3-494a-ad60-be2abb56066e | | uuid | 6b240789-cfe3-494a-ad60-be2abb56066e | | name | cherrypy | +-------------+---------------------------------------------------------------------+
您可以使用 solum app list 命令查看所有已注册的应用程序
$ solum app list
+--------------------------------------+------+-----------------+ | uuid | name | description | +--------------------------------------+------+-----------------+ | 6b240789-cfe3-494a-ad60-be2abb56066e | cherrypy | python web app | +--------------------------------------+------+-----------------+
现在,您可以按如下方式部署应用程序
$ solum app deploy cherrypy +-----------------+----------------------------------------------------+ | Property | Value | +-----------------+----------------------------------------------------+ | status | None | | description | None | | application_uri | None | | name | cherrypy | | trigger_uri | http://10.0.2.15:9777/v1/public/triggers/7a34065c- | | | da6a-4443-a8d4-8e7abd292a21 | | uuid | 1221ea22-7913-4813-8982-48246db36e0f | +-----------------+----------------------------------------------------+
现在您可以观察构建过程遍历 BUILDING、DEPLOYING 和最终 READY 的各种状态。 要显示详细信息,可以使用 solum app show <app_name|uuid>
$ solum app show cherrypy
+-----------------+----------------------------------------------------+ | Property | Value | +-----------------+----------------------------------------------------+ | status | BUILDING | | description | None | | application_uri | None | | name | cherrypy | | trigger_uri | http://10.0.2.15:9777/v1/public/triggers/7a34065c- | | | da6a-4443-a8d4-8e7abd292a21 | | uuid | 1221ea22-7913-4813-8982-48246db36e0f | +-----------------+----------------------------------------------------+
$ solum app show cherrypy
+-----------------+----------------------------------------------------+ | Property | Value | +-----------------+----------------------------------------------------+ | status | DEPLOYING | | description | None | | application_uri | None | | name | cherrypy | | trigger_uri | http://10.0.2.15:9777/v1/public/triggers/7a34065c- | | | da6a-4443-a8d4-8e7abd292a21 | | uuid | 1221ea22-7913-4813-8982-48246db36e0f | +-----------------+----------------------------------------------------+
$ solum app show cherrypy
+-----------------+----------------------------------------------------+ | Property | Value | +-----------------+----------------------------------------------------+ | status | READY | | description | None | | application_uri | http://192.168.78.2:5000 | | name | cherrypy | | trigger_uri | http://10.0.2.15:9777/v1/public/triggers/7a34065c- | | | da6a-4443-a8d4-8e7abd292a21 | | uuid | 1221ea22-7913-4813-8982-48246db36e0f | +-----------------+----------------------------------------------------+
您还可以使用 solum app delete <app_name|uuid> 命令取消注册应用程序
$ solum app delete ex1
注册应用程序没有惩罚。 如果没有正在运行的应用程序实例,则没有与之关联的运行服务,因此注册一个应用程序只是使用相同已注册的应用程序信息创建更多应用程序实例的一种快速简便的方法。
故障排除
在使用 CLI 时出现问题,以下是一些跟踪问题的技巧。 如果在创建应用程序时出现问题,它将显示 ERROR 状态。 以下是了解发生了什么的方式
$ solum app show ex1
+-----------------+--------------------------------------------------------------------------+ | Property | Value | +-----------------+--------------------------------------------------------------------------+ | status | ERROR | | description | None | | application_uri | None | | name | ex1 | | trigger_uri | http://10.0.2.15:9777/v1/public/triggers/4009c664-710b-4521-a468-cc24f04 | | | 04e6b | | uuid | 050ff625-d32a-483b-8df4-715ed623b8af | +-----------------+--------------------------------------------------------------------------+
我们可以查看相关的 Heat 堆栈
$ heat stack-list
+--------------------------------------+------------+---------------+----------------------+ | id | stack_name | stack_status | creation_time | +--------------------------------------+------------+---------------+----------------------+ | ba6f1ecf-77f8-434f-b4ff-4555d1b71d2e | ex1 | CREATE_FAILED | 2014-05-09T20:30:26Z | +--------------------------------------+------------+---------------+----------------------+
$ heat stack-show ex1 | grep stack_status
| stack_status | CREATE_FAILED | | stack_status_reason | Resource CREATE failed: Error: Creation of server ex1 failed |
现在我们可以查看该堆栈的事件历史记录
$ heat event-list ba6f1ecf-77f8-434f-b4ff-4555d1b71d2e
+-----------------+--------------------------------------+---------------------------------------+--------------------+----------------------+ | resource_name | id | resource_status_reason | resource_status | event_time | +-----------------+--------------------------------------+---------------------------------------+--------------------+----------------------+ | compute | 09876afc-7547-4268-bd19-2b908f768ad9 | Error: Creation of server ex1 failed. | CREATE_FAILED | 2014-05-09T20:30:41Z | | compute | ae7dc18f-5a63-48d4-af98-469e45aae52d | state changed | CREATE_IN_PROGRESS | 2014-05-09T20:30:27Z | | external_access | 7a22de89-509d-457e-bfd9-e518cba6b9f2 | state changed | CREATE_IN_PROGRESS | 2014-05-09T20:30:26Z | | external_access | f421fd64-6b71-495a-8fbc-9e29148f500b | state changed | CREATE_COMPLETE | 2014-05-09T20:30:27Z | +-----------------+--------------------------------------+---------------------------------------+--------------------+----------------------+
这表明计算服务未能创建计算实例(服务器)。
所以,让我们查看该特定事件
$ heat event-show ba6f1ecf-77f8-434f-b4ff-4555d1b71d2e compute 09876afc-7547-4268-bd19-2b908f768ad9 | grep physical_resource_id
| physical_resource_id | b282f2b9-88e2-4666-85bfa5fd86c9979a |
现在我们可以查看该单个 nova 实例,以找出它处于 ERROR 状态的原因。
$ nova show b282f2b9-88e2-4666-85bf-a5fd86c9979a| grep fault
| fault | {"message": "No valid host was found. ", "code": 500, "created": "2014-05-09T20:30:40Z"} |
这表明调度器找不到任何具有新应用程序实例空间的计算节点。