Provides methods and classes to connect and interact with a DiData Cloud Server provider. See connect() for information on how to establish a connection.
Creates a new connection to a DiData Cloud Server or DiData Cloud Network provider. Multiple calls to connect() can be made to establish connections to multiple providers.
| Parameters: | endpoint (str) – The endpoint to connect to. For example: api-na.dimensiondata.com |
|---|---|
| Returns: | An authenticated connection to the cloud provider |
| Return type: | CloudConnection |
Here is a simple usage example:
from aeronaut.cloud import connect
conn = connect('api-na.dimensiondata.com')
servers = conn.list_servers()
To successfully authenticate against the given endpoint, the function will look for a file in the path ~/.aeronaut with a section name matching the same endpoint. The file must be valid YAML with the following structure:
api-na.dimensiondata.com:
username: myuser
password: mypassword
another.endpoint.com:
username: myotheruser
password: mypasswordtoo!
Note that this function is really just syntactic sugar that wraps in a single step the act of instantiating a CloudConnection object and calling authenticate() against it. To learn more about the authentication process, see aeronaut.cloud.CloudConnection.authenticate().
Here is a more detailed usage example:
from aeronaut.cloud import connect
conn = connect('api-na.dimensiondata.com')
images = conn.list_base_images()
image = images[0]
networks = conn.list_networks()
network = networks[0]
status = conn.deploy_server(name='My New Server',
description='First server deployment',
image_id=image.id,
start=True,
admin_password='32456sdkddd',
network_id=network.id)
print status.is_success
All requests such as deploy_server() and list_base_images() are delegated to request classes under the aeronaut.request.cloud package. Whereas the return values are instances of classes under the aeronaut.resource.cloud package. Documentation is currently sparse in both packages so you are required to read the source code to fully understand what the request and resource objects do.
Represents a connection to a DiData Cloud provider
| Parameters: |
|
|---|
Creates an additional disk/volume for an existing server
| Parameters: |
|
|---|---|
| Returns: | The status of the operation. |
| Return type: |
Sample usage:
import aeronaut.cloud
conn = aeronaut.cloud.connect('api-na.dimensiondata.com')
filters = [
['name', '==', 'myserver01']
]
servers = conn.list_servers(filters=filters)
server = servers[0]
dc = next(dc for dc in conn.list_data_centers() if dc.is_default)
speed = dc.hypervisor.disk_speeds[0]
# The disk_speed_id argument below is optional
result = conn.add_storage_to_server(server_id=server.id,
size_gb=13,
disk_speed_id=speed.id)
print result.is_success
print result.result_detail
Authenticates against the endpoint provided during initialization
To successfully authenticate against the given endpoint, the method will look for a file in the path ~/.aeronaut with a section name matching the same endpoint. The file must be valid YAML with the following structure:
api-na.dimensiondata.com:
username: myuser
password: mypassword
another.endpoint.com:
username: myotheruser
password: mypasswordtoo!
If the backend server does not return an HTTP status code of 200 or 201, the method will raise aeronaut.cloud.AuthenticationError
Removes a failed server deployment from the list of pending deployed servers
| Parameters: | |
|---|---|
| Returns: | The status of the operation |
| Return type: | aeronaut.resource.cloud.server.CleanFailedServerDeploymentStatus |
Creates an ACL Rule
| Parameters: |
|
|---|---|
| Returns: | The status of the operation |
| Return type: |
Creates a network with the given name in the given location
| Parameters: | |
|---|---|
| Returns: | The status of the operation |
| Return type: |
Deletes the given rule from the given network
| Parameters: | |
|---|---|
| Returns: | The status of the operation |
| Return type: |
Delete the given server. Note that a Server must be stopped before it can be deleted
| Parameters: | |
|---|---|
| Returns: | The status of the operation |
| Return type: |
Deploys a new server from an existing customer or base image
| Parameters: |
|---|
Additional arguments are listed in the source code of aeronaut.request.cloud.v0_9.deploy_server.DeployServer
| Returns: | The status of the operation |
|---|---|
| Return type: | aeronaut.resource.cloud.server.DeployServerStatus |
Sample usage:
import aeronaut.cloud
conn = aeronaut.cloud.connect('api-na.dimensiondata.com')
dcs = conn.list_data_centers()
dc = next(dc for dc in dcs if dc.is_default)
images = conn.list_base_images(filters=filters)
image = images[0]
networks = conn.list_networks(location=dc.location)
network = networks[0]
status = conn.deploy_server(name='My new server',
description='A new deployment',
image_id=image.id,
start=True,
admin_password='asdfkjhw',
network_id=network.id)
print status.is_success
Note how there is no argument for adding disks above. To add one, you need to call add_storage_to_server()
Returns True if the given image name exists in the data center
| Parameters: |
|
|---|---|
| Returns: | True if the image_name exists. False if otherwise. |
| Return type: |
Returns a full description of the indicated server image
| Parameters: | |
|---|---|
| Returns: | The image with the given ID |
| Return type: |
Returns a list of ACL rules
| Parameters: | |
|---|---|
| Returns: | A list of ACL rules in the given network |
| Return type: |
Returns a list of base images
| Parameters: | |
|---|---|
| Return type: |
Here is an example usage with the above parameters included:
filters = [
["location", "==", "NA5"],
["location", "==", "NA3"],
["name", "like", "Windows*"]
]
page_size = 5
page_number = 1
sort = [
"location ASC",
"name DESC"
]
images = conn.list_base_images(filters=filters,
sort=sort,
page_size=page_size,
page_number=page_number)
print images.page_number, "of", images.total_pages
print images.page_size
print images.total_count
print len(images)
for image in images:
print image.id, image.name
Returns a list of customer images
| Return type: | aeronaut.resource.cloud.image.ImageList |
|---|
Returns a list of data centers
| Return type: | aeronaut.resource.cloud.data_center.DataCenterList |
|---|
Returns a list of base or customer images. While this is available, you are better off calling either list_customer_images() or list_base_images()
| Return type: | aeronaut.resource.cloud.image.ImageList |
|---|
Returns a list of networks
| Parameters: |
|
|---|---|
| Return type: |
Returns a list of servers
| Parameters: | org_id (str) – Optional. The organization ID that owns the server. Defaults to the current user’s org_id if not provided. |
|---|---|
| Return type: | aeronaut.resource.cloud.server.ServerList |
Changes the name, description, CPU, or RAM profile of an existing deployed server.
| Parameters: |
|
|---|---|
| Return type: |
Forcefully power off the server
| Parameters: | |
|---|---|
| Return type: |
Sends a request to the provider. This is a low-level method used by all other operations exposed by this class. You do not need to call it directly but it’s here anyway in case you really want to use it.
| Parameters: |
|
|---|
Example:
params = {
'cpu_count': 2,
'memory': 2048
}
response = self.request('modify_server',
api_version='v0.9',
params=params)
print response.status_code
The above call results in the class aeronaut.request.cloud.v0_9.modify_server.ModifyServer being used to send a request to the provider.
Note that this method returns a raw response object, not an object representation of the XML returned by the server.
Forcefully power cycle the server.
| Parameters: | |
|---|---|
| Return type: |