Jump to: navigation, search

Difference between revisions of "Solum/CLI"

(Mailing List Threads)
(Using)
 
(18 intermediate revisions by 6 users not shown)
Line 1: Line 1:
Solum Command Line Interface
+
= Solum Command Line Interface =
  
== Blueprints ==
+
== Installing ==
* https://blueprints.launchpad.net/solum/+spec/solum-cli
+
To install the solum CLI on any host that has Python and pip:
* https://blueprints.launchpad.net/solum/+spec/solum-minimal-cli
+
pip install python-solumclient
 +
solum -h
  
== Mailing List Threads ==
+
== Identity Credentials ==
* http://lists.openstack.org/pipermail/openstack-dev/2013-November/018505.html
+
Solum works like existing OpenStack CLI commands. If you are not familiar with the prerequisites for using these tools, you can use DevStack, and just source the <code>devstack/openrc</code> script like this:
  
== Minimal CLI Options ==
+
source devstack/openrc
=== Argparse (WIP pull request - https://review.openstack.org/66065) ===
 
==== Pros ====
 
* Fast-track to completing an M1 CLI
 
* Relatively simple Python standard argparse library-based code
 
* No external (potentially changing) code dependencies
 
* Modeled after Trove architecture recommendations
 
  
==== Cons ====
+
== Using ==
* May be the largest porting effort to the eventual OpenStack client of any options
+
To build and run an application with Solum, you can register your app using a YAML file called a <code>app file</code>. Example:
* No authentication handling built in (likely need to make a dependency on the python keystone client - https://github.com/openstack/python-keystoneclient)
 
  
=== Cliff (no pull request) ===
+
  version: 1
https://cliff.readthedocs.org/en/latest/
+
  name: cherrypy
Cliff Demo App: https://github.com/dreamhost/cliff/tree/master/demoapp
+
  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
  
[Not very familiar with this library, can someone else provide benefits?]
+
For demonstration purposes, I have saved this in a file named ex1.yaml. First register the application:
  
=== OSC (WIP pull request/hack - https://review.openstack.org/#/c/64703/) ===
+
$ solum app create --app-file ex1.yaml
Note: dtroyer is PTL
 
  
==== Pros ====
+
+-------------+---------------------------------------------------------------------+
* Considered by many to be the best path for integration into the future OpenStack CLI architecture
+
| Property    | Value                                                              |
* Integrates authentication already
+
+-------------+---------------------------------------------------------------------+
* dtroyer agreed to implement two Solum plugin features to provide an example
+
| 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                                                                |
 +
+-------------+---------------------------------------------------------------------+
  
==== Cons ====
+
You can see all of your registered apps using the <code>solum app list</code> command:
* Not complete - some APIs may change, especially around authentication
+
$ solum app list
* The plugin documentation is not complete - https://github.com/dtroyer/python-oscplugin
+
 
* No other project has implemented the OSC plugin yet (core OpenStack projects add their features directly into the OSC without plugins)
+
+--------------------------------------+------+-----------------+
* There are discussions about potential OSC architectural changes within OpenStack; want to verify that we will not be chasing large code changes
+
| uuid                                | name | description    |
 +
+--------------------------------------+------+-----------------+
 +
| 6b240789-cfe3-494a-ad60-be2abb56066e | cherrypy  | python web app |
 +
+--------------------------------------+------+-----------------+
 +
 
 +
Now, you can deploy the app as follows:
 +
 
 +
$ 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              |
 +
+-----------------+----------------------------------------------------+
 +
Now you can observe the build process traverse through the various states of BUILDING, DEPLOYING, and finally READY. To display the details, you can use <code>solum app show <app_name|uuid></code>
 +
 
 +
$ 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              |
 +
+-----------------+----------------------------------------------------+
 +
 
 +
You can also un-register an application using the <code>solum app delete <app_name|uuid></code> command:
 +
 
 +
$ solum app delete ex1
 +
 
 +
There's no penalty to have an application registered. There are no running services associated with it if there are no application instances running, so having one registered is just a quick and easy way to create more application instances using that same registered app information.
 +
 
 +
== Troubleshooting ==
 +
When something goes wrong using the CLI, here are some tips for tracking down the problem. If something goes wrong while creating an app, it will display ERROR state. Here is how to find out what happened:
 +
 
 +
$ 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                                    |
 +
+-----------------+--------------------------------------------------------------------------+
 +
 
 +
We can look at the associated Heat stack:
 +
$ 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 |
 +
 +
Now we can look at the event history for that stack:
 +
$ 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 |
 +
+-----------------+--------------------------------------+---------------------------------------+--------------------+----------------------+
 +
 +
This is showing you that the compute service failed to create a compute instance (server).
 +
 
 +
So, let's look at that particular event:
 +
$ 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 |
 +
 
 +
Now we can look at that individual nova instance to find out why it is in ERROR state.
 +
$ nova show b282f2b9-88e2-4666-85bf-a5fd86c9979a| grep fault
 +
 
 +
| fault | {"message": "No valid host was found. ", "code": 500, "created": "2014-05-09T20:30:40Z"} |
 +
 
 +
This indicates that the scheduler can not find any compute nodes that have room for the new app instance.

Latest revision as of 16:23, 5 April 2016

Solum Command Line Interface

Installing

To install the solum CLI on any host that has Python and pip:

pip install python-solumclient
solum -h

Identity Credentials

Solum works like existing OpenStack CLI commands. If you are not familiar with the prerequisites for using these tools, you can use DevStack, and just source the devstack/openrc script like this:

source devstack/openrc

Using

To build and run an application with Solum, you can register your app using a YAML file called a app file. Example:

 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

For demonstration purposes, I have saved this in a file named ex1.yaml. First register the application:

$ 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                                                                 |
+-------------+---------------------------------------------------------------------+

You can see all of your registered apps using the solum app list command:

$ solum app list
+--------------------------------------+------+-----------------+
| uuid                                 | name | description     |
+--------------------------------------+------+-----------------+
| 6b240789-cfe3-494a-ad60-be2abb56066e | cherrypy  | python web app |
+--------------------------------------+------+-----------------+

Now, you can deploy the app as follows:

$ 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               |
+-----------------+----------------------------------------------------+

Now you can observe the build process traverse through the various states of BUILDING, DEPLOYING, and finally READY. To display the details, you can use 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               |
+-----------------+----------------------------------------------------+

You can also un-register an application using the solum app delete <app_name|uuid> command:

$ solum app delete ex1

There's no penalty to have an application registered. There are no running services associated with it if there are no application instances running, so having one registered is just a quick and easy way to create more application instances using that same registered app information.

Troubleshooting

When something goes wrong using the CLI, here are some tips for tracking down the problem. If something goes wrong while creating an app, it will display ERROR state. Here is how to find out what happened:

$ 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                                     |
+-----------------+--------------------------------------------------------------------------+

We can look at the associated Heat stack:

$ 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 |

Now we can look at the event history for that stack:

$ 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 |
+-----------------+--------------------------------------+---------------------------------------+--------------------+----------------------+

This is showing you that the compute service failed to create a compute instance (server).

So, let's look at that particular event:

$ 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 | 

Now we can look at that individual nova instance to find out why it is in ERROR state.

$ nova show b282f2b9-88e2-4666-85bf-a5fd86c9979a| grep fault
| fault | {"message": "No valid host was found. ", "code": 500, "created": "2014-05-09T20:30:40Z"} |

This indicates that the scheduler can not find any compute nodes that have room for the new app instance.