Javelin: enable volume resources
In javelin, volumes resources are not yet managed. This patch aims to bring it up again. Prereq for blueprint:javelin2 Change-Id: I4ef12e5b6e75aff363ad527f2cc932b4108ea019
This commit is contained in:
parent
9d7d28b66f
commit
d18fec1de7
@ -213,9 +213,7 @@ class JavelinCheck(unittest.TestCase):
|
|||||||
self.check_users()
|
self.check_users()
|
||||||
self.check_objects()
|
self.check_objects()
|
||||||
self.check_servers()
|
self.check_servers()
|
||||||
# TODO(sdague): Volumes not yet working, bring it back once the
|
self.check_volumes()
|
||||||
# code is self testing.
|
|
||||||
# self.check_volumes()
|
|
||||||
self.check_telemetry()
|
self.check_telemetry()
|
||||||
|
|
||||||
def check_users(self):
|
def check_users(self):
|
||||||
@ -300,15 +298,15 @@ class JavelinCheck(unittest.TestCase):
|
|||||||
LOG.info("checking volumes")
|
LOG.info("checking volumes")
|
||||||
for volume in self.res['volumes']:
|
for volume in self.res['volumes']:
|
||||||
client = client_for_user(volume['owner'])
|
client = client_for_user(volume['owner'])
|
||||||
found = _get_volume_by_name(client, volume['name'])
|
vol_body = _get_volume_by_name(client, volume['name'])
|
||||||
self.assertIsNotNone(
|
self.assertIsNotNone(
|
||||||
found,
|
vol_body,
|
||||||
"Couldn't find expected volume %s" % volume['name'])
|
"Couldn't find expected volume %s" % volume['name'])
|
||||||
|
|
||||||
# Verify that a volume's attachment retrieved
|
# Verify that a volume's attachment retrieved
|
||||||
server_id = _get_server_by_name(client, volume['server'])['id']
|
server_id = _get_server_by_name(client, volume['server'])['id']
|
||||||
attachment = self.client.get_attachment_from_volume(volume)
|
attachment = client.volumes.get_attachment_from_volume(vol_body)
|
||||||
self.assertEqual(volume['id'], attachment['volume_id'])
|
self.assertEqual(vol_body['id'], attachment['volume_id'])
|
||||||
self.assertEqual(server_id, attachment['server_id'])
|
self.assertEqual(server_id, attachment['server_id'])
|
||||||
|
|
||||||
def _confirm_telemetry_sample(self, server, sample):
|
def _confirm_telemetry_sample(self, server, sample):
|
||||||
@ -501,8 +499,8 @@ def destroy_servers(servers):
|
|||||||
|
|
||||||
def _get_volume_by_name(client, name):
|
def _get_volume_by_name(client, name):
|
||||||
r, body = client.volumes.list_volumes()
|
r, body = client.volumes.list_volumes()
|
||||||
for volume in body['volumes']:
|
for volume in body:
|
||||||
if name == volume['name']:
|
if name == volume['display_name']:
|
||||||
return volume
|
return volume
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@ -512,11 +510,15 @@ def create_volumes(volumes):
|
|||||||
client = client_for_user(volume['owner'])
|
client = client_for_user(volume['owner'])
|
||||||
|
|
||||||
# only create a volume if the name isn't here
|
# only create a volume if the name isn't here
|
||||||
r, body = client.volumes.list_volumes()
|
if _get_volume_by_name(client, volume['name']):
|
||||||
if any(item['name'] == volume['name'] for item in body):
|
LOG.info("volume '%s' already exists" % volume['name'])
|
||||||
continue
|
continue
|
||||||
|
|
||||||
client.volumes.create_volume(volume['name'], volume['size'])
|
size = volume['gb']
|
||||||
|
v_name = volume['name']
|
||||||
|
resp, body = client.volumes.create_volume(size=size,
|
||||||
|
display_name=v_name)
|
||||||
|
client.volumes.wait_for_volume_status(body['id'], 'available')
|
||||||
|
|
||||||
|
|
||||||
def destroy_volumes(volumes):
|
def destroy_volumes(volumes):
|
||||||
@ -529,9 +531,10 @@ def destroy_volumes(volumes):
|
|||||||
def attach_volumes(volumes):
|
def attach_volumes(volumes):
|
||||||
for volume in volumes:
|
for volume in volumes:
|
||||||
client = client_for_user(volume['owner'])
|
client = client_for_user(volume['owner'])
|
||||||
|
|
||||||
server_id = _get_server_by_name(client, volume['server'])['id']
|
server_id = _get_server_by_name(client, volume['server'])['id']
|
||||||
client.volumes.attach_volume(volume['name'], server_id)
|
volume_id = _get_volume_by_name(client, volume['name'])['id']
|
||||||
|
device = volume['device']
|
||||||
|
client.volumes.attach_volume(volume_id, server_id, device)
|
||||||
|
|
||||||
|
|
||||||
#######################
|
#######################
|
||||||
@ -552,10 +555,8 @@ def create_resources():
|
|||||||
create_objects(RES['objects'])
|
create_objects(RES['objects'])
|
||||||
create_images(RES['images'])
|
create_images(RES['images'])
|
||||||
create_servers(RES['servers'])
|
create_servers(RES['servers'])
|
||||||
# TODO(sdague): volumes definition doesn't work yet, bring it
|
create_volumes(RES['volumes'])
|
||||||
# back once we're actually executing the code
|
attach_volumes(RES['volumes'])
|
||||||
# create_volumes(RES['volumes'])
|
|
||||||
# attach_volumes(RES['volumes'])
|
|
||||||
|
|
||||||
|
|
||||||
def destroy_resources():
|
def destroy_resources():
|
||||||
|
@ -36,11 +36,13 @@ volumes:
|
|||||||
- name: assegai
|
- name: assegai
|
||||||
server: peltast
|
server: peltast
|
||||||
owner: javelin
|
owner: javelin
|
||||||
size: 1
|
gb: 1
|
||||||
|
device: /dev/vdb
|
||||||
- name: pifpouf
|
- name: pifpouf
|
||||||
server: hoplite
|
server: hoplite
|
||||||
owner: javelin
|
owner: javelin
|
||||||
size: 2
|
gb: 2
|
||||||
|
device: /dev/vdb
|
||||||
servers:
|
servers:
|
||||||
- name: peltast
|
- name: peltast
|
||||||
owner: javelin
|
owner: javelin
|
||||||
|
Loading…
Reference in New Issue
Block a user