Additional Installation Options

The next few sections describe CloudStack features above and beyond the basic deployment options.

Installing the Usage Server (Optional)

You can optionally install the Usage Server once the Management Server is configured properly. The Usage Server takes data from the events in the system and enables usage-based billing for accounts.

When multiple Management Servers are present, the Usage Server may be installed on any number of them. The Usage Servers will coordinate usage processing. A site that is concerned about availability should install Usage Servers on at least two Management Servers.

Requirements for Installing the Usage Server

  • The Management Server must be running when the Usage Server is installed.
  • The Usage Server must be installed on the same server as a Management Server.

Steps to Install the Usage Server

  1. Package repository should already being configured. Refer to Configure Package Repository

  2. Install package cloudstack-usage

    On RHEL/CentOS systems, use:

    1. # yum install cloudstack-usage

    On Debian/Ubuntu systems, use:

    1. # apt-get install cloudstack-usage
  3. Once installed, start the Usage Server with the following command.

    1. # service cloudstack-usage start
  4. Enable the service at boot

    On RHEL/CentOS systems, use:

    1. # chkconfig cloudstack-usage on

    On Debian/Ubuntu systems, use:

    1. # update-rc.d cloudstack-usage defaults

Working with Usage discusses further configuration of the Usage Server.

SSL (Optional)

CloudStack provides HTTP access in its default installation. There are a number of technologies and sites which choose to implement SSL/TLS. As a result, we have left CloudStack to expose HTTP under the assumption that a site will implement its typical practice.

CloudStack 4.9 and above uses embedded Jetty as its servlet container. For sites that would like CloudStack to terminate the SSL session, HTTPS can be enabled by configuring the https-related settings in CloudStack management server’s server.properties file at /etc/cloudstack/management/ location:

  1. # For management server to pickup these configuration settings, the configured
  2. # keystore file should exists and be readable by the management server.
  3. https.enable=true
  4. https.port=8443
  5. https.keystore=/etc/cloudstack/management/cloud.jks
  6. https.keystore.password=vmops.com

For storing certificates, admins can create and configure a java keystore file and configure the same in the server.properties file as illustrated above.

Database Replication (Optional)

CloudStack supports database replication from one MySQL node to another. This is achieved using standard MySQL replication. You may want to do this as insurance against MySQL server or storage loss. MySQL replication is implemented using a master/slave model. The master is the node that the Management Servers are configured to use. The slave is a standby node that receives all write operations from the master and applies them to a local, redundant copy of the database. The following steps are a guide to implementing MySQL replication.

Note

Creating a replica is not a backup solution. You should develop a backup procedure for the MySQL data that is distinct from replication.

  1. Ensure that this is a fresh install with no data in the master.

  2. Edit my.cnf on the master and add the following in the [mysqld] section below datadir.

    1. log_bin=mysql-bin
    2. server_id=1

    The server_id must be unique with respect to other servers. The recommended way to achieve this is to give the master an ID of 1 and each slave a sequential number greater than 1, so that the servers are numbered 1, 2, 3, etc.

  3. Restart the MySQL service. On RHEL/CentOS systems, use:

    1. # service mysqld restart

    On Debian/Ubuntu systems, use:

    1. # service mysql restart
  4. Create a replication account on the master and give it privileges. We will use the “cloud-repl” user with the password “password”. This assumes that master and slave run on the 172.16.1.0/24 network.

    1. # mysql -u root
    2. mysql> create user 'cloud-repl'@'172.16.1.%' identified by 'password';
    3. mysql> grant replication slave on . TO 'cloud-repl'@'172.16.1.%';
    4. mysql> flush privileges;
    5. mysql> flush tables with read lock;
  5. Leave the current MySQL session running.

  6. In a new shell start a second MySQL session.

  7. Retrieve the current position of the database.

    1. # mysql -u root
    2. mysql> show master status;
    3. +------------------+----------+--------------+------------------+
    4. | File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
    5. +------------------+----------+--------------+------------------+
    6. | mysql-bin.000001 | 412 | | |
    7. +------------------+----------+--------------+------------------+
  8. Note the file and the position that are returned by your instance.

  9. Exit from this session.

  10. Complete the master setup. Returning to your first session on the master, release the locks and exit MySQL.

    1. mysql> unlock tables;
  11. Install and configure the slave. On the slave server, run the following commands.

    1. # yum install mysql-server
    2. # chkconfig mysqld on
  12. Edit my.cnf and add the following lines in the [mysqld] section below datadir.

    1. server_id=2
    2. innodb_rollback_on_timeout=1
    3. innodb_lock_wait_timeout=600
  13. Restart MySQL. Use “mysqld” on RHEL/CentOS systems:

    1. # service mysqld restart

    On Ubuntu/Debian systems use “mysql.”

    1. # service mysql restart
  14. Instruct the slave to connect to and replicate from the master. Replace the IP address, password, log file, and position with the values you have used in the previous steps.

    1. mysql> change master to
    2. -> master_host='172.16.1.217',
    3. -> master_user='cloud-repl',
    4. -> master_password='password',
    5. -> master_log_file='mysql-bin.000001',
    6. -> master_log_pos=412;
  15. Then start replication on the slave.

    1. mysql> start slave;
  16. Optionally, open port 3306 on the slave as was done on the master earlier.

    This is not required for replication to work. But if you choose not to do this, you will need to do it when failover to the replica occurs.

Failover

This will provide for a replicated database that can be used to implement manual failover for the Management Servers. CloudStack failover from one MySQL instance to another is performed by the administrator. In the event of a database failure you should:

  1. Stop the Management Servers (via service cloudstack-management stop).

  2. Change the replica’s configuration to be a master and restart it.

  3. Ensure that the replica’s port 3306 is open to the Management Servers.

  4. Make a change so that the Management Server uses the new database. The simplest process here is to put the IP address of the new database server into each Management Server’s /etc/cloudstack/management/db.properties.

  5. Restart the Management Servers:

    1. # service cloudstack-management start

Amazon Web Services Interface

Amazon Web Services Compatible Interface

CloudStack can translate Amazon Web Services (AWS) API calls to native CloudStack API calls so that users can continue using existing AWS-compatible tools. This translation service runs as a separate web application in the same tomcat server as the management server of CloudStack, listening on a different port. The Amazon Web Services (AWS) compatible interface provides the EC2 SOAP and Query APIs as well as the S3 REST API.

Note

This service was previously enabled by separate software called CloudBridge. It is now fully integrated with the CloudStack management server.

Warning

The compatible interface for the EC2 Query API and the S3 API are Work In Progress. The S3 compatible API offers a way to store data on the management server file system, it is not an implementation of the S3 backend.

Limitations

  • Supported only in zones that use basic networking.
  • Available in fresh installations of CloudStack. Not available through upgrade of previous versions.
  • Features such as Elastic IP (EIP) and Elastic Load Balancing (ELB) are only available in an infrastructure with a Citrix NetScaler device. Users accessing a Zone with a NetScaler device will need to use a NetScaler-enabled network offering (DefaultSharedNetscalerEIP and ELBNetworkOffering).

Supported API Version

Note

Work is underway to support a more recent version of the EC2 API

Enabling the EC2 and S3 Compatible Interface

The software that provides AWS API compatibility is installed along with CloudStack. You must enable the services and perform some setup steps prior to using it.

  1. Set the global configuration parameters for each service to true. See *Setting Global Configuration Parameters*.

  2. Create a set of CloudStack service offerings with names that match the Amazon service offerings. You can do this through the CloudStack UI as described in the Administration Guide.

    Warning

    Be sure you have included the Amazon default service offering, m1.small. As well as any EC2 instance types that you will use.

  3. If you did not already do so when you set the configuration parameter in step 1, restart the Management Server.

    1. # service cloudstack-management restart

The following sections provides details to perform these steps

