Sfoglia il codice sorgente

Fixed issue with public_ips returning null elements and corrected flake8 errors

Nuwan Goonasekera 8 anni fa
parent
commit
1014ffde51

+ 0 - 1
cloudbridge/cloud/base/services.py

@@ -4,7 +4,6 @@ Base implementation for services available through a provider
 import logging
 
 from cloudbridge.cloud.interfaces.resources import Router
-
 from cloudbridge.cloud.interfaces.services import BucketService
 from cloudbridge.cloud.interfaces.services import CloudService
 from cloudbridge.cloud.interfaces.services import ComputeService

+ 1 - 0
cloudbridge/cloud/providers/aws/helpers.py

@@ -1,5 +1,6 @@
 """A set of AWS-specific helper methods used by the framework."""
 import logging as log
+
 from boto3.resources.params import create_request_parameters
 
 from botocore import xform_name

+ 4 - 2
cloudbridge/cloud/providers/aws/resources.py

@@ -230,11 +230,13 @@ class AWSInstance(BaseInstance):
 
     @property
     def public_ips(self):
-        return [self._ec2_instance.public_ip_address]
+        return ([self._ec2_instance.public_ip_address]
+                if self._ec2_instance.public_ip_address else [])
 
     @property
     def private_ips(self):
-        return [self._ec2_instance.private_ip_address]
+        return ([self._ec2_instance.private_ip_address]
+                if self._ec2_instance.private_ip_address else [])
 
     @property
     def vm_type_id(self):

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

@@ -37,7 +37,6 @@ import requests
 
 from .helpers import BotoEC2Service
 from .helpers import BotoS3Service
-
 from .resources import AWSBucket
 from .resources import AWSFloatingIP
 from .resources import AWSInstance

+ 0 - 1
cloudbridge/cloud/providers/openstack/provider.py

@@ -1,7 +1,6 @@
 """Provider implementation based on OpenStack Python clients for OpenStack."""
 
 import inspect
-
 import os
 
 from cinderclient import client as cinder_client

+ 0 - 2
cloudbridge/cloud/providers/openstack/resources.py

@@ -3,7 +3,6 @@ DataTypes used by this provider
 """
 import inspect
 import ipaddress
-
 import logging
 import os
 
@@ -49,7 +48,6 @@ import novaclient.exceptions as novaex
 from openstack.exceptions import HttpException
 
 import swiftclient
-
 from swiftclient.service import SwiftService, SwiftUploadObject
 
 

+ 0 - 1
test/helpers/__init__.py

@@ -4,7 +4,6 @@ import sys
 import traceback
 import unittest
 import uuid
-
 from contextlib import contextmanager
 
 from cloudbridge.cloud.factory import CloudProviderFactory

+ 0 - 1
test/test_block_store_service.py

@@ -1,6 +1,5 @@
 import time
 import uuid
-
 from test import helpers
 from test.helpers import ProviderTestBase
 from test.helpers import standard_interface_tests as sit

+ 0 - 1
test/test_cloud_factory.py

@@ -1,5 +1,4 @@
 import unittest
-
 from test import helpers
 
 from cloudbridge.cloud import factory

+ 0 - 1
test/test_cloud_helpers.py

@@ -1,5 +1,4 @@
 import itertools
-
 from test.helpers import ProviderTestBase
 
 from cloudbridge.cloud.base.resources import ClientPagedResultList

+ 6 - 1
test/test_compute_service.py

@@ -1,5 +1,4 @@
 import ipaddress
-
 from test import helpers
 from test.helpers import ProviderTestBase
 from test.helpers import standard_interface_tests as sit
@@ -96,7 +95,13 @@ class CloudComputeServiceTestCase(ProviderTestBase):
                 test_instance.image_id,
                 helpers.get_provider_test_data(self.provider, "image"))
             self.assertIsInstance(test_instance.public_ips, list)
+            if test_instance.public_ips:
+                self.assertTrue(
+                    test_instance.public_ips[0], "public ip should contain a"
+                    " valid value if a list of public_ips exist")
             self.assertIsInstance(test_instance.private_ips, list)
+            self.assertTrue(test_instance.private_ips[0], "private ip should"
+                            " contain a valid value")
             self.assertEqual(
                 test_instance.key_pair_name,
                 kp.name)

+ 0 - 2
test/test_interface.py

@@ -1,9 +1,7 @@
 import unittest
-
 from test.helpers import ProviderTestBase
 
 import cloudbridge
-
 from cloudbridge.cloud import interfaces
 from cloudbridge.cloud.factory import CloudProviderFactory
 from cloudbridge.cloud.interfaces import TestMockHelperMixin

+ 0 - 1
test/test_network_service.py

@@ -1,5 +1,4 @@
 import test.helpers as helpers
-
 from test.helpers import ProviderTestBase
 from test.helpers import get_provider_test_data
 from test.helpers import standard_interface_tests as sit

+ 0 - 1
test/test_object_store_service.py

@@ -2,7 +2,6 @@ import filecmp
 import os
 import tempfile
 import uuid
-
 from datetime import datetime
 from io import BytesIO
 from test import helpers

+ 0 - 1
test/test_vm_types_service.py

@@ -1,5 +1,4 @@
 from test import helpers
-
 from test.helpers import ProviderTestBase
 from test.helpers import standard_interface_tests as sit