def _run_instance_request(): args = {} if helpers.get('InstanceType') is None: instance_type = 'm1.small' else: instance_type = helpers.get('InstanceType') if instance_type in current_app.config['INSTANCE_TYPE_MAP']: instance_type = current_app.config[ 'INSTANCE_TYPE_MAP'][instance_type] else: instance_type = instance_type args['serviceofferingid'] = \ service_offerings.get_service_offering(instance_type)['id'] args['templateid'] = helpers.get('ImageId') if helpers.contains_parameter('Placement.AvailabilityZone'): args['zoneid'] = zones.get_zone( helpers.get('Placement.AvailabilityZone') ) else: args['zoneid'] = zones.get_zone( current_app.config['CLOUDSTACK_DEFAULT_ZONE'] )['id'] if helpers.contains_parameter('KeyName'): args['keypair'] = helpers.get('KeyName') if helpers.contains_parameter('UserData'): args['userdata'] = helpers.get('UserData') if helpers.contains_parameter_with_keyword('SecurityGroupId.'): keys = helpers.get_request_parameter_keys('SecurityGroupId.') securitygroupids = [] for key in keys: securitygroupids.append(helpers.get(key)) args['securitygroupids'] = ",".join(securitygroupids) if helpers.contains_parameter_with_keyword('SecurityGroup.'): keys = helpers.get_request_parameter_keys('SecurityGroup.') securitygroupnames = [] for key in keys: securitygroupnames.append(helpers.get(key)) args['securitygroupnames'] = ",".join(securitygroupnames) args['command'] = 'deployVirtualMachine' response = requester.make_request_async(args) return response
def describe_item(args, keyname, not_found, prefix): if helpers.contains_parameter_with_keyword(prefix): response = _describe_specific_item(args, keyname, not_found, prefix) else: response = describe_items_request(args, {}) return response
def describe_item(args, keyname, not_found, prefix): """ Describe a specific item or all items. @param args: Arguments involved in the request. @param keyname: Keyname of the Cloudstack response. @param not_found: Function to if the item is not found. @param prefix: Parameter prefix. @return: Response. """ if helpers.contains_parameter_with_keyword(prefix): response = _describe_specific_item(args, keyname, not_found, prefix) else: response = describe_items_request(args, {}) return response
def _run_instance_request(): """ Request to bring up an instance. @return: Response. """ args = {} if helpers.contains_parameter('Placement.AvailabilityZone'): args['zoneid'] = zones.get_zone( helpers.get('Placement.AvailabilityZone')) else: args['zoneid'] = zones.get_zone( current_app.config['CLOUDSTACK_DEFAULT_ZONE'])['id'] if helpers.get('BlockDeviceMapping.1.Ebs.VolumeType') is not None: disk_type = helpers.get('BlockDeviceMapping.1.Ebs.VolumeType') if disk_type == 'gp2': args['diskofferingid'] = disk_offerings.get_disk_offering( current_app.config['CLOUDSTACK_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' else: instance_type = helpers.get('InstanceType') if instance_type in current_app.config['INSTANCE_TYPE_MAP']: instance_type = current_app.config['INSTANCE_TYPE_MAP'][instance_type] else: instance_type = instance_type args['serviceofferingid'] = \ service_offerings.get_service_offering(instance_type)['id'] args['templateid'] = helpers.get('ImageId') if helpers.contains_parameter('KeyName'): args['keypair'] = helpers.get('KeyName') if helpers.contains_parameter('UserData'): args['userdata'] = helpers.get('UserData') if helpers.contains_parameter_with_keyword('SecurityGroupId.'): keys = helpers.get_request_parameter_keys('SecurityGroupId.') securitygroupids = [] for key in keys: securitygroupids.append(helpers.get(key)) args['securitygroupids'] = ",".join(securitygroupids) if helpers.contains_parameter_with_keyword('SecurityGroup.'): keys = helpers.get_request_parameter_keys('SecurityGroup.') securitygroupnames = [] for key in keys: securitygroupnames.append(helpers.get(key)) args['securitygroupnames'] = ",".join(securitygroupnames) if helpers.get('SubnetId') is not None: args['networkids'] = helpers.get('SubnetId') args['command'] = 'deployVirtualMachine' response = requester.make_request_async(args) return response
def _run_instance_request(): """ Request to bring up an instance. @return: Response. """ args = {} if helpers.contains_parameter('Placement.AvailabilityZone'): args['zoneid'] = zones.get_zone( helpers.get('Placement.AvailabilityZone') ) else: args['zoneid'] = zones.get_zone( current_app.config['CLOUDSTACK_DEFAULT_ZONE'] )['id'] if helpers.get('BlockDeviceMapping.1.Ebs.VolumeType') is not None: disk_type = helpers.get('BlockDeviceMapping.1.Ebs.VolumeType') if disk_type == 'gp2': args['diskofferingid'] = disk_offerings.get_disk_offering( current_app.config['CLOUDSTACK_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' else: instance_type = helpers.get('InstanceType') if instance_type in current_app.config['INSTANCE_TYPE_MAP']: instance_type = current_app.config[ 'INSTANCE_TYPE_MAP'][instance_type] else: instance_type = instance_type args['serviceofferingid'] = \ service_offerings.get_service_offering(instance_type)['id'] args['templateid'] = helpers.get('ImageId') if helpers.contains_parameter('KeyName'): args['keypair'] = helpers.get('KeyName') if helpers.contains_parameter('UserData'): args['userdata'] = helpers.get('UserData') if helpers.contains_parameter_with_keyword('SecurityGroupId.'): keys = helpers.get_request_parameter_keys('SecurityGroupId.') securitygroupids = [] for key in keys: securitygroupids.append(helpers.get(key)) args['securitygroupids'] = ",".join(securitygroupids) if helpers.contains_parameter_with_keyword('SecurityGroup.'): keys = helpers.get_request_parameter_keys('SecurityGroup.') securitygroupnames = [] for key in keys: securitygroupnames.append(helpers.get(key)) args['securitygroupnames'] = ",".join(securitygroupnames) args['command'] = 'deployVirtualMachine' response = requester.make_request_async(args) return response