Ver Fonte

Merge pull request #155 from CloudVE/aws_instance_types_by_region

Filter out instance type by region.
Nuwan Goonasekera há 7 anos atrás
pai
commit
3df95d3433
1 ficheiros alterados com 6 adições e 3 exclusões
  1. 6 3
      cloudbridge/cloud/providers/aws/services.py

+ 6 - 3
cloudbridge/cloud/providers/aws/services.py

@@ -619,13 +619,16 @@ class AWSVMTypeService(BaseVMTypeService):
         https://github.com/powdahound/ec2instances.info (in particular, this
         file: https://raw.githubusercontent.com/powdahound/ec2instances.info/
         master/www/instances.json).
-
-        TODO: Needs a caching function with timeout
         """
         r = requests.get(self.provider.config.get(
             "aws_instance_info_url",
             self.provider.AWS_INSTANCE_DATA_DEFAULT_URL))
-        return r.json()
+        # Some instances are only available in certain regions. Use pricing
+        # info to determine and filter out instance types that are not
+        # available in the current region
+        vm_types_list = r.json()
+        return [vm_type for vm_type in vm_types_list
+                if vm_type.get('pricing', {}).get(self.provider.region_name)]
 
     def list(self, limit=None, marker=None):
         vm_types = [AWSVMType(self.provider, vm_type)