Storage-as-a-Service Integration Guide

Table Of Contents
Acronis Storage 2.4
Storage-as-a-Service Integration
Guide
January 15, 2019

Summary of content (66 pages)

'; } // Show user. if ($_SESSION['s3_query_user'] == 1) { // Table header. $result = $result . '
S3 Information for User: ' . $_SESSION['s3_userid'] . '
'; // One row per access key pair.

  • PAGE 38

    4.1. Requirements if ($_SESSION['s3_stat_objects'] == 1) { // Table header. $result = $result . '

    S3 Statistics List
  • AWSAccessKeyId AWSSecretAccessKey
    '; // One row per access key pair. foreach ($_SESSION['s3_stat']['items'] as $s3_object) { $result = $result . ' '; } // Table footer.

  • PAGE 39

    Chapter 4. Integration with WHMCS // 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 . '
    Object Name
    ' . $s3_object . '
    ' . $s3_type . ' ' . $s3_limit . ' ' . $s3_value . '
    '; } // Show limits for bucket. if (!empty($_SESSION['s3_limits_bucket'])) { // Table header. $result = $result .

  • PAGE 40

    4.1. Requirements } // Table footer. $result = $result . ' '; } // Table footer and next header. $result = $result . '

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

  • PAGE 41

    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 42

    4.2. Managing S3 Users in WHMCS # Enable usage statistics collection. S3_GW_COLLECT_STAT=1 Restart the S3 storage service to apply the configuration changes. Run the following command on all S3 storage nodes: # systemctl restart ostor-agentd.service Now you can login to WHMCS. Additional links and S3 management options will be shown in the Client Profile section. 4.2 Managing S3 Users in WHMCS This section describes how to manage users in WHMCS in a service provider scenario.

  • PAGE 43

    Chapter 4. Integration with WHMCS 4.2.1 Creating S3 Users You can create a user with the ostor-users service and parameter emailAddress specifying the user email address. WHMCS creates the user in S3 cluster when you click Create User. Create a file S3_createUser.php with the following contents:

  • PAGE 44

    4.2. Managing S3 Users in 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 45

    Chapter 4. Integration with WHMCS $_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 46

    4.2. Managing S3 Users in 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 47

    Chapter 4. Integration with WHMCS 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=" . $s3_whmcs['email'], "GET" ); // Store s3 result.

  • PAGE 48

    4.2. Managing S3 Users in WHMCS 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 49

    Chapter 4. Integration with WHMCS $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. S3_disableUser($_GET['userid']); ?> 4.2.5 Enabling S3 Users You can enable a previously disabled user with the ostor-users service and parameter emailAddress specifying the user email address.

  • PAGE 50

    4.2. Managing S3 Users in WHMCS "POST" ); // Redirect back. header('Location: ' . $_SERVER['HTTP_REFERER']); } // Call function. S3_enableUser($_GET['userid']); ?> 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 51

    Chapter 4. Integration with WHMCS S3_requestCurl( $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 52

    4.2. Managing S3 Users in WHMCS // Get whmcs user email. $s3_whmcs = S3_getClient($userid, $s3_config['whmcs_username']); // Generate s3 key pair. $s3_client = S3_requestCurl( $s3_config['s3_key'], $s3_config['s3_secret'], $s3_config['s3_gateway'], "/?ostor-users&emailAddress=" . $s3_whmcs['email'] . "&genKey", "POST" ); // Add note with the s3 access key and s3 secret.

  • PAGE 53

    Chapter 4. Integration with WHMCS 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 S3_revokeAccessKey.php with the following contents:

  • PAGE 54

    4.3. Managing S3 User and Bucket Limits in WHMCS $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. S3_requestCurl( $s3_config['s3_key'], $s3_config['s3_secret'], $s3_config['s3_gateway'], "/?ostor-users&emailAddress=" . $s3_whmcs['email'] . "&revokeKey=" .

  • PAGE 55

    Chapter 4. Integration with WHMCS 4.3.1 Setting User Limits You can limit operations rate with the ostor-limits service and the following parameters: emailAddress specifying the email address, default=, get=, put=, list=, or delete= specifying the limit value. Similarly, you can limit outgoing bandwidth of a response with the following parameters: emailAddress specifying the email address, out= specifying the limit value. WHMCS configures user limits in an S3 cluster when you click the Set button.

  • PAGE 56

    4.3. Managing S3 User and Bucket Limits in WHMCS $s3_config['s3_secret'], $s3_config['s3_gateway'], "/?ostor-limits&emailAddress=" . $s3_whmcs['email'] . "&limit-type=bandwidth&limit-resource=" . $vars['bandwidth-name'] . '&limit-value=' . $vars['bandwidth-value'], "PUT" ); } // Redirect back. header('Location: ' . $_SERVER['HTTP_REFERER']); } // Call function. S3_setLimitsForUser($_GET); ?> 4.3.

  • PAGE 57

    Chapter 4. Integration with WHMCS

  • PAGE 58

    4.3. Managing S3 User and Bucket Limits in WHMCS // Load configuration and libraries. require('../../includes/staas_scripts/S3_getClient.php'); require('../../includes/staas_scripts/S3_getConfig.php'); require('../../includes/staas_scripts/S3_requestCurl.php'); require('../../init.php'); // Delete s3 user limits. function S3_getLimitsForUser($userid) { // Load configuration. $s3_config = s3_getConfig(); // Get whmcs user email.

  • PAGE 59

    Chapter 4. Integration with WHMCS

  • PAGE 60

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

  • PAGE 61

    Chapter 4. Integration with WHMCS 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 62

    4.4. Obtaining Usage Statistics in WHMCS "/?ostor-limits&bucket=" . $bucket, "DELETE" ); // Clear array. $_SESSION['s3_limits_bucket'] = null; // Redirect back. header('Location: ' . $_SERVER['HTTP_REFERER']); } // Call function. S3_deleteLimitsForBucket($_GET['bucket']); ?> 4.4 Obtaining Usage Statistics in WHMCS Thi section describes how to obtain usage statistics via in WHMCS for billing or other purposes. Note: Delete statistics objects after collecting the required data. 4.4.

  • PAGE 63

    Chapter 4. Integration with WHMCS $_SESSION['s3_stat_objects'] = 0; // Redirect back. header('Location: ' . $_SERVER['HTTP_REFERER']); // Return immediately. return; } // Load configuration. $s3_config = s3_getConfig(); // 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: ' .

  • PAGE 64

    4.4. Obtaining Usage Statistics in 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 65

    Chapter 4. Integration with WHMCS "/?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. S3_getStatsObjects($_GET['object']); ?> 4.4.3 Deleting Statistics Objects You can delete existing statistics objects with the ostor-usage service and parameter obj specifying the statistics object.

  • PAGE 66

    4.4. Obtaining Usage Statistics in WHMCS