Enabling the Services

To enable the EC2 and S3 compatible services you need to set the configuration variables enable.ec2.api and enable.s3.api to true. You do not have to enable both at the same time. Enable the ones you need. This can be done via the CloudStack GUI by going in Global Settings or via the API.

The snapshot below shows you how to use the GUI to enable these services

Use the GUI to set the configuration variable to true

Using the CloudStack API, the easiest is to use the so-called integration port on which you can make unauthenticated calls. In Global Settings set the port to 8096 and subsequently call the updateConfiguration method. The following urls shows you how:

  1. http://localhost:8096/client/api?command=updateConfiguration&name=enable.ec2.api&value=true
  2. http://localhost:8096/client/api?command=updateConfiguration&name=enable.ec2.api&value=true

Once you have enabled the services, restart the server.

Creating EC2 Compatible Service Offerings

You will also need to define compute service offerings with names compatible with the Amazon EC2 instance types API names (e.g m1.small,m1.large). This can be done via the CloudStack GUI. Go under Service Offerings select Compute offering and either create a new compute offering or modify an existing one, ensuring that the name matches an EC2 instance type API name. The snapshot below shows you how:

Use the GUI to set the name of a compute service offering to an EC2 instance type API name.

Modifying the AWS API Port

Note

(Optional) The AWS API listens for requests on port 7080. If you prefer AWS API to listen on another port, you can change it as follows:

  1. Edit the files /etc/cloudstack/management/server.xml, /etc/cloudstack/management/server-nonssl.xml, and /etc/cloudstack/management/server-ssl.xml.
  2. In each file, find the tag <Service name=”Catalina7080”>. Under this tag, locate <Connector executor=”tomcatThreadPool-internal” port= ….<.
  3. Change the port to whatever port you want to use, then save the files.
  4. Restart the Management Server.

If you re-install CloudStack, you will have to re-enable the services and if need be update the port.

AWS API User Setup

In general, users need not be aware that they are using a translation service provided by CloudStack. They only need to send AWS API calls to CloudStack’s endpoint, and it will translate the calls to the native CloudStack API. Users of the Amazon EC2 compatible interface will be able to keep their existing EC2 tools and scripts and use them with their CloudStack deployment, by specifying the endpoint of the management server and using the proper user credentials. In order to do this, each user must perform the following configuration steps:

  • Generate user credentials.
  • Register with the service.
  • For convenience, set up environment variables for the EC2 SOAP command-line tools.

AWS API Command-Line Tools Setup

To use the EC2 command-line tools, the user must perform these steps:

  1. Be sure you have the right version of EC2 Tools. The supported version is available at http://s3.amazonaws.com/ec2-downloads/ec2-api-tools-1.3-62308.zip.
  2. Set up the EC2 environment variables. This can be done every time you use the service or you can set them up in the proper shell profile. Replace the endpoint (i.e EC2_URL) with the proper address of your CloudStack management server and port. In a bash shell do the following.
  1. $ export EC2_CERT=/path/to/cert.pem
  2. $ export EC2_PRIVATE_KEY=/path/to/private_key.pem
  3. $ export EC2_URL=http://localhost:7080/awsapi
  4. $ export EC2_HOME=/path/to/EC2_tools_directory

Using Timeouts to Ensure AWS API Command Completion

The Amazon EC2 command-line tools have a default connection timeout. When used with CloudStack, a longer timeout might be needed for some commands. If you find that commands are not completing due to timeouts, you can specify a custom timeouts. You can add the following optional command-line parameters to any CloudStack-supported EC2 command:

Specifies a connection timeout (in seconds)

  1. --connection-timeout TIMEOUT

Specifies a request timeout (in seconds)

  1. --request-timeout TIMEOUT

Example:

  1. ec2-run-instances 2 z us-test1 n 1-3 --connection-timeout 120 --request-timeout 120

Note

The timeouts optional arguments are not specific to CloudStack.

Supported AWS API Calls

