[英]specifying VirtualizationType when launching aws ec2 instances with boto3
有人知道使用boto3启动AWS EC2实例时如何设置VirtualizationType吗? 我尝试过
session = boto3.session.Session(
aws_access_key_id=self.access_key_id,
aws_secret_access_key=self.secret_access_key,
region_name=self.region)
ec2resource = session.resource('ec2')
ec2resource.create_instances(
ImageId=ami_id, MinCount=1, MaxCount=count, KeyName=key_name,
InstanceType=type, SecurityGroups=security_groups,
VirtualizationType='paravirtual')
但是得到了
[2016-01-15 10:54:18 CST] INFO Calling ec2:run_instances with {'VirtualizationType': 'paravirtual', 'KeyName': 'common', 'SecurityGroups': ['default'], 'MaxCount': 2, 'MinCount': 1, 'InstanceType': 'm1.small', 'ImageId': 'ami-d05e75b8'}
Traceback (most recent call last):
File "suites/ec2.py", line 21, in <module>
print ec2.launch(count=2, VirtualizationType='paravirtual')
File "/Users/bchung/Dropbox/PycharmProjects/perf/lib/aws/ec2.py", line 183, in launch
InstanceType=type, SecurityGroups=security_groups, **kwargs)
File "/Library/Python/2.7/site-packages/boto3/resources/factory.py", line 455, in do_action
response = action(self, *args, **kwargs)
File "/Library/Python/2.7/site-packages/boto3/resources/action.py", line 79, in __call__
response = getattr(parent.meta.client, operation_name)(**params)
File "/Library/Python/2.7/site-packages/botocore/client.py", line 310, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/Library/Python/2.7/site-packages/botocore/client.py", line 383, in _make_api_call
api_params, operation_model, context=request_context)
File "/Library/Python/2.7/site-packages/botocore/client.py", line 425, in _convert_to_request_dict
api_params, operation_model)
File "/Library/Python/2.7/site-packages/botocore/validate.py", line 273, in serialize_to_request
raise ParamValidationError(report=report.generate_report())
botocore.exceptions.ParamValidationError:
Parameter validation failed:
Unknown parameter in input: "VirtualizationType", must be one of:
DryRun, ImageId, MinCount, MaxCount, KeyName, SecurityGroups,
SecurityGroupIds, UserData, InstanceType, Placement, KernelId,
RamdiskId, BlockDeviceMappings, Monitoring, SubnetId,
DisableApiTermination, InstanceInitiatedShutdownBehavior,
PrivateIpAddress, ClientToken, AdditionalInfo, NetworkInterfaces,
IamInstanceProfile, EbsOptimized
我需要设置VirtualizationType,因为我需要一些仅允许准虚拟而不是hvm的旧实例类型(m1.small),并且似乎boto3默认使用hvm :
Traceback (most recent call last):
File "suites/ec2.py", line 21, in <module>
print ec2.launch(count=2)
File "/Users/bchung/Dropbox/PycharmProjects/perf/lib/aws/ec2.py", line 183, in launch
InstanceType=type, SecurityGroups=security_groups, **kwargs)
File "/Library/Python/2.7/site-packages/boto3/resources/factory.py", line 455, in do_action
response = action(self, *args, **kwargs)
File "/Library/Python/2.7/site-packages/boto3/resources/action.py", line 79, in __call__
response = getattr(parent.meta.client, operation_name)(**params)
File "/Library/Python/2.7/site-packages/botocore/client.py", line 310, in _api_call
return self._make_api_call(operation_name, kwargs)
File "/Library/Python/2.7/site-packages/botocore/client.py", line 396, in _make_api_call
raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred
(InvalidParameterCombination) when calling the RunInstances operation:
Non-Windows instances with a virtualization type of 'hvm' are currently not supported for this instance type.
我检查过: http : //boto3.readthedocs.org/en/latest/reference/services/ec2.html#EC2.ServiceResource.create_instances和http://boto3.readthedocs.org/en/latest/reference/services/ec2 .html#EC2.Client.run_instances
并且params中没有VirtualizationType ,所以我想知道是否有设置方法,或者因为将要弃用它,所以boto3只是不允许指定它?
欢迎任何提示或建议,并在此先感谢!
无法从HVM AMI映像启动半虚拟EC2实例。 这不仅是boto3的事情,而且是AWS的限制。 准虚拟EC2实例只能从准虚拟AMI启动。
这是因为与HVM EC2实例相比,PV EC2实例的启动方式不同。
为了启动Linux m1.small实例,您需要找到和/或创建一个准虚拟AMI映像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.