Server Plugin Development Guide

  • April 15, 2021
  • 0 Comments

A server plugin allows Clientexec to automatically provision and manage services.

We have created a sample server module that should be used as a starting point: https://github.com/clientexec/sample-server

Naming Convention

The name of the plugin directory MUST be all lower case, and alphanumeric, such as sample.

The name of the plugin file, and the plugin class MUST start with Plugin, followed by the name of the directory with ONLY the first letter capitalized, such as PluginSample

Features

Each server plugin can define certain features to be available or not.

  • packageName - If Clientexec should show the "Package Name On Server" option.
  • testConnection - If this plugin supports testing the server credentials (coded in the testConnection function).
  • showNameservers - If this plugin should have name servers associated with it.
  • directlink - If this plugin has a direct login link from the client side.

public $features = [
    'packageName' => true,
    'testConnection' => true,
    'showNameservers' => false,
    'directlink' => true
];

Configuration

Each server plugin must have a getVariables() function which will define options for each server and package. The function must return an array of values.

public function getVariables()
{
    $variables = [
        'Name' => [
            'type' => 'hidden',
            'description' => 'Used by CE to show plugin',
            'value' => 'Sample'
        ],
        'Description' => [
            'type' => 'hidden',
            'description' => 'Description viewable by admin in server settings',
            'value' => 'Sample Server Plugin'
        ],
        'Text Field' => [
            'type' => 'text',
            'description' => 'Text Field Description',
            'value' => 'Default Value',
        ],
        'Encrypted Text Field' => [
            'type' => 'text',
            'description' => 'Encrypted Text Field Description',
            'value' => '',
            'encryptable' => true
        ],
        'Password Text Field' => [
            'type' => 'password',
            'description' => 'Encrypted Password Field Description',
            'value' => '',
            'encryptable' => true
        ],
        'Text Area' => [
            'type' => 'textarea',
            'description' => 'Text Area Description',
            'value' => 'Default Value',
        ],
        'Yes / No' => [
            'type' => 'yesno',
            'description' => 'Yes / No Description',
            'value' => '1',
        ],
        'Actions' => [
            'type' => 'hidden',
            'description' => 'Current actions that are active for this plugin per server',
            'value'=>'Create,Delete,Suspend,UnSuspend'
        ],
        'Registered Actions For Customer' => [
            'type' => 'hidden',
            'description' => 'Current actions that are active for this plugin per server for customers',
            'value' => 'authenticateClient'
        ],
        'package_addons' => [
            'type' => 'hidden',
            'description' => 'Supported signup addons variables',
            'value' => ['DISKSPACE', 'BANDWIDTH', 'SSL']
        ],
        'package_vars' => [
            'type' => 'hidden',
            'description' => 'Whether package settings are set',
            'value' => '1',
        ],
        'package_vars_values' => [
            'type'  => 'hidden',
            'description' => lang('Package Settings'),
            'value' => [
                'Text Field' => [
                    'type' => 'text',
                    'label' => 'Text Field Label',
                    'description' => 'Text Field Description',
                    'value' => 'Default Value',
                ],
                'Drop Down' => [
                    'type' => 'dropdown',
                    'multiple' => false,
                    'getValues' => 'getDropDownValues',
                    'label' => 'Drop Down Label',
                    'description' => 'Drop Down Description',
                    'vaue' => '',
                ]
            ]
        ]
    ];

    return $variables;
}

Error Handling

Throwing a CE_Exception will display the error message to the client/admin.

Functions

The following is a list of minimal functions for a server plugin. Additional functions may be created, and assigned to the "Actions" (for admin) or "Registered Actions For Customer" (for client side) array. Only actions should be prepended with "do" in the actual server class (i.e. function doCreate()).

doCreate

Called when a package is being created on the server. Either automatically with the order processor, or manually from the pending orders view, or by manually triggering the "Create" action.

doUpdate

Called when a package is updated, such as a password change, or the package itself is changed.

doSuspend

Called when the package is suspended. Either automatically with the auto suspend service or manually by triggering the "Suspend" action.

doUnSuspend

Called when the package is unsuspended. Either automatically with the auto suspend service or manually by triggering the "UnSuspend" action.

doDelete

Called when the package is cancelled or deleted. Either automatically with the auto terminate service or manually by triggering the "Delete" action.

testConnection

Called when the "Test Connection" button is pressed on the edit server page. Must throw an exception to signal a failure.

getAvailableActions

Called to determine what Actions can be performed on the package, based on the status of the package at the server.

getDirectLink

Called to get the direct login link for the package.

dopanellogin

Should return the link to direct login to package when accessing from admin.

dopanellogin_reseller

Should return the link to direct login to reseller package when accessing from admin.

How helpful was this article to you?

Posting has been disabled.