Merge "Onboarding documentation update for CLI"
[dcaegen2.git] / docs / sections / components / dcae-cli / commands.rst
diff --git a/docs/sections/components/dcae-cli/commands.rst b/docs/sections/components/dcae-cli/commands.rst
new file mode 100644 (file)
index 0000000..d34ba43
--- /dev/null
@@ -0,0 +1,590 @@
+.. This work is licensed under a Creative Commons Attribution 4.0 International License.\r
+.. http://creativecommons.org/licenses/by/4.0\r
+\r
+.. _dcae_cli_commands:\r
+\r
+dcae_cli Commands\r
+=================\r
+\r
+The dcae_cli tool has four command groups. Each has several\r
+sub-commands.\r
+\r
+``catalog``\r
+-----------\r
+\r
+The ``catalog`` command lists and shows resources (components and\r
+data_formats) in the ‘onboarding’ catalog (regardless of the owner). A\r
+resource can have a status of ``staged`` or ``published``. By default,\r
+only ``published`` resources are displayed. To see ``staged`` resources,\r
+add the –expanded argument.\r
+\r
++-----------------------------------------------+-----------------------+\r
+| Catalog Status                                | Meaning               |\r
++===============================================+=======================+\r
+| staged                                        | resource has be added |\r
+|                                               | (and validated), but  |\r
+|                                               | is under development  |\r
++-----------------------------------------------+-----------------------+\r
+| staged data_formats can only be referenced in |\r
+| their owners component specs                  |\r
++-----------------------------------------------+-----------------------+\r
+| staged components can only be deployed by     |\r
+| their owners                                  |\r
++-----------------------------------------------+-----------------------+\r
+| published                                     | resource has been     |\r
+|                                               | tested and can be     |\r
+|                                               | shared                |\r
++-----------------------------------------------+-----------------------+\r
+| published data_formats can be used in         |\r
+| anyone’s component spec                       |\r
++-----------------------------------------------+-----------------------+\r
+| published components and be deployed by       |\r
+| anyone                                        |\r
++-----------------------------------------------+-----------------------+\r
+\r
+::\r
+\r
+    $ dcae_cli catalog --help\r
+    Usage: dcae_cli catalog [OPTIONS] COMMAND [ARGS]...\r
+\r
+    Options:\r
+      --help  Show this message and exit.\r
+\r
+    Commands:\r
+      list      Lists resources in the onboarding catalog\r
+      show      Provides more information about resource\r
+\r
+List onboarding catalog contents\r
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+\r
+::\r
+\r
+    $ dcae_cli catalog list\r
+    Components:\r
+    +--------------------------------+---------+--------+---------------------------------------------------------------------+--------+-----------+------------+\r
+    | Name                           | Version | Type   | Description                                                         | Owner  | Status    | Published  |\r
+    +--------------------------------+---------+--------+---------------------------------------------------------------------+--------+-----------+------------+\r
+    | DcaeSyslogCollector            | 2.0.0   | docker | DCAE Control Plane Syslog Collector                                 | sh1986 | published | 2017-08-04 |\r
+    | cdap.dmaap.spec.example        | 0.2.0   | cdap   | dmaap spec example. Not a functioning application, only for showing | tc677g | published | 2017-07-24 |\r
+    |                                |         |        | how to pub/sub dmaap. Pretend this is like MAP with VES in and ou.. |        |           |            |\r
+    | cdap.event.proc.enrich.app     | 1.0.3   | cdap   | CDAP Event Processing Enrich application                            | an4828 | published | 2017-09-20 |\r
+    | cdap.event.proc.map.app        | 1.0.3   | cdap   | CDAP Event Processing Map application                               | an4828 | published | 2017-09-20 |\r
+\r
+    ...\r
+\r
+    Data formats:\r
+    +--------------------------------------------+---------+-----------------------------------------------------------------------+--------+-----------+------------+\r
+    | Name                                       | Version | Description                                                           | Owner  | Status    | Published  |\r
+    +--------------------------------------------+---------+-----------------------------------------------------------------------+--------+-----------+------------+\r
+    | FOI_PM_VHSS_data_format                    | 1.0.0   | CSV pipe delimited data format for VHSS PM files                      | sr229c | published | 2017-09-05 |\r
+    | Map_input                                  | 1.0.0   | The input format for Mapper, that in 1707 is the UCSNMP Collector     | an4828 | published | 2017-07-18 |\r
+    |                                            |         | output format, but will support more formats later                    |        |           |            |\r
+    | Syslog Collector Parsed Json Message       | 1.0.0   | Post processed/parsed collected syslog message                        | sh1986 | published | 2017-08-04 |\r
+    | Syslog Collector Syslog Message Input      | 1.0.0   | The input message for the DCAE syslog collector is free/unstructured  | sh1986 | published | 2017-08-04 |\r
+    |                                            |         | text                                                                  |        |           |            |\r
+    | myapp Alert Definition                     | 1.0.0   | The format of the output event from myapp                               | an4828 | published | 2017-08-10 |\r
+    | VES_specification                          | 5.28.4  | VES spec for 5.4                                                      | vv770d | published | 2017-09-19 |\r
+\r
+    ...\r
+\r
+Show the contents of an item in the catalog\r
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+\r
+::\r
+\r
+    $ dcae_cli catalog show FOI_PM_VHSS_data_format\r
+\r
+    Data format\r
+    -----------\r
+    {\r
+        "dataformatversion": "1.0.0", \r
+        "delimitedschema": {\r
+            "delimiter": "|", \r
+            "fields": [\r
+                {\r
+                    "description": "System ID", \r
+                    "fieldtype": "string", \r
+                    "name": "SYSTEM"\r
+                }, \r
+                {\r
+                    "description": "Date", \r
+                    "fieldtype": "string", \r
+                    "name": "DATE"\r
+                }, \r
+                {\r
+                    "description": "Time", \r
+                    "fieldtype": "string", \r
+                    "name": "TIME"\r
+                }, \r
+\r
+    ...\r
+\r
+.. _dcae_cli_component_commands:\r
+\r
+--------------\r
+\r
+``component``\r
+-------------\r
+\r
+The ``component`` command is for validating (adding), listing, showing,\r
+verifying generated configuration, running, undeploying, and publishing\r
+components that YOU own.\r
+\r
+::\r
+\r
+    $ dcae_cli component --help\r
+    Usage: dcae_cli component [OPTIONS] COMMAND [ARGS]...\r
+\r
+    Options:\r
+      --help  Show this message and exit.\r
+\r
+    Commands:\r
+      add\r
+      dev       Set up component in development for...\r
+      list      Lists components in the onboarding catalog.\r
+      publish   Pushes COMPONENT to the onboarding catalog\r
+      run       Runs the latest version of COMPONENT.\r
+      show      Provides more information about COMPONENT\r
+      undeploy  Undeploys the latest version of COMPONENT.\r
+\r
+--------------\r
+\r
+.. _dcae_cli_add_a_component:\r
+\r
+Add a Component\r
+~~~~~~~~~~~~~~~\r
+\r
+A component must be added to the onboarding catalog in order to be\r
+tested by the dcae_cli tool. The process of adding a component also\r
+validates it’s component specification. In order to add a component, the\r
+component docker image (or CDAP jar) must exist locally.\r
+\r
+Components in the onboarding catalog can be run by others, once they are\r
+``published.`` ``Published`` components cannot be modified or deleted.\r
+Rather a new version can be created instead.\r
+\r
+Validated component specs are used later to generate Tosca models and\r
+Cloudify Blueprints for the component, which makes them available for\r
+use in the SDC Tool for creating services.\r
+\r
+::\r
+\r
+    $ dcae_cli component add --help\r
+    Usage: dcae_cli component add [OPTIONS] COMPONENT-SPECIFICATION\r
+\r
+    Options:\r
+      --update  Updates a previously added component if it has not been already\r
+                published\r
+      --help    Show this message and exit.\r
+\r
+::\r
+\r
+    $ dcae_cli component add component-spec.json \r
+\r
+--------------\r
+\r
+List Components\r
+~~~~~~~~~~~~~~~\r
+\r
+List components in the onboarding catalog that owned by YOUR userid..\r
+\r
+::\r
+\r
+    $ dcae_cli component list\r
+    Active profile: solutioning\r
+    +-------------------------+---------+--------+---------------------------------------------------------------+--------+----------------------------+-----------+\r
+    | Name                    | Version | Type   | Description                                                   | Status | Modified                   | #Deployed |\r
+    +-------------------------+---------+--------+---------------------------------------------------------------+--------+----------------------------+-----------+\r
+    | cdap.helloworld.endnode | 0.8.0   | cdap   | cdap test component                                           | staged | 2017-05-23 04:14:35.588075 | 0         |\r
+    | sandbox.platform.yourapp| 0.5.0   | docker | Web service used as a stand-alone test DCAE service compone.. | staged | 2017-05-23 04:07:44.065610 | 0         |\r
+    +-------------------------+---------+--------+---------------------------------------------------------------+--------+----------------------------+-----------+\r
+\r
+The fields ``Name``, ``Version``, ``Type``, ``Description`` are\r
+referenced from the component specification’s ``self`` JSON. Use the\r
+“–deployed” argument to see more details on deploymed components\r
+\r
+--------------\r
+\r
+.. _dcae_cli_run_a_component:\r
+\r
+Run a Component\r
+~~~~~~~~~~~~~~~\r
+\r
+The ``run`` operation is to be used for running your application in its\r
+container remotely on the activated environment. Docker containers have\r
+the additional option to run locally on your development machine. If the\r
+component uses Dmaap, you can specify the Dmaap Connection Object as\r
+well. Refer to :doc:`Dmaap Connection Object <../component-specification/dmaap-connection-objects>`.\r
+\r
+When you run a component via the dcae_cli Tool, remember the blueprint\r
+has not been created and is not used for deployment.\r
+\r
+In order to run the component, the data formats and component must have\r
+been added to the onboarding catalog.\r
+\r
+**DOCKER NOTE:** Make sure the Docker image has been uploaded to the\r
+shared registry.\r
+\r
+A docker component can be run in either ``attached`` or ``unattached``\r
+mode. (Default is unattached).\r
+\r
++------------------+---------------------------------------------------+\r
+| Mode             | Description                                       |\r
++==================+===================================================+\r
+| attached         | component is run in the ‘foreground’, container   |\r
+|                  | logs are streamed to stdout. Ctrl-C is used to    |\r
+|                  | terminate the dcae_cli session.                   |\r
++------------------+---------------------------------------------------+\r
+| unattached       | component is run in the ‘background’, container   |\r
+|                  | logs are viewed via ``docker logs`` command,      |\r
+|                  | container runs until undeployed with dcae_cli     |\r
+|                  | ``undeploy`` command.                             |\r
++------------------+---------------------------------------------------+\r
+\r
+Run a component in attached mode:\r
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r
+\r
+::\r
+\r
+    $ dcae_cli -v component run --attached sandbox.platform.yourapp:0.5.0\r
+\r
+    DCAE.Docker | INFO | Running image 'registry.proto.server.com/dcae-rework/yourapp:0.4.0' as 'user1.b7287639-37f5-4f25-8d54-8a2087f4c8da.0-5-0.sandbox-platform-yourapp'\r
+    DCAE.Docker.user1.b7287639-37f5-4f25-8d54-8a2087f4c8da.0-5-0.sandbox-platform-yourapp | INFO | Consul host: yourconsulhost.com\r
+\r
+    DCAE.Docker.user1.b7287639-37f5-4f25-8d54-8a2087f4c8da.0-5-0.sandbox-platform-yourapp | INFO | service name: mh677g.b7287639-37f5-4f25-8d54-8a2087f4c8da.0-5-0.sandbox-platform-yourapp\r
+\r
+    DCAE.Docker.user1.b7287639-37f5-4f25-8d54-8a2087f4c8da.0-5-0.sandbox-platform-yourapp | INFO | Generated config: {'multiplier': 3}\r
+\r
+    DCAE.Docker.user1.b7287639-37f5-4f25-8d54-8a2087f4c8da.0-5-0.sandbox-platform-yourapp | INFO |  * Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)\r
+\r
+    DCAE.Docker.user1.b7287639-37f5-4f25-8d54-8a2087f4c8da.0-5-0.sandbox-platform-yourapp | INFO | 135.205.226.140 - - [24/May/2017 03:37:57] "GET /health HTTP/1.1" 200 -\r
+\r
+    DCAE.Docker.user1.b7287639-37f5-4f25-8d54-8a2087f4c8da.0-5-0.sandbox-platform-yourapp | INFO | 135.205.226.140 - - [24/May/2017 03:38:12] "GET /health HTTP/1.1" 200 -\r
+\r
+Hit Ctrl-C to terminate session.\r
+\r
+::\r
+\r
+    ^CDCAE.Docker | INFO | Stopping container 'user1.b7287639-37f5-4f25-8d54-8a2087f4c8da.0-5-0.sandbox-platform-yourapp' and cleaning up...\r
+\r
+Run a component in unattached mode:\r
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r
+\r
+::\r
+\r
+    $ dcae_cli -v component run sandbox.platform.yourapp:0.5.0\r
+    DCAE.Docker | INFO | Running image 'registry.proto.server.com/dcae-rework/yourapp:0.4.0' as 'user1.4811da0e-08d5-429f-93bf-bf6814924577.0-5-0.sandbox-platform-yourapp'\r
+    DCAE.Run | INFO | Deployed /user1.4811da0e-08d5-429f-93bf-bf6814924577.0-5-0.sandbox-platform-yourapp\r
+\r
+**NOTE** You must undeploy this component when finished testing. This is\r
+important to conserve resources in the environment.\r
+\r
+Run a component that subscribes to Dmaap MR or DR\r
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r
+\r
+::\r
+\r
+    $ dcae_cli -v component run --attached --dmaap-file $dmaap-connection-file sandbox.platform.yourapp:0.5.0 \r
+\r
+--------------\r
+\r
+Undeploy a Component\r
+~~~~~~~~~~~~~~~~~~~~\r
+\r
+The ``undeploy`` command is used to undeploy any instance of a specified\r
+component/version that you have deployed. This includes cleaning up the\r
+configuration.\r
+\r
+::\r
+\r
+    $ dcae_cli component undeploy sandbox.platform.yourapp:0.5.0\r
+    DCAE.Undeploy | WARNING | Undeploying components: 1\r
+    DCAE.Undeploy | WARNING | Undeployed components: 1\r
+\r
+--------------\r
+\r
+Publish a component\r
+~~~~~~~~~~~~~~~~~~~\r
+\r
+| Once a component has been tested, it should be published in the\r
+  onboarding catalog using the ``publish`` sub-command .\r
+| Publishing will change the status of the component (from ``staged`` to\r
+  ``published``), indicating that it has been tested, and making it\r
+  accessible for other developers to use.\r
+\r
+**Note** Before a component can be published, all data_formats that it\r
+references must be published.\r
+\r
+::\r
+\r
+    dcae_cli component publish sandbox.platform.yourapp:0.5.0\r
+\r
+--------------\r
+\r
+Show a Component\r
+~~~~~~~~~~~~~~~~\r
+\r
+This will print out the contents of a component and is useful to copy a\r
+component spec.\r
+\r
+::\r
+\r
+    $ dcae_cli component show\r
+\r
+--------------\r
+\r
+.. _dcae-cli-run-the-dev-command:\r
+\r
+Run the ``dev`` command\r
+~~~~~~~~~~~~~~~~~~~~~~~\r
+\r
+The ``dev`` command is used as part of a process to see the platform\r
+generated configuration. It established the environment variables and is\r
+best explained\r
+:any:`here <dcae-cli-view-the-platform>`.\r
+\r
+::\r
+\r
+    $ dcae_cli component dev component-spec.json\r
+    Ready for component development\r
+\r
+--------------\r
+\r
+.. _dcae_cli_data_format:\r
+\r
+``data_format``\r
+---------------\r
+\r
+The ``data_format`` command is for validating (adding), listing,\r
+showing, publishing data_formats that YOU own. data_formats can also be\r
+generated with this command.\r
+\r
+::\r
+\r
+    $ dcae_cli data_format --help\r
+    Usage: dcae_cli data_format [OPTIONS] COMMAND [ARGS]...\r
+\r
+    Options:\r
+      --help  Show this message and exit.\r
+\r
+    Commands:\r
+      add       Tracks a data format file DATA_FORMAT-SPECIFICATION...\r
+      generate  Create schema from a file or directory...\r
+      list      Lists all your data formats\r
+      publish   Publishes data format to make available to others...\r
+      show      Provides more information about FORMAT\r
+\r
+--------------\r
+\r
+.. _dcae_cli_add_a_data_format:\r
+\r
+Add a Data Format\r
+~~~~~~~~~~~~~~~~~\r
+\r
+A data_format must be in the onboarding catalog in order to be\r
+referenced in the component specification. The process of adding a\r
+data_format also validates it. Data_formats in the onboarding catalog\r
+can be run by others, once they are ``published.`` ``Published``\r
+data_formats cannot be modified or deleted. Rather a new version can be\r
+created instead.\r
+\r
+::\r
+\r
+    $ dcae_cli data_format add --help\r
+    Usage: dcae_cli data_format add [OPTIONS] DATA_FORMAT-SPECIFICATION\r
+\r
+    Options:\r
+      --update  Updates a previously added data_format if it has not been already\r
+                published\r
+      --help    Show this message and exit.\r
+\r
+::\r
+\r
+    dcae_cli data_format add health.json\r
+\r
+--------------\r
+\r
+List Data Formats\r
+~~~~~~~~~~~~~~~~~\r
+\r
+Only data_formats owned by YOUR userid will be shown.\r
+\r
+::\r
+\r
+    $ dcae_cli data_format list\r
+\r
+    Data formats for user1\r
+    +---------------------------------+---------+-------------------------------------------+--------+----------------------------+\r
+    | Name                            | Version | Description                               | Status | Modified                   |\r
+    +---------------------------------+---------+-------------------------------------------+--------+----------------------------+\r
+    | sandbox.platform.yourapp.health | 0.1.0   | Data format used for the /health endpoint | staged | 2017-05-23 04:02:38.952799 |\r
+    +---------------------------------+---------+-------------------------------------------+--------+----------------------------+\r
+\r
+The fields ``name``, ``version``, ``description`` are referenced from\r
+the data format specification’s ``self`` JSON. ``Status`` represents the\r
+status of the data format in the catalog. See `Publish a Data\r
+Format <#publish-a-data-format>`__ for more info.\r
+\r
+--------------\r
+\r
+Show a Data Format\r
+~~~~~~~~~~~~~~~~~~\r
+\r
+This will print out the contents of a data_format and is useful for\r
+copying a data_format.\r
+\r
+::\r
+\r
+    $ dcae_cli data_format show\r
+\r
+--------------\r
+\r
+Publish a Data Format\r
+~~~~~~~~~~~~~~~~~~~~~\r
+\r
+| Once a data_format has been tested (by referencing it in a component\r
+  spec that has been tested), it should be published in the onboarding\r
+  catalog using the ``publish`` sub-command .\r
+| Publishing will change the status of the data_format (from ``staged``\r
+  to ``published``), indicating that it has been tested, and making it\r
+  accessible for other developers to use.\r
+\r
+::\r
+\r
+    $ dcae_cli data_format publish data_format.json\r
+\r
+--------------\r
+\r
+Generate a Data Format\r
+~~~~~~~~~~~~~~~~~~~~~~\r
+\r
+If you already have a valid input or output file, you can use the\r
+generate command to create the it’s data format specification.\r
+\r
+::\r
+\r
+    $ dcae_cli data_format generate name:version file-or-dir-path\r
+\r
+--------------\r
+\r
+``profiles``\r
+------------\r
+\r
+The\ ``profiles`` command is for creating, deleting, listing, showing,\r
+activating, and updating (set) profiles. The profile contains\r
+environment variables used to connect to different environments. This is\r
+used in the running and deployment of a component using the\r
+``dcae_cli component run`` or ``dev`` command.\r
+\r
+::\r
+\r
+    $ dcae_cli profiles --help\r
+    Usage: dcae_cli profiles [OPTIONS] COMMAND [ARGS]...\r
+\r
+    Options:\r
+      --help  Show this message and exit.\r
+\r
+    Commands:\r
+      activate  Sets profile NAME as the active profile\r
+      create    Creates a new profile NAME initialized with...\r
+      delete    Deletes profile NAME\r
+      list      Lists available profiles\r
+      set       Updates profile NAME such that KEY=VALUE\r
+      show      Prints the profile dictionary\r
+\r
+--------------\r
+\r
+List the available profiles\r
+~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+\r
+::\r
+\r
+    $ dcae_cli profiles list\r
+    *  solutioning\r
+       1710\r
+       1802\r
+\r
+The \* identifies the active profile. ``dcae-cli`` is currently\r
+installed with profiles for the ``solutioning``, ``1710``, and ``1802``\r
+environments. They are intended for the following:\r
+\r
++-----------------------------------+-----------------------------------+\r
+| Environment                       | Description                       |\r
++===================================+===================================+\r
+| solutioning                       | default environment; used for     |\r
+|                                   | initial component developer       |\r
+|                                   | testing with the dcae_cli tool.   |\r
++-----------------------------------+-----------------------------------+\r
+| 1710                              | FTL3 (Functional Testing Lab 3)   |\r
+|                                   | environment, which represents the |\r
+|                                   | 1710 release.                     |\r
++-----------------------------------+-----------------------------------+\r
+| 1802                              | FTL3a (Functional Testing Lab 3a) |\r
+|                                   | environment, which represents the |\r
+|                                   | 1802 release.                     |\r
++-----------------------------------+-----------------------------------+\r
+\r
+--------------\r
+\r
+Show the details of a profile\r
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+\r
+::\r
+\r
+    $ dcae_cli profiles show solutioning\r
+    {\r
+        "cdap_broker": "cdap_broker",\r
+        "config_binding_service": "config_binding_service",\r
+        "consul_host": "yourconsulhost.com",\r
+        "docker_host": "yourdockerhost.com:2376"\r
+    }\r
+\r
+--------------\r
+\r
+.. _dcae_cli_activate_profile:\r
+\r
+Activate a profile\r
+~~~~~~~~~~~~~~~~~~\r
+\r
+To switch among profiles, use the activate sub-command. A subsequent\r
+``list`` will reveal the change made.\r
+\r
+::\r
+\r
+    $ dcae_cli profiles activate test\r
+\r
+--------------\r
+\r
+Create a new profile\r
+~~~~~~~~~~~~~~~~~~~~\r
+\r
+If you want to work in a different environment using the dcae_cli tool,\r
+you can make your own profile. (The environment must be a working DCAE\r
+Platform environment).\r
+\r
+::\r
+\r
+    $ dcae_cli profiles create new-profile\r
+\r
+After creating you would assign the variables with the ``set``\r
+sub-command. Then activate it to use.\r
+\r
+--------------\r
+\r
+Set variables in a profile\r
+~~~~~~~~~~~~~~~~~~~~~~~~~~\r
+\r
+::\r
+\r
+    $ dcae_cli profiles set $profile $key $value \r
+\r
+--------------\r
+\r
+Delete a profile\r
+~~~~~~~~~~~~~~~~\r
+\r
+::\r
+\r
+    $ dcae_cli profiles delete new-profile\r
+\r
+\r