protected by United States and international copyright laws. The product’s underlying
technology, patents, and trademarks are listed at http://www.parallels.com/trademarks.
Microsoft, Windows, Windows Server, Windows NT, Windows Vista, and MS-DOS are
registered trademarks of Microsoft Corporation.
Linux is a registered trademark of Linus Torvalds.
Mac is a registered trademark of Apple, Inc.
All other marks and names mentioned herein may be trademarks of their respective owners.
Page 3
Contents
Preface 5
About This Guide ........................................................................................................................... 5
Items you must select,
such as menu options,
command buttons, or
items in a list.
Go to the System tab.
Titles of chapters,
sections, and
subsections.
Read the Basic Administration chapter.
C H A P T E R 1
Preface
About This Guide
This guide explains how to perform certain development tasks, such as, creating
custom Unix-hosted and Windows-hosted resources. It provides Parallels H-Sphere XML API reference to manage Parallels H-Sphere services from remote applications
via SOAP. The guide also describes EasyApp SDK for the integration of third-party
PHP/MySQL applications into Parallels H-Sphere and respective SDKs for adding new
Web payment systems, domain registration services, merchant gateways.
It is helpful that you also refer to Parallels H-Sphere Customization Guide for the
explanation of Parallels H-Sphere customization, localization, and Parallels H-Sphere
addons (packages).
Typographical Conventions
Before you start using this guide, it is important to understand the documentation
conventions used in it.
The following kinds of formatting in the text identify special information.
Page 6
6 Preface
Italics
Used to emphasize the
importance of a point, to
introduce a term or to
designate a command
line placeholder, which is
to be replaced with a real
name or value.
The system supports the
so called wildcard character search.
Monospace
The names of
commands, files,
directories, and domain
names.
The license file is located
in the
http://docs/common/
licenses directory.
Preformatted
On-screen computer
output in your commandline sessions; source
code in XML, C++, or
other programming
languages.
# ls –al /files
total 14470
Preformatted
Bold
What you type,
contrasted with on-screen
computer output.
# cd /root/rpms/php
CAPITALS
Names of keys on the
keyboard.
SHIFT, CTRL, ALT
KEY+KEY
Key combinations for
which the user must
press and hold down one
key and then press
another.
CTRL+P, ALT+F4
Feedback
If you have found a mistake in this guide, or if you have suggestions or ideas on how to
improve this guide, please send your feedback using the online form at
http://www.parallels.com/en/support/usersdoc/. Please include in your report the
guide‟s title, chapter and section titles, and the fragment of text in which you have found
an error.
Page 7
This chapter explains how to write common queries to the H-Sphere system database
In this chapter:
Getting User Information from the Parallels H-Sphere System Database .......... 8
Getting User Information from the
Parallels H-Sphere System Database
Selecting user info:
select users.* from users, user_account where
users.id=user_account.user_id and user_account.account_id=
USER_ACCOUNT_ID;
Selecting mail accounts info:
select m.* from mailboxes m, parent_child p where p.child_type=1002 and
p.child_id=m.id and p.account_id= USER_ACCOUNT_ID;
Selecting resellers info:
select u.* from users u, resellers r, user_account a where
u.id=r.admin_id and r.id=a.user_id and account_id= USER_ACCOUNT_ID;
Selecting credit card info:
select c.* from users u, user_billing_infos u_b, credit_card c,
user_account a
where u.id = u_b.user_id and c.id = u_b.billing_info_id and
u.id=a.user_id and a.account_id= USER_ACCOUNT_ID;
Selecting reseller’s users credit card info:
This is possible if you don‟t encrypt credit card numbers in Parallels H-Sphere
database. In this case run the following query:
select cc.cc_number, cc.name, cc.exp_year, cc.exp_month, cc.type from
accounts as acc join credit_card as cc on (cc.id=acc.bi_id) where
acc.reseller_id= RESELLER_ACCOUNT_ID;
Selecting credit card types:
All supported credit cards:
select * from cc_brands;
Credit cards allowed in Merchant Gateway:
select * from active_merch_gateway;
Selecting virtual FTP info:
select f.* from ftp_vuser f, parent_child p where p.child_type=2003 and
p.child_id=f.id and p.account_id= USER_ACCOUNT_ID;
Page 9
H-Sphere System Database 9
Selecting user’s home directory:
To select user‟s home directory from the system database and connect it to account:
select * from unix_user where unix_user.id = parent_child.child_id and
parent_child.account_id = USER_ACCOUNT_ID;
Selecting user’s website directory:
Website directory always equals user‟s home directory and domain name.
Selecting user’s hosting plan:
To select the name of the plan, run the following query:
select plans.description from plans, accounts where accounts.id =
USER_ACCOUNT_ID and plans.id = accounts.plan_id;
Selecting domain name:
To obtain data on domain names, run the following query:
select domains.name from domains, parent_child where domains.id =
parent_child.child_id and parent_child.account_id = USER_ACCOUNT_ID;
Selecting IP address:
To retrieve data on all IPs, run the following query:
select IP from l_server_ips, parent_child where child_id =
l_server_ips.r_id and parent_child.child_type = 8 and
parent_child.account_id = USER_ACCOUNT_ID;.
There can be multiple IPs per domain.
Selecting IP of the domain:
To retrieve IP for the given domain name, run the following command:
select IP from l_server_ips, domains, parent_child where domains.id =
parent_child.parent_id and parent_child.child_id = l_server_ips.r_id
and domains.name =’YOUR_DOMAIN_NAME’;
Selecting account ID for the domain:
To get the data about account ID of the given domain, execute the query:
select account_id from domains, parent_child where domains.id =
parent_child.child_id and domains.name =’DOMAIN_NAME’;
Page 10
10 H-Sphere System Database
Selecting logical server of the domain:
To retrieve IP for the given domain name, run the following command:
select hostid from unix_user, parent_child where
parent_child.account_id = YOUR_ACCOUNT_ID and child_id = unix_user.id;
Selecting shared IP of the domain:
To get the information about shared IPs for the domain, run:
select IP from l_server_ips where where l_server_id =’HOSTID’ and flag
=’SHARED_IP’;
Selecting user’s e-mail address:
To receive data on clients contact emails, run the following query:
select * from contact_info, accounts where contact_info.id =
accounts.ci_id and accounts.id = USER_ACCOUNT_ID;
Selecting emails of all users, excluding resellers’ end users:
To receive the list of all email addresses ignoring resellers‟ end users, run the following
query:
select c_i.email from contact_info c_i join accounts a on
(c_i.id=a.ci_id and a.reseller_id=1);
Getting user emails by their MySQL database names:
select c.email from mysqldb m, parent_child pc, accounts a,
contact_info c where m.db_name=’DBNAME’ and m.id=pc.child_id and
pc.child_type=6001 and pc.account_id=a.id and a.ci_id=c.id;
Verify users:
To verify whether a user exists in Parallels H-Sphere:
select id from users where username=’USER_NAME’ and
password=’PASSWORD’;
Defining physical/logical servers:
Run the following commands to get info about physical/logical servers:
by IP address:
select l_server_id from l_server_ips where l_server_ips =
‘IP_ADDRESS’;
by logical server:
select p_server_id from l_server where id = ‘LOGICAL_SERVER_ID’;
Page 11
H-Sphere System Database 11
selecting info about physical server:
select * from p_server where id = ‘PHYSICAL_SERVER_ID’;
Selecting user’s billing info:
To select billing info from accounts, run the following query:
select * from billing_info, accounts where billing_info.id =
accounts.bi_id and accounts.id =USER_ACCOUNT_ID;
Billing periods for plans:
All information including discounts if present:
select * from plan_value where name like ‘_PERIOD%’ and plan_id=plan_id;
Discounts:
select * from plan_value where name like ‘%_DISC_%’ and plan_id=plan_id;
Payment modes:
select billing from plans where id=plan_id;
plans.billing takes the following values:
0 - without billing;
1 - billing mode;
2 - billing with trial period.
Getting plan pricing details:
select * from plan_value where plan_id=plan_id;
Getting domain registration pricing details:
select * from tld_prices;
select * from plan_value where name like „_TLD_%‟;
Page 12
12 H-Sphere System Database
Database Connections
There are two possible types of connections to the Parallels H-Sphere database:
Regular shared connections
Connections with opened transaction
Important: In any case, you should use only prepared stataments when working with
the Parallels H-Sphere database!
Regular Shared Connections
The part of the code which establishes and uses a regular database connection should
look something similar to this:
PreparedStatement ps = null;
Connection con = Session.getDb();
try {
In general, the part of the code which establishes and uses a transaction connection
should look as follows:
// checking if the transaction exists
boolean wasTrans = Session.isTransConnection();
Connection con = wasTrans ? Session.getDb() :
Session.getTransConnection();
try {
// some operation with the database
} catch (Exception ex){
if (!wasTrans) {
// rollback transaction
con.rollback();
// some data to release cache and to synchronize with old
data in HS DB
}
throw ex;
} finally {
if (!wasTrans) {
// commit transaction and release connection
Session.commitTransConnection(con);
} else {
con.close();
Page 13
H-Sphere System Database 13
}
}
Important:
1. There is the pool of transaction connections (5 by default). Opening a
new transaction that exceeds this maximum would cause the system to
hang up.
2. As the number of available transactions is resctricted, you must release
the transaction connection you have opened by using the following
command:
Session.commitTransConnection(con);
3. To get an opened transaction connection:
con = Session.getTransConnection();
4. Later in the code, you may get the same connection:
con = Session.getDb();
Note: Never close a transaction connection you haven‟t opened!
5. Please make sure you synchronize your objects with the corresponding
data in the database. You must release your cache if you make a
rollback.
Page 14
This chapter explains how to write custom Unix hosting resources and outlines some
public class MyResource extends Resource {
public MyResource(int type, Collection init) throws Exception
{
super(type, init);
...........
}
public MyResource(ResourceId rid) throws Exception {
super(rid);
...........
}
}
The class must have 2 constructors, as illustrated in the above example.
The first constructor, MyResource(int type, Collection init), is used
on the resource creation and its init argument contains the list of the String class
objects. The MyResource method‟s arguments starting from the third are
parameters passed from the HTML form. For example:
Here, db_id and user_id are parameters taken from the HTML form.
In this case, the values of db_id and user_id are passed to constructor as
Collection of Strings.
The second constructor, MyResource(ResourceId rid), is used when the
user (owner of the resource) is logged in and ClassLoader loads the resource.
Also, the resource may overwrite the initDone() method called upon the
resource creation. initDone() is designed to save all additional parameters into
the database and to execute additional scripts.
The resource may also overwrite the delete() method called upon the recource
deletion. This method is used to delete all additional database records related to
this resource.
If the resource creates system resources (directories, files, etc.) on a certain host,
the resource should implement the HostDependentResource interface:
package psoft.hsphere.resource;
public interface HostDependentResource {
Page 16
16 Unix Hosting Resources and Tools
/**
• Method checks if a resource can be moved to the target
server
• @param newHostId
• @return
• @throws Exception
*/
public boolean canBeMovedTo(long newHostId) throws Exception;
/** The method physically creates a physical implementation
• of a resource on a logical serevr with the passed ID
• @param targetHostId
• @throws Exception
*/
public void physicalCreate(long targetHostId) throws
Exception;
/**
• The metod deletes a physical implementation of a resource
on
• a logical server with the passed ID
• @param targetHostId
• @throws Exception
*/
public void physicalDelete(long targetHostId) throws
Exception;
/**
• The method sets an ID of the logical server to
• which this resource is linked
• @param newHostId
• @throws Exception
*/
public void setHostId(long newHostId) throws Exception;
/**
• The method returns an ID of a logical server
• to which this resource is being linked
• @return
• @throws Exception
*/
public long getHostId() throws Exception;
}
In case of the HostDependentResource implementation, the method
physicalCreate(long targetHostId) must be called from the method
initDone(), and the method physicalDelete(long targetHostId) from
the method delete(). The methods physicalCreate(long targetHostId)
and physicalDelete(long targetHostId) call scripts to create and delete
system resources, respectfully. The method canBeMovedTo(long newHostId)
should return true if physical components of the resource (files, directories, etc) can
be moved to or created on the host. The methods setHostId(long newHostId)
and getHostId() respectfully set and get id of the host where resource physical
components are located.
General order of calling methods during the first resource creation is as follows:
Page 17
Unix Hosting Resources and Tools 17
MyResource(int type, Collection init)
Column
Type
Modifier
Description
id
integer
not null
unique resource type id
name
character
varying(40)
not null
unique resource name
price
character
varying(5)
flags:
M (initial value must be set)
R (recurrent)
U (usage)
F (initial value is optional)
S (setup)
description
character
varying(100)
resource brief description
public void initDone()
public void physicalCreate(long targetHostId)
The resource parameter values predefined in the <plan_name>.xml file can be
retrieved by calling the getPlanValue(String key) method defined in Resource.class. For example, in unix.xml, the myresource resource is
described with the res_myresource construction with the block of predefined values:
In order to retrieve the resource values, FM_ methods should be implemented to be
called from the HTML form. FM_ method, with its name having the FM_ prefix, is a
method that returns a value of the TemplateModel class. If you call an FM_
method from a template, the Freemarker code will look like:
<assign multiply=myresource.multiply(a, b)>
Here, myresource is resource name in the plan, and multiply refers to the
FM_multiply(a, b) method, where a and b are the method‟s arguments. In
this case, the TemplateModel‟s FM_multiply(int x, int y) method of
MyResource class will be called.
3. Insert resource information into the Parallels H-Sphere database.
Information must be added to the type_name table:
Page 18
18 Unix Hosting Resources and Tools
rprice
character
varying(5)
reseller flags:
R (recurrent)
U (usage)
F (initial value is optional)
S (setup)
required
smallint
flag indicating if this resource is
required for all accounts
priority
smallint
must be 0
ttl
integer
resource deletion time (should not be
set initially)
Page 19
Unix Hosting Resources and Tools 19
Index: type_name_name
Primary key: type_name_pkey To add a resource, insert the resource data into the
type_name table, like this:
INSERT INTO type_name (id,name,description,required,priority)
VALUES (119, „my_resource‟, „My Resource‟,0,0);
1. Include the resource to the plan XML configuration file.
The resource should be included into XML configuration files for each type of plans
where this resource is to be enabled (for example, unix.xml for Unix plan). These
files are located in the ~cpanel/shiva/psoft/hsphere/plan/wizard/xml/
directory.
You need to add the resource tags with the new resource wherever necessary
according to the guide on creating XML plan wizards in Parallels H-Sphere Customization Guide.
To make the resource available automatically upon accounts‟ creation, add the
res_RESOURCE_NAME construction to the plan XML file, where RESOURCE_NAME is
the value set in the name attribute of the resource tag for the given resource.
Make sure you also set the interface text label set as the description attribute of the
category tag. This is done in the custom hsphere_lang.properties file. For the
label in the above example, the label is set as follows:
planeditor.myresource = My Resource
2. Implement the resource in CP Web interface.
1. Create templates for this resource.
Create templates according to the template procedure. See the example below
for the templates you may need to add.
2. Add a new menu item for this resource in CP menu.
Customize CP menu and add a new menu item to the custom menu.xml, for
Then, add labels myresource.label and myresource.tip to the custom hsphere_lang.properties file and run language bundle compiler:
[]$ java psoft.hsphere.LangBundlesCompiler
3. Create scripts for the resource’s physical implementation.
You must be logged in as root to create these scripts in the
/hsphere/shared/scripts/ directory. See the example below on how you
may create these scripts.
Note: Make changes to custom templates, interface text bundles and XML files, not to
the default ones! Otherwise, you will lose your settings with subsequent Parallels HSphere upgrades. Please refer to the Parallels H-Sphere Customization Guide for
details.
Example:
Below is a detailed example of how to create and add a new resource to Parallels HSphere.
1. Login as cpanel user (on page 76) to the CP server.
2. Create a resource class:
package psoft.hsphere.resource;
import java.util.*;
import psoft.hsphere.*;
public class MyResource extends Resource implements
HostDependentResource {
public MyResource(int type, Collection init) throws Exception
{
super(type, init);
}
public MyResource(ResourceId rid) throws Exception {
super(rid);
}
/*In this case the resource can be moved to any host*/
public boolean canBeMovedTo(long newHostId) throws Exception
{
return true;
}
/* This method is started when the resource is created */
public void initDone() throws Exception {
physicalCreate(Long.parseLong(recursiveGet(“host_id”).toStrin
g()));
}
/*
• Deletes persistant representation of the resource as well
as its system/physical representation
• @throws Exception
Page 21
Unix Hosting Resources and Tools 21
*/
public void delete() throws Exception {
physicalDelete(Long.parseLong(recursiveGet(“host_id”).toStrin
g()));
}
/*This method implements method of HostDependentResource
interface.
• In this case method collects the information about resource
• and runs the „myresource-init‟ script with collected
• information as arguments.
*/
public void physicalCreate(long targetHostId) throws
Exception {
//Unix-based implementation:
List l = new ArrayList();
l.add(recursiveGet(“login”).toString());
l.add(recursiveGet(“dir”).toString());
HostEntry he = HostManager.getHost(targetHostId);
he.exec(“myresource-init”, l);
//Win-based implementation:
// WinHostEntry he = (WinHostEntry)
HostManager.getHost(targetHostId);
// boolean isSOAP = WinService.isSOAPSupport();
// if (isSoap) {
// SOAPEnvelope envelope =
he.invokeMethod(“create”, new String[][] {
// {”resourcename”, “myresource”},
// {”username”, recursiveGet(“login”).toString()},
// {”directory”, recursiveGet(“dir”).toString()}}
// );
// if (envelope == null) {
// throw new HSUserException(“The error invoked
during SOAP calling”);
// }
// } else {
// throw new HSUserException(“SOAP is not supported”);
// }
}
/*This method implements method of HostDependentResource
interface.
• In this case method collects the information about resource
• and executes the „myresource-init‟ script with collected
• information as arguments in order to physically delete
resource.
*/
public void physicalDelete(long targetHostId) throws
Exception {
//Unix-based realisation:
List l = new ArrayList();
l.add(recursiveGet(“login”).toString());
l.add(recursiveGet(“dir”).toString());
HostEntry he = HostManager.getHost(targetHostId);
Page 22
22 Unix Hosting Resources and Tools
he.exec(“myresource-delete”, l);
//Win-based realisation:
// WinHostEntry he = (WinHostEntry)
HostManager.getHost(targetHostId);
// boolean isSOAP = WinService.isSOAPSupport();
// if (isSoap) {
// SOAPEnvelope envelope =
he.invokeMethod(“delete”, new String[][] {
// {”resourcename”, “myresource”},
// {”username”, recursiveGet(“login”).toString()},
// {”directory”, recursiveGet(“dir”).toString()}}
// );
// if (envelope == null) {
// throw new HSUserException(“The error invoked
during SOAP calling”);
// }
// } else {
// throw new HSUserException(“SOAP is not supported”);
// }
}
/*This method implements method of HostDependentResource
interface.
• id of this resource host cannot be set
*/
public void setHostId(long newHostId) throws Exception {
return;
}
/*This method implements method of HostDependentResource
interface
• and returns value of “hos_id” key in resource tree.
*/
public long getHostId() throws Exception {
return Long.parseLong(recursiveGet(“host_id”).toString());
}
}
3. Insert the resource info into the system database:
Then, add labels myresource.label and myresource.tip to ~cpanel/shiva/psoft/hsphere/lang/hsphere_lang.properties and
run language bundle compiler:
Page 24
24 Unix Hosting Resources and Tools
[]$ java psoft.hsphere.LangBundlesCompiler
6. Create scripts for physical implementation of the resource. You must
login as root.
Create the file hsphere/shared/scripts/myresource-init:
#!/bin/sh
cd $2;
mkdir myresource;
exit 0
Create the file hsphere/shared/scripts/myresource-delete:
#!/bin/sh
cd $2;
rm -rf myresource;
exit 0
Page 25
Unix Hosting Resources and Tools 25
Global Resources And Resource
Dependencies
To simplify describing and provide flexible access mechanism, it was logically split into
two parts: „globals‟ and „resource dependencies‟.
Globals is the mechanism to provide enabling/disabling some features (resources) both
for the entire system and for separate reseller hosting systems. By now, we have the
following Globals: Parallels H-Sphere resources, “key - value” like objects stored in db,
Class managed key sets, Class maintained sophisticated objects (former “pseudo
resources”).
„Resource Dependencies‟ is a description of how resources/objects depend on other
resources/objects. Not only chains of dependencies up to Globals can be defined here,
there is also a possibility to describe parent-child and ancestor-descendant resource
dependencies. Such resource dependencies are used to make a decision which
resources can be added to user accounts and which cannot.
globals.xml
This file lists global resources. Location:
~cpanel/shiva/psoft/hsphere/globals.xml
<!ATTLIST object name CDATA #REQUIRED>
<!ATTLIST object label CDATA #IMPLIED>
<!ATTLIST object label_enabled CDATA #IMPLIED>
<!ATTLIST object label_disabled CDATA #IMPLIED>
<!ATTLIST object default (enabled | disabled | unavailable)
“enabled”>
<!ATTLIST plan_dependent_resource name CDATA #REQUIRED>
<!ATTLIST set name CDATA #REQUIRED>
<!ATTLIST set label CDATA #REQUIRED>
<!ATTLIST set default (enabled | disabled | unavailable)
“enabled”>
<!ATTLIST set class CDATA #REQUIRED>
<!ATTLIST set managed (globally | reseller) “globally”>
<!ATTLIST property key CDATA #REQUIRED>
<!ATTLIST property value CDATA “*”>
<!ATTLIST maintained_object name CDATA #REQUIRED>
<!ATTLIST maintained_object class CDATA #REQUIRED>
<!ATTLIST user_plan type CDATA #REQUIRED>
<!ATTLIST user_plan label CDATA #IMPLIED>
<!ATTLIST user_plan default (enabled | disabled |
unavailable) “enabled”>
]
It can be seen that the root level consists of one or more „section‟ elements. Section is
the way to combine several „global‟ objects or sets into a group and to show them in
Parallels H-Sphere CP interface in a suitable form.
Beside this, there is also one more auxiliary section „special‟ which is used to define
Class Maintained Global Objects.
Elements and attributes:
section:
id: mnemonic identifier; mandatory attribute, the rest are non-mandatory
label: a key having correspondences in the language bundle files
description: a key, like the above one, for the text describing some peculiarities of
the section
online_help: a key having correspondence in the online_help.xml file. You may
choose which one of „description‟ or „online_help‟ is more suitable in each
particular case.
show: by default is set to show always. If necessary, you may restrict this rule by
specifying one of the following values:
globals: to show in master admin‟s „globals‟ menu
plans: to show in reseller plan wizards only
invisible: to exclude the section from standard page flow and show it
somewhere else on the page calling it by hand (e.g.:
admin.getGlobalSection)
Page 27
Unix Hosting Resources and Tools 27
store: by default, it is set to “each” what means storing the status values of all
objects in the section both into the settings table of the hsphere database
and in the table plan_value for reseller plans. Normally, the attributes show
and store should match to each other (have the similar values). Be careful with
changing these attributes as it may lead to undesired results. For instance, if the
attribute store is set to settings, whereas the section objects are shown in reseller
plan wizards, these values won‟t be stored in the plan_value table, so they
won‟t affect separate reseller hosting systems. And one more case, if the
attribute „store‟ is set by default to “each”, but the globals from this section are
prohibited to be shown on the page Globals (e.g. attribute show is set to plans),
the respective values will be set to DISABLED in the settings table. So, all the
object in the section will become Disabled.
Global object: an Parallels H-Sphere resource or a simple “property” that has a
mandatory attribute name (treat this as a property key). An example of the global
object is cp_ssl_ip_based. By default, all global objects are Enabled unless you decide
to change this by specifying the value explicitly (the attribute default).
default: if necessary, you may change it to „disabled‟
name: mandatory attribute, the rest attributes are non-mandatory
label: the same as for „section‟
label_enabled, label_disabled: replace the label attribute and are used to show the
object as radio button instead of checkbox
plan_dependent_resource: added to provide solution for disabling resources for
different plan types separately, frontpage for Unix and Windows platforms in
particular
set of keys: the way to describe a group of entities where each of them contains a
unique key, description and status. An example of a set is Logical Server Groups.
Each server group has a key which is group id, description and status. Due to
significant difficulties to describe each global set in XML, the behavior of this type of
globals is implemented by a Java class specified with the attribute class. The other
attributes label and default are described above.
managed: this attribute shows if this global resource, being managed by admin, is
also manageable by reseller: managed=”reseller”. In particular, this is
implemented in dedicated server template (see Admin Guide) where resellers
can set prices for templates provided by main hosting provider (admin).
If managed is not set, it is considered to be “globally” by default (i.e., not
manageable by resellers).
maintained_object: the class Maintained Global Objects belong to a special type of global
objects. Each object is maintained by a Java class specified in the attribute class in
the xml. To get Maintained Global Objects”working, all you need is to write a
maintainer class maintainer. This class should extend the standard class
psoft.hsphere.global.ClassMaintainedGlobalObject. In your class you
either:
a override the method boolean isEnabled(), or
b override all the 3 methods: boolean isEnabled(Reseller r), boolean
isEnabled(int resellerPlanId), boolean
isEnabled(ServletRequest rq), or
Page 28
28 Unix Hosting Resources and Tools
c override all the methods: Globals.State getObjectState(Reseller r),
Globals.State getObjectState(int resellerPlanId) and
Globals.State getObjectState(ServletRequest rq).
Doing (a) and (b), you can have only 2 possible statuses for the objects: ENABLED
or UNAVAILABLE. The method (c) allows you to have any status you need (at least
those ones defined in the class Globals.State). Please note that the Maintained Global Objects are neither shown on the ‘Globals’ page in the CP interface nor they
are shown in Reseller plans. Their states cannot be stored in the database either.
Besides, none of the true “Parallels H-Sphere resources” can be made Maintained Global Object.
check_config: each of the objects/sets described above may require additional
checks whether it is configured to work properly in the
~cpanel/shiva/psoft_config/hsphere.properties file. To provide this,
the additional structure is added:
Here, an object will be considered as “configured” if all of the specified properties
are defined in the hsphere.properties file, no matter what values they have.
You may strengthening this by specifying the desired values in the property
elements (the attribute value). If necessary, you may also implement the “OR” logic
in conditions by including the following structure::
Here, the hosting resource can be a child resource for either domain (Transferred
Domain), or 3ldomain (Third-Level Domain), or parked_domain (Parked Domain)
resources.
resource_dependences.xml
This file describes relationships between parent and dependent resources. Location:
~cpanel/shiva/psoft/hsphere/resource_dependences.xml
<!ATTLIST resource name CDATA #REQUIRED>
<!ATTLIST requires name CDATA #REQUIRED>
<!ATTLIST requires relation (parent) #IMPLIED>
]>
As you can see, this is quite a simple structure, so it is very easy to write resource
dependence rules. For example, to make vps_ip resource the available, is it required
to enable the resource vps:
Using the attribute relation you may specify that the required resource is a direct parent
or ancestor for the current resource.
List of Resource Dependencies
Page 30
30 Unix Hosting Resources and Tools
MySQLDatabase
MySQL
MySQLUser
MySQL
mysqldb_quota
MySQL
MSSQLLogin
MSSQL
MSSQLDatabase
MSSQL
MSSQLUser
MSSQL
MSSQLQuota
MSSQL
pgsqldatabase
pgsql
pgsqluser
pgsql
pgsqldb_quota
pgsql
real_user
realserver_user
real_server_traffic
realserver_user
winquota
realserver_user
cfentry
cf
mnogosearch
MySQL
phpbb
php, MySQL
asp_secured
asp
sshresource
sshmanager
vps_ip
vps
vps_mem_limit
vps
vps_proc_limit
vps
vps_ip_traffic
vps
kanoodlemanager
kanoodle
ds_custom_build
ds_enable
ds_manager
ds_enable
ds_reboot_enable
ds_enable
ds_backup_enable
ds_enable
Page 31
Unix Hosting Resources and Tools 31
allow_ds_resell
ds_enable
allow_own_ds
ds_enable
ds
ds_enable
ds_bandwidth
ds
cf_dsn_record
odbc, cf
Page 32
32 Unix Hosting Resources and Tools
Account Preferences
You can set individual interface preferences: preferred design (skin), icon set, or
language - for a particular account.
This can be implemented within an Parallels H-Sphere template by using the following
Freemarker commands:
1. Set account preferences:
<assign res = account.preferences(“KEY”, “VALUE”)>
2. Retrieve account preferences:
<assign property1 = account.preferences(“KEY”)>
Here:
KEY is the key of an interface preference to be assigned to an account (up to 64
chars),
VALUE is its value (up to 256 chars).
The following keys are available in Parallels H-Sphere (refer to the Skin And Icon Set
Customization document in Parallels H-Sphere Customization Guide for detailed
description of the ~cpanel/shiva/psoft/hsphere/design_config.xml file):
design_id - preferred design id (in design_config.xml);
icon_image_set - preferred icons image set (in design_config.xml);
skill_icon_set - preferred icons skill set (in design_config.xml);
lang - preferred language.
For example, to assign the XPressia design for an account:
<assign res = account.preferences(“design_id”, “xcp”)>
TimeUtils Class
The TimeUtils class is designed to subsitute all other Parallels H-Sphere classes
dealing with time. This class is needed for testing any Parallels H-Sphere features that
use time (like accounts, domain registration renewals, and the like).
From now on, please ALWAYS use the following TimeUtils wrappers instead of any
other Date/Time functions:
FreeMarker Access Control List (FMACL) Objects provide an easy and effective way to
manage Parallels H-Sphere resources and grant different levels of access to their
methods from FreeMarker templates. This technology is especially useful for making
changes in third-party products implemented as Parallels H-Sphere .hsp packages (for
example, custom plans and reports) See Parallels H-Sphere Customization Guide for
details on packages.
Purpose
Formerly, when we needed to handle the same functionality related to different objects
(take domain registration as an example), we would split the code among these
resources. For example, some of the methods would be in BillViewer, some in
BillManager, CreateUser, HsphereToolbox, etc... This led to problems with
changing the code - it had to be changed across a wide variety of classes. Also, due to
that, the same code was often repeated.
Especially, it was hard for third parties to integrate such functionality to Parallels HSphere. In particular, to add a custom resource manager, the resource should be
added and should be represented in all admin plans, which, in turn, required changes in
the system database.
The idea comes from the fact that some functionality is not really a “resource”, but a set
of facilities of common purpose (for example, report generation), accessed differently
on different levels. This solution is implemented in FMACL objects.
Implementation
To provide access to required methods, the new FreeMarker obj tag is introduced.
Now the methods will be accessible in FreeMarker templates as obj.key.method. For
example, to call the getTLDPrice method of the
psoft.hsphere.admin.DomainRegistration class from a template, we simply
write:
obj.domreg.getTLDPrice()
Here, domreg is a key associated with
psoft.hsphere.admin.DomainRegistration in the acl_objects.xml file.
Each object is instantiated via default constructor (without params) and must implement
the FreeMarker‟s TemplateHashModel:
Access permissions to class methods must be set in the corresponding .acl files for
each class, located in the same directory and bearing the same name as the class files.
For example, access permissions for the
psoft.hsphere.admin.DomainRegistration class must be set in the
psoft/hsphere/admin/DomainRegistration.acl file.
FMACL Objects XML File
The objects are defined in ~cpanel/shiva/psoft/hsphere/acl_objects.xml in
the following format:
Here, each unique key corresponds to an Parallels H-Sphere class. Each class defined
here must have its .acl file in the same directory and with the same name. For
example, for psoft.hsphere.admin.DomainRegistration there must be the psoft/hsphere/admin/DomainRegistration.acl file with access permissions
for used methods of this class.
To re-define or customize (merge) the default acl_objects.xml file, set the
ACL_OBJECTS property in a package properties file. See Customizing XMLs With
Packages in Parallels H-Sphere Customization Guide for details.
Setting Levels of Access to Class Methods
Access permissions to class methods are set in hsphere_class.acl files in the following
lines:
key access_mask
where:
key is template hash model key;
access_mask is a combination of the following characters defining the level of
access:
a - Parallels H-Sphere admin
r - reseller admin
u - user
e - everyone, including access from the outside of Parallels H-Sphere.
Access mask specifies on which level a key is accessible (the level will be determined
by checking the plan of a user logged in). If the key is not accessible, the system will
throw TemplateModelException.
Page 36
36 Unix Hosting Resources and Tools
Example for setting access permission for domain
registration (domreg):
getTLDPrice aru
setTLDPrice ar
lookup e
enableTLD a
This means that the getTLDPrice method will be accessible by admin, reseller admin
and user, setTLDPrice by admin and reseller admin, lookup by everyone (even if
user is not logged in), enableTLD only by admin.
The access will be provided by calling obj.domreg.lookup,
obj.domreg.geTLDPrice, etc., in Parallels H-Sphere templates (see Parallels H-
Sphere Customization Guide).
External Credits
Parallels H-Sphere supports external credits, or external charges: charges exported
from external billing systems.
External charges are stored in the external_credits table. The ecCron internal CP
cron adds charges from external billing software to the external_credits table as
the accounts‟ credits.
To set the time interval when ecCron is launched, you need to add the following line to
~cpanel/shiva/psoft_config/hsphere.properties:
EX_CHARGE_CRON=5
In the above example, ecCron would start every 5 minutes.
The external_credits table is created during Parallels H-Sphere upgrade and has
the following structure:
CREATE TABLE external_credits (
id int NOT NULL,
account_id int4,
amount float,
created timestamp with time zone,
description varchar(128),
PRIMARY KEY(id)
);
Page 37
Unix Hosting Resources and Tools 37
Running Parallels H-Sphere in Debug
Mode
To run Parallels H-Sphere in debug mode:
1. Compile classes with debug information:
./configure -javac—with-params=”-g” make shiva
2. Set the following option “on” in jserv.conf to be able to launch JServ
manually:
ApJServManual on
3. Create debug.sh shell script to run JServ in debug mode:
#!/bin/sh
properties=/home/shiva/apache/etc/jserv.properties
log=/home/shiva/apache/logs/jserv_manual.log
CLASSPATH=$CLASSPATH:/usr/local/java/JSDK2.0/lib/jsdk.jar
CLASSPATH=$CLASSPATH:/usr/local/apache/libexec/ApacheJServ.ja
r
java -Xdebug Xrunjdwp:transport=dt_socket,address=9999,server=y,suspend=n
\
org.apache.jserv.JServ $properties $1 2 >> $log
# address=9999 - port to which the debugger may be attached
# choose any available port you like
5. Start Apache and run debug.sh after Apache start. Set IDE breakpoints
and launch debug from IDE.
Page 38
38 Unix Hosting Resources and Tools
Script Runner
Script-runner is a utility that launches Parallels H-Sphere scripts on Unix servers.
Parallels H-Sphere control panel establishes an SSH connection with a Unix box and
runs script-runner:
ssh -a -x root@xxx.xxx.xxx.xxx /hsphere/shared/scripts/script-runner.pl
Further, the control panel sends commands to the output stream of the SSH session
and script-runner reads and performs the commands and then outputs.
It starts with the keyword COMMAND followed by actual command. Then, if necessary,
it‟s followed by the parameters that are numbered from 1 and further. All parts of the
command are separated with the ampersand (&). The „=‟ symbol is followed by the
value. The command ends with the line feed character.
If the command requires standard input, you should set the INPUT parameter.
Commands are passed in the 8-bit ASCII encoding. Command parameters and
standard input are passed in the URL-encoding. Version 1.8 contains script-runner-b64
utility that has the same functionality as script-runner, but data should be passed in the
Base64 encoding and it returns the result in the same encoding.
Script-runner returns output in the following format:
If there is an error during script execution, parameter ERROR will contain the error text
and output code EXIT_CODE will be non-zero. OUTPUT is a standard script output.
To check if script-runner is ready to accept commands, use the PING command. You
should get the PONG output.
Script-runner logs all executed scripts and their output. They can be found in the
/var/log/scriptrunner directory on the box where script-runner is running.
Page 39
This section outlines certain development tasks for H-Sphere Winbox-related
In this chapter:
Creating Resources for Winbox ......................................................................... 40
Crash Reporting on Winbox .............................................................................. 52
In terms of Parallels H-Sphere, any resource on a Windows server can be considered
as a module (or a group of modules), and has to support the following functionalities:
create and delete a physical resource;
read and change parameters of the physical resource.
By physical resource we mean any resource of the OS (IP address, account, etc), or
additional software used as a part of the hosting service. Different physical resources
can have the same functionality in terms of hosting (even if they are implemented in
completely different ways), like MS FTP Server. Even for the same software, different
versions of the physical resource implementation can exist with different functionality.
As a result, each Parallels H-Sphere resource can have several implementations, i.e.,
modules working with a particular implementation of a physical resource. Yet, only one
implementation of a particular Parallels H-Sphere resource can be active at a time. To
put it simply, we will be using a resource to describe its physical implementation.
Requirements
To implement a new resource, the following software is required:
.NET Framework version 1.0.3705 and higher
Parallels H-Sphere Windows package installed or Psoft.HSphere.dll
assembly available
You can use any .NET compatible language. Yet, since the core part of Parallels HSphere winbox is written in C#, all examples will be presented in C#.
Naming Conventions
We recommend using the following naming conventions when developing new
resources.
Namespaces
All resources should belong to Psoft.Hsphere.Resources or to namespaces inside
it. If there are several implementations of the same resource, they should be placed in
the same namespace.
Assemblies
The name of the assembly should have the following format:
Page 41
Windows Hosting Resources 41
Resources.<Resource class name> if assembly contains class of only one resource
and the resource is located directly in the namespace
Psoft.HSphere.Resources (e.g.: Resources.Diskquota for resource
Psoft.HSphere.Resources.DiskQuota)
Resources.<Namespace Name> if assembly contains several resources in this
namespace. (e.g.: Resource.IIS.ColdFusion for the implementation of different
versions of the ColdFusion resource)
Attributes
All names in attributes (logical name of the resource, physical name, parameter names
in schemas) should be typed in lower case.
General Scheme of Resource Functioning
Each resource has a logical name known to the CP. If there are several
implementations of the same resource, only one can be active at a time.
The implementation is defined in the config file. The implementation of the resources
should be in separate non-core assemblies that will be loaded dynamically. The class
that implements resource and its assembly is defined in the config file. Also, in the
config file, the attributes of the resource are defined, and each instance of the resource
will get those attributes in addition to parameters. Attributes should represent constant
parameters for a given implementation that are common for all instances.
A resource (group of resources) has to be implemented as a public class (classes)
inherited from the abstract class Psoft.HSphere.Resources.Resource that can
be found in Psoft.HSphere.dll and is implemented as class library. To do that, you
need to add references to Psoft.HSphere.dll during the compilation using
option/reference.
Class Psoft.HSphere.Resources.Resource defines the set of methods that have
to be implemented by the inherited resource:
public abstract void Create();
public abstract void Get();
public abstract void Update(Parameters newParams);
public abstract void Delete();
public abstract void Suspend();
public abstract void Resume();
Page 42
42 Windows Hosting Resources
The names of the methods describe their functionality (more details are below).
Besides that, each resource inherits a collection of parameters from the abstract parent
of the Psoft.HSphere.Transport.Protocols.Parameters type. That collection
is represented as a hash table, and the values of parameters can be retrieved via the
parameter names. When a particular operation is executed on the resource (like create,
delete, update parameters... etc), Parallels H-Sphere Windows engine creates an
instance of a corresponding resource and sets values for the parameters as they are
passed from the CP. Besides that, the resource can have a collection of configurable
attributes, which are defined in the Parallels H-Sphere config file. Parallels H-Sphere
Windows engine adds attributes into the collection of parameters as well. After that, a
corresponding method is called on the resource. Due to that, during a call of any of
those methods, the instance of the resource has all the required information to perform
the operation.
While developing a resource, you have to consider that the resource does not support
statuses, and you should not save any type of info in the instance of the resource, as it
can be destroyed as soon as a method is executed.
Methods
void Create()
This code should implement physical creation of the resource. Parameters required to
create the resource will be passed as parameters collection. The number and names of
parameters are defined by specifics of physical resource and set in special attributesschemas (defined later in this document).
void Get()
This method should implement the code to retrieve parameters of a physical resource.
Retrieved values should be written into a collection of parameters. If such functionality
is not required for the resource, it can be implemented as an empty method:
void Get() {}
void Update(Parameters newParams)
This method should implement a way to change all or some parameters of a physical
resource. The method accepts a collection of parameters that need to be changed.
During the implementation of this method, you don‟t have to update the collection
resource parameters (this will be done by Parallels H-Sphere Windows engine if the
code is completed successfully). It is enough to update parameters of the physical
resource.
If the given functionality is not required for the resource, it can be implemented as an
empty method:
void Update(Parameters newParams) {}
void Delete()
This method should implement the deletion of the physical resource. If the given
functionality is not required for the resource, it can be implemented as an empty
method:
Page 43
Windows Hosting Resources 43
void Delete() {}
void Suspend()
This method should implement the suspension of the physical resource. If the given
functionality is not required for the resource, it can be implemented as an empty
method:
void Suspend() {}
void Resume()
This method should resume the physical resource. If the given functionality is not
required for the resource, it can be implemented as an empty method:
void Resume() {}
Keys
Parallels H-Sphere Windows engine and resource classes deal with resource keys.
There are two types of keys, logical and physical. Logical key can be defined as a
parameter which differentiates instance of the resource from the set of other instances
for the resource user (i.e. CP). To operate with particular instance of the resource, in
addition to all other parameters added to its methods, you need to pass the parameter
that will uniquely identify the resource. Physical key is very much like a logical key, with
the only difference that resource user (i.e. CP) knows nothing about it (there is no
unique identifier). Sometimes physical resources require keys to operate with them,
which makes sense only in the context of the given physical key. It can be exemplified
by numeric IDs of virtual Web or FTP hosts (unique numerical identifiers) in the IIS
metabase, that are required to operate with a given host on the level of metabase.
On the other hand, for virtual Web host uniqueness can be implemented by means of
domain name, and for virtual FTP host by means of IP. In that case domain name is a
logical key for the resource that implements virtual web host. A number in the
metabase - its resource‟s physical key. At the same moment Parallels H-Sphere
Windows engine provides mechanisms for the translation of virtual key into physical
key. In most cases, logical key can coincide with physical key.
As mentioned above, a resource has two types of parameters that eventually are stored
in common collection of parameters - configuration (common to all instances) and
instance (different for each particular instance of the resource). Instance parameters
are passed during the method call and should contain logical key for the given
resource.
Each key is implemented via subclass of abstract class
Psoft.HSphere.Resources.Key. This class defines the following set of methods to
be overloaded:
public abstract object Val { get; set; }
public abstract int Compare(object objVal);
public abstract Key Add(object objVal);
public abstract Key Sub(object objVal);
public abstract Key Inc();
public abstract Key Dec();
Page 44
44 Windows Hosting Resources
Those methods define basic operations for manipulating and comparing keys. In most
cases, you don‟t need to create a new key class, as you can use two already existing
classes: Psoft.HSphere.Resources.NumKey and
Psoft.HSphere.Resources.StrKey, that correspondingly implement numeric and
string keys.
Class Resource has two attributes, Pkey and Lkey, to represent physical and logical
keys for the instance of the resource:
public Key PKey { get; set; }
public Key LKey { get; }
LKey is read-only, as the value of the logical key is automatically retrieved from the
parameter collection.
Error Handling
All the classes implementing exceptions that are connected with resources have to be
inherited from the class Psoft.HSphere.Resources.ResourceException. There
are several types of error conditions that should be indicated when manipulating with
resources:
an attempt to create resource that already exists
This error type can appear only in the method Create(). For that type, there is the
class Psoft.HSphere.Resources.ResourceAlreadyExistsException
inherited from ResourceException. During the implementation of the Create()
method, you have to make sure that given exception is thrown in the situation when
the physical resource exists and from the point of view of the resource‟s logic it is
considered as an error. (For some resources, given condition may not be an error,
for example, an error that appears while adding an IP that has been already set up
before can be safely ignored).
an attempt to do an operation on the resource that doesn‟t exist
The second type of error conditions can appear in any method, but Create(). That
type of errors is described by the class
Psoft.HSphere.Resources.ResourceNotFoundException. During the
implementation of such methods, you have to make sure that those conditions are
taken care of, and that the exception is thrown.
an error in the data passed as parameters.
The third type of conditions is described by the class
Psoft.HSphere.Resources.ResourceInvalidParameterException. That
type is used to describe situations when the problem is created by incorrect data
entered by end user - to allow end user to fix them.
Class Resource has got a set of methods to generate exceptions of these types:
According to the Parallels H-Sphere logic, each resource belongs to a hierarchy of
resources. This hierarchy shows dependence of one resource on another. For
example, to create the virtual Web host resource, it is required to specify an account
name that will be the owner of that virtual host. It means that virtual host resource
depends on resource account, and stands below it in the hierarchy of resources.
During the development of resource class, you can specify the place of the resource in
the hierarchy using a special attribute. Even though the configuration of resource
attributes is located in the config file, each resource has access to only its own set of
attributes. Yet, it also inherits configuration parameters of its parent resource (in the
hierarchy). Therefore, resource gets configuration parameters of all its parents in
parameters collection.
This resource‟s quality does not depend on the instance of the resource, such as
configuration parameters are common for all instances of the resource.
There is another aspect of using resource hierarchy. The child resource can access
parent resource to retrieve parent resource‟s instance parameters. Each resource has
instance parameter which is its logical key. That parameter uniquely identifies the
instance of this resource. We can connect child resource with parent resource by
means of parameter from the instance parameters set, that has the same name as key
parameter. In such child resource we have access to instance of parent resource, using
the Parent attribute inherited from Resource:
public Resource Parent { get; }
Accordingly, by means of the Pkey attribute, physical key of the parent resource
instance can access the collection of parameters via the Params‟ property:
public Parameters Params {get; set;}
Logging
Each resource inherits the method Log that can be used for logging. The log output
will be placed in the common log file resource.log. The method has the following
signature:
protected void Log(string format, params object[] args)
Resource Types
Page 46
46 Windows Hosting Resources
Resources can be of two types: those that support listing and those that don‟t support
listing. In the case of listable resource, Parallels H-Sphere Windows engine will load all
instances of the resource into cache. Cache will be used to consequently retrieve
instances of the given resource. Listable resources do two important things: the
information is cached that allows to optimize the method Get(), and such resources
support automatic generation of new physical keys during creation of resource. If
resource has to support physical keys and it requires their automatic management,
resource has to be listable. To notify that resource is listable, you have to overload a
static method:
This method has to return list of physical keys for existing instances of resource. As
parameters, the value of physical key of corresponding parent resource is passed (if
there is no parent resource, or if parent resource doesn‟t support physical keys, the
parameter can be ignored), configuration resource parameters and log object.
Resources that don‟t support physical keys can be listable as well.
The method Enum has to return list of logical keys, as they are also physical keys for
those resources.
Listable resources support automatic access synchronization to their instances. They
also provide additional level of checking the existing resource during creation, and
missing resource check during other operations using cache. They will automatically
generate ResourceAlreadyExistsException or
ResourceNotFoundException exceptions.
Schemas
Schemas are used not only in resources, but we will discuss them only in the context of
Resource. Schemas are descriptions of attributes of a particular object. Schemas are
implemented by class Psoft.HSPhere.Configuraiton.Schema. Constructor of
the given class accepts XML string as a parameter. That XML string describes the
given schema. XML schemas consist of the following elements: schema tag, properties
tag (prop), attributes of properties. Schema tag contains a prop tag which can have
attribute tags. The prop tag has the following attributes:
name: required attribute, it defines name of the property
description: contains short description of the property
type: contains identifier of the property type. The following identifiers are supported:
str: string (default)
num: numeric
unum: non-signed numeric
bool: boolean
select: list (will be described bellow)
path: file system path
password: password
Page 47
Windows Hosting Resources 47
ip: IP address
domain: domain name
url: URL
mail: mailbox name
mask: IP mask
mac: MAC address
value: default value of the property
key: false by default. If false, it is not the key property. If true, property is a key
property.
Optional: false by default. If false the property is optional, otherwise it is required.
readonly: false by default. If false, the property can be changed (can be passed as
the parameter), if true, the property is read-only.
If parameter has the type select, this tag has to contain list of tags that describe values
of the list. Values by default are set to be equal to the name of the value.
There are two types of schemas for resources:
schemas that describe configuration parameters,
schemas that describe instance parameters.
A resource doesn‟t have to have a configuration parameters schema (for example, if it
doesn‟t have config parameters), but schema of instantace parameters must always be
defined.
Based on that schema, the input is validated on the presence of key and required
parameters. The default values are also set at that stage for missing parameters. If the
parameter is described in both config and instance schemas, then if parameter wasn‟t
passed (it is possible, if it was described as optional), the value for it will be taken from
the config file, otherwise, the input value has higher priority and is used as the
parameter. Examples of schemas are represented below in the chapter Attributes.
Attributes
Resource has a list of attributes, some of them are required. Attributes define
properties of the resource and define its behavior.
ResourceName
Required attribute that specifies logical name of the resource. It will be passed as the
name to invoke that resource by the CP.
Example: [ResourceName(“hosting”)]
PhysicalName
Required attribute that contains implementation name of the given logical resource.
Page 48
48 Windows Hosting Resources
Example: [PhysicalName(“iis5_website”)]
LKey
Required attribute that defines logical key for the resource, or, more specifically, the
name of the key parameter of the implementing class.
Example: [LKey(“hostname”, typeof(StrKey))]
ResourceDescription
Optional attribute that contains short description of the
resource.
Example: [ResourceDescription(“IIS 5.0 virtual web host”)]
Even though this attribute is not required, we highly recommend
using it.
ParentName
Optional attribute that contains logical name of the parent resource.
Example: [ParentName(“account”)]
This attribute defines the place of the resource in the resource hierarchy. If it is not
defined, the resource is considered to be root in the hierarchy.
ManagedPKey
Optional attribute. Shows if physical keys will be automatically managed.
Example: [ManagedPKey]
If the attribute is not defined, the resource has to generate unique physical keys. If the
resource doesn‟t support physical keys, this attribute is meaningless.
ResourceSchema
Optional attribute. Describes the configuration schema and input parameters of the
resource.
Example:
[ResourceSchema(
@”<schema>
<prop name=‟hostname‟ type=‟domain‟ description=‟Virtual web
host name‟/>
<prop name=‟ip‟ type=‟ip‟ description=‟Virtual web host IP‟/>
This attribute has two constructors. The first constructor accepts both schemas as
shown in the example. The second constructor is used for resources that don‟t have
configuration parameters and have only one schema.
Exclusive
Optional attribute. Specifies if synchronization should be used to access different
instances of the resource.
Example: [Exclusive]
If the attribute is not defined, synchronization will not be performed. If the resource is
listable, the attribute is ignored, because listable resources automatically support
synchronization.
Offline
Optional attribute. Shows that all the operation on the resource has to be performed
offline.
Example: [Offline]
Currently not implemented.
IgnoreExists
Optional Attribute. Affects the behaviour when there‟s an attempt to create an already
existing resource.
Example: [IgnoreExists]
If the attribute is set, the already existing condition is not considered to be an error.
Cacheable
Optional attribute. Affects the cache behaviour during data access from cache for
listable resources.
Page 51
Windows Hosting Resources 51
Example: [Cacheable(false)]
The default is true. If set to false, the data will not be caught. This can be useful for
resources with read-only parameters, such as “usage” for disk quota. For non-listable
parameters, this attribute is ignored.
CaseSensitive
Optional. Defines if logical keys are case sensitive.
Example: [CaseSensitive]
False by default.
Page 52
52 Windows Hosting Resources
Crash Reporting on Winbox
Parallels H-Sphere Winbox writes unhandled exceptions to files iis.log and
hssvc.log that are located in the <Parallels H-Sphere dir>\logs\crash
directory. The messages written to these logs aren‟t very informative and are barely
helpful in debugging unless you install the pdb package that complements error logs
with detailed debug information. To install the pdb package, see how to update Winbox
to the latest stable version. The pdb package can send crash reports to Positive
Software support - the installer will prompt you for the SMTP server.
Crash Record File Structure
Each crash record file is of the following structure:
the first line contains a crash date and crash description;
the rest of the lines contain a crash stack.
Example:
[26.07.2004 / 16:36:33] Thread: 27904; Access violation occurred in
module inetinfo (image )
at RtlAllocateHeap() in :line 0 (in module ntdll)
at () in :line 0 (in module htaccess)
at () in :line 0 (in module htaccess)
at () in :line 0 (in module htaccess)
at
?BuildURLMovedResponse@HTTP_REQ_BASE@@QAEHPAVBUFFER@@PAVSTR@@KH@Z() in
:line 0 (in module w3svc)
at
?BuildURLMovedResponse@HTTP_REQ_BASE@@QAEHPAVBUFFER@@PAVSTR@@KH@Z() in
:line 0 (in module w3svc)
at ?ResetSSLInfo@W3_SERVER_INSTANCE@@SGXPAX@Z() in :line 0 (in
module w3svc)
at ?Disconnect@CLIENT_CONN@@QAEXPAVHTTP_REQ_BASE@@KKHPAH@Z() in
:line 0 (in module w3svc)
at ?ScanForTerminator@@YGPAEPBD@Z() in :line 0 (in module w3svc)
at ?Copy@STR@@QAEHPBDK@Z() in :line 0 (in module w3svc)
at
?RemoveEntry@CDirMonitor@@QAE?AW4LK_RETCODE@@PAVCDirMonitorEntry@@@Z()
in :line 0 (in module ISATQ)
at () in :line 0 (in module )
Each crash stack line may contain:
information about the function being executed when the crash occurred;
source information, such as a source file‟s name and line‟s number
Note: to record Parallels H-Sphere module‟s source information the pdb package is
required (see the Parallels H-Sphere Winbox update instructions for details).
module name containing crashed function
Page 53
Windows Hosting Resources 53
Detecting Crashes in Parallels H-Sphere and non
Parallels H-Sphere Modules
The name of the module in the crash stack line indicates which module the crash
occurred in. The example above (in module htaccess) indicates that the crash occurred
in Parallels H- Sphere module. An empty module file‟s name, for example (in module)
indicates that the crash occurred in the main module.
When a crash occurs in any module, the crash report framework generates an
exception containing information about the crash. A crash in Parallels H-Sphere module
will trigger the exception and a record with Parallels H- Sphere module name will be
written to the report file, for example (in module htaccess). As non Parallels H-Sphere
modules can‟t catch the exception generated by the crash report framework, it will
return back to crash report as “C++ exception” and will be registered in the crash report
file immediately after the initial crash record. In this case two records will be written into
the report file: the initial crash record and the “C++ exception” record as shown in the
following example:
[26.07.2004 / 16:36:33] Thread: 3432; Access violation occured in
module w3wp (image )
at () in :line 0 (in module )
[26.07.2004 / 16:36:33] Thread: 3432; C++ exception occured in module
w3wp (image )
at RaiseException() in :line 0 (in module kernel32)
at () in :line 0 (in module htaccess)
at () in :line 0 (in module htaccess)
at UnhandledExceptionFilter() in :line 0 (in module kernel32)
at FlsSetValue() in :line 0 (in module kernel32)
Two records with the same crash date, time and crash description indicate that the
crash occurred in a non Parallels H-Sphere module.
Note: the time for the second record can differ by several seconds.
IIS 6.0 Native Mode
Parallels H-Sphere is compatible with IIS 6.0 native mode. Parallels H-Sphere
automatically switches IIS 6.0 to native mode during the installation or update
procedure. After this, you need to restart IIS to apply changes.
In addition, Parallels H-Sphere switches the identity of all existing application pools to a
Local System account instead of the default Network service account. It doesn‟t manage
application pools at this time, so if a new application pool is created, its identity should
be manually set to Local System account.
There are several ISAPI filters and IIS log plugins that are part of Parallels H-Sphere
which are implemented in the modules described below.
Page 54
54 Windows Hosting Resources
ISAPI Filters
Since IIS 6.0 in native mode has quite different architecture regarding the ISAPI filters
and log plugins, these modules were rewritten to accomplish compatibility with IIS 6.0
native mode simultaneously with IIS 5.0 support.
HsAuth.dll - ISAPI filter intended to realize several of web authentication schemes
such as web authentication for virtual accounts (for Serv-U users), web
authentication for FrontPage and cookie authentication.
Parallels H-Sphere uses a user account as an anonymous account for the user
domain instead of the standard built-in IUSR account to avoid unapproved content
changes. For SERV-U FTP, FrontPage reads the anonymous account settings for
the virtual host and treats this account as an account which has the anonymous
access to FrontPage. Therefore Parallels H-Sphere sets the Basic authentication to
the FrontPage virtual directories and installs the HSauth filter to authenticate the
user when he connects via FrontPage client.
HtAccess.dll - ISAPI filter intended to realize folder protect feature for WebShell 4.0.
Parallels H-Sphere does not support „ISAPI_Rewrite‟ filter because it processes the
URL and then changes it. But in the current security model of HTProtect work such
operation is not allowed . So „ISAPI_Rewrite‟ and „HTAccess‟ filters conflict with
each other when both are running in IIS.
SharedSSL.dll - ISAPI filter intended to realize Shared SSL functionality.
To process https requests, we created service virtual hosts for each IP where
shared SSL service is used, including dedicated IPs. A service virtual host home dir
contains virtual directories for websites that have shared SSL enabled. Such a
virtual directory bears the name of the third level domain alias and points to the
document root of the corresponding website. ISAPI shared SSL filter, which is
installed on every service virtual host, redirects https requests to the appropriate
virtual directory.
IIS Log Plugin
Now due to changes in Parallels H-Sphere log plugins, even currently modified HTTP
log files can be opened for writing or removed.
HsLogPlugin.dll - module which contains several IIS log plugin intended to realize stats
collecting on the fly, different schemes of web and ftp logging such as simple web
logging, transfer log, etc.
Page 55
Parallels H-Sphere XML API, written in Java, is designed to manage Parallels H-
C H A P T E R 5
Parallels H-Sphere XML API
Sphere services from remote applications via SOAP. It uses the Apache Axis
implementation of SOAP and runs under the Apache Tomcat engine.
Remote applications interact with CP services by means of XML-formatted requests
transferred via HTTP (direct TCP connection can also be set up). Error messages are
also processed in XML.
XML schema is based on the SOAP RPC convention: http://www.w3.org/TR/soap12/.
Mechanism of Interaction
XML API provides the following mechanism of communication between remote
applications and the Control Panel:
A remote Java application calls CP methods to perform particular actions (for
example, to create an account or to return the list of domains). For this, it invokes its
SOAP client to form the corresponding XML request and to http it to the Control
Panel;
the CP SOAP server receives this XML request, parses the request> and calls a
target Parallels H-Sphere service;
the target Parallels H-Sphere service performs actions according to the received
request (for example, creates an account or returns the list of domains), and
responds via the SOAP server to the remote application.
If the request is incorrect, the SOAP server returns XML with SOAP fault.
Therefore, though HTTP is used for data transfer, Parallels H-Sphere XML API services are
not called from a Web browser!
Where To Get Parallels H-Sphere XML API
For Java, you may download Parallels H-Sphere XML API from the following location:
Axis libraries: http://hsphere.parallels/shiv/HS/xml-api/Libraries.tgz
Parallels H-Sphere Java XML API library: http://hsphere.parallels.com/shiv/HS/xml-
api/hsphereXMLApi.jar
Sample Java classes for testing Parallels H-Sphere XML API functionality:
For other programming languages (for Java as well), you can use WSDL file to
implement Parallels H-Sphere XML API services in this language. See how to generate
WSDL via Axis (on page 57).
Page 56
56 Parallels H-Sphere XML API
Here you may find a sample Parallels H-Sphere signup form written in PHP 5 (which
In this chapter:
Enabling Parallels H-Sphere XML API ............................................................... 57
Testing Parallels H-Sphere XML API ................................................................. 58
Getting the List of Available XML API Services ................................................. 60
Generating WSDL Files for Parallels H-Sphere XML API Services .................... 61
Parallels H-Sphere XML API Security Settings .................................................. 61
has an embedded SOAP client) using Parallels H-Sphere XML API:
Actions supported by XML API are grouped by services:
Admin Services - basic admin services: adding new accounts, etc.
User Services - basic user services: getting account information
Domain Services - creating/deleting domains and subdomains
Web Services - managing Web options
FTP Services - managing FTP options
User FTP Services - managing user FTP resources: subusers, passwors, etc.
DNS Services - managing DNS
Mail Services - creating/deleting mailboxes, mailing lists, autoresponders, mail
forwards, etc.
MySQL Services - managing MySQL databases and users
PostgreSQL Services - managing PostgreSQL databases and users
MSSQL Services - managing MSSQL databases and users
Support Services - managing trouble tickets (Parallels H-Sphere support center)
Migration Services - migrating users and resellers by means of corresponding XML
forms
PGP Services - PGP encryption/decryption in Parallels H-Sphere trouble tickets
See the XML API services documentation generated by the Javadoc tool:
Note: When generating AuthToken for reseller, in addition to defining reseller‟s
accountID, login and password, set also login in the Role to “” (empty) and account id
in the Role to “0”.
Page 57
Parallels H-Sphere XML API 57
Enabling Parallels H-Sphere XML API
Parallels H-Sphere XML API is designed to manage Parallels H-Sphere services via
SOAP protocol. It is based on Apache Axis implementation of SOAP
(http://ws.apache.org/axis/index.html) and runs under Apache Tomcat engine.
You can download (on page 55) Axis libraries and the latest version of XML API
libraries.
Warning: Parallels H-Sphere XML API is an experimental feature. Please be careful in
using it for critical tasks!
To enable XML API in Parallels H-Sphere:
1. Log into the CP server as the cpanel user (on page 76).
2. Edit the
~cpanel/shiva/psoft_config/allow_access.properties file
to grant access to CP server via SOAP port from external IPs (on page
After that, XML API will be available. You may wish to test if it works correctly by
means of our test Java classes that use Parallels H-Sphere XML API:
your_cp_host is your CP host domain (CP_HOST in hsphere.properties)
your_cp_url_path is usually psoft/servlet if not configured otherwise in your CP
server‟s Tomcat configuration.
If this doesn‟t work, check servlet mapping in your Tomcat configuration:
1. Log into the CP server as the cpanel user (on page 76).
2. Open the ~cpanel/hsphere/WEB-INF/web.xml file for edition.
3. Make sure the following lines are present in the file:
Example: Parallels H-Sphere XML API signup form implementation in PHP 5 (SOAP
client embedded) via WSDL: http://hsphere.parallels.com/HSdocumentation/xmls/xml-
api/hs_xml_api_signup_example.tgz.
Parallels H-Sphere XML API Security
Settings
In order to tighten Parallels H-Sphere XML API security, the
psoft.hsphere.axis.AxisAccessFilter class is created, implementing the
javax.servlet.Filter interface. This filter allows to check incoming request to a
certain servlet to match some condition BEFORE passing it to the servlet, and allows to
wrap/change request/response.
When the filter is turned on, the following lines are added into the <web-app> tag in
the ~cpanel/hsphere/WEB-INF/web.xml file:
where AxisServletName is Axis servlet name (usually, AxisServlet) and
axis_access_filter is the filter‟s name.
Granting SOAP Access from Remote IPs
Page 62
62 Parallels H-Sphere XML API
AxisAccessFilter checks if remote IP address of incoming request is specified in the
~cpanel/shiva/psoft_config/allow_access.properties file. If this IP is in
the file, the request will be passed to Axis servlet. Otherwise the response will return
the 403 error.
If the file does not exist, SOAP access is blocked for all IPs.
allow_access.properties has the following format:
To set the list of IPs (semicolon-separated):
ACCESS_ALLOW = ip1;ip2;ip3;...
To grant SOAP access from all IPs:
ACCESS_ALLOW = ALL
Page 63
This chapter dwells on developer tools for adding new payment gateways and domain
In this chapter:
Web Payment SDK ........................................................................................... 64
Adding Custom Payment Gateways and
Domain Registrars
registration services into H-Sphere.
Page 64
64 Adding Custom Payment Gateways and Domain Registrars
Web Payment SDK
Parallels H-Sphere Web Payment SDK is a development tool to integrate Web payment
systems as installable Parallels H-Sphere packages (.hsp). The SDK allows
developing and testing Web payment packages outside Parallels H-Sphere.
To use Web payment SDK, make sure you have the following software installed:
Java 1.3 or higher: http://java.sun.com/
Apache Ant 1.5 or higher - a Java-based build tool: http://ant.apache.org/
JUnit - a framework to write repeatable tests: http://junit.sourceforge.net/
Read about .hsp package installation in Parallels H-Sphere Customization Guide.
Domain Registrar SDK
Parallels H-Sphere Registrar SDK is a toolkit to integrate domain registration services
(domain registrars) as installable Parallels H-Sphere packages (.hsp). The SDK allows
developing and testing gateway packages outside Parallels H-Sphere.
To use Registrar SDK, make sure you have the following software installed:
Java 1.3 or higher: http://java.sun.com/
Apache Ant 1.6 or higher - a Java-based build tool: http://ant.apache.org/
JUnit - a framework to write repeatable tests: http://junit.sourceforge.net/
Read about .hsp packages in Parallels H-Sphere Customization Guide.
Merchant Gateway SDK
Page 65
Adding Custom Payment Gateways and Domain Registrars 65
Parallels H-Sphere Merchant Gateway SDK is a development tool to integrate
merchant gateways as installable Parallels H-Sphere packages (.hsp). The SDK allows
developing and testing gateway packages outside Parallels H-Sphere.
To use Merchant Gateway SDK, make sure you have the following software installed:
Java 1.3 or higher: http://java.sun.com/
Apache Ant 1.6.1 or higher - a Java-based build tool: http://ant.apache.org/
JUnit - a framework to write repeatable tests: http://junit.sourceforge.net/
applications to Parallels H-Sphere. The goal of SDK is to provide the developer with the
ability to generate Parallels H-Sphere package without programming any java or html
UI code. It should be useful to integrate applications like phpBB2, Mambo, phpMyChat,
b2evolution, PHPnuke, etc.
The user gets a web installer which collects application installation data (db username,
db password, email, etc.), then writes it to config files and populates app database with
the specified dump.
Positive Software offers its own collection of over 30 popular PHP/MySQL applications.
They are available for download: http://www.psoft.net/downloads#easyapp.
Page 67
EasyApp SDK 67
Building EasyApp Packages for Unix
Hosting
To build an EasyApp package for Unix with a custom collection:
1. Download and install:
Java 1.3 or higher: http://java.sun.com/
Apache Ant 1.5 or higher - a Java-based build tool: http://ant.apache.org/
JUnit - a framework to write repeatable tests (recommended but optional):
6. Setup a separate directory inside the collections directory for each
application that you want to include into the package.
7. Create main.xml (on page 71) descriptor in the application directory for
each application you want in the package.
8. Place application tarball in the application directory (.tar.gz, .tgz, .zip
extensions are supported)
9. Place application configs, sql templates, and logo into the application
directory.
10. Inside the collections directory create collection.xml (on page 70) file.
11. Inside the collections directory, create hsphere_lang language file
with all the labels used.
12. Place icons for different Parallels H-Sphere designs into the collections
directory. The icons must represent your package on the home page of
the user control panel.
Page 68
68 EasyApp SDK
13. Set up a .yafv file for the collection file.
14. Type:
ant
As the result, you should get a Parallels H-Sphere package in the pkg/ directory.
Now you can install the package according to our documentation on package
installation.
Page 69
Building EasyApp Packages for Windows
Hosting
To build an EasyApp package for Winbox with a custom collection:
1. Download the latest version of WiX and install it:
http://sourceforge.net/projects/wix/.
2. Download NAnt 0.85RC3 or older and install it: http://nant.sourceforge.net/.
3. Register paths to WiX and NAnt tools in the PATH environment variable.
4. Register path to the currently used .NET Framework in the DOTNETDIR
5. Download the EasyApp_MSI_SDK_hs-version-code_build.zip file from the
EasyApp MSI SDK download directory:
http://hsphere.parallels.com/HSdocumentation/sdk/easyapp-msi-sdk/, where
hs-version-code is your Parallels H-Sphere Winbox version code (for example,
243p7, 250b4, 250rc1), and build is the latest available build number for this
EasyApp MSI SDK version. Then, unzip the downloaded archive to any
appropriate location.
6. Create the EasyApp directory for EasyApp MSI SDK.
7. Create the easyapp-col directory inside the EasyApp directory.
8. Setup a separate directory inside the easyapp-col directory for each
application that you want to include into the package.
9. Create the main.xml (on page 71) descriptor in the application directory for
each application you want in the package.
10. Place application tarball in the application directory (.tar.gz, .tgz,
.zip extensions are supported)
11. Place application configs, sql templates, and logo into the application
directory.
12. Inside the easyapp-col directory create the collection.xml (on page 70)
file.
13. Inside the easyapp-col directory, create hsphere_lang.properties
language files with all the labels used.
14. From the EasyApp MSI SDK directory type:
nant
An MSI package should be created in this directory.
Page 70
Now you can install the package according to our documentation on EasyApp MSI installation
Tag
Description
id
the type id of the resource in Parallels H-Sphere, e.g.
20011. For Parallels H-Sphere packages, we use IDs
starting with 20000, 20000 to 20010 are already
taken. Third party developers must reserve IDs in
http://www.psoft.net/my-hsphere/
name
the name of the resource, e.g. easyapp
descripti
on
will be used as resource description
version
package version
group
application category. The ID of the application is
added to the custom template filename for each
application, e.g. info-19.html, install-19.html etc.
lang
language files bundled with the package
icon
icons representing the package resource in different
Parallels H-Sphere designs
menu
where in the menu the link will show
in Parallels H-Sphere Administrator Guide.
EasyApp SDK Collection Descriptor
collection.xml is located in the collections directory (typically easyapp-col/) and
stores information about the applications included in the package.
Page 71
EasyApp SDK Descriptor
Tag
Description
name
the name of the project (alphanumeric), will be used as
resource type in h-sphere
description
will be used as resource description
version
Application version
title
label to use as a title of the application
intro
label to use as basic decription/intro for the app
tarball
name of the tarball/bundle within the application. File under
the same name should be in application directory
size
disk space that script requires, in MB
license
attribute type=”XXX” - specifies the license type, value
specifies URL to the license. If known type is used, no url is
necessary. Known types: “GPL”, “BSD”, “MPL”
homepage
url to application homepage
donation
url to donation page
documentat
ion
url to documentation page
forum
url to support forum
logo
image name - logo image, should be present in the
application directory
variables
(on page
73)
list of configurational parameters/variables user will be
prompted with during install/or when he wants to change
parameters
install
list of actions (on page 74) to perform during the installation
of application; it can contain optional done tag that
describes actions performed at the end of the installation, if
any. It can include other tags:
iframe - link to the original installation page the user will
be taken to at some stage of the installation. You can
use this tag if it‟s too complicated to perform the entire
For each application you want to package via EasyApp SDK, you need to create a descriptor.
Inside application directory create main.xml. The file starts with app tag.
There are several tags inside:
Page 72
procedure in Parallels H-Sphere.
access - gives link to application or its parts the user will
be taken to after the installation is finished, e.g. page of
the application‟s administrator.
change
list of actions (on page 74) to perform on change
uninstall
list of actions (on page 74) to perform on uninstall
upgrade
attribute from=”XXX” - where XXX is previously defined
version. There can be multiple upgrade tags, from different
versions. Inside upgrade tag, there is actions (on page 74)
tag for actions to perform during upgrade. The tag is used
to automate upgrades of the application
lang
language files bundled with package.
Sections
<lang> - Specifies which lang file must be used for this application
<install>,<remove> - Describes the actions that constitute install/uninstall of the application
software.
<upgrade> - Used for possible autoupgrades, just like in <install>, <uninstall>, and
<change>, but in the title requires the number of the version you upgrade from. Example:
<upgrade from=”2.9.7”>
Here is an example of descriptor for Mambo server:
Generator Helper is a set of classes that simplify the development of various Parallels HSphere SDK. It is based on Velocity engine for templating and XML files for descriptors - and
manages setup of necessary directory structure as well as generation of various package
config files, including _pkg.xml, design_config.xml, menu.xml, language files,
property file, etc...
The toolkit can be retrieved from CVS via the GeneratorHelpers repository. It contains
README file that explains how to use it.
Download Generator Helper:
The following attributes can be defined for each field:
Page 74
EasyApp SDK Actions
Actions
Parameters
Description
uncompres
s
target - directory where to
place uncompressed files
uncompresses default tarball, and moves file
into target directory below webspace for
selected domain
remove
target - directory to
remove
removes files from the directory under the
given domain name
sql
mysql - mysql var, value
corresponds to target
template
processed defined template, and uses it as
SQL to import into specified db. SDK will
automatically include template into the
package
config
target - where to place
config file, name - config
file name, value =
template to use
Processes template and places it under
domain/target/name, automatically
stores template in package
move_safe
from - target directory
inside domain, to directory in the safe zone
takes
domain/place_where_app_installed/
from directory and moves it under
safe_zone/to directory outside of the web
accessible space.
remove_sa
fe
target - directory to
remove, in the safe zone
removes directory in safe zone
config_safe
target - where to place
config file, name - config
file name, value =
template to use
same as config, but in safe zone
EasyApp can perform actions to install/uninstall/upgrade software. There are several defined
actions:
safe zone - each easyapp can have the safe_zone directory, where it can store files outside
of the web accessible space.
Page 75
In this chapter:
Logging in as the cpanel User ........................................................................... 76
Restarting Parallels H-Sphere Control Panel ..................................................... 76
C H A P T E R 8
Appendix
Page 76
76 Appendix
Logging in as the cpanel User
Parallels H-Sphere control panel runs under the cpanel user on the CP server. You
need to log in as cpanel to perform many administrative tasks, such as CP
configuration, customization, access the system databse, running console Parallels HSphere java tools, and many others.
Under cpanel, Parallels H-Sphere control panel communicates with other Parallels HSphere boxes via SSH.