Browse Source

Fix default subnet detection according to placement zone

Partially addresses: https://github.com/galaxyproject/cloudlaunch-ui/issues/25
Nuwan Goonasekera 8 năm trước cách đây
mục cha
commit
5a1a0bff19
1 tập tin đã thay đổi với 8 bổ sung0 xóa
  1. 8 0
      cloudbridge/cloud/providers/aws/services.py

+ 8 - 0
cloudbridge/cloud/providers/aws/services.py

@@ -727,6 +727,14 @@ class AWSSubnetService(BaseSubnetService):
             snl = self.svc.find('availabilityZone', zone)
         else:
             snl = self.svc.list()
+
+        # Find first available default subnet by sorted order
+        # of availability zone. (e.g. prefer us-east-1a over 1e,
+        # This is because newer zones tend to have less compatibility
+        # with different instance types. (e.g. c5.large not available
+        # on us-east-1e as of 14 Dec. 2017
+        # pylint:disable=protected-access
+        snl.sort(key=lambda sn: sn._subnet.availability_zone)
         for sn in snl:
             # pylint:disable=protected-access
             if sn._subnet.default_for_az: