View Source

The following example demonstrates how to create a Volume, a Power User assigned to this Volume, and an Agent assigned to this User. In this case, Power Users are not allowed to create Sub-Users.

A PHP file called {{Volumes_With_Limits_Power_User_No_Sub_User_Allowed.php}} can be found in {{<installdir>/apisamples}}. Read more in [Accessing Example API Functions].

The PHP script creates objects with the defined options in the system and prints the following result messages on the screen:
* "Successfully created volume" or "Failed to create volume"
* "Successfully created power user" or "Failed to create power user"
* "Successfully executed created Agent" or "Failed to create Agent"

h4. Sequence of Automated Actions

The following steps can be accomplished by using this script:

# Create a Volume.
# Create a Power User with attributes. Assign the Volume to the newly created Power User.
# Create an Agent. Make the newly created Power User its owner.

h4. How to Fulfill Appropriate Actions in CDP User Interface

Below, you can find the steps to perform these actions using the program user interface. Screen shots are provided to illustrate the scripts for each step.

----
{toc:location=top|maxLevel=5|minLevel=5|type=flat|separator=pipe|style=border:1}
----
h5. Defining server configuration variables

{code}########====CDP Server Configuration Start====########
#set CDP server host name
$HOST="127.0.0.1";
#set CDP server to access API
$PORT="9443";
#set CDP user
$USER="admin";
#set CDP user password
$PASS="admin";
########====CDP Server Configuration End====########{code}

Log in to the CDP Server user interface using your username and password.

!1.png!

h5. Creating a Volume

{code}########====Create Volume Start====########

$volume->name = "volumeName";
$volume->description = "volumeDescription";
$volume->path = "C:/volumePath";

$volume->quotaType = "ON_DISK_SIZE";
// If Quota is NONE then unset soft and hard quota
$volume->softQuota = "1000000";
$volume->hardQuota = "2000000";

$MAP = array(
array( key => "FILE_EXCLUDES_ENABLED", value => "true"),
array( key => "ARCHIVING_ENABLED", value => "false"),
array( key => "CONTROLPANELS_ENABLED", value => "true"),
array( key => "REPLICATION_FREQUENCY_LIMIT", value => "HOURLY"),
# RECOVERY_POINT_LIMIT set the value to "-1" to disable recovery point limit
array( key => "RECOVERY_POINT_LIMIT", value => "-1"),
# ARCHIVE_POINT_LIMIT set the value to "-1" to disable archive point limit
array( key => "ARCHIVE_POINT_LIMIT", value => "-1"),
array( key => "CREATE_DIRECTORY", value => "true")
);

$volume->volumeAttributeMap = $MAP;


try{
$volumeClient = new soapclient("https://$HOST:$PORT/Volume?wsdl",
array('login'=>"$USER",
'password'=>"$PASS",
'trace'=>1,
'cache_wsdl' => WSDL_CACHE_NONE,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS)
);

$createdVolume = $volumeClient->createVolumeWithObject(array('volume'=>$volume));

echo "Successfully created volume\n";

}
catch (SoapFault $exception)
{
echo "Failed to create volume \n";
echo $exception;
exit(1);
}


########====Create Volume End====########{code}
1. Click on "Volumes" in the Main Menu to access the Volumes page.

!volumes-menu.png!

2. Then click "Create New Volume" in the Volumes menu located in the top left area of the interface.

!create-new-vol.png!

3. Define the following Identification options:

* *Name* \- Volume name used to identify the Volume in the system. For example, to assign a Volume to the Disk Safe, you need to select a Volume name from the drop-down menu.
* *Description* \- Additional information describing the Volume. The Description is displayed in the Volumes list.
* *Volume Path* \- New or existing folder. The assigned Disk Safes will be placed in this folder.

!vol-ident.png!

4. Define the "Replication Limit" as "Hourly," and specify the "Soft Quota" and "Hard Quota." Set the "Allow File Excludes" option to "True," un-check the rest of the options, and click "Save."

!vol-limits.png!

5. Click "OK" in the "Warning" window to create a directory.

!dir-create.png!

6. Click "OK" in the "Success" window to complete the process.

!vol-created.png!

h5. Creating a Power User

{code}########====Create Power User Start====########

