Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
184 changes: 155 additions & 29 deletions docs/creating-manifest/addons.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,86 @@
# Add-Ons

Cloud Scripting allows you to install a custom add-on either to a new environment, or to the existing one. You can develop your custom add-on in confines of another - *parent* manifest. Therefore, you need to state the add-on's installation type to *update* and declare essential properties within the *addons* section.
Cloud Scripting allows you to install a custom add-on either to existing environment, or a new one. Thus you can develop your custom add-on as a separate manifest or in confines of another - *parent* manifest. Respectively, you need to state the add-on's installation type to *update* or declare its essential properties within the *addons* section of *parent* manifest.

You can install the developed add-on either by specifying a target <a href="../selecting-containers/#all-containers-by-group" target="blank">*nodeGroup*</a>, or by calling the <a href="../actions/#installaddon" target="blank">*installAddon*</a> action.
You can install the developed add-on either by specifying a *[target](../visual-settings/#target-nodes)* and/or by calling the [*installAddon*](../actions/#installaddon) action.

The following examples illustrate the add-on's installation to a specific *nodeGroup* (layer) ***cp***.

Separate manifest with type *update* can be implemented in different ways:

Example #1.

@@@
```yaml
type: update
name: Custom Addon
id: custom-addon-id
targetNodes:
nodeGroup: cp

onInstall:
api [cp]: environment.control.RestartNodes
```
```json
{
"type": "update",
"name": "Custom Addon",
"id": "custom-addon-id",
"targetNodes": {
"nodeGroup": "cp"
},
"onInstall": {
"api [cp]": "environment.control.RestartNodes"
}
}
```
@@!

Example #2. The *installAddon* action call:

@@@
```yaml
type: update
name: Addon installation
targetNodes:
nodeGroup: cp

onInstall:
installAddon:
id: custom-addon-id

addons:
- id: custom-addon-id
name: Custom Addon
onInstall:
api [cp]: environment.control.RestartNodes
```
```json
{
"type": "update",
"name": "Addon installation",
"targetNodes": {
"nodeGroup": "cp"
},
"onInstall": {
"installAddon": {
"id": "custom-addon-id"
}
},
"addons": [
{
"id": "custom-addon-id",
"name": "Custom Addon",
"onInstall": {
"api [cp]": "environment.control.RestartNodes"
}
}
]
}
```

Custom add-on installation on newly created environment via built-in implementation in parent manifest:

The following example illustrates the add-on's installation to a specific *nodeGroup* (layer).
@@@
```yaml
type: install
Expand Down Expand Up @@ -45,46 +121,96 @@ addons:
```
@@!

In the example above, the <a href="https://docs.jelastic.com/api/" target="_blank">Jelastic API</a> <b>*RestartNodes*</b> method is executed after the environment creation is completed. The compute node is restarted at the end of the manifest installation procedure. Herewith, the add-on is installed, if the *parent* manifest's installation type is *install*. When the add-on is installed, the **Add-ons** tab for the corresponding compute node becomes available at the dashboard.
In the examples above, the Jelastic API *[RestartNodes](https://docs.jelastic.com/api/#!/api/environment.Control-method-RestartNodes)* method is executed after the environment creation is completed. The compute node is restarted at the end of the manifest installation procedure. Herewith, the add-on is installed, if the *parent* manifest's installation type is *install*.

When the add-on is installed, the ***Add*-ons** tab for the corresponding compute node becomes available at the dashboard.

![new-addon](/img/new-addon.png)

The following example illustrates the add-on's installation by calling the *installAddon* action. You can call this action for both *update* and *install* installation types of a *parent* manifest.
### Add-On Uninstallation

By default add-on is created with an ***Uninstall*** menu item within **Add-ons** tab.

![uninstall-button](/img/uninstall-button.png)

If required this menu item can be hidden with an optional boolean parameter ***permanent***.
Where:

- `permanent`: *true* - hides the *Uninstall* button for the specified custom add-on
- `permanent`: *false* - this option is equal default behaviour when the *permanent* parameter is not specified and makes the *Uninstall* button visible

For example:

@@@
```yaml
type: install
name: Addon installation

type: update
name: Custom Addon
id: custom-addon-id
permanent: true
targetNodes:
nodeGroup: cp

onInstall:
installAddon:
id: custom-addon-id

addons:
- id: custom-addon-id
name: Custom Addon
onInstall:
createFile [cp]: /var/log/test.log
api [cp]: environment.control.RestartNodes
```
```json
{
"type": "install",
"name": "Addon installation",
"onInstall": {
"installAddon": {
"id": "custom-addon-id"
}
"type": "update",
"name": "Custom Addon",
"id": "custom-addon-id",
"permanent": true,
"targetNodes": {
"nodeGroup": "cp"
},
"addons": {
"id": "custom-addon-id",
"name": "Custom Addon",
"onInstall": {
"createFile [cp]": "/var/log/test.log"
}
"onInstall": {
"api [cp]": "environment.control.RestartNodes"
}
}
```
@@!
Through this example, a new *test.log* file is created during the *onInstall* action execution. You can declare the add-on's expected behaviour within the *addons* section, while the *installAddon* action is needed to specify the appropriate add-on's identifier.

![no-uninstall-button](/img/no-uninstall-button.png)

In case the addon was created with disabled the *Uninstall* button(*permanent: true*) and this add-on is not required anymore, you can forcibly delete it via an API action: *[marketplace.jps.Uninstall](https://docs.jelastic.com/api/#!/api/marketplace.Jps-method-Uninstall)* with a parameter ***force=true***.

For example:

@@@
```yaml
id: addon-uninstall
type: update
name: Custom Add-On Forcible Uninstall

onInstall: unInstallAddon

actions:
unInstallAddon:
- api: marketplace.jps.Uninstall
appid : "3bf111ec625c0e8b1a9ed2d473a7aec2"
force : true
appUniqueName":"114d6123-8a22-4d36-9bb2-26e1effa6fdf"
```
```json
{
"id": "addon-uninstall",
"type": "update",
"name": "Custom Add-On Forcible Uninstall",
"onInstall": "unInstallAddon",
"actions": {
"unInstallAddon": [
{
"api": "marketplace.jps.Uninstall",
"appid": "3bf111ec625c0e8b1a9ed2d473a7aec2",
"force": true,
"appUniqueName": "114d6123-8a22-4d36-9bb2-26e1effa6fdf"
}
]
}
}
```
@@!


<br>
<h2> What’s next?</h2>

Expand Down
Binary file modified theme/readthedocs/img/new-addon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/readthedocs/img/no-uninstall-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added theme/readthedocs/img/uninstall-button.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.