5. Enabling integration

To enable integration with CloudBlue Connect, first, check that the Virtuozzo Hybrid Server CloudBlue connector packages are properly installed inside the VA MN container (see To install Virtuozzo Hybrid Server CloudBlue connector).

5.1. Configure a config.json file

To ensure the smooth connection of the CloudBlue Connect API with the virtual infrastructure managed by the VA API, adjust a config.json file, start and enable the following four applications:

  • cloudblue-fulfillments processes fulfillments; creates and manages domains, projects, and users.

  • cloudblue-usage sends usage reports for active assets.

  • cloudblue-usage-files confirms processed usage files.

  • cloudblue-subscriptions-cleaner removes a virtual environment and backups for a terminated subscription.

5.1.1. To adjust a config.json file

  1. Copy the configuration file example to your config.json file and open the latter for editing:

    cp /etc/cloudblue-connector/config.json.example /etc/cloudblue-connector/config.json
    vi /etc/cloudblue-connector/config.json
    {
        "pva_socket": "/var/opt/pva/mn/mn.sock",
        "pva_connect_timeout": 600,
        "pva_socket_read_delay": 2,
        "keystone_endpoint": "https://power-panel.local:35357/v3",
        "pp_url": "https://power-panel.local/api/v1",
        "pp_login": "admin",
        "post_hook_script": "/etc/cloudblue-connector/posthook.sh",
        "post_hook_exec_timeout": 120,
        "misc": {
            "domainDeleteOnFail": true,
            "hidePasswordsInLog": true,
            "testMarketplaceId": "MP-43209",
            "testMode": false,
            "orderRamInMegabytes": false
        },
        "apiEndpoint": "https://api.connect.cloud.im/public/v1",
        "products": ["PRD-718-365-521", "PRD-428-165-279", "PRD-713-462-300"],
        "report_usage": ["PRD-718-365-521"],
        "report_suspended": true,
        "dataRetentionPeriod": 15,
        "templates": {
            "PRD-718-365-521": {"grant": "TL-623-078-399", "revoke": "Access to VDC has been revoked"},
            "PRD-428-165-279": {"grant": "TL-581-343-333", "revoke": "Access to VDC has been revoked"},
            "PRD-713-462-300": {"grant": "TL-601-357-392", "revoke": "Access to Power Panel has been revoked"}
        }
    }
    
  2. Change the default parameters:

    1. In "pva_socket", specify the Virtuozzo Automator UNIX socket. If not changed previously, no additional modifications are required.

    2. In "pva_connect_timeout", enter the maximum time (in seconds) while the Virtuozzo Hybrid Server CloudBlue connector waits for the response from Virtuozzo Automator.

    3. In "pva_socket_read_delay", specify the delay between the reading data frame from the Virtuozzo Automator response.

    4. In "keystone_endpoint", specify the default PowerPanel URL, including the keystone port and endpoint, for example, http://power-panel.com:35357/v3.

    5. In "pp_url", enter the default PowerPanel URL, including the API endpoint, for example, http://power-panel.com/api/v1.

    6. In "pp_login", specify the PowerPanel admin user name.

    7. In "post_hook_script", specify a path to your script. The script should include the subscription_id, action, and action result parameters. For example:

      #!/bin/bash
      
      # $1 - subscription_id
      # $2 - action ['purchase', 'resume', 'change', 'suspend', 'cancel']
      # $3 - action result ['success', 'fail']
      
      LOGFILE="/var/log/cloudblue-connector/post_hook.log"
      TIMESTAMP=`date "+%Y-%m-%d %H:%M:%S"`
      
      echo "[${TIMESTAMP}]: $1 $2 $3" >> ${LOGFILE}
      exit 0
      
    8. In "post_hook_exec_timeout", specify the amount of time in seconds allocated for the execution of a post-hook script. When the allowed period of time has ended and the script has not finished executing, the system will forcefully terminate it. If the specified period of time is too short, increase the value or optimize the script.

      Note

      The system will not start processing a new request for a subscription until the previous post-hook script is completed or forcefully terminated after the period of time specified in "post_hook_exec_timeout". Then, the system will process the following subscription request in the queue, and the post-hook script will start running again.

    9. "misc" contains additional configuration options to define the Virtuozzo Hybrid Server CloudBlue connector behavior:

      1. "domainDeleteOnFail" is a parameter used for debugging purposes. Set false if you want the virtual environment not deleted in case of a subscription failure. Otherwise, set true.

      2. "hidePasswordsInLog" wipes plain-text passwords in the Virtuozzo Hybrid Server CloudBlue connector events output. The default value is true.

      3. In "testMarketplaceId", specify the ID of a marketplace used to place asset requests for evaluation. If not set, all asset requests from all marketplaces will be processed, regardless of the "testMode" setting.

      4. In "testMode", set true to have requests made in "testMarketplaceId" processed only. Set false to have requests made in "testMarketplaceId" ignored. The default value is false.

      5. In "orderRamInMegabytes", set false to have the requested amount of RAM defined in gigabytes (GB). If true, the amount of RAM is specified in megabytes (MB).

    10. In "apiEndpoint", specify the API endpoint to interact with the CloudBlue Connect API copied on the vendor portal. For this:

      1. Go to your CloudBlue Connect vendor portal and click the Integrations icon.

      2. Go to the API tab and copy the API endpoint.

    11. In "products", specify the list of product IDs copied on the vendor portal. For this:

      1. Go to your CloudBlue Connect vendor portal and click the Products icon.

      2. Select the desired product.

      3. Go to the General tab and copy the product ID.

    12. In "report_usage", specify the IDs of products with the pay-as-you-go resource model, copied on the vendor portal. For this:

      1. Go to your CloudBlue Connect vendor portal and click the Products icon.

      2. Select the desired product.

      3. Go to the General tab and copy the product ID.

    13. In "report_suspended", set true if you want a usage report to show data for a subscription when it is suspended. Otherwise, set false. The default value is true.

    14. "dataRetentionPeriod" is the number of days a virtual environment and its backups for a terminated subscription exist. During this period, the virtual environment is stopped, and the user cannot view and manage it via PowerPanel, except for the administrator. After the expiration of this period, the system removes the virtual environment and its existing backups for such a subscription. They are immediately removed during the cancellation request if "dataRetentionPeriod" is set to zero (0).

    15. In "templates", specify template IDs for each product copied on the vendor portal. For this:

      1. Go to your CloudBlue Connect vendor portal and click the Products icon.

      2. Select the desired product.

      3. Go to the Embedding tab and copy the ID specified in the Approved Templates box.

  3. For security reasons, the Virtuozzo Hybrid Server CloudBlue connector does not store passwords in plain text. For specifying the CloudBlue API token and PowerPanel admin user password, run cloudblue-password-manager.

    # cloudblue-password-manager [-h] [--set-cloudblue-token]
                                 [--set-pp-password]
    

    When specifying an API token, enter the ID and API key.

    For example, "ApiKey SU-469-692-689:*****************". Copy the ID and API key on the vendor portal:

    1. Go to your CloudBlue Connect vendor portal and click the Integrations icon.

    2. Go to the Tokens tab and select the desired token.

    3. On the Token details page, copy the ID and API key.

  4. Enable and start all four services, such as cloudblue-fulfillments.service, cloudblue-usage.service, cloudblue-usage-files.service, and cloudblue-subscriptions-cleaner.service:

    Note

    To ensure that the cloudblue-fulfillments service runs properly, execute the following:

    cloudblue-fulfillments
    

    Additionally, you can verify cloudblue-usage, cloudblue-usage-files, and cloudblue-subscriptions-cleaner. For example:

    cloudblue-usage
    
    cloudblue-usage-files
    
    cloudblue-subscriptions-cleaner
    
    systemctl enable cloudblue-fulfillments.service
    systemctl start cloudblue-fulfillments.service
    
    systemctl enable cloudblue-usage.service
    systemctl start cloudblue-usage.service
    
    systemctl enable cloudblue-usage-files.service
    systemctl start cloudblue-usage-files.service
    
    systemctl enable cloudblue-subscriptions-cleaner.service
    systemctl start cloudblue-subscriptions-cleaner.service
    

Note

If you want to change a PowerPanel admin user password, use the same API key and generate a new password. Otherwise, you can delete the connector.pem file, implying the subsequent generation of a new API key and password. Encrypted passwords are stored in the passwords_db.sqlite3 database.

# cd /etc/cloudblue-connector/ ; ls -la

-rw-r--r-- 1 root root 4619 May 15 19:49 config-logging.json
-rw-r--r-- 1 root root 2471 Jun 19 17:22 config.json
-rw-r--r-- 1 root root 4567 Jun 19 17:27 connector.pem
-rw-r--r-- 1 root root 9753 Jun 19 17:27 passwords_db.sqlite3