You can start a new virtual machine, install an application in it, set security group to access such application, assign ssh key and public IPv4 without using the web control panel. All features of DreamCompute can be programmed with Python to automate application deployment: This is what makes OpenStack clouds like DreamCompute so powerful and different from other virtual servers.
When you want to create an instance on DreamCompute, you can login to the DreamCompute dashboard in a browser and follow the steps to create a new instance as described on DreamCompute documentation. It’s pretty easy but also requires lots of clicking that cannot be automated.
Why would you want to script these steps? Because you can — with a full cloud platform based on OpenStack like DreamCompute, you can consider resources such as a virtual machine, storage and network fully programmable. Since you can automate the creation and configuration of instances, then you can replicate actions more easily and develop applications that launch instances under certain circumstances and kill them in others. This not only helps you provide a better service, it can save you money by letting you use only the compute and storage resources you need.
The alternative to clicking on the DreamCompute web panel is to script actions with a programming language. Since DreamHost cloud is based on open source components like OpenStack and Ceph, there are already lots of tools and SDKs for many programming languages.
For example, Python enthusiasts like us use the Apache Libcloud project to create an instance with the image and flavor you want, assign volumes, networks and all the things you do on the web panel. It also gives you the ability to deploy an application to the instance in a seamless manner, using cloud-init to apply the user data to the instance.
Below is python code that will spin up a small instance running Ubuntu 14.04 using python code and libcloud. To get authentication information needed to run the code, download the OpenStack RC file and see we have already provided some of the information for you. You will also need to install libcloud with `pip install apache-libcloud`.from libcloud.compute.types import Provider from libcloud.compute.providers import get_driver # Authentication information so you can authenticate to DreamCompute # copy the details from the OpenStack RC file # https://dashboard.dreamcompute.com/project/access_and_security/api_access/openrc/ auth_username = 'your_auth_username' auth_password = 'your_auth_password' project_name = 'your_project_name_or_id' auth_url = 'https://keystone.dream.io' region_name = 'RegionOne' provider = get_driver(Provider.OPENSTACK) conn = provider(auth_username, auth_password, ex_force_auth_url=auth_url, ex_force_auth_version='2.0_password', ex_tenant_name=project_name, ex_force_service_region=region_name) # Get the image that we want to use by its id # NOTE: the image_id may change. See the documentation to find # all the images available to your user image_id = '90d5e049-aaed-4abc-aa75-60c2b1ed6516' image = conn.get_image(image_id) # Get the flavor that we want to use by its id flavor_id = '100' flavor = conn.ex_get_size(flavor_id) # Create the node with the name “PracticeInstance” # and the size and image we chose above instance = conn.create_node(name='PracticeInstance', image=image, size=flavor)
There are more examples of what you can do with DreamCompute and Python with Libcloud on the DreamCloud wiki.
There are a lot more possible ways to interact with DreamCloud, and in the coming weeks we’ll be adding more examples and tutorials, also for fans of Ruby, Java and other programming languages. Watch the DreamCompute wiki pages and this blog for the latest news.