The following Amazon EC2 commands are supported by CloudStack when the AWS API compatible interface is enabled. For a few commands, there are differences between the CloudStack and Amazon EC2 versions, and these differences are noted. The underlying SOAP call for each command is also given, for those who have built tools using those calls.

Table 1. Elastic IP API mapping

EC2 commandSOAP callCloudStack API call
ec2-allocate-addressAllocateAddressassociateIpAddress
ec2-associate-addressAssociateAddressenableStaticNat
ec2-describe-addressesDescribeAddresseslistPublicIpAddresses
ec2-diassociate-addressDisassociateAddressdisableStaticNat
ec2-release-addressReleaseAddressdisassociateIpAddress

Table 2. Availability Zone API mapping

EC2 commandSOAP callCloudStack API call
ec2-describe-availability-zonesDescribeAvailabilityZoneslistZones

Table 3. Images API mapping

EC2 commandSOAP callCloudStack API call
ec2-create-imageCreateImagecreateTemplate
ec2-deregisterDeregisterImageDeleteTemplate
ec2-describe-imagesDescribeImageslistTemplates
ec2-registerRegisterImageregisterTemplate

Table 4. Image Attributes API mapping

EC2 commandSOAP callCloudStack API call
ec2-describe-image-attributeDescribeImageAttributelistTemplatePermissions
ec2-modify-image-attributeModifyImageAttributeupdateTemplatePermissions
ec2-reset-image-attributeResetImageAttributeupdateTemplatePermissions

Table 5. Instances API mapping

EC2 commandSOAP callCloudStack API call
ec2-describe-instancesDescribeInstanceslistVirtualMachines
ec2-run-instancesRunInstancesdeployVirtualMachine
ec2-reboot-instancesRebootInstancesrebootVirtualMachine
ec2-start-instancesStartInstancesstartVirtualMachine
ec2-stop-instancesStopInstancesstopVirtualMachine
ec2-terminate-instancesTerminateInstancesdestroyVirtualMachine

Table 6. Instance Attributes Mapping

EC2 commandSOAP callCloudStack API call
ec2-describe-instance-attributeDescribeInstanceAttributelistVirtualMachines

Table 7. Keys Pairs Mapping

EC2 commandSOAP callCloudStack API call
ec2-add-keypairCreateKeyPaircreateSSHKeyPair
ec2-delete-keypairDeleteKeyPairdeleteSSHKeyPair
ec2-describe-keypairsDescribeKeyPairslistSSHKeyPairs
ec2-import-keypairImportKeyPairregisterSSHKeyPair

Table 8. Passwords API Mapping

EC2 commandSOAP callCloudStack API call
ec2-get-passwordGetPasswordDatagetVMPassword

Table 9. Security Groups API Mapping

EC2 commandSOAP callCloudStack API call
ec2-authorizeAuthorizeSecurityGroupIngressauthorizeSecurityGroupIngress
ec2-add-groupCreateSecurityGroupcreateSecurityGroup
ec2-delete-groupDeleteSecurityGroupdeleteSecurityGroup
ec2-describe-groupDescribeSecurityGroupslistSecurityGroups
ec2-revokeRevokeSecurityGroupIngressrevokeSecurityGroupIngress

Table 10. Snapshots API Mapping

EC2 commandSOAP callCloudStack API call
ec2-create-snapshotCreateSnapshotcreateSnapshot
ec2-delete-snapshotDeleteSnapshotdeleteSnapshot
ec2-describe-snapshotsDescribeSnapshotslistSnapshots

Table 11. Volumes API Mapping

EC2 commandSOAP callCloudStack API call
ec2-attach-volumeAttachVolumeattachVolume
ec2-create-volumeCreateVolumecreateVolume
ec2-delete-volumeDeleteVolumedeleteVolume
ec2-describe-volumeDescribeVolumelistVolumes
ec2-detach-volumeDetachVolumedetachVolume

Examples