$user->username = "powerWithLimit_UserName";
$user->password = "password";
$user->userType = "POWER_USER";
$user->emailAddress = "userName@domain.com";
$user->volumeIDs = array($createdVolume->return->id);
$user->userAttributes = array(
#Indicates whether or not the power-user has the ability to create and administrate agents on the CDP server.
array( "key" => "CAN_ADMIN_AGENTS", "value" => "true"),

#If the power-user can create agents, a limit on the maximum number of agents can be set.
array( "key" => "MAX_AGENT_COUNT", "value" => 2),

#If the power-user can create agents, a limit on the maximum number of MySQL add-ons the power-user
array( "key" => "MAX_MYSQL_ADDON_COUNT", "value" => 2),

#If the power-user can create sub-users, a limit on the maximum number of sub-users can be set.
# This give the power user permission to create two sub users (for resellers)
array( "key" => "CAN_ADMIN_SUBUSERS", "value" => "false")
);

try{

$client = new soapclient("https://$HOST:$PORT/User?wsdl",
array('login'=>"$USER",
'password'=>"$PASS",
'trace'=>1,
'cache_wsdl' => WSDL_CACHE_NONE,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS)
);

);
$createdUser = $client->createUserWithObject(array( 'user' => $user));
echo "Successfully created power user\n";
}
catch (SoapFault $exception)
{
echo "Failed to create power user \n";
echo $exception;
exit(1);
}

########====Create Power User End====########{code}

1. Click on "Users" in the Main Menu to access the Volumes page.

!users-menu.png!

2. In the "Users" menu, click on "Create New User."

!create-new-user.png!

3. Define the new User properties in this window:
* *Username* \- Enter User login name.
* *Password* \- Enter a password for the User account.
* *Confirm Password* \- Reenter the same password for the User account.
* *Email Address* \- Enter email address of the User.
* *User Type&nbsp;* \- Choose the type of User: Power-User.

Un-check the following option:
* *User can create and administrate sub-users*

Select the following check-box:
* *User can create and administrate agents*
** *Restrict maximum agent count*&nbsp;(Set to "2").
** *Restrict maximum My-SQL add-on count* (Set to "2").

!create-user-window.png!

4. Add the previously created Volume in the "Volumes" tab.

!vol-added.png!

5. Click "Create."

6. Click "OK" in the "Success" window.

!created-user.png!

h5. Creating an Agent

{code}########====Create Agent Start====########

##Add all the basic properties to the agent object

# Description of agent
$agentObj->description = "agentDescription";
# Host name of the agent ( It can be an IP or name )
$agentObj->hostname = "127.0.0.1";
# port number on whcih the agent will connect to the CDP server
$agentObj->portNumber = 1167;
# Set the agent OS type (ex: LINUX or WINDOWS) see Java Doc for more details
$agentObj->osType = "WINDOWS";
#set database addon to true if you have a database addon license and you want to backup a database
$agentObj->databaseAddOnEnabled = true;

$agentObj->ownerId = $createdUser->return->id;
$agentObj->ownerPermissions = array("FULL_CONTROL");
try{
$agentClient = new soapclient("https://$HOST:$PORT/Agent?wsdl",
array('login'=>"$USER",
'password'=>"$PASS",
'trace'=>1,
'cache_wsdl' => WSDL_CACHE_NONE,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS)
);

$createdAgent=$agentClient->createAgentWithObject(array('agent'=>$agentObj));
echo "Successfully executed created Agent\n";

}
catch (SoapFault $exception)
{
echo "Failed to create agent \n";
echo $exception;
exit(1);
}

########====Create Agent End====########

?> {code}
1. Click on "Agents" in the Main Menu to access the "Agents" page.

!menu-agents.png!

2. Then click "Create New Agent" in the Agents menu located in the top left area of the interface.

!create-new-agent.png!

3. The "Create New Agent" window will appear. You will need to define the following options:
* *Name* \- Enter a name for the Agent. It will be displayed in the "Agents" List. In this case, it is "agentDescription."
* *Host Name* \- Enter the Host Name or IP address of the Agent. In this case, it is 127.0.0.1.
* *Port Number* \- Define a Port to connect to the Agent, if different from the default value (1167).

To assign an Agent owner, choose the previously-created Power User's username from the drop-down list, and set permissions to "Full Control."

!agent-window.png!

4. Click "Create."

5. Click "OK" in the "Success" window.

!created-agent.png!