Storage-as-a-Service Integration Guide

Table Of Contents
Acronis Storage 2.2
Storage-as-a-Service Integration
Guide
August 11, 2017

Summary of content (76 pages)

’; } // Show user. if ($_SESSION[’s3_query_user’] == 1) { // Table header. $result = $result .

  • PAGE 40

    4.1. Requirements AWSSecretAccessKey ’; // One row per access key pair. foreach ($_SESSION[’s3_aws_access_keys’] as $s3_row) { $result = $result . ’ ’ . $s3_row[’AWSAccessKeyId’] . ’ ’ . $s3_row[’AWSSecretAccessKey’] . ’ ’; } // Table footer. $result = $result . ’ ’; } // Table footer and next header. $result = $result . ’

    ’; // Show statistics list.

  • PAGE 41

    Chapter 4. Integration with WHMCS

    S3 Statistics List
    ’; // One row per access key pair. foreach ($_SESSION[’s3_stat’][’items’] as $s3_object) { $result = $result . ’ ’; } // Table footer. $result = $result . ’
    Object Name
    ’ . $s3_object . ’
    ’; } // Show limits for user.

  • PAGE 42

    4.1. Requirements

    ’; // One row per access key pair. foreach ($_SESSION[’s3_limits_user’] as $s3_limits => $s3_value) { list($s3_type, $s3_limit) = explode(”:”, $s3_limits); $result = $result . ’ ’; } // Table footer. $result = $result .

  • PAGE 43

    Chapter 4. Integration with WHMCS

    S3 Limits for Bucket: ’ . $_SESSION[’s3_bucket’] . ’
  • Type Name Value
    ’ . $s3_type . ’ ’ . $s3_limit . ’ ’ . $s3_value . ’
    ’; // One row per access key pair. foreach ($_SESSION[’s3_limits_bucket’] as $s3_limits => $s3_value) { list($s3_type, $s3_limit) = explode(”:”, $s3_limits); $result = $result . ’
    Type Name Value
    ’ . $s3_type .

  • PAGE 44

    4.1. Requirements

    ’; // Show statistics for object. if (!empty($_SESSION[’s3_object_statistic’])) { // Table header. $result = $result . ’
    S3 Statistics for Object: ’ . $_SESSION[’s3_object’] .

  • PAGE 45

    Chapter 4. Integration with WHMCS

  • ’ . $_SESSION[’s3_object_statistic’][’fmt_version’]. ’ ’ . $_SESSION[’s3_object_statistic’][’service_id’]. ’ ’ . $_SESSION[’s3_object_statistic’][’start_ts’]. ’ ’ . $_SESSION[’s3_object_statistic’][’period’]. ’ ’ . $s3_object[’key’][’bucket’] . ’ ’ . $s3_object[’key’][’epoch’] . ’ ’ . $s3_object[’key’][’user’] . ’ ’ . $s3_object[’key’][’tag’] . ’ ’ .

  • PAGE 46

    4.1. Requirements // Modify admin area. add_hook(’AdminAreaClientSummaryPage’, 1, ”S3_adminAreaClientSummaryPage”); ?> 4.1.4 Statistics You need to have statistics collection enabled on your S3 gateway. The S3 gateway will save the statistics as regular storage objects. On each S3 storage node, create a file /var/lib/ostor/local/gw.conf with the following contents: # Enable usage statistics collection. S3_GW_COLLECT_STAT=1 Restart the S3 storage service to apply the configuration changes.

  • PAGE 47

    Chapter 4. Integration with WHMCS 4.2 Managing S3 Users in WHMCS This section describes how to manage users in WHMCS in a service provider scenario. New customers will sign up for the service during purchase in your online store and you will need to create users for them in the S3 cluster. Create all files mentioned further in the directory whmcs/admin/AcronisStorage. 4.2.1 Creating S3 Users You can create a user with the ostor-users service and parameter emailAddress specifying the user email address.

  • PAGE 48

    4.2. Managing S3 Users in WHMCS $s3_config[’s3_secret’], $s3_config[’s3_gateway’], ”/?ostor-users&emailAddress=” . $s3_whmcs[’email’], ”PUT” ); // Add note with the s3 access key and s3 secret. S3_addClientNote( $s3_whmcs[’userid’], $s3_config[’whmcs_username’], $s3_client[’UserId’], $s3_client[’AWSAccessKeys’][’0’][’AWSAccessKeyId’], $s3_client[’AWSAccessKeys’][’0’][’AWSSecretAccessKey’] ); // Redirect back. header(’Location: ’ . $_SERVER[’HTTP_REFERER’]); } // Call function.

  • PAGE 49

    Chapter 4. Integration with WHMCS 4.2.2 Listing S3 Users You can list information about all users with the ostor-users service. Additional rows may list S3 access key pairs associated with the user. WHMCS lists the users information fetched from S3 cluster when you click List Users (on/off). Create a file S3_listUsers.php with the following contents:

  • PAGE 50

    4.2. Managing S3 Users in WHMCS // Hide. $_SESSION[’s3_list_users’] = 0; // Redirect back. header(’Location: ’ . $_SERVER[’HTTP_REFERER’]); // Return immediately. return; } // Load configuration. $s3_config = s3_getConfig(); // Get s3 users. $s3_client = S3_requestCurl( $s3_config[’s3_key’], $s3_config[’s3_secret’], $s3_config[’s3_gateway’], ”/?ostor-users”, ”GET” ); // Store s3 result. $_SESSION[’s3_list_users’] = 1; $_SESSION[’s3_list’] = $s3_client; // Redirect back. header(’Location: ’ .

  • PAGE 51

    Chapter 4. Integration with WHMCS 4.2.3 Querying S3 Users You can display information and status of a user with the ostor-users service and parameter emailAddress specifying the user email address. WHMCS displays the user information fetched from S3 cluster when you click Query User (on/off). Create a file S3_queryUser.php with the following contents:

  • PAGE 52

    4.2. Managing S3 Users in WHMCS if ($_SESSION[’s3_query_user’] == 1) { // Hide. $_SESSION[’s3_query_user’] = 0; // Redirect back. header(’Location: ’ . $_SERVER[’HTTP_REFERER’]); // Return immediately. return; } // Load configuration. $s3_config = s3_getConfig(); // Get whmcs user email. $s3_whmcs = S3_getClient($userid, $s3_config[’whmcs_username’]); // Get s3 user id. $s3_client = S3_requestCurl( $s3_config[’s3_key’], $s3_config[’s3_secret’], $s3_config[’s3_gateway’], ”/?ostor-users&emailAddress=” .

  • PAGE 53

    Chapter 4. Integration with WHMCS // Call function. S3_queryUser($_GET[’userid’]); ?> 4.2.4 Disabling S3 Users You can disable users with the ostor-users service and parameter emailAddress specifying the user email address. WHMCS disables read and write access to S3 cluster when you click Disable User. Create a file S3_disableUser.php with the following contents:

  • PAGE 54

    4.2. Managing S3 Users in WHMCS // Disable user. function S3_disableUser($userid) { // Load configuration. $s3_config = s3_getConfig(); // Get whmcs user email. $s3_whmcs = S3_getClient($userid, $s3_config[’whmcs_username’]); // Disable user. $s3_client = S3_requestCurl( $s3_config[’s3_key’], $s3_config[’s3_secret’], $s3_config[’s3_gateway’], ”/?ostor-users&emailAddress=” . $s3_whmcs[’email’] . ”&disable”, ”POST” ); // Redirect back. header(’Location: ’ . $_SERVER[’HTTP_REFERER’]); } // Call function.

  • PAGE 55

    Chapter 4. Integration with WHMCS

  • PAGE 56

    4.2. Managing S3 Users in WHMCS 4.2.6 Deleting S3 Users You can delete users with the ostor-users service and parameter emailAddress specifying the user email address. WHMCS removes the user from S3 cluster when you click Delete User. Create a file S3_deleteUser.php with the following contents:

  • PAGE 57

    Chapter 4. Integration with WHMCS $s3_config[’s3_key’], $s3_config[’s3_secret’], $s3_config[’s3_gateway’], ”/?ostor-users&emailAddress=” . $s3_whmcs[’email’], ”DELETE” ); // Delete note with the s3 access key and s3 secret. S3_delClientNote( $s3_whmcs[’userid’], $s3_config[’whmcs_username’], $s3_client[’UserId’], ”” ); // Redirect back. header(’Location: ’ . $_SERVER[’HTTP_REFERER’]); } // Call function. S3_deleteUser($_GET[’userid’]); ?> 4.2.

  • PAGE 58

    4.2. Managing S3 Users in WHMCS require(’../../includes/AcronisStorage/S3_getConfig.php’); require(’../../includes/AcronisStorage/S3_requestCurl.php’); require(’../../init.php’); // Generate s3 access key pair. function S3_generateAccessKey($userid) { // Load configuration. $s3_config = s3_getConfig(); // Get whmcs user email. $s3_whmcs = S3_getClient($userid, $s3_config[’whmcs_username’]); // Generate s3 key pair.

  • PAGE 59

    Chapter 4. Integration with WHMCS // Call function. S3_generateAccessKey($_GET[’userid’]); ?> 4.2.8 Revoking S3 Access Keys You can revoke the specified access key pair of the specified user with the ostor-users service and the following parameters: emailAddress specifying the user email address, revokeKey specifying the access key in the key pair. WHMCS removes the key pair when you click Revoke Access Key. Create a file following contents:

  • PAGE 60

    4.2. Managing S3 Users in WHMCS require(’../../init.php’); // Revoke s3 access key pair. function S3_revokeAccessKey($userid) { // Load configuration. $s3_config = s3_getConfig(); // Get whmcs user email. $s3_whmcs = S3_getClient($userid, $s3_config[’whmcs_username’]); // Get first s3 access key. $s3_client = S3_requestCurl( $s3_config[’s3_key’], $s3_config[’s3_secret’], $s3_config[’s3_gateway’], ”/?ostor-users&emailAddress=” . $s3_whmcs[’email’], ”GET” ); // Revoke s3 access key.

  • PAGE 61

    Chapter 4. Integration with WHMCS $s3_client[’AWSAccessKeys’][’0’][’AWSAccessKeyId’] ); // Redirect back. header(’Location: ’ . $_SERVER[’HTTP_REFERER’]); } // Call function. S3_revokeAccessKey($_GET[’userid’]); ?> 4.3 Managing S3 User and Bucket Limits in WHMCS This section describes limits you can define for users and buckets in WHMCS. You can apply the limits according to specific options that can be a part of your service plan. 4.3.

  • PAGE 62

    4.3. Managing S3 User and Bucket Limits in WHMCS // Set s3 user limits. function S3_setLimitsForUser($vars) { // Load configuration. $s3_config = s3_getConfig(); // Get whmcs user email. $s3_whmcs = S3_getClient($vars[’userid’], $s3_config[’whmcs_username’]); // Set only if value specified. if (!empty($vars[’ops-value’])) { // Set s3 bucket limits (ops). S3_requestCurl( $s3_config[’s3_key’], $s3_config[’s3_secret’], $s3_config[’s3_gateway’], ”/?ostor-limits&emailAddress=” . $s3_whmcs[’email’] .

  • PAGE 63

    Chapter 4. Integration with WHMCS ’&limit-value=’ . $vars[’bandwidth-value’], ”PUT” ); } // Redirect back. header(’Location: ’ . $_SERVER[’HTTP_REFERER’]); } // Call function. S3_setLimitsForUser($_GET); ?> 4.3.2 Querying User Limits You can display the current limits with the ostor-limits service and parameter emailAddress specifying the email address. WHMCS displays the user limits in S3 cluster when you click the Get button. Create a file S3_getLimitsForUser.

  • PAGE 64

    4.3. Managing S3 User and Bucket Limits in WHMCS

  • PAGE 65

    Chapter 4. Integration with WHMCS ?> 4.3.3 Deleting User Limits You can delete the current limits with the ostor-limits service and parameter emailAddress specifying the email address. WHMCS removes the user limits from S3 cluster when you click the Delete button. Create a file S3_deleteLimitsForUser.php with the following contents:

  • PAGE 66

    4.3. Managing S3 User and Bucket Limits in WHMCS // Clear array. $_SESSION[’s3_limits_user’] = null; // Redirect back. header(’Location: ’ . $_SERVER[’HTTP_REFERER’]); } // Call function. S3_getLimitsForUser($_GET[’userid’]); ?> 4.3.4 Setting Buckets Limits You can limit operations rate with the ostor-limits service and the following parameters: bucket specifying the bucket name, default=, get=, put=, list=, delete= specifying the limit value.

  • PAGE 67

    Chapter 4. Integration with WHMCS if (!empty($vars[’ops-value’])) { // Set s3 bucket limits (ops). S3_requestCurl( $s3_config[’s3_key’], $s3_config[’s3_secret’], $s3_config[’s3_gateway’], ”/?ostor-limits&bucket=” . $vars[’bucket’] . ”&limit-type=ops&limit-resource=” . $vars[’ops-name’] . ’&limit-value=’ . $vars[’ops-value’], ”PUT” ); } // Set only if value specified. if (!empty($vars[’bandwidth-value’])) { // Set s3 bucket limits (bandwidth).

  • PAGE 68

    4.3. Managing S3 User and Bucket Limits in WHMCS ?> 4.3.5 Querying Bucket Limits You can display the current limits with the name. ostor-limits service and parameter bucket specifying the bucket WHMCS displays the bucket limits in S3 cluster when you click the Get button. S3_getLimitsForBucket.php Create a file with the following contents:

  • PAGE 69

    Chapter 4. Integration with WHMCS // Redirect back. header(’Location: ’ . $_SERVER[’HTTP_REFERER’]); } // Call function. S3_getLimitsForBucket($_GET[’bucket’]); ?> 4.3.6 Deleting Bucket Limits You can delete the current limits with the ostor-limits service and parameter bucket specifying the bucket name. WHMCS removes the bucket limits from S3 cluster when you click the Delete button. Create a file S3_deleteLimitsForBucket.php with the following contents:

  • PAGE 70

    4.4. Obtaining Usage Statistics in WHMCS require(’../../includes/AcronisStorage/S3_requestCurl.php’); require(’../../init.php’); // Delete s3 bucket limits. function S3_deleteLimitsForBucket($bucket) { // Load configuration. $s3_config = s3_getConfig(); // Delete s3 bucket limits. S3_requestCurl( $s3_config[’s3_key’], $s3_config[’s3_secret’], $s3_config[’s3_gateway’], ”/?ostor-limits&bucket=” . $bucket, ”DELETE” ); // Clear array. $_SESSION[’s3_limits_bucket’] = null; // Redirect back.

  • PAGE 71

    Chapter 4. Integration with WHMCS Note: Delete statistics objects after collecting the required data. 4.4.1 Listing Statistics Objects You can list all available statistics objects with the ostor-usage service and no parameters. IThe output only contains objects that have not been deleted. WHMCS lists the available statistics objects from S3 cluster when you click List statistics objects (on/off). Create a file S3_listStatsObjects.

  • PAGE 72

    4.4. Obtaining Usage Statistics in WHMCS // Get s3 statistics objects. $s3_client = S3_requestCurl( $s3_config[’s3_key’], $s3_config[’s3_secret’], $s3_config[’s3_gateway’], ”/?ostor-usage”, ”GET” ); // Store s3 result. $_SESSION[’s3_stat_objects’] = 1; $_SESSION[’s3_stat’] = $s3_client; // Redirect back. header(’Location: ’ . $_SERVER[’HTTP_REFERER’]); } // Call function.

  • PAGE 73

    Chapter 4. Integration with WHMCS 4.4.2 Querying Statistics Objects You can display usage statistics with the ostor-usage service and parameter obj specifying the statistics object. WHMCS displays the accessed buckets, user ID, and counters when you click the Get button. Create a file S3_getStatsForObject.php with the following contents:

  • PAGE 74

    4.4. Obtaining Usage Statistics in WHMCS // Get s3 statistics object. $s3_client = S3_requestCurl( $s3_config[’s3_key’], $s3_config[’s3_secret’], $s3_config[’s3_gateway’], ”/?ostor-usage&obj=” . $object, ”GET” ); // Store s3 result. $_SESSION[’s3_object_statistic’] = $s3_client; $_SESSION[’s3_object’] = $object; // Redirect back. header(’Location: ’ . $_SERVER[’HTTP_REFERER’]); } // Call function.

  • PAGE 75

    Chapter 4. Integration with WHMCS 4.4.3 Deleting Statistics Objects You can delete existing statistics objects with the ostor-usage service and parameter obj specifying the statistics object. WHMCS removes the statistics object from S3 cluster when you click the Delete button. Create a file S3_deleteStatsForObject.php with the following contents:

  • PAGE 76

    4.4. Obtaining Usage Statistics in WHMCS // Delete s3 statistics object. S3_requestCurl( $s3_config[’s3_key’], $s3_config[’s3_secret’], $s3_config[’s3_gateway’], ”/?ostor-usage&obj=” . $object, ”DELETE” ); // Clear array. $_SESSION[’s3_limits_bucket’] = null; // Redirect back. header(’Location: ’ . $_SERVER[’HTTP_REFERER’]); } // Call function.