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:
Nuwan Goonasekera 2021-02-22 15:51:59 +05:30 committed by GitHub
commit a0d7a943ee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 46 additions and 154 deletions

View file

@ -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