Creating Plan Wizards with XML

This document explains how to customize plan wizards by modifying plan wizard XML configuration files.

Introduction

Parallels H-Sphere supports XML-based plan wizards. Wizards are located in the ~cpanel/shiva/psoft/hsphere/plan/wizard/xml directory. Location can be altered by setting PLAN_WIZARDS_DIR in ~cpanel/shiva/psoft_config/hsphere.properties to a target directory.

PLAN_WIZARDS_DIR = /hsphere/local/home/cpanel/shiva/psoft/hsphere/plan/wizard/xml

The list of wizards is defined in the plan_wizards.xml file, which is by default located in the plan wizards directory. The file's name and location is set in the PLAN_WIZARDS parameter in hsphere.properties (the full path to the file is required):

PLAN_WIZARDS = /hsphere/local/home/cpanel/shiva/psoft/hsphere/plan/wizard/xml/plan_wizards.xml

Important: When you customize plan wizard XMLs make sure the PLAN_WIZARDS_DIR and PLAN_WIZARDS parameters are set in hsphere.properties.

You can also customize plan wizard XML files by means of Parallels H-Sphere packages.

Adding a New Wizard to the List of Plan Wizards

To add a new wizard, add the following line to the list of wizards in plan_wizards.xml:

<wizard name="NAME" description="DESCRIPTION"/>

Here,

Example:

<wizard name="unix" description="planeditor.res_unix"/>

Here, Unix plan XML definition file is ~cpanel/shiva/psoft/hsphere/xml/unix.xml, and the plan's description is set in the lang.planeditor.res_unix label in ~cpanel/shiva/psoft/hsphere/lang/hsphere_lang.properties.

Defining Plan Wizard

Plan wizard definition starts with creating a new .xml file. See unix.xml (http://hsphere.parallels.com/HSdocumentation/xmls/unix.xml) as an example of planwizard definition.

<PlanWizard>

The root XML tag is <PlanWizard>:

<PlanWizard name="NAME" description="DESCRIPTION">

Attributes:

<DefaultName>

DefaultName is the name that will serve as the default plan name in creating plans.

<DefaultName>name</DefaultName>

<DefaultValues>

DefaultValues is a construction where the plan's default values are set. Usually, the add _template and menuId values are added here.

<DefaultValues>

<value name="NAME1">VALUE1</value>

<value name="NAME2">VALUE2</value>

...

</DefaultValues>

<categories>

The categories tag defines plan resources. Resources are grouped into categories and described within the <category> tags. Each category tag can have the description attribute which is optional. Categories are used in plan wizard screens to group resources into logical groups.

<categories>

<category>

...

</category>

<category description="DESCRIPTION">

...

</category>

</category>

<resource>

The <resource> tag within the <category> construction defines the resource class, name, description and includes the following attributes if necessary:

<field>

Inside the <resource> construction, the <field> tag allows to get more info from the user for a resource specified. The data will be returned as a part of HTTP request and can be used later via the #name parameter.

Attributes:

If type = "textbox", the following attributes are set:

Example:

<field type="textbox" name="max_conn" label="planeditor.max_connections" value="10" planvalue="MAX_CONN" size="4" check="vPriceReq"/>

<LogicalGroup>

The <LogicalGroup> tag defines a logical server, allows user to select one logical server if several are present.

Attributes:

Example:

<LogicalGroup name="unix_real" type="unix_real" help="admin-editwizard-o_lsgunix_real"/>

<ifresource>

The <ifresource> element allows to group resources/LogicalGroup and activate them for the plan, only if the resource is enabled via global resources, or for the reseller plan.

Attributes:

<ifgroup>

The <ifgroup> element works in the same way as ifresource but checks if the server group is available.

Attributes:

<resources>

The <resources> element is used to define resources and their initialization sequence.

Resources are defined in the resources element in the custom res_RESOURCE_NAME child tag where RESOURCE_NAME is the resource mnemonic identifier.

For example, for the unixuser resource the tag would look like:

<res_unixuser> </res_unixuser>

<mod>

The <mod> tags determine what mods will be defined in the plan.

Attributes:

<initresource>

The <initresource> tags inside mod constructions define what child resources are created with the creation of this resource.

Attributes:

Example:

<initresource name="ip" mod="shared" unique="1"/>

<initvalue>

The <initvalue> tag defines initial plan values.

Initvalues are passed to the resource constructor as a Collection, and you need to be very careful with their order. Initvalue names aren't used as keys. Typically, the constructor would read initvalues like this:

Iterator i = initValues.iterator();

value1 = (String) i.next();

value2 = (String) i.next();

Attributes:

The initvalue tag content is a string. If it starts with #, the value will be used as a name of the parameter which is passed via http request.

Here are several pre-defined variables that could serve as the initvalue tag content:

Example:

<initvalue type="static" label="Home Directory">#homedir</initvalue> <initvalue type="static">$INSTANT_PREFIX</initvalue>

<if>

The <if> tag allows to include initresources or initvalues under a certain condition. For example:

<if type="eq" left="#mixedip" right="dedicated">

<true><initresource name="ip" mod="dedic_no_a"/></true>

<false><initresource name="ip" mod="shard_no_a"/></false>

</if>

Here, the value of the mixedip parameter that is passed via HTTP request is checked for being equal to the value of the dedicated parameter.

<values>

The <values> element includes the <value> constructions inside.

<value>

The <value> tag defines the resource values in the plan.

Attributes:

Example:

<value name="SSI">1</value>

<special>

The <special> element is used to define some additional settings such as tld pricing. It allows to add checkbox to any resource and, if checkbox is selected, to include another template.

To define the special attribute for a resouce, create the <res_RESOURCE_NAME> tag (like <res_opensrs>) inside the <special> element (you can have multiple tags inside the special section).

<field>

Inside <res_RESOURCENAME> tag, the <field> tag is used to define the HTML field.

Attributes:

<include>

Inside the <field> element, the <include> tag defines a template to be included.

Attributes:

Example:

<special>

<res_opensrs>

<field type="checkbox" name="leave_osrs_prices"

label="planwizard.leave_osrs_prices" value="1" checked="1">

<include ifvalue="" name="admin/wizards/tldprices.html"/>

</field>

</res_opensrs>

</special>