diff --git a/resources/cinder_puppet/README.md b/resources/cinder_puppet/README.md index 0f288ca..5202183 100644 --- a/resources/cinder_puppet/README.md +++ b/resources/cinder_puppet/README.md @@ -1,6 +1,6 @@ # Cinder resource for puppet handler -Controlls a live cycle of the cinder entities, +Controls a live cycle of the cinder entities, like the main puppet class, auth, DB, AMQP, packages, keystone user, role and endpoint. @@ -109,4 +109,4 @@ source https://github.com/openstack/puppet-cinder/blob/5.1.0/manifests/init.pp ``sql_connection`` DEPRECATED ``sql_idle_timeout`` - DEPRECATED \ No newline at end of file + DEPRECATED diff --git a/resources/glance_api_service/test.py b/resources/glance_api_service/test.py index 23dcb7d..ba87049 100644 --- a/resources/glance_api_service/test.py +++ b/resources/glance_api_service/test.py @@ -9,7 +9,7 @@ def test(resource): args = resource.args - token = validation.validate_token( + token, _ = validation.validate_token( keystone_host=args['keystone_host'].value, keystone_port=args['keystone_port'].value, user='glance_admin', diff --git a/resources/glance_puppet/README.md b/resources/glance_puppet/README.md index 8c84b90..74be185 100644 --- a/resources/glance_puppet/README.md +++ b/resources/glance_puppet/README.md @@ -1,6 +1,6 @@ # Glance (API) resource for puppet handler -Controlls a live cycle of the glance entities, +Controls a live cycle of the glance entities, like the main puppet class, auth, DB, AMQP, packages, keystone user, role and endpoint, API service. Also configures glance file backend. diff --git a/resources/glance_puppet/test.py b/resources/glance_puppet/test.py index b3ee8f0..e6fece1 100644 --- a/resources/glance_puppet/test.py +++ b/resources/glance_puppet/test.py @@ -13,7 +13,7 @@ def test(resource): args = resource.args - token = validation.validate_token( + token, _ = validation.validate_token( keystone_host=args['keystone_host'].value, keystone_port=args['keystone_port'].value, user=args['keystone_user'].value, diff --git a/resources/keystone_service_endpoint/test.py b/resources/keystone_service_endpoint/test.py index edeede0..1981912 100644 --- a/resources/keystone_service_endpoint/test.py +++ b/resources/keystone_service_endpoint/test.py @@ -12,7 +12,7 @@ def test(resource): 'http://%s:%s/v3/services' % (resource.args['ip'].value, resource.args['keystone_admin_port'].value), headers={ 'X-Auth-Token': resource.args['admin_token'].value, - } + } ) resp_json = resp.json() diff --git a/resources/keystone_user/test.py b/resources/keystone_user/test.py index fcce950..f37f375 100644 --- a/resources/keystone_user/test.py +++ b/resources/keystone_user/test.py @@ -9,7 +9,7 @@ def test(resource): args = resource.args - token = validation.validate_token( + token, _ = validation.validate_token( keystone_host=args['keystone_host'].value, keystone_port=args['keystone_port'].value, user=args['user_name'].value, diff --git a/resources/nova_api_puppet/test.py b/resources/nova_api_puppet/test.py new file mode 100644 index 0000000..ca32863 --- /dev/null +++ b/resources/nova_api_puppet/test.py @@ -0,0 +1,92 @@ +import json +import requests + +from solar.core.log import log +from solar.core import validation + + +def test(resource): + log.debug('Testing nova api') + + args = resource.args + + token, token_data = validation.validate_token( + keystone_host=args['auth_host'].value, + keystone_port=args['auth_port'].value, + user=args['admin_user'].value, + tenant=args['admin_tenant_name'].value, + password=args['admin_password'].value, + ) + + endpoints = [ + e['endpoints'] for e in token_data['access']['serviceCatalog'] + if e['name'] == 'nova' + ][0] + public_url = endpoints[0]['publicURL'] + + log.debug('nova admin_url: %s', public_url) + + servers = requests.get( + '{public_url}/servers/detail'.format(public_url=public_url), + headers={ + 'X-Auth-Token': token, + 'Content-Type': 'application/json', + } + ) + + servers_json = servers.json() + + log.debug( + 'NOVA API SERVERS: %s', + json.dumps(servers_json, indent=2) + ) + + assert 'servers' in servers_json + assert isinstance(servers_json['servers'], list) + + flavors = requests.get( + '{public_url}/flavors'.format(public_url=public_url), + headers={ + 'X-Auth-Token': token, + 'Content-Type': 'application/json', + } + ) + + flavors_json = flavors.json() + + log.debug('NOVA API FLAVORS: %s', json.dumps(flavors_json, indent=2)) + + assert 'flavors' in flavors_json + assert isinstance(flavors_json['flavors'], list) + assert len(flavors_json['flavors']) > 0 + + for flavor_data in flavors_json['flavors']: + url = [link['href'] for link in flavor_data['links'] + if link['rel'] == 'self'][0] + + flavor = requests.get( + url, + headers={ + 'X-Auth-Token': token, + 'Content-Type': 'application/json', + } + ) + + flavor_json = flavor.json() + + log.debug( + 'NOVA API FLAVOR %s data: %s', + flavor_data['name'], + json.dumps(flavor_json, indent=2) + ) + + images = requests.get( + '{public_url}/images'.format(public_url=public_url), + headers={ + 'X-Auth-Token': token, + 'Content-Type': 'application/json', + } + ) + + log.debug('NOVA API IMAGES: %s', images.json()) + diff --git a/resources/nova_puppet/README.md b/resources/nova_puppet/README.md index 76b594e..ad41226 100644 --- a/resources/nova_puppet/README.md +++ b/resources/nova_puppet/README.md @@ -1,6 +1,6 @@ # Nova resource for puppet handler -Controlls a live cycle of the nova entities, +Controls a live cycle of the nova entities, like the main puppet class, auth, DB, AMQP, packages, keystone user, role and endpoint.