Nova API test.py with servers, flavors, images
This commit is contained in:
parent
a2ad4c1f15
commit
f83c70bdb4
@ -1,6 +1,6 @@
|
|||||||
# Cinder resource for puppet handler
|
# 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,
|
like the main puppet class, auth, DB, AMQP, packages,
|
||||||
keystone user, role and endpoint.
|
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``
|
``sql_connection``
|
||||||
DEPRECATED
|
DEPRECATED
|
||||||
``sql_idle_timeout``
|
``sql_idle_timeout``
|
||||||
DEPRECATED
|
DEPRECATED
|
||||||
|
@ -9,7 +9,7 @@ def test(resource):
|
|||||||
|
|
||||||
args = resource.args
|
args = resource.args
|
||||||
|
|
||||||
token = validation.validate_token(
|
token, _ = validation.validate_token(
|
||||||
keystone_host=args['keystone_host'].value,
|
keystone_host=args['keystone_host'].value,
|
||||||
keystone_port=args['keystone_port'].value,
|
keystone_port=args['keystone_port'].value,
|
||||||
user='glance_admin',
|
user='glance_admin',
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Glance (API) resource for puppet handler
|
# 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,
|
like the main puppet class, auth, DB, AMQP, packages,
|
||||||
keystone user, role and endpoint, API service. Also configures
|
keystone user, role and endpoint, API service. Also configures
|
||||||
glance file backend.
|
glance file backend.
|
||||||
|
@ -13,7 +13,7 @@ def test(resource):
|
|||||||
|
|
||||||
args = resource.args
|
args = resource.args
|
||||||
|
|
||||||
token = validation.validate_token(
|
token, _ = validation.validate_token(
|
||||||
keystone_host=args['keystone_host'].value,
|
keystone_host=args['keystone_host'].value,
|
||||||
keystone_port=args['keystone_port'].value,
|
keystone_port=args['keystone_port'].value,
|
||||||
user=args['keystone_user'].value,
|
user=args['keystone_user'].value,
|
||||||
|
@ -12,7 +12,7 @@ def test(resource):
|
|||||||
'http://%s:%s/v3/services' % (resource.args['ip'].value, resource.args['keystone_admin_port'].value),
|
'http://%s:%s/v3/services' % (resource.args['ip'].value, resource.args['keystone_admin_port'].value),
|
||||||
headers={
|
headers={
|
||||||
'X-Auth-Token': resource.args['admin_token'].value,
|
'X-Auth-Token': resource.args['admin_token'].value,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
resp_json = resp.json()
|
resp_json = resp.json()
|
||||||
|
@ -9,7 +9,7 @@ def test(resource):
|
|||||||
|
|
||||||
args = resource.args
|
args = resource.args
|
||||||
|
|
||||||
token = validation.validate_token(
|
token, _ = validation.validate_token(
|
||||||
keystone_host=args['keystone_host'].value,
|
keystone_host=args['keystone_host'].value,
|
||||||
keystone_port=args['keystone_port'].value,
|
keystone_port=args['keystone_port'].value,
|
||||||
user=args['user_name'].value,
|
user=args['user_name'].value,
|
||||||
|
92
resources/nova_api_puppet/test.py
Normal file
92
resources/nova_api_puppet/test.py
Normal file
@ -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())
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
# Nova resource for puppet handler
|
# 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,
|
like the main puppet class, auth, DB, AMQP, packages,
|
||||||
keystone user, role and endpoint.
|
keystone user, role and endpoint.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user