Beispiel #1
0
 def _validate_config(self, config):
     """
     Parameter for Consul
     - host, port=8500, token=None, scheme=http, consistency=default, dc=None, verify=True, cert=None
     """
     options = ['host', 'port', 'token', 'scheme', 'consistency', 'dc', 'verify', 'cert']
     result = {}
     for item in options:
         value = config.get(item, None)
         if value:
             result[item] = value
     return result
Beispiel #2
0
class TestCloudServiceAPIs(TestCase):
    config = utils.load_yaml_from_file(
        os.environ.get('SPACEONE_TEST_CONFIG_FILE', './config.yml'))
    endpoints = config.get('ENDPOINTS', {})
    secret_data = {
        'aws_access_key_id': AKI,
        'aws_secret_access_key': SAK,
    }

    if ROLE_ARN is not None:
        secret_data.update({
            'role_arn': ROLE_ARN
        })

    if REGION_NAME is not None:
        secret_data.update({
            'region_name': REGION_NAME
        })

    def test_init(self):
        v_info = self.inventory.Collector.init({'options': {}})
        print_json(v_info)

    def test_verify(self):
        options = {
            'domain': 'mz.co.kr'
        }
        v_info = self.inventory.Collector.verify({'options': options, 'secret_data': self.secret_data})
        print_json(v_info)

    def test_collect(self):

        options = {
            'cloud_service_types': [
                'Lightsail'
            ]
        }

        # options = {}
        filter = {}

        res_stream = self.inventory.Collector.collect(
            {'options': options, 'secret_data': self.secret_data, 'filter': filter}
        )

        for res in res_stream:
            self.assertIsNotNone(res)
            print_json(res)
            # self.assertEqual('CLOUD_SERVICE', res.resource_type)
Beispiel #3
0
class TestCloudServiceAPIs(TestCase):
    config = utils.load_yaml_from_file(
        os.environ.get('SPACEONE_TEST_CONFIG_FILE', './config.yml'))
    endpoints = config.get('ENDPOINTS', {})
    secret_data = {
        'aws_access_key_id': AKI,
        'aws_secret_access_key': SAK,
    }

    if ROLE_ARN is not None:
        secret_data.update({'role_arn': ROLE_ARN})

    if REGION_NAME is not None:
        secret_data.update({'region_name': REGION_NAME})

    def test_init(self):
        v_info = self.inventory.Collector.init({'options': {}})
        print_json(v_info)

    def test_verify(self):
        options = {'domain': 'mz.co.kr'}
        v_info = self.inventory.Collector.verify({
            'options':
            options,
            'secret_data':
            self.secret_data
        })
        print_json(v_info)

    def test_collect(self):
        options = {}
        filter = {}

        res_stream = self.inventory.Collector.collect({
            'options': options,
            'secret_data': self.secret_data,
            'filter': filter
        })

        for res in res_stream:
            #print_json(res)
            res_json = to_json(res)
            try:
                if res_json['resource']['data']['resources_summary'][
                        'resources_flagged'] > 0:
                    print_json(res)
            except:
                pass