There are many tools available to interface with a AWS compatible API. In this section we provide a few examples that users of CloudStack can build upon.

Boto Examples

Boto is one of them. It is a Python package available at https://github.com/boto/boto. In this section we provide two examples of Python scripts that use Boto and have been tested with the CloudStack AWS API Interface.

First is an EC2 example. Replace the Access and Secret Keys with your own and update the endpoint.

Example 1. An EC2 Boto example

  1. #!/usr/bin/env python
  2. import sys
  3. import os
  4. import boto
  5. import boto.ec2
  6. region = boto.ec2.regioninfo.RegionInfo(name="ROOT",endpoint="localhost")
  7. apikey='GwNnpUPrO6KgIdZu01z_ZhhZnKjtSdRwuYd4DvpzvFpyxGMvrzno2q05MB0ViBoFYtdqKd'
  8. secretkey='t4eXLEYWw7chBhDlaKf38adCMSHx_wlds6JfSx3z9fSpSOm0AbP9Moj0oGIzy2LSC8iw'
  9. def main():
  10. '''Establish connection to EC2 cloud'''
  11. conn = boto.connect_ec2(aws_access_key_id=apikey,
  12. aws_secret_access_key=secretkey,
  13. is_secure=False,
  14. region=region,
  15. port=7080,
  16. path="/awsapi",
  17. api_version="2010-11-15")
  18. '''Get list of images that I own'''
  19. images = conn.get_all_images()
  20. print images
  21. myimage = images[0]
  22. '''Pick an instance type'''
  23. vm_type='m1.small'
  24. reservation = myimage.run(instance_type=vm_type,security_groups=['default'])
  25. if __name__ == '__main__':
  26. main()

Second is an S3 example. The S3 interface in CloudStack is obsolete. If you need an S3 interface you should look at systems like RiakCS, Ceph or GlusterFS. This example is here for completeness and can be adapted to other S3 endpoint.

Example 2. An S3 Boto Example

  1. #!/usr/bin/env python
  2. import sys
  3. import os
  4. from boto.s3.key import Key
  5. from boto.s3.connection import S3Connection
  6. from boto.s3.connection import OrdinaryCallingFormat
  7. apikey='ChOw-pwdcCFy6fpeyv6kUaR0NnhzmG3tE7HLN2z3OB_s-ogF5HjZtN4rnzKnq2UjtnHeg_yLA5gOw'
  8. secretkey='IMY8R7CJQiSGFk4cHwfXXN3DUFXz07cCiU80eM3MCmfLs7kusgyOfm0g9qzXRXhoAPCH-IRxXc3w'
  9. cf=OrdinaryCallingFormat()
  10. def main():
  11. '''Establish connection to S3 service'''
  12. conn = S3Connection(aws_access_key_id=apikey,aws_secret_access_key=secretkey, \
  13. is_secure=False, \
  14. host='localhost', \
  15. port=7080, \
  16. calling_format=cf, \
  17. path="/awsapi/rest/AmazonS3")
  18. try:
  19. bucket=conn.create_bucket('cloudstack')
  20. k = Key(bucket)
  21. k.key = 'test'
  22. try:
  23. k.set_contents_from_filename('/Users/runseb/Desktop/s3cs.py')
  24. except:
  25. print 'could not write file'
  26. pass
  27. except:
  28. bucket = conn.get_bucket('cloudstack')
  29. k = Key(bucket)
  30. k.key = 'test'
  31. try:
  32. k.get_contents_to_filename('/Users/runseb/Desktop/foobar')
  33. except:
  34. print 'Could not get file'
  35. pass
  36. try:
  37. bucket1=conn.create_bucket('teststring')
  38. k=Key(bucket1)
  39. k.key('foobar')
  40. k.set_contents_from_string('This is my silly test')
  41. except:
  42. bucket1=conn.get_bucket('teststring')
  43. k = Key(bucket1)
  44. k.key='foobar'
  45. k.get_contents_as_string()
  46. if __name__ == '__main__':
  47. main()