Fix unknown instance type (#3710)
* Use apiname when comparing unknown instance ids * Use get_instance_types API to populate instance_types.json * Fix scope of instances array when retrieving instance types
This commit is contained in:
parent
442fcd4e51
commit
a0d7a943ee
6 changed files with 46 additions and 154 deletions
|
|
@ -1156,9 +1156,11 @@ class InstanceTypeBackend(object):
|
|||
def describe_instance_types(self, instance_types=None):
|
||||
matches = INSTANCE_TYPES.values()
|
||||
if instance_types:
|
||||
matches = [t for t in matches if t.get("apiname") in instance_types]
|
||||
matches = [t for t in matches if t.get("InstanceType") in instance_types]
|
||||
if len(instance_types) > len(matches):
|
||||
unknown_ids = set(instance_types) - set(matches)
|
||||
unknown_ids = set(instance_types) - set(
|
||||
t.get("InstanceType") for t in matches
|
||||
)
|
||||
raise InvalidInstanceTypeError(unknown_ids)
|
||||
return matches
|
||||
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -825,23 +825,25 @@ EC2_DESCRIBE_INSTANCE_TYPES = """<?xml version="1.0" encoding="UTF-8"?>
|
|||
<instanceTypeSet>
|
||||
{% for instance_type in instance_types %}
|
||||
<item>
|
||||
<instanceType>{{ instance_type.apiname }}</instanceType>
|
||||
<instanceType>{{ instance_type.InstanceType }}</instanceType>
|
||||
<vCpuInfo>
|
||||
<defaultVCpus>{{ instance_type.vcpus|int }}</defaultVCpus>
|
||||
<defaultCores>{{ instance_type.vcpus|int }}</defaultCores>
|
||||
<defaultThreadsPerCore>1</defaultThreadsPerCore>
|
||||
<defaultVCpus>{{ instance_type.get('VCpuInfo', {}).get('DefaultVCpus', 0)|int }}</defaultVCpus>
|
||||
<defaultCores>{{ instance_type.get('VCpuInfo', {}).get('DefaultCores', 0)|int }}</defaultCores>
|
||||
<defaultThreadsPerCore>{{ instance_type.get('VCpuInfo').get('DefaultThreadsPerCore', 0)|int }}</defaultThreadsPerCore>
|
||||
</vCpuInfo>
|
||||
<memoryInfo>
|
||||
<sizeInMiB>{{ instance_type.memory|int }}</sizeInMiB>
|
||||
<sizeInMiB>{{ instance_type.get('MemoryInfo', {}).get('SizeInMiB', 0)|int }}</sizeInMiB>
|
||||
</memoryInfo>
|
||||
<instanceStorageInfo>
|
||||
<totalSizeInGB>{{ instance_type.storage|int }}</totalSizeInGB>
|
||||
<totalSizeInGB>{{ instance_type.get('InstanceStorageInfo', {}).get('TotalSizeInGB', 0)|int }}</totalSizeInGB>
|
||||
</instanceStorageInfo>
|
||||
<processorInfo>
|
||||
<supportedArchitectures>
|
||||
{% for arch in instance_type.get('ProcessorInfo', {}).get('SupportedArchitectures', []) %}
|
||||
<item>
|
||||
x86_64
|
||||
{{ arch }}
|
||||
</item>
|
||||
{% endfor %}
|
||||
</supportedArchitectures>
|
||||
</processorInfo>
|
||||
</item>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue