cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From seb...@apache.org
Subject [31/50] cloudstack-ec2stack git commit: If volume type set to gp2 - attach shared on instance creation
Date Tue, 05 May 2015 13:26:24 GMT
If volume type set to gp2 - attach shared on instance creation


Project: http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/commit/249834f8
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/tree/249834f8
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/diff/249834f8

Branch: refs/heads/master
Commit: 249834f8c816e90dfc3ca40a1aadddca8e28e947
Parents: ad3b688
Author: BroganD1993 <darrenbrogan@hotmail.com>
Authored: Sat Aug 16 10:32:59 2014 +0100
Committer: BroganD1993 <darrenbrogan@hotmail.com>
Committed: Sat Aug 16 10:32:59 2014 +0100

----------------------------------------------------------------------
 ec2stack/providers/cloudstack/instances.py | 123 +++++++++++-------------
 1 file changed, 55 insertions(+), 68 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack-ec2stack/blob/249834f8/ec2stack/providers/cloudstack/instances.py
----------------------------------------------------------------------
diff --git a/ec2stack/providers/cloudstack/instances.py b/ec2stack/providers/cloudstack/instances.py
index b391c51..84aa429 100644
--- a/ec2stack/providers/cloudstack/instances.py
+++ b/ec2stack/providers/cloudstack/instances.py
@@ -8,7 +8,8 @@ instances.
 from flask import current_app
 
 from ec2stack.providers import cloudstack
-from ec2stack.providers.cloudstack import requester, service_offerings, zones, disk_offerings
+from ec2stack.providers.cloudstack import requester, service_offerings, zones, \
+    disk_offerings, volumes
 from ec2stack import helpers, errors
 
 
@@ -104,6 +105,48 @@ def _describe_instances_response(response):
 
 
 @helpers.authentication_required
+def reboot_instance():
+    """
+    Reboot an instance.
+
+    @return: Response.
+    """
+    helpers.require_parameters(['InstanceId.1'])
+    instance_id = helpers.get('InstanceId.1')
+    _reboot_instance_request(instance_id)
+    return _reboot_instance_response()
+
+
+def _reboot_instance_request(instance_id):
+    """
+    Request to reboot an instance.
+
+    @param instance_id: Id of instance to be rebooted.
+    @return: Response.
+    """
+    args = {'command': 'rebootVirtualMachine',
+            'id': instance_id}
+    response = requester.make_request_async(args)
+    response = response['virtualmachine']
+    return response
+
+
+def _reboot_instance_response():
+    """
+    Generates a response for a reboot instance request.
+
+    @return: Response.
+    """
+    response = {
+        'template_name_or_list': 'status.xml',
+        'response_type': 'RebootInstancesResponse',
+        'return': 'true'
+    }
+
+    return response
+
+
+@helpers.authentication_required
 def run_instance():
     """
     Run a instance.
@@ -122,21 +165,26 @@ def _run_instance_request():
 
     @return: Response.
     """
-
     args = {}
     if helpers.contains_parameter('Placement.AvailabilityZone'):
-        zone_id = zones.get_zone(
+        args['zoneid'] = zones.get_zone(
             helpers.get('Placement.AvailabilityZone')
         )
     else:
-        zone_id = zones.get_zone(
+        args['zoneid'] = zones.get_zone(
             current_app.config['CLOUDSTACK_DEFAULT_ZONE']
         )['id']
 
     if helpers.get('BlockDeviceMapping.1.Ebs.VolumeType') is not None:
-        args = _get_simulated_combination_instance_storage_args(zone_id)
-    else:
-        args['zoneid'] = zone_id
+        disk_type = helpers.get('BlockDeviceMapping.1.Ebs.VolumeType')
+        if disk_type == 'gp2':
+            args['diskofferingid'] = disk_offerings.get_disk_offering(
+                current_app.config['CLOUDSTACK_LOCAL_CUSTOM_DISK_OFFERING']
+            )['id']
+        if helpers.get('BlockDeviceMapping.1.Ebs.VolumeSize') is None:
+            errors.invalid_request("VolumeSize not found in BlockDeviceMapping")
+        else:
+            args['size'] = helpers.get('BlockDeviceMapping.1.Ebs.VolumeSize')
 
     if helpers.get('InstanceType') is None:
         instance_type = 'm1.small'
@@ -183,25 +231,6 @@ def _run_instance_request():
 
     return response
 
-def _get_simulated_combination_instance_storage_args(zone_id):
-    args = {}
-    disk_type = helpers.get('BlockDeviceMapping.1.Ebs.VolumeType')
-    if disk_type == 'gp2':
-        if 'CLOUDSTACK_LOCAL_CUSTOM_DISK_OFFERING' in current_app.config:
-            args['diskofferingid'] = disk_offerings.get_disk_offering(
-                current_app.config['CLOUDSTACK_LOCAL_CUSTOM_DISK_OFFERING']
-            )['id']
-        else:
-            errors.invalid_request(
-                str('CLOUDSTACK_LOCAL_CUSTOM_DISK_OFFERING') + " not found in "
-                "configuration, no able to configure gp2 disk, please run ec2stack-configure
and chose to configure "
-                "a local disk")
-
-    if helpers.get('BlockDeviceMapping.1.Ebs.VolumeSize') is None:
-        errors.invalid_request("VolumeSize not found in BlockDeviceMapping")
-    else:
-        args['size'] = helpers.get('BlockDeviceMapping.1.Ebs.VolumeSize')
-
 
 def _run_instance_response(response):
     """
@@ -231,48 +260,6 @@ def _run_instance_response(response):
 
 
 @helpers.authentication_required
-def reboot_instance():
-    """
-    Reboot an instance.
-
-    @return: Response.
-    """
-    helpers.require_parameters(['InstanceId.1'])
-    instance_id = helpers.get('InstanceId.1')
-    _reboot_instance_request(instance_id)
-    return _reboot_instance_response()
-
-
-def _reboot_instance_request(instance_id):
-    """
-    Request to reboot an instance.
-
-    @param instance_id: Id of instance to be rebooted.
-    @return: Response.
-    """
-    args = {'command': 'rebootVirtualMachine',
-            'id': instance_id}
-    response = requester.make_request_async(args)
-    response = response['virtualmachine']
-    return response
-
-
-def _reboot_instance_response():
-    """
-    Generates a response for a reboot instance request.
-
-    @return: Response.
-    """
-    response = {
-        'template_name_or_list': 'status.xml',
-        'response_type': 'RebootInstancesResponse',
-        'return': 'true'
-    }
-
-    return response
-
-
-@helpers.authentication_required
 def start_instance():
     """
     Starts an instance.


Mime
View